From: <dat...@us...> - 2006-10-21 19:13:01
|
Revision: 17556 http://svn.sourceforge.net/gaim/?rev=17556&view=rev Author: datallah Date: 2006-10-21 12:12:54 -0700 (Sat, 21 Oct 2006) Log Message: ----------- This will fix the constant network change notification in Wingaim when "Peer Name Resolution Protocol" service is enabled. We now only look at the Network Location Awareness namespace. Add some better error handling. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-10-20 23:08:07 UTC (rev 17555) +++ trunk/libgaim/network.c 2006-10-21 19:12:54 UTC (rev 17556) @@ -377,6 +377,9 @@ } #ifdef _WIN32 +#ifndef NS_NLA +#define NS_NLA 15 +#endif static gint wgaim_get_connected_network_count(void) { @@ -388,13 +391,15 @@ memset(&qs, 0, sizeof(WSAQUERYSET)); qs.dwSize = sizeof(WSAQUERYSET); - qs.dwNameSpace = NS_ALL; + qs.dwNameSpace = NS_NLA; retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); if (retval != ERROR_SUCCESS) { int errorid = WSAGetLastError(); gchar *msg = g_win32_error_message(errorid); - gaim_debug_warning("network", "Couldn't look up connected networks. %s (%d).\n", msg, errorid); + gaim_debug_warning("network", "Couldn't retrieve NLA SP lookup handle. " + "NLA service is probably not running. Message: %s (%d).\n", + msg, errorid); g_free(msg); return -1; @@ -446,13 +451,11 @@ time_t last_trigger = time(NULL); int WSAAPI (*MyWSANSPIoctl) ( - HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, - DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, - LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion) = NULL; + HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, + DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, + LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion) = NULL; - MyWSANSPIoctl = (void*) wgaim_find_and_loadproc("ws2_32.dll", "WSANSPIoctl"); - if (!MyWSANSPIoctl) { - gaim_debug_error("network", "Couldn't load WSANSPIoctl from ws2_32.dll.\n"); + if (!(MyWSANSPIoctl = (void*) wgaim_find_and_loadproc("ws2_32.dll", "WSANSPIoctl"))) { g_thread_exit(NULL); return NULL; } @@ -463,10 +466,18 @@ memset(&qs, 0, sizeof(WSAQUERYSET)); qs.dwSize = sizeof(WSAQUERYSET); - qs.dwNameSpace = NS_ALL; + qs.dwNameSpace = NS_NLA; + if (WSALookupServiceBegin(&qs, 0, &h) == SOCKET_ERROR) { + int errorid = WSAGetLastError(); + gchar *msg = g_win32_error_message(errorid); + gaim_debug_warning("network", "Couldn't retrieve NLA SP lookup handle. " + "NLA service is probably not running. Message: %s (%d).\n", + msg, errorid); + g_free(msg); + g_thread_exit(NULL); + return NULL; + } - retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); - /* Make sure at least 30 seconds have elapsed since the last * notification so we don't peg the cpu if this keeps changing. */ if ((time(NULL) - last_trigger) < 30) @@ -475,13 +486,22 @@ last_trigger = time(NULL); /* This will block until there is a network change */ - retval = MyWSANSPIoctl(h, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, NULL); + if (MyWSANSPIoctl(h, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, NULL) == SOCKET_ERROR) { + int errorid = WSAGetLastError(); + gchar *msg = g_win32_error_message(errorid); + gaim_debug_warning("network", "Unable to wait for changes. Message: %s (%d).\n", + msg, errorid); + g_free(msg); + } retval = WSALookupServiceEnd(h); g_idle_add(wgaim_network_change_thread_cb, NULL); } + + g_thread_exit(NULL); + return NULL; } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |