/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1090 - (show annotations)
Fri Mar 10 09:01:51 2006 UTC (18 years, 3 months ago) by astrand
File MIME type: text/plain
File size: 4785 byte(s)
Removed the version numbers from SeamlessRDP commands

1 /* -*- c-basic-offset: 8 -*-
2 rdesktop: A Remote Desktop Protocol client.
3 Seamless Windows support
4 Copyright (C) Peter Astrand <astrand@cendio.se> 2005-2006
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "rdesktop.h"
22
23 /* #define WITH_DEBUG_SEAMLESS */
24
25 #ifdef WITH_DEBUG_SEAMLESS
26 #define DEBUG_SEAMLESS(args) printf args;
27 #else
28 #define DEBUG_SEAMLESS(args)
29 #endif
30
31 extern BOOL g_seamless_rdp;
32 static VCHANNEL *seamless_channel;
33
34 static char *
35 seamless_get_token(char **s)
36 {
37 char *comma, *head;
38 head = *s;
39
40 if (!head)
41 return NULL;
42
43 comma = strchr(head, ',');
44 if (comma)
45 {
46 *comma = '\0';
47 *s = comma + 1;
48 }
49 else
50 {
51 *s = NULL;
52 }
53
54 return head;
55 }
56
57
58 static BOOL
59 seamless_process_line(const char *line, void *data)
60 {
61 char *p, *l;
62 char *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;
63 unsigned long id, flags;
64 char *endptr;
65
66 l = xstrdup(line);
67 p = l;
68
69 DEBUG_SEAMLESS(("seamlessrdp line:%s\n", p));
70
71 if (!g_seamless_rdp)
72 return True;
73
74 tok1 = seamless_get_token(&p);
75 tok2 = seamless_get_token(&p);
76 tok3 = seamless_get_token(&p);
77 tok4 = seamless_get_token(&p);
78 tok5 = seamless_get_token(&p);
79 tok6 = seamless_get_token(&p);
80 tok7 = seamless_get_token(&p);
81 tok8 = seamless_get_token(&p);
82
83 if (!strcmp("CREATE", tok1))
84 {
85 if (!tok3)
86 return False;
87
88 id = strtol(tok2, &endptr, 16);
89 if (*endptr)
90 return False;
91
92 flags = strtol(tok3, &endptr, 16);
93 if (*endptr)
94 return False;
95
96 ui_seamless_create_window(id, flags);
97 }
98 else if (!strcmp("DESTROY", tok1))
99 {
100 if (!tok3)
101 return False;
102
103 id = strtol(tok2, &endptr, 16);
104 if (*endptr)
105 return False;
106
107 flags = strtol(tok3, &endptr, 16);
108 if (*endptr)
109 return False;
110
111 ui_seamless_destroy_window(id, flags);
112
113 }
114 else if (!strcmp("SETICON", tok1))
115 {
116 unimpl("SeamlessRDP SETICON1\n");
117 }
118 else if (!strcmp("POSITION", tok1))
119 {
120 int x, y, width, height;
121
122 if (!tok7)
123 return False;
124
125 id = strtol(tok2, &endptr, 16);
126 if (*endptr)
127 return False;
128
129 x = strtol(tok3, &endptr, 10);
130 if (*endptr)
131 return False;
132 y = strtol(tok4, &endptr, 10);
133 if (*endptr)
134 return False;
135
136 width = strtol(tok5, &endptr, 10);
137 if (*endptr)
138 return False;
139 height = strtol(tok6, &endptr, 10);
140 if (*endptr)
141 return False;
142
143 flags = strtol(tok7, &endptr, 16);
144 if (*endptr)
145 return False;
146
147 ui_seamless_move_window(id, x, y, width, height, flags);
148 }
149 else if (!strcmp("ZCHANGE", tok1))
150 {
151 unimpl("SeamlessRDP ZCHANGE1\n");
152 }
153 else if (!strcmp("SETSTATE", tok1))
154 {
155 unsigned int state;
156
157 if (!tok5)
158 return False;
159
160 id = strtol(tok2, &endptr, 16);
161 if (*endptr)
162 return False;
163
164 state = strtol(tok4, &endptr, 16); // XXX
165 if (*endptr)
166 return False;
167
168 flags = strtol(tok5, &endptr, 16);
169 if (*endptr)
170 return False;
171
172 /* FIXME */
173 ui_seamless_settitle(id, tok3);
174 ui_seamless_setstate(id, state, flags);
175 }
176 else if (!strcmp("DEBUG", tok1))
177 {
178 printf("SeamlessRDP:%s\n", line);
179 }
180
181 xfree(l);
182 return True;
183 }
184
185
186 static BOOL
187 seamless_line_handler(const char *line, void *data)
188 {
189 if (!seamless_process_line(line, data))
190 {
191 warning("SeamlessRDP: Invalid request:%s\n", line);
192 }
193 return True;
194 }
195
196
197 static void
198 seamless_process(STREAM s)
199 {
200 unsigned int pkglen;
201 static char *rest = NULL;
202 char *buf;
203
204 pkglen = s->end - s->p;
205 /* str_handle_lines requires null terminated strings */
206 buf = xmalloc(pkglen + 1);
207 STRNCPY(buf, (char *) s->p, pkglen + 1);
208 #if 0
209 printf("seamless recv:\n");
210 hexdump(s->p, pkglen);
211 #endif
212
213 str_handle_lines(buf, &rest, seamless_line_handler, NULL);
214
215 xfree(buf);
216 }
217
218
219 BOOL
220 seamless_init(void)
221 {
222 seamless_channel =
223 channel_register("seamrdp", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,
224 seamless_process);
225 return (seamless_channel != NULL);
226 }
227
228
229 static void
230 seamless_send(const char *output)
231 {
232 STREAM s;
233 size_t len;
234
235 len = strlen(output);
236 s = channel_init(seamless_channel, len);
237 out_uint8p(s, output, len) s_mark_end(s);
238
239 #if 0
240 printf("seamless send:\n");
241 hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);
242 #endif
243
244 channel_send(s, seamless_channel);
245 }
246
247
248 void
249 seamless_send_sync()
250 {
251 seamless_send("SYNC\n");
252 }

  ViewVC Help
Powered by ViewVC 1.1.26