From cfef30d5a18d232c3841e2c6bf3c44ffe95156fd Mon Sep 17 00:00:00 2001 From: "dougt%meer.net" Date: Mon, 17 Apr 2006 22:59:10 +0000 Subject: [PATCH] Bug 334361. Failure to honor network changes. wince only r=darin --- netwerk/base/src/nsAutodialWin.cpp | 42 +++++++++++++++++------------- netwerk/base/src/nsAutodialWin.h | 4 +-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/netwerk/base/src/nsAutodialWin.cpp b/netwerk/base/src/nsAutodialWin.cpp index d271bf3d6fee..d3f9ffb21cf8 100644 --- a/netwerk/base/src/nsAutodialWin.cpp +++ b/netwerk/base/src/nsAutodialWin.cpp @@ -276,21 +276,7 @@ static nsresult DoPPCConnection() { static HANDLE gConnectionHandle = NULL; - DWORD status; - - if (gConnectionHandle) - { - ConnMgrConnectionStatus(gConnectionHandle, &status); - if (status == CONNMGR_STATUS_CONNECTED) - return NS_OK; - - // Release it immediately since we currently only do - // sync connections. the assumption here is that - // ConnMgrEstablishConnectionSync has to either return - // a failure or a connected connection. - ConnMgrReleaseConnection(gConnectionHandle, 0); - } - + // Make the connection to the new network CONNMGR_CONNECTIONINFO conn_info; memset(&conn_info, 0, sizeof(CONNMGR_CONNECTIONINFO)); @@ -301,12 +287,32 @@ static nsresult DoPPCConnection() conn_info.bExclusive = FALSE; conn_info.bDisabled = FALSE; - if(ConnMgrEstablishConnectionSync(&conn_info, &gConnectionHandle, 25000, &status) != S_OK) + HANDLE tempConnectionHandle; + DWORD status; + HRESULT result = ConnMgrEstablishConnectionSync(&conn_info, + &tempConnectionHandle, + 60000, + &status); + + if (result != S_OK) + { return NS_ERROR_FAILURE; - + } + if (status != CONNMGR_STATUS_CONNECTED) + { + // could not connect to this network. release the + // temp connection. + ConnMgrReleaseConnection(tempConnectionHandle, 0); return NS_ERROR_FAILURE; - + } + + // At this point, we have a new connection, so release + // the old connection + if (gConnectionHandle) + ConnMgrReleaseConnection(gConnectionHandle, 0); + + gConnectionHandle = tempConnectionHandle; return NS_OK; } diff --git a/netwerk/base/src/nsAutodialWin.h b/netwerk/base/src/nsAutodialWin.h index 36f7bc64dd41..df6b5856d723 100644 --- a/netwerk/base/src/nsAutodialWin.h +++ b/netwerk/base/src/nsAutodialWin.h @@ -61,8 +61,8 @@ typedef RASAUTODIALENTRYA RASAUTODIALENTRY, *LPRASAUTODIALENTRY; #endif // WINVER // Loading the RAS DLL dynamically. -typedef DWORD (WINAPI* tRASPHONEBOOKDLG)(LPTSTR,LPTSTR,LPRASPBDLG); -typedef DWORD (WINAPI* tRASDIALDLG)(LPTSTR,LPTSTR,LPTSTR,LPRASDIALDLG); +typedef DWORD (WINAPI* tRASPHONEBOOKDLG)(LPTSTR,LPTSTR,void*); +typedef DWORD (WINAPI* tRASDIALDLG)(LPTSTR,LPTSTR,LPTSTR,void*); typedef DWORD (WINAPI* tRASENUMCONNECTIONS)(LPRASCONN,LPDWORD,LPDWORD); typedef DWORD (WINAPI* tRASENUMENTRIES)(LPTSTR,LPTSTR,LPRASENTRYNAME,LPDWORD,LPDWORD); typedef DWORD (WINAPI* tRASSETAUTODIALADDRESS)(LPCTSTR,DWORD,LPRASAUTODIALENTRY,DWORD,DWORD);