ReactOS  0.4.13-dev-259-g5ca9c9c
seamless.c File Reference
#include "rdesktop.h"
#include <stdarg.h>
#include <assert.h>
Include dependency graph for seamless.c:

Go to the source code of this file.

Macros

#define DEBUG_SEAMLESS(args)
 

Functions

static charseamless_get_token (char **s)
 
static BOOL seamless_process_line (RDPCLIENT *This, const char *line, void *data)
 
static BOOL seamless_line_handler (RDPCLIENT *This, const char *line, void *data)
 
static void seamless_process (RDPCLIENT *This, STREAM s)
 
BOOL seamless_init (RDPCLIENT *This)
 
static unsigned int seamless_send (RDPCLIENT *This, const char *command, const char *format,...)
 
unsigned int seamless_send_sync (RDPCLIENT *This)
 
unsigned int seamless_send_state (RDPCLIENT *This, unsigned long id, unsigned int state, unsigned long flags)
 
unsigned int seamless_send_position (RDPCLIENT *This, unsigned long id, int x, int y, int width, int height, unsigned long flags)
 
void seamless_select_timeout (RDPCLIENT *This, struct timeval *tv)
 
unsigned int seamless_send_zchange (RDPCLIENT *This, unsigned long id, unsigned long below, unsigned long flags)
 
unsigned int seamless_send_focus (RDPCLIENT *This, unsigned long id, unsigned long flags)
 

Macro Definition Documentation

◆ DEBUG_SEAMLESS

#define DEBUG_SEAMLESS (   args)

Definition at line 30 of file seamless.c.

Function Documentation

◆ seamless_get_token()

static char* seamless_get_token ( char **  s)
static

Definition at line 34 of file seamless.c.

35 {
36  char *comma, *head;
37  head = *s;
38 
39  if (!head)
40  return NULL;
41 
42  comma = strchr(head, ',');
43  if (comma)
44  {
45  *comma = '\0';
46  *s = comma + 1;
47  }
48  else
49  {
50  *s = NULL;
51  }
52 
53  return head;
54 }
struct outqueuenode * head
Definition: adnsresfilter.c:66
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
char * strchr(const char *String, int ch)
Definition: utclib.c:501

Referenced by seamless_process_line().

◆ seamless_init()

BOOL seamless_init ( RDPCLIENT This)

Definition at line 333 of file seamless.c.

334 {
335  if (!This->seamless_rdp)
336  return False;
337 
338  This->seamless.serial = 0;
339 
340  This->seamless.channel =
343  return (This->seamless.channel != NULL);
344 }
static void seamless_process(RDPCLIENT *This, STREAM s)
Definition: seamless.c:311
VCHANNEL * channel_register(char *name, uint32 flags, void(*callback)(STREAM))
Definition: channels.c:46
#define CHANNEL_OPTION_INITIALIZED
Definition: constants.h:431
smooth NULL
Definition: ftsmooth.c:416
#define False
Definition: types.h:25
#define CHANNEL_OPTION_ENCRYPT_RDP
Definition: constants.h:432

◆ seamless_line_handler()

static BOOL seamless_line_handler ( RDPCLIENT This,
const char line,
void data 
)
static

Definition at line 300 of file seamless.c.

301 {
303  {
304  warning("SeamlessRDP: Invalid request:%s\n", line);
305  }
306  return True;
307 }
static BOOL seamless_process_line(RDPCLIENT *This, const char *line, void *data)
Definition: seamless.c:58
Definition: parser.c:48
#define True
Definition: types.h:24
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define warning(s)
Definition: debug.h:71

Referenced by seamless_process().

◆ seamless_process()

static void seamless_process ( RDPCLIENT This,
STREAM  s 
)
static

Definition at line 311 of file seamless.c.

312 {
313  unsigned int pkglen;
314  static char *rest = NULL;
315  char *buf;
316 
317  pkglen = s->end - s->p;
318  /* str_handle_lines requires null terminated strings */
319  buf = xmalloc(pkglen + 1);
320  STRNCPY(buf, (char *) s->p, pkglen + 1);
321 #if 0
322  printf("seamless recv:\n");
323  hexdump(s->p, pkglen);
324 #endif
325 
327 
328  xfree(buf);
329 }
RD_BOOL str_handle_lines(const char *input, char **rest, str_handle_lines_t linehandler, void *data)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define STRNCPY(dst, src, n)
Definition: rdesktop.h:168
void * xmalloc(int size)
Definition: uimain.c:747
smooth NULL
Definition: ftsmooth.c:416
static BOOL seamless_line_handler(RDPCLIENT *This, const char *line, void *data)
Definition: seamless.c:300
void xfree(void *mem)
Definition: uimain.c:758
GLdouble s
Definition: gl.h:2039
void hexdump(unsigned char *p, unsigned int len)
Definition: shimdbg.c:234
#define printf
Definition: config.h:203

Referenced by seamless_init().

◆ seamless_process_line()

static BOOL seamless_process_line ( RDPCLIENT This,
const char line,
void data 
)
static

Definition at line 58 of file seamless.c.

59 {
60  char *p, *l;
61  char *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;
62  unsigned long id, flags;
63  char *endptr;
64 
65  l = xstrdup(line);
66  p = l;
67 
68  DEBUG_SEAMLESS(("seamlessrdp got:%s\n", p));
69 
70  tok1 = seamless_get_token(&p);
71  tok2 = seamless_get_token(&p);
72  tok3 = seamless_get_token(&p);
73  tok4 = seamless_get_token(&p);
74  tok5 = seamless_get_token(&p);
75  tok6 = seamless_get_token(&p);
76  tok7 = seamless_get_token(&p);
77  tok8 = seamless_get_token(&p);
78 
79  if (!strcmp("CREATE", tok1))
80  {
81  unsigned long group, parent;
82  if (!tok6)
83  return False;
84 
85  id = strtoul(tok3, &endptr, 0);
86  if (*endptr)
87  return False;
88 
89  group = strtoul(tok4, &endptr, 0);
90  if (*endptr)
91  return False;
92 
93  parent = strtoul(tok5, &endptr, 0);
94  if (*endptr)
95  return False;
96 
97  flags = strtoul(tok6, &endptr, 0);
98  if (*endptr)
99  return False;
100 
102  }
103  else if (!strcmp("DESTROY", tok1))
104  {
105  if (!tok4)
106  return False;
107 
108  id = strtoul(tok3, &endptr, 0);
109  if (*endptr)
110  return False;
111 
112  flags = strtoul(tok4, &endptr, 0);
113  if (*endptr)
114  return False;
115 
117 
118  }
119  else if (!strcmp("DESTROYGRP", tok1))
120  {
121  if (!tok4)
122  return False;
123 
124  id = strtoul(tok3, &endptr, 0);
125  if (*endptr)
126  return False;
127 
128  flags = strtoul(tok4, &endptr, 0);
129  if (*endptr)
130  return False;
131 
133  }
134  else if (!strcmp("SETICON", tok1))
135  {
136  unimpl("SeamlessRDP SETICON1\n");
137  }
138  else if (!strcmp("POSITION", tok1))
139  {
140  int x, y, width, height;
141 
142  if (!tok8)
143  return False;
144 
145  id = strtoul(tok3, &endptr, 0);
146  if (*endptr)
147  return False;
148 
149  x = strtol(tok4, &endptr, 0);
150  if (*endptr)
151  return False;
152  y = strtol(tok5, &endptr, 0);
153  if (*endptr)
154  return False;
155 
156  width = strtol(tok6, &endptr, 0);
157  if (*endptr)
158  return False;
159  height = strtol(tok7, &endptr, 0);
160  if (*endptr)
161  return False;
162 
163  flags = strtoul(tok8, &endptr, 0);
164  if (*endptr)
165  return False;
166 
168  }
169  else if (!strcmp("ZCHANGE", tok1))
170  {
171  unsigned long behind;
172 
173  id = strtoul(tok3, &endptr, 0);
174  if (*endptr)
175  return False;
176 
177  behind = strtoul(tok4, &endptr, 0);
178  if (*endptr)
179  return False;
180 
181  flags = strtoul(tok5, &endptr, 0);
182  if (*endptr)
183  return False;
184 
185  ui_seamless_restack_window(This, id, behind, flags);
186  }
187  else if (!strcmp("TITLE", tok1))
188  {
189  if (!tok5)
190  return False;
191 
192  id = strtoul(tok3, &endptr, 0);
193  if (*endptr)
194  return False;
195 
196  flags = strtoul(tok5, &endptr, 0);
197  if (*endptr)
198  return False;
199 
200  ui_seamless_settitle(This, id, tok4, flags);
201  }
202  else if (!strcmp("STATE", tok1))
203  {
204  unsigned int state;
205 
206  if (!tok5)
207  return False;
208 
209  id = strtoul(tok3, &endptr, 0);
210  if (*endptr)
211  return False;
212 
213  state = strtoul(tok4, &endptr, 0);
214  if (*endptr)
215  return False;
216 
217  flags = strtoul(tok5, &endptr, 0);
218  if (*endptr)
219  return False;
220 
222  }
223  else if (!strcmp("DEBUG", tok1))
224  {
225  DEBUG_SEAMLESS(("SeamlessRDP:%s\n", line));
226  }
227  else if (!strcmp("SYNCBEGIN", tok1))
228  {
229  if (!tok3)
230  return False;
231 
232  flags = strtoul(tok3, &endptr, 0);
233  if (*endptr)
234  return False;
235 
237  }
238  else if (!strcmp("SYNCEND", tok1))
239  {
240  if (!tok3)
241  return False;
242 
243  flags = strtoul(tok3, &endptr, 0);
244  if (*endptr)
245  return False;
246 
247  /* do nothing, currently */
248  }
249  else if (!strcmp("HELLO", tok1))
250  {
251  if (!tok3)
252  return False;
253 
254  flags = strtoul(tok3, &endptr, 0);
255  if (*endptr)
256  return False;
257 
259  }
260  else if (!strcmp("ACK", tok1))
261  {
262  unsigned int serial;
263 
264  serial = strtoul(tok3, &endptr, 0);
265  if (*endptr)
266  return False;
267 
269  }
270  else if (!strcmp("HIDE", tok1))
271  {
272  if (!tok3)
273  return False;
274 
275  flags = strtoul(tok3, &endptr, 0);
276  if (*endptr)
277  return False;
278 
280  }
281  else if (!strcmp("UNHIDE", tok1))
282  {
283  if (!tok3)
284  return False;
285 
286  flags = strtoul(tok3, &endptr, 0);
287  if (*endptr)
288  return False;
289 
291  }
292 
293 
294  xfree(l);
295  return True;
296 }
#define DEBUG_SEAMLESS(args)
Definition: seamless.c:30
GLint GLint GLsizei width
Definition: gl.h:1546
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
static char * seamless_get_token(char **s)
Definition: seamless.c:34
void ui_seamless_ack(unsigned int serial)
void ui_seamless_destroy_window(unsigned long id, unsigned long flags)
void ui_seamless_hide_desktop(void)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
void ui_seamless_restack_window(unsigned long id, unsigned long behind, unsigned long flags)
void ui_seamless_setstate(unsigned long id, unsigned int state, unsigned long flags)
void ui_seamless_syncbegin(unsigned long flags)
Definition: parser.c:48
r l[0]
Definition: byte_order.h:167
GLboolean GLuint group
Definition: glext.h:11120
#define True
Definition: types.h:24
#define False
Definition: types.h:25
void xfree(void *mem)
Definition: uimain.c:758
r parent
Definition: btrfs.c:2677
GLbitfield flags
Definition: glext.h:7161
static int state
Definition: maze.c:121
void ui_seamless_begin(RD_BOOL hidden)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void ui_seamless_unhide_desktop(void)
uint32_t serial
Definition: fsck.fat.h:64
#define SEAMLESSRDP_HELLO_HIDDEN
Definition: constants.h:576
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
void ui_seamless_settitle(unsigned long id, const char *title, unsigned long flags)
GLenum GLuint id
Definition: glext.h:5579
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void unimpl(char *format,...)
Definition: uimain.c:801
void ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags)
GLfloat GLfloat p
Definition: glext.h:8902
char * xstrdup(const char *s)
Definition: uimain.c:768
void ui_seamless_destroy_group(unsigned long id, unsigned long flags)
void ui_seamless_create_window(unsigned long id, unsigned long group, unsigned long parent, unsigned long flags)

Referenced by seamless_line_handler().

◆ seamless_select_timeout()

void seamless_select_timeout ( RDPCLIENT This,
struct timeval tv 
)

Definition at line 416 of file seamless.c.

417 {
418  struct timeval ourtimeout = { 0, SEAMLESSRDP_POSITION_TIMER };
419 
420  if (This->seamless_rdp)
421  {
422  if (timercmp(&ourtimeout, tv, <))
423  {
424  tv->tv_sec = ourtimeout.tv_sec;
425  tv->tv_usec = ourtimeout.tv_usec;
426  }
427  }
428 }
unsigned long tv_sec
Definition: linux.h:1738
unsigned long tv_usec
Definition: linux.h:1739
#define SEAMLESSRDP_POSITION_TIMER
Definition: constants.h:570
#define timercmp(tvp, uvp, cmp)
Definition: rdesktop.h:184

◆ seamless_send()

static unsigned int seamless_send ( RDPCLIENT This,
const char command,
const char format,
  ... 
)
static

Definition at line 348 of file seamless.c.

349 {
350  STREAM s;
351  size_t len;
352  va_list argp;
353  char buf[1025];
354 
355  len = snprintf(buf, sizeof(buf) - 1, "%s,%u,", command, This->seamless.serial);
356 
357  assert(len < (sizeof(buf) - 1));
358 
359  va_start(argp, format);
360  len += vsnprintf(buf + len, sizeof(buf) - len - 1, format, argp);
361  va_end(argp);
362 
363  assert(len < (sizeof(buf) - 1));
364 
365  buf[len] = '\n';
366  buf[len + 1] = '\0';
367 
368  len++;
369 
370  s = channel_init(This, This->seamless.channel, len);
372 
373  DEBUG_SEAMLESS(("SeamlessRDP sending:%s", buf));
374 
375 #if 0
376  printf("seamless send:\n");
377  hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);
378 #endif
379 
380  channel_send(This, s, This->seamless.channel);
381 
382  return This->seamless.serial++;
383 }
#define vsnprintf
Definition: tif_win32.c:406
#define DEBUG_SEAMLESS(args)
Definition: seamless.c:30
#define out_uint8p(s, v, n)
Definition: parse.h:93
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define snprintf
Definition: wintirpc.h:48
#define assert(x)
Definition: debug.h:53
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
Definition: parse.h:22
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
void hexdump(unsigned char *p, unsigned int len)
Definition: shimdbg.c:234
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define s_mark_end(s)
Definition: parse.h:41
void channel_send(STREAM s, VCHANNEL *channel)
Definition: channels.c:79
#define printf
Definition: config.h:203
STREAM channel_init(VCHANNEL *channel, uint32 length)
Definition: channels.c:69

Referenced by seamless_send_focus(), seamless_send_position(), seamless_send_state(), seamless_send_sync(), and seamless_send_zchange().

◆ seamless_send_focus()

unsigned int seamless_send_focus ( RDPCLIENT This,
unsigned long  id,
unsigned long  flags 
)

Definition at line 443 of file seamless.c.

444 {
445  if (!This->seamless_rdp)
446  return (unsigned int) -1;
447 
448  return seamless_send(This, "FOCUS", "0x%08lx,0x%lx", id, flags);
449 }
static unsigned int seamless_send(RDPCLIENT *This, const char *command, const char *format,...)
Definition: seamless.c:348
GLbitfield flags
Definition: glext.h:7161

◆ seamless_send_position()

unsigned int seamless_send_position ( RDPCLIENT This,
unsigned long  id,
int  x,
int  y,
int  width,
int  height,
unsigned long  flags 
)

Definition at line 407 of file seamless.c.

408 {
409  return seamless_send(This, "POSITION", "0x%08lx,%d,%d,%d,%d,0x%lx", id, x, y, width, height,
410  flags);
411 }
GLint GLint GLsizei width
Definition: gl.h:1546
static unsigned int seamless_send(RDPCLIENT *This, const char *command, const char *format,...)
Definition: seamless.c:348
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ seamless_send_state()

unsigned int seamless_send_state ( RDPCLIENT This,
unsigned long  id,
unsigned int  state,
unsigned long  flags 
)

Definition at line 397 of file seamless.c.

398 {
399  if (!This->seamless_rdp)
400  return (unsigned int) -1;
401 
402  return seamless_send(This, "STATE", "0x%08lx,0x%x,0x%lx", id, state, flags);
403 }
static unsigned int seamless_send(RDPCLIENT *This, const char *command, const char *format,...)
Definition: seamless.c:348
GLbitfield flags
Definition: glext.h:7161
static int state
Definition: maze.c:121

◆ seamless_send_sync()

unsigned int seamless_send_sync ( RDPCLIENT This)

Definition at line 387 of file seamless.c.

388 {
389  if (!This->seamless_rdp)
390  return (unsigned int) -1;
391 
392  return seamless_send(This, "SYNC", "");
393 }
static unsigned int seamless_send(RDPCLIENT *This, const char *command, const char *format,...)
Definition: seamless.c:348

◆ seamless_send_zchange()

unsigned int seamless_send_zchange ( RDPCLIENT This,
unsigned long  id,
unsigned long  below,
unsigned long  flags 
)

Definition at line 432 of file seamless.c.

433 {
434  if (!This->seamless_rdp)
435  return (unsigned int) -1;
436 
437  return seamless_send(This, "ZCHANGE", "0x%08lx,0x%08lx,0x%lx", id, below, flags);
438 }
static unsigned int seamless_send(RDPCLIENT *This, const char *command, const char *format,...)
Definition: seamless.c:348
GLbitfield flags
Definition: glext.h:7161