CVS: seamlessrdp/ServerExe main.c,1.31,1.32
Pierre Ossman <[email protected]> Tue, 30 May 2006 03:39:14 -0700
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv718/ServerExe
Modified Files:
main.c
Log Message:
Use a polled system to detect when clients reconnect. This way we can support
Windows 2000 as well.
Index: main.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** main.c 22 Mar 2006 16:19:41 -0000 1.31
--- main.c 30 May 2006 10:39:11 -0000 1.32
***************
*** 36,49 ****
#define APP_NAME "SeamlessRDP Shell"
- #ifndef WM_WTSSESSION_CHANGE
- #define WM_WTSSESSION_CHANGE 0x02B1
- #endif
- #ifndef WTS_REMOTE_CONNECT
- #define WTS_REMOTE_CONNECT 0x3
- #endif
-
/* Global data */
static HINSTANCE g_instance;
- static HWND g_hwnd;
static DWORD g_session_id;
--- 36,41 ----
***************
*** 51,54 ****
--- 43,47 ----
static int g_startup_num_procs;
+ static BOOL g_connected;
static BOOL g_desktop_hidden;
***************
*** 230,291 ****
}
- static LRESULT CALLBACK
- wndproc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
- {
- if (message == WM_WTSSESSION_CHANGE)
- {
- if (wparam == WTS_REMOTE_CONNECT)
- {
- int flags;
- /* These get reset on each reconnect */
- SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);
- SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
- SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);
-
- flags = SEAMLESS_HELLO_RECONNECT;
- if (g_desktop_hidden)
- flags |= SEAMLESS_HELLO_HIDDEN;
- vchannel_write("HELLO", "0x%08x", flags);
- }
- }
-
- return DefWindowProc(hwnd, message, wparam, lparam);
- }
-
- static BOOL
- register_class(void)
- {
- WNDCLASSEX wcx;
-
- memset(&wcx, 0, sizeof(wcx));
-
- wcx.cbSize = sizeof(wcx);
- wcx.lpfnWndProc = wndproc;
- wcx.hInstance = g_instance;
- wcx.lpszClassName = "SeamlessClass";
-
- return RegisterClassEx(&wcx);
- }
-
- static BOOL
- create_wnd(void)
- {
- if (!register_class())
- return FALSE;
-
- g_hwnd = CreateWindow("SeamlessClass",
- "Seamless Window",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT, (HWND) NULL, (HMENU) NULL, g_instance, (LPVOID) NULL);
-
- if (!g_hwnd)
- return FALSE;
-
- return TRUE;
- }
-
static BOOL
build_startup_procs(void)
--- 223,226 ----
***************
*** 366,369 ****
--- 301,324 ----
static BOOL
+ is_connected(void)
+ {
+ BOOL res;
+ INT *state;
+ DWORD size;
+
+ res = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
+ WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *) & state,
+ &size);
+ if (!res)
+ return TRUE;
+
+ res = *state == WTSActive;
+
+ WTSFreeMemory(state);
+
+ return res;
+ }
+
+ static BOOL
is_desktop_hidden(void)
{
***************
*** 422,434 ****
}
- if (!create_wnd())
- {
- FreeLibrary(hookdll);
- message("Couldn't create a window to catch events.");
- return -1;
- }
-
- WTSRegisterSessionNotification(g_hwnd, NOTIFY_FOR_THIS_SESSION);
-
ProcessIdToSessionId(GetCurrentProcessId(), &g_session_id);
--- 377,380 ----
***************
*** 437,440 ****
--- 383,387 ----
vchannel_open();
+ g_connected = is_connected();
g_desktop_hidden = is_desktop_hidden();
***************
*** 481,484 ****
--- 428,451 ----
while (check_counter-- || !should_terminate())
{
+ BOOL connected;
+
+ connected = is_connected();
+ if (connected && !g_connected)
+ {
+ int flags;
+ /* These get reset on each reconnect */
+ SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);
+ SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL,
+ 0);
+ SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);
+
+ flags = SEAMLESS_HELLO_RECONNECT;
+ if (g_desktop_hidden)
+ flags |= SEAMLESS_HELLO_HIDDEN;
+ vchannel_write("HELLO", "0x%08x", flags);
+ }
+
+ g_connected = connected;
+
if (check_counter < 0)
{
***************
*** 515,520 ****
}
- WTSUnRegisterSessionNotification(g_hwnd);
-
remove_hooks_fn();
--- 482,485 ----
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642