From: <dat...@us...> - 2006-10-19 01:56:44
|
Revision: 17540 http://svn.sourceforge.net/gaim/?rev=17540&view=rev Author: datallah Date: 2006-10-18 18:56:40 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Various fixes for wingaim network manager stuff. When unable to look up network connections, assume that there is one. Fix error handling. Remove note about using WSANSPIoctl directly - it isn't supported on w2k anyway. Fix compile warning Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-10-19 00:03:10 UTC (rev 17539) +++ trunk/libgaim/network.c 2006-10-19 01:56:40 UTC (rev 17540) @@ -392,9 +392,12 @@ retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); if (retval != ERROR_SUCCESS) { - gchar *msg = g_win32_error_message(retval); - gaim_debug_warning("network", "Couldn't look up connected networks. %s (%lu).\n", msg, retval); + 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); g_free(msg); + + net_cnt = 1; /* Assume something is connected */ } else { char buf[1024]; WSAQUERYSET *res = (LPWSAQUERYSET) buf; @@ -461,10 +464,7 @@ retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); /* This will block until there is a network change */ - /* This is missing from the MinGW libws2_32.a as of version 3.7. - * When this patch: http://sourceforge.net/tracker/index.php?func=detail&aid=1576083&group_id=2435&atid=302435 gets into a release, we can call this directly - * retval = WSANSPIoctl(h, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, NULL);*/ - retval = MyWSANSPIoctl(h, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, NULL); + retval = MyWSANSPIoctl(h, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, NULL); retval = WSALookupServiceEnd(h); @@ -489,7 +489,7 @@ } if (libnm_retval == LIBNM_ACTIVE_NETWORK_CONNECTION) return TRUE; } -#elif _WIN32 +#elif define _WIN32 return (current_network_count > 0); #endif return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-10-19 01:58:34
|
Revision: 17541 http://svn.sourceforge.net/gaim/?rev=17541&view=rev Author: datallah Date: 2006-10-18 18:58:21 -0700 (Wed, 18 Oct 2006) Log Message: ----------- I suck. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-10-19 01:56:40 UTC (rev 17540) +++ trunk/libgaim/network.c 2006-10-19 01:58:21 UTC (rev 17541) @@ -489,7 +489,7 @@ } if (libnm_retval == LIBNM_ACTIVE_NETWORK_CONNECTION) return TRUE; } -#elif define _WIN32 +#elif defined _WIN32 return (current_network_count > 0); #endif return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-10-19 03:23:06
|
Revision: 17544 http://svn.sourceforge.net/gaim/?rev=17544&view=rev Author: datallah Date: 2006-10-18 20:23:01 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Robustify the wingaim network managers stuff. Apparently if people disable certain windows services the networks lookup fails and the "wait for changes" function returns immediately. This will make wingaim not go ape when this is the case. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-10-19 03:14:51 UTC (rev 17543) +++ trunk/libgaim/network.c 2006-10-19 03:23:01 UTC (rev 17544) @@ -377,7 +377,7 @@ } #ifdef _WIN32 -static guint +static gint wgaim_get_connected_network_count(void) { guint net_cnt = 0; @@ -397,7 +397,7 @@ gaim_debug_warning("network", "Couldn't look up connected networks. %s (%d).\n", msg, errorid); g_free(msg); - net_cnt = 1; /* Assume something is connected */ + return -1; } else { char buf[1024]; WSAQUERYSET *res = (LPWSAQUERYSET) buf; @@ -418,11 +418,14 @@ static gboolean wgaim_network_change_thread_cb(gpointer data) { - guint new_count; + gint new_count; GaimConnectionUiOps *ui_ops = gaim_connections_get_ui_ops(); new_count = wgaim_get_connected_network_count(); + if (new_count < 0) + return FALSE; + gaim_debug_info("network", "Received Network Change Notification. Current network count is %d, previous count was %d.\n", new_count, current_network_count); if (new_count > 0) { @@ -440,6 +443,7 @@ { HANDLE h; WSAQUERYSET qs; + time_t last_trigger = time(NULL); int WSAAPI (*MyWSANSPIoctl) ( HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, @@ -463,12 +467,20 @@ 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) + Sleep(30000); + + 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); retval = WSALookupServiceEnd(h); g_idle_add(wgaim_network_change_thread_cb, NULL); + } } #endif @@ -534,9 +546,17 @@ { #ifdef _WIN32 GError *err = NULL; - current_network_count = wgaim_get_connected_network_count(); - if (!g_thread_create(wgaim_network_change_thread, NULL, FALSE, &err)) - gaim_debug_error("network", "Couldn't create Network Monitor thread: %s\n", err ? err->message : ""); + gint cnt = wgaim_get_connected_network_count(); + + if (cnt < 0) /* Assume there is a network */ + current_network_count = 1; + /* Don't listen for network changes if we can't tell anyway */ + else + { + current_network_count = cnt; + if (!g_thread_create(wgaim_network_change_thread, NULL, FALSE, &err)) + gaim_debug_error("network", "Couldn't create Network Monitor thread: %s\n", err ? err->message : ""); + } #endif gaim_prefs_add_none ("/core/network"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <nos...@us...> - 2006-10-25 12:51:32
|
Revision: 17581 http://svn.sourceforge.net/gaim/?rev=17581&view=rev Author: nosnilmot Date: 2006-10-25 05:51:22 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Check to make sure UI ops exist for network_connected and network_disconnected before calling them. Thanks to plaes on #gaim who says this fixes some gaim-text crashes. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-10-25 12:14:23 UTC (rev 17580) +++ trunk/libgaim/network.c 2006-10-25 12:51:22 UTC (rev 17581) @@ -436,9 +436,10 @@ gaim_debug_info("network", "Received Network Change Notification. Current network count is %d, previous count was %d.\n", new_count, current_network_count); - if (new_count > 0) { + if (new_count > 0 && ui_ops != NULL && ui_ops->network_connected != NULL) { ui_ops->network_connected(); - } else if (new_count == 0 && current_network_count > 0) { + } else if (new_count == 0 && current_network_count > 0 && + ui_ops != NULL && ui_ops->network_disconnected != NULL) { ui_ops->network_disconnected(); } @@ -548,13 +549,15 @@ case LIBNM_ACTIVE_NETWORK_CONNECTION: /* Call res_init in case DNS servers have changed */ res_init(); - ui_ops->network_connected(); + if (ui_ops != NULL && ui_ops->network_connected != NULL) + ui_ops->network_connected(); prev = current; break; case LIBNM_NO_NETWORK_CONNECTION: if (prev != LIBNM_ACTIVE_NETWORK_CONNECTION) break; - ui_ops->network_disconnected(); + if (ui_ops != NULL && ui_ops->network_disconnected != NULL) + ui_ops->network_disconnected(); prev = current; break; case LIBNM_NO_DBUS: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-11-04 22:00:31
|
Revision: 17667 http://svn.sourceforge.net/gaim/?rev=17667&view=rev Author: datallah Date: 2006-11-04 14:00:22 -0800 (Sat, 04 Nov 2006) Log Message: ----------- Add further error checking and fallbacks to the Network awareness code. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-11-04 03:42:04 UTC (rev 17666) +++ trunk/libgaim/network.c 2006-11-04 22:00:22 UTC (rev 17667) @@ -390,7 +390,8 @@ WSAQUERYSET qs; HANDLE h; - int retval; + gint retval; + int errorid; memset(&qs, 0, sizeof(WSAQUERYSET)); qs.dwSize = sizeof(WSAQUERYSET); @@ -398,8 +399,9 @@ retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); if (retval != ERROR_SUCCESS) { - int errorid = WSAGetLastError(); - gchar *msg = g_win32_error_message(errorid); + gchar *msg; + errorid = WSAGetLastError(); + 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); @@ -410,14 +412,23 @@ char buf[1024]; WSAQUERYSET *res = (LPWSAQUERYSET) buf; DWORD size = sizeof(buf); - while (WSALookupServiceNext(h, 0, &size, res) == ERROR_SUCCESS) { + while ((retval = WSALookupServiceNext(h, 0, &size, res)) == ERROR_SUCCESS) { net_cnt++; gaim_debug_info("network", "found network '%s'\n", res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"); size = sizeof(buf); } - WSALookupServiceEnd(h); + errorid = WSAGetLastError(); + if (!(errorid == WSA_E_NO_MORE || errorid == WSAENOMORE)) { + gchar *msg = g_win32_error_message(errorid); + gaim_debug_error("network", "got unexpected NLA response %s (%d)\n", msg, errorid); + g_free(msg); + + net_cnt = -1; + } + + retval = WSALookupServiceEnd(h); } return net_cnt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-11-05 08:22:44
|
Revision: 17669 http://svn.sourceforge.net/gaim/?rev=17669&view=rev Author: datallah Date: 2006-11-05 00:22:33 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Vista needs a bigger buffer for the NLA lookup stuff. This will fix network detection on Vista. Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-11-05 00:11:52 UTC (rev 17668) +++ trunk/libgaim/network.c 2006-11-05 08:22:33 UTC (rev 17669) @@ -409,7 +409,7 @@ return -1; } else { - char buf[1024]; + char buf[4096]; WSAQUERYSET *res = (LPWSAQUERYSET) buf; DWORD size = sizeof(buf); while ((retval = WSALookupServiceNext(h, 0, &size, res)) == ERROR_SUCCESS) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-15 07:46:23
|
Revision: 18006 http://svn.sourceforge.net/gaim/?rev=18006&view=rev Author: thekingant Date: 2006-12-14 23:46:08 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Another bug fix from Graham Booker to allow gaim_network_get_local_system_ip() to work correctly/reliably on Mac OS X (and probably some BSDs) Modified Paths: -------------- trunk/libgaim/network.c Modified: trunk/libgaim/network.c =================================================================== --- trunk/libgaim/network.c 2006-12-15 07:28:23 UTC (rev 18005) +++ trunk/libgaim/network.c 2006-12-15 07:46:08 UTC (rev 18006) @@ -47,6 +47,16 @@ #include "stun.h" #include "upnp.h" +/* + * Calling sizeof(struct ifreq) isn't always correct on + * Mac OS X (and maybe others). + */ +#ifdef _SIZEOF_ADDR_IFREQ +# define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a) +#else +# define HX_SIZE_OF_IFREQ(a) sizeof(a) +#endif + #ifdef HAVE_LIBNM #include <libnm_glib.h> @@ -135,7 +145,7 @@ while (tmp < buffer + ifc.ifc_len) { ifr = (struct ifreq *)tmp; - tmp += sizeof(struct ifreq); + tmp += HX_SIZE_OF_IFREQ(*ifr); if (ifr->ifr_addr.sa_family == AF_INET) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |