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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1094 - (hide annotations)
Fri Mar 10 10:40:50 2006 UTC (18 years, 3 months ago) by astrand
File MIME type: text/plain
File size: 4976 byte(s)
SETSTATE is not two ops: TITLE and STATE

1 astrand 1089 /* -*- 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 astrand 1090 if (!strcmp("CREATE", tok1))
84 astrand 1089 {
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 astrand 1090 else if (!strcmp("DESTROY", tok1))
99 astrand 1089 {
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 astrand 1090 else if (!strcmp("SETICON", tok1))
115 astrand 1089 {
116     unimpl("SeamlessRDP SETICON1\n");
117     }
118 astrand 1090 else if (!strcmp("POSITION", tok1))
119 astrand 1089 {
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 astrand 1090 else if (!strcmp("ZCHANGE", tok1))
150 astrand 1089 {
151     unimpl("SeamlessRDP ZCHANGE1\n");
152     }
153 astrand 1094 else if (!strcmp("TITLE", tok1))
154 astrand 1089 {
155 astrand 1094 if (!tok4)
156     return False;
157    
158     id = strtol(tok2, &endptr, 16);
159     if (*endptr)
160     return False;
161    
162     flags = strtol(tok4, &endptr, 16);
163     if (*endptr)
164     return False;
165    
166     ui_seamless_settitle(id, tok3, flags);
167     }
168     else if (!strcmp("STATE", tok1))
169     {
170 astrand 1089 unsigned int state;
171    
172 astrand 1094 if (!tok4)
173 astrand 1089 return False;
174    
175     id = strtol(tok2, &endptr, 16);
176     if (*endptr)
177     return False;
178    
179 astrand 1094 state = strtol(tok3, &endptr, 16);
180 astrand 1089 if (*endptr)
181     return False;
182    
183 astrand 1094 flags = strtol(tok4, &endptr, 16);
184 astrand 1089 if (*endptr)
185     return False;
186    
187     ui_seamless_setstate(id, state, flags);
188     }
189 astrand 1090 else if (!strcmp("DEBUG", tok1))
190 astrand 1089 {
191     printf("SeamlessRDP:%s\n", line);
192     }
193    
194     xfree(l);
195     return True;
196     }
197    
198    
199     static BOOL
200     seamless_line_handler(const char *line, void *data)
201     {
202     if (!seamless_process_line(line, data))
203     {
204     warning("SeamlessRDP: Invalid request:%s\n", line);
205     }
206     return True;
207     }
208    
209    
210     static void
211     seamless_process(STREAM s)
212     {
213     unsigned int pkglen;
214     static char *rest = NULL;
215     char *buf;
216    
217     pkglen = s->end - s->p;
218     /* str_handle_lines requires null terminated strings */
219     buf = xmalloc(pkglen + 1);
220     STRNCPY(buf, (char *) s->p, pkglen + 1);
221     #if 0
222     printf("seamless recv:\n");
223     hexdump(s->p, pkglen);
224     #endif
225    
226     str_handle_lines(buf, &rest, seamless_line_handler, NULL);
227    
228     xfree(buf);
229     }
230    
231    
232     BOOL
233     seamless_init(void)
234     {
235     seamless_channel =
236     channel_register("seamrdp", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP,
237     seamless_process);
238     return (seamless_channel != NULL);
239     }
240    
241    
242     static void
243     seamless_send(const char *output)
244     {
245     STREAM s;
246     size_t len;
247    
248     len = strlen(output);
249     s = channel_init(seamless_channel, len);
250     out_uint8p(s, output, len) s_mark_end(s);
251    
252     #if 0
253     printf("seamless send:\n");
254     hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);
255     #endif
256    
257     channel_send(s, seamless_channel);
258     }
259    
260    
261     void
262     seamless_send_sync()
263     {
264     seamless_send("SYNC\n");
265     }

  ViewVC Help
Powered by ViewVC 1.1.26