changeset 3907:41e7544a9c67

[gaim-migrate @ 4060] wgaim_cleanup added committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 05 Nov 2002 23:00:53 +0000
parents eb1d58c2d6af
children d65cf1d628d8
files src/aim.c src/win32/win32dep.c src/win32/win32dep.h
diffstat 3 files changed, 51 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;
 
 }
--- 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;
--- 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