# HG changeset patch # User Herman Bloggs # Date 1036537253 0 # Node ID 41e7544a9c67199163fb8875aa257d9e38f338a6 # Parent eb1d58c2d6afa8d4dbd3e7816c5feb0ecf636ace [gaim-migrate @ 4060] wgaim_cleanup added committer: Tailor Script diff -r eb1d58c2d6af -r 41e7544a9c67 src/aim.c --- a/src/aim.c Tue Nov 05 22:59:53 2002 +0000 +++ b/src/aim.c Tue Nov 05 23:00:53 2002 +0000 @@ -778,6 +778,12 @@ #if GAIM_PLUGINS || USE_PERL gaim_probe_plugins(); #endif + +#ifdef _WIN32 + /* Various win32 initializations */ + wgaim_init(); +#endif + load_prefs(); core_main(); #ifndef _WIN32 @@ -812,15 +818,13 @@ account_editor(NULL, NULL); } else if ((dologin_ret == -1) && !connections) show_login(); -#ifdef _WIN32 - /* Various win32 initializations */ - wgaim_init(); -#endif gtk_main(); core_quit(); /* don't need ui_quit here because ui doesn't create anything */ - +#ifdef _WIN32 + wgaim_cleanup(); +#endif return 0; } diff -r eb1d58c2d6af -r 41e7544a9c67 src/win32/win32dep.c --- a/src/win32/win32dep.c Tue Nov 05 22:59:53 2002 +0000 +++ b/src/win32/win32dep.c Tue Nov 05 23:00:53 2002 +0000 @@ -145,9 +145,35 @@ /* Windows Initializations */ void wgaim_init(void) { + WORD wVersionRequested; + WSADATA wsaData; + int err; char* locale=0; char newenv[128]; + debug_printf("wgaim_init\n"); + /* + * Winsock init + */ + wVersionRequested = MAKEWORD( 2, 2 ); + + err = WSAStartup( wVersionRequested, &wsaData ); + if ( err != 0 ) { + return 1; + } + + /* Confirm that the winsock DLL supports 2.2 */ + /* Note that if the DLL supports versions greater than + 2.2 in addition to 2.2, it will still return 2.2 in + wVersion since that is the version we requested. */ + + if ( LOBYTE( wsaData.wVersion ) != 2 || + HIBYTE( wsaData.wVersion ) != 2 ) { + debug_printf("Could not find a usable WinSock DLL. Oh well.\n"); + WSACleanup( ); + return 1; + } + /* Filter to catch systray events */ gdk_add_client_message_filter (GDK_POINTER_TO_ATOM (WM_TRAYMESSAGE), traymsg_filter_func, @@ -165,11 +191,25 @@ debug_printf("putenv failed\n"); g_free(locale); - /* IdleTracker Initialization */ + /* + * IdleTracker Initialization + */ if(!IdleTrackerInit()) debug_printf("IdleTracker failed to initialize\n"); } +/* Windows Cleanup */ + +void wgaim_cleanup(void) { + debug_printf("wgaim_cleanup\n"); + + /* winsock cleanup */ + WSACleanup( ); + + /* IdleTracker cleanup */ + IdleTrackerTerm(); +} + BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { gaimdll_hInstance = hinstDLL; return TRUE; diff -r eb1d58c2d6af -r 41e7544a9c67 src/win32/win32dep.h --- a/src/win32/win32dep.h Tue Nov 05 22:59:53 2002 +0000 +++ b/src/win32/win32dep.h Tue Nov 05 23:00:53 2002 +0000 @@ -22,6 +22,7 @@ GdkEvent *event, gpointer data); extern void wgaim_init(void); +extern void wgaim_cleanup(void); /* * MACROS