CVS: seamlessrdp/ServerExe main.c,1.17,1.18

Pierre Ossman <[email protected]> Thu, 16 Mar 2006 06:54:05 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1735/ServerExe

Modified Files:
	main.c 
Log Message:
Send a HELLO when starting up and when a client reconnects.


Index: main.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** main.c	16 Mar 2006 13:24:18 -0000	1.17
--- main.c	16 Mar 2006 14:54:02 -0000	1.18
***************
*** 25,28 ****
--- 25,30 ----
  #include <windows.h>
  #include <stdio.h>
+ #include <wtsapi32.h>
+ #include <cchannel.h>
  
  #include "vchannel.h"
***************
*** 32,37 ****
--- 34,47 ----
  #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;
  
  typedef void (*set_hooks_proc_t) ();
***************
*** 194,197 ****
--- 204,254 ----
  }
  
+ static LRESULT CALLBACK
+ wndproc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
+ {
+ 	if (message == WM_WTSSESSION_CHANGE)
+ 	{
+ 		if (wparam == WTS_REMOTE_CONNECT)
+ 			vchannel_write("HELLO,0x%08x", 1);
+ 	}
+ 
+ 	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;
+ }
+ 
  int WINAPI
  WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow)
***************
*** 232,237 ****
--- 289,305 ----
  	}
  
+ 	if (!create_wnd())
+ 	{
+ 		FreeLibrary(hookdll);
+ 		message("Couldn't create a window to catch events.");
+ 		return -1;
+ 	}
+ 
+ 	WTSRegisterSessionNotification(g_hwnd, NOTIFY_FOR_THIS_SESSION);
+ 
  	vchannel_open();
  
+ 	vchannel_write("HELLO,0x%08x", 0);
+ 
  	set_hooks_fn();
  
***************
*** 254,257 ****
--- 322,326 ----
  		PROCESS_INFORMATION proc_info;
  		STARTUPINFO startup_info;
+ 		MSG msg;
  
  		memset(&startup_info, 0, sizeof(STARTUPINFO));
***************
*** 265,268 ****
--- 334,342 ----
  			do
  			{
+ 				while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ 				{
+ 					TranslateMessage(&msg);
+ 					DispatchMessage(&msg);
+ 				}
  				process_cmds();
  				Sleep(100);
***************
*** 285,288 ****
--- 359,364 ----
  	}
  
+ 	WTSUnRegisterSessionNotification(g_hwnd);
+ 
  	remove_hooks_fn();
  



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