CVS: seamlessrdp/ServerExe main.c,1.3,1.4 vchannel.c,1.2,1.3 vchannel.h,1.2,1.3
Pierre Ossman <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14201
Modified Files:
main.c vchannel.c vchannel.h
Log Message:
Implement the SYNC command. Enumerates all windows and sends over their
information.
Index: main.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** main.c 9 Mar 2006 13:24:35 -0000 1.3
--- main.c 9 Mar 2006 15:14:48 -0000 1.4
***************
*** 45,48 ****
--- 45,128 ----
}
+ static char *
+ get_token(char **s)
+ {
+ char *comma, *head;
+ head = *s;
+
+ if (!head)
+ return NULL;
+
+ comma = strchr(head, ',');
+ if (comma)
+ {
+ *comma = '\0';
+ *s = comma + 1;
+ }
+ else
+ {
+ *s = NULL;
+ }
+
+ return head;
+ }
+
+ static BOOL CALLBACK enum_cb(HWND hwnd, LPARAM lparam)
+ {
+ RECT rect;
+ char title[150];
+ LONG styles;
+ int state;
+
+ styles = GetWindowLong(hwnd, GWL_STYLE);
+
+ if (!(styles & WS_VISIBLE))
+ return TRUE;
+
+ vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);
+
+ if (!GetWindowRect(hwnd, &rect)) {
+ debug("GetWindowRect failed!");
+ return TRUE;
+ }
+
+ vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",
+ hwnd,
+ rect.left, rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ 0);
+
+ GetWindowText(hwnd, title, sizeof(title));
+
+ /* FIXME: Strip title of dangerous characters */
+
+ if (styles & WS_MAXIMIZE)
+ state = 2;
+ else if (styles & WS_MINIMIZE)
+ state = 1;
+ else
+ state = 0;
+
+ vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",
+ hwnd, title, state, 0);
+
+ return TRUE;
+ }
+
+ static void
+ do_sync(void)
+ {
+ vchannel_block();
+
+ vchannel_write("SYNCBEGIN,0x0");
+
+ EnumWindows(enum_cb, 0);
+
+ vchannel_write("SYNCEND,0x0");
+
+ vchannel_unblock();
+ }
+
static void
process_cmds(void)
***************
*** 51,56 ****
--- 131,152 ----
int size;
+ char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;
+
while ((size = vchannel_read(line, sizeof(line))) >= 0) {
debug("Got: %s", line);
+
+ p = line;
+
+ tok1 = get_token(&p);
+ tok2 = get_token(&p);
+ tok3 = get_token(&p);
+ tok4 = get_token(&p);
+ tok5 = get_token(&p);
+ tok6 = get_token(&p);
+ tok7 = get_token(&p);
+ tok8 = get_token(&p);
+
+ if (strcmp(tok1, "SYNC") == 0)
+ do_sync();
}
}
Index: vchannel.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vchannel.c 9 Mar 2006 13:24:35 -0000 1.2
--- vchannel.c 9 Mar 2006 15:14:50 -0000 1.3
***************
*** 183,184 ****
--- 183,196 ----
return bytes_written;
}
+
+ void
+ vchannel_block()
+ {
+ WaitForSingleObject(g_mutex, INFINITE);
+ }
+
+ void
+ vchannel_unblock()
+ {
+ ReleaseMutex(g_mutex);
+ }
Index: vchannel.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vchannel.h 9 Mar 2006 13:24:35 -0000 1.2
--- vchannel.h 9 Mar 2006 15:14:53 -0000 1.3
***************
*** 36,38 ****
--- 36,41 ----
int vchannel_write(char *format, ...);
+ void vchannel_block();
+ void vchannel_unblock();
+
#endif
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642