/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/rdesktop/seamless.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/branches/seamlessrdp-branch/rdesktop/seamless.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1162 by astrand, Fri Mar 17 12:39:09 2006 UTC revision 1163 by ossman_, Mon Mar 20 10:31:58 2006 UTC
# Line 20  Line 20 
20    
21  #include "rdesktop.h"  #include "rdesktop.h"
22  #include <stdarg.h>  #include <stdarg.h>
23    #include <assert.h>
24    
25  /* #define WITH_DEBUG_SEAMLESS */  /* #define WITH_DEBUG_SEAMLESS */
26    
# Line 31  Line 32 
32    
33  extern BOOL g_seamless_rdp;  extern BOOL g_seamless_rdp;
34  static VCHANNEL *seamless_channel;  static VCHANNEL *seamless_channel;
35    static unsigned int seamless_serial;
36    
37  static char *  static char *
38  seamless_get_token(char **s)  seamless_get_token(char **s)
# Line 81  seamless_process_line(const char *line, Line 83  seamless_process_line(const char *line,
83          if (!strcmp("CREATE", tok1))          if (!strcmp("CREATE", tok1))
84          {          {
85                  unsigned long parent;                  unsigned long parent;
86                  if (!tok4)                  if (!tok5)
87                          return False;                          return False;
88    
89                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
90                  if (*endptr)                  if (*endptr)
91                          return False;                          return False;
92    
93                  parent = strtoul(tok3, &endptr, 0);                  parent = strtoul(tok4, &endptr, 0);
94                  if (*endptr)                  if (*endptr)
95                          return False;                          return False;
96    
97                  flags = strtoul(tok4, &endptr, 0);                  flags = strtoul(tok5, &endptr, 0);
98                  if (*endptr)                  if (*endptr)
99                          return False;                          return False;
100    
# Line 100  seamless_process_line(const char *line, Line 102  seamless_process_line(const char *line,
102          }          }
103          else if (!strcmp("DESTROY", tok1))          else if (!strcmp("DESTROY", tok1))
104          {          {
105                  if (!tok3)                  if (!tok4)
106                          return False;                          return False;
107    
108                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
109                  if (*endptr)                  if (*endptr)
110                          return False;                          return False;
111    
112                  flags = strtoul(tok3, &endptr, 0);                  flags = strtoul(tok4, &endptr, 0);
113                  if (*endptr)                  if (*endptr)
114                          return False;                          return False;
115    
# Line 122  seamless_process_line(const char *line, Line 124  seamless_process_line(const char *line,
124          {          {
125                  int x, y, width, height;                  int x, y, width, height;
126    
127                  if (!tok7)                  if (!tok8)
128                          return False;                          return False;
129    
130                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
131                  if (*endptr)                  if (*endptr)
132                          return False;                          return False;
133    
134                  x = strtol(tok3, &endptr, 0);                  x = strtol(tok4, &endptr, 0);
135                  if (*endptr)                  if (*endptr)
136                          return False;                          return False;
137                  y = strtol(tok4, &endptr, 0);                  y = strtol(tok5, &endptr, 0);
138                  if (*endptr)                  if (*endptr)
139                          return False;                          return False;
140    
141                  width = strtol(tok5, &endptr, 0);                  width = strtol(tok6, &endptr, 0);
142                  if (*endptr)                  if (*endptr)
143                          return False;                          return False;
144                  height = strtol(tok6, &endptr, 0);                  height = strtol(tok7, &endptr, 0);
145                  if (*endptr)                  if (*endptr)
146                          return False;                          return False;
147    
148                  flags = strtoul(tok7, &endptr, 0);                  flags = strtoul(tok8, &endptr, 0);
149                  if (*endptr)                  if (*endptr)
150                          return False;                          return False;
151    
# Line 153  seamless_process_line(const char *line, Line 155  seamless_process_line(const char *line,
155          {          {
156                  unsigned long behind;                  unsigned long behind;
157    
158                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
159                  if (*endptr)                  if (*endptr)
160                          return False;                          return False;
161    
162                  behind = strtoul(tok3, &endptr, 0);                  behind = strtoul(tok4, &endptr, 0);
163                  if (*endptr)                  if (*endptr)
164                          return False;                          return False;
165    
166                  flags = strtoul(tok4, &endptr, 0);                  flags = strtoul(tok5, &endptr, 0);
167                  if (*endptr)                  if (*endptr)
168                          return False;                          return False;
169    
# Line 169  seamless_process_line(const char *line, Line 171  seamless_process_line(const char *line,
171          }          }
172          else if (!strcmp("TITLE", tok1))          else if (!strcmp("TITLE", tok1))
173          {          {
174                  if (!tok4)                  if (!tok5)
175                          return False;                          return False;
176    
177                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
178                  if (*endptr)                  if (*endptr)
179                          return False;                          return False;
180    
181                  flags = strtoul(tok4, &endptr, 0);                  flags = strtoul(tok5, &endptr, 0);
182                  if (*endptr)                  if (*endptr)
183                          return False;                          return False;
184    
185                  ui_seamless_settitle(id, tok3, flags);                  ui_seamless_settitle(id, tok4, flags);
186          }          }
187          else if (!strcmp("STATE", tok1))          else if (!strcmp("STATE", tok1))
188          {          {
189                  unsigned int state;                  unsigned int state;
190    
191                  if (!tok4)                  if (!tok5)
192                          return False;                          return False;
193    
194                  id = strtoul(tok2, &endptr, 0);                  id = strtoul(tok3, &endptr, 0);
195                  if (*endptr)                  if (*endptr)
196                          return False;                          return False;
197    
198                  state = strtoul(tok3, &endptr, 0);                  state = strtoul(tok4, &endptr, 0);
199                  if (*endptr)                  if (*endptr)
200                          return False;                          return False;
201    
202                  flags = strtoul(tok4, &endptr, 0);                  flags = strtoul(tok5, &endptr, 0);
203                  if (*endptr)                  if (*endptr)
204                          return False;                          return False;
205    
# Line 209  seamless_process_line(const char *line, Line 211  seamless_process_line(const char *line,
211          }          }
212          else if (!strcmp("SYNCBEGIN", tok1))          else if (!strcmp("SYNCBEGIN", tok1))
213          {          {
214                  if (!tok2)                  if (!tok3)
215                          return False;                          return False;
216    
217                  flags = strtoul(tok2, &endptr, 0);                  flags = strtoul(tok3, &endptr, 0);
218                  if (*endptr)                  if (*endptr)
219                          return False;                          return False;
220    
# Line 220  seamless_process_line(const char *line, Line 222  seamless_process_line(const char *line,
222          }          }
223          else if (!strcmp("SYNCEND", tok1))          else if (!strcmp("SYNCEND", tok1))
224          {          {
225                  if (!tok2)                  if (!tok3)
226                          return False;                          return False;
227    
228                  flags = strtoul(tok2, &endptr, 0);                  flags = strtoul(tok3, &endptr, 0);
229                  if (*endptr)                  if (*endptr)
230                          return False;                          return False;
231    
# Line 231  seamless_process_line(const char *line, Line 233  seamless_process_line(const char *line,
233          }          }
234          else if (!strcmp("HELLO", tok1))          else if (!strcmp("HELLO", tok1))
235          {          {
236                  if (!tok2)                  if (!tok3)
237                          return False;                          return False;
238    
239                  flags = strtoul(tok2, &endptr, 0);                  flags = strtoul(tok3, &endptr, 0);
240                  if (*endptr)                  if (*endptr)
241                          return False;                          return False;
242    
# Line 286  seamless_init(void) Line 288  seamless_init(void)
288          if (!g_seamless_rdp)          if (!g_seamless_rdp)
289                  return False;                  return False;
290    
291            seamless_serial = 0;
292    
293          seamless_channel =          seamless_channel =
294                  channel_register("seamrdp", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,                  channel_register("seamrdp", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,
295                                   seamless_process);                                   seamless_process);
# Line 294  seamless_init(void) Line 298  seamless_init(void)
298    
299    
300  static void  static void
301  seamless_send(const char *format, ...)  seamless_send(const char *command, const char *format, ...)
302  {  {
303          STREAM s;          STREAM s;
304          size_t len;          size_t len;
305          va_list argp;          va_list argp;
306          char buf[1024];          char buf[1025];
307    
308            len = snprintf(buf, sizeof(buf) - 1, "%s,%u,", command, seamless_serial);
309    
310            assert(len < (sizeof(buf) - 1));
311    
312          va_start(argp, format);          va_start(argp, format);
313          len = vsnprintf(buf, sizeof(buf), format, argp);          len += vsnprintf(buf + len, sizeof(buf) - len - 1, format, argp);
314          va_end(argp);          va_end(argp);
315    
316            assert(len < (sizeof(buf) - 1));
317    
318            buf[len] = '\n';
319            buf[len + 1] = '\0';
320    
321          s = channel_init(seamless_channel, len);          s = channel_init(seamless_channel, len);
322          out_uint8p(s, buf, len) s_mark_end(s);          out_uint8p(s, buf, len) s_mark_end(s);
323    
324            seamless_serial++;
325    
326          DEBUG_SEAMLESS(("SeamlessRDP sending:%s", buf));          DEBUG_SEAMLESS(("SeamlessRDP sending:%s", buf));
327    
328  #if 0  #if 0
# Line 325  seamless_send_sync() Line 340  seamless_send_sync()
340          if (!g_seamless_rdp)          if (!g_seamless_rdp)
341                  return;                  return;
342    
343          seamless_send("SYNC\n");          seamless_send("SYNC", "");
344  }  }
345    
346    
# Line 335  seamless_send_state(unsigned long id, un Line 350  seamless_send_state(unsigned long id, un
350          if (!g_seamless_rdp)          if (!g_seamless_rdp)
351                  return;                  return;
352    
353          seamless_send("STATE,0x%08lx,0x%x,0x%lx\n", id, state, flags);          seamless_send("STATE", "0x%08lx,0x%x,0x%lx", id, state, flags);
354  }  }
355    
356    
357  void  void
358  seamless_send_position(unsigned long id, int x, int y, int width, int height, unsigned long flags)  seamless_send_position(unsigned long id, int x, int y, int width, int height, unsigned long flags)
359  {  {
360          seamless_send("POSITION,0x%08lx,%d,%d,%d,%d,0x%lx\n", id, x, y, width, height, flags);          seamless_send("POSITION", "0x%08lx,%d,%d,%d,%d,0x%lx", id, x, y, width, height, flags);
361  }  }
362    
363    
# Line 362  seamless_select_timeout(struct timeval * Line 377  seamless_select_timeout(struct timeval *
377          }          }
378  }  }
379    
   
380  void  void
381  seamless_send_zchange(unsigned long id, unsigned long below, unsigned long flags)  seamless_send_zchange(unsigned long id, unsigned long below, unsigned long flags)
382  {  {
383          if (!g_seamless_rdp)          if (!g_seamless_rdp)
384                  return;                  return;
385    
386          seamless_send("ZCHANGE,0x%08lx,0x%08lx,0x%lx\n", id, below, flags);          seamless_send("ZCHANGE", "0x%08lx,0x%08lx,0x%lx", id, below, flags);
387  }  }
388    
389    
# Line 379  seamless_send_focus(unsigned long id, un Line 393  seamless_send_focus(unsigned long id, un
393          if (!g_seamless_rdp)          if (!g_seamless_rdp)
394                  return;                  return;
395    
396          seamless_send("FOCUS,0x%08lx,0x%lx\n", id, flags);          seamless_send("FOCUS", "0x%08lx,0x%lx", id, flags);
397  }  }

Legend:
Removed from v.1162  
changed lines
  Added in v.1163

  ViewVC Help
Powered by ViewVC 1.1.26