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 |
|
|
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) |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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); |
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 |
340 |
if (!g_seamless_rdp) |
if (!g_seamless_rdp) |
341 |
return; |
return; |
342 |
|
|
343 |
seamless_send("SYNC\n"); |
seamless_send("SYNC", ""); |
344 |
} |
} |
345 |
|
|
346 |
|
|
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 |
|
|
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 |
|
|
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 |
} |
} |