diff --git a/netwerk/base/src/Makefile.in b/netwerk/base/src/Makefile.in index b6f063ded14..3bd823c0151 100644 --- a/netwerk/base/src/Makefile.in +++ b/netwerk/base/src/Makefile.in @@ -96,11 +96,8 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),os2) else ifeq ($(MOZ_WIDGET_TOOLKIT),windows) CPPSRCS += nsURLHelperWin.cpp - -ifneq (,$(filter-out WINCE,$(OS_ARCH))) CPPSRCS += nsNativeConnectionHelper.cpp CPPSRCS += nsAutodialWin.cpp -endif else ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) diff --git a/netwerk/base/src/nsAutodialWin.cpp b/netwerk/base/src/nsAutodialWin.cpp index 582906a4b18..37060643a2c 100644 --- a/netwerk/base/src/nsAutodialWin.cpp +++ b/netwerk/base/src/nsAutodialWin.cpp @@ -46,6 +46,18 @@ #include "nsAutodialWin.h" #include "prlog.h" +#ifdef WINCE +#include +#include +#include +#endif + +#ifdef WINCE +#define AUTODIAL_DEFAULT AUTODIAL_ALWAYS +#else +#define AUTODIAL_DEFAULT AUTODIAL_NEVER +#endif + // // Log module for autodial logging... // @@ -71,7 +83,7 @@ PRIntervalTime nsRASAutodial::mDontRetryUntil = 0; tRASPHONEBOOKDLG nsRASAutodial::mpRasPhonebookDlg = nsnull; -tRASENUMCONNECTIONS nsRASAutodial::mpRasEnumConnections = nsnull; +tRASENUMCONNECTIONS nsRASAutodial::mpRasEnumConnections = nsnull; tRASENUMENTRIES nsRASAutodial::mpRasEnumEntries = nsnull; tRASDIALDLG nsRASAutodial::mpRasDialDlg = nsnull; tRASSETAUTODIALADDRESS nsRASAutodial::mpRasSetAutodialAddress = nsnull; @@ -84,18 +96,20 @@ HINSTANCE nsRASAutodial::mhRASapi32 = nsnull; // ctor. nsRASAutodial::nsRASAutodial() -: mAutodialBehavior(AUTODIAL_NEVER), +: mAutodialBehavior(AUTODIAL_DEFAULT), mNumRASConnectionEntries(0), mAutodialServiceDialingLocation(-1) { mOSVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&mOSVerInfo); +#ifndef WINCE // We only need to dial on nt based systems. For all other platforms, // mAutodialBehavior will remain AUTODIAL_NEVER, and we can skip // these initializations. if ((mOSVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && (mOSVerInfo.dwMajorVersion >= 4)) +#endif { // Initializations that can be made again since RAS OS settings can // change. @@ -146,6 +160,7 @@ nsresult nsRASAutodial::Init() // force it to dial in that case by adding the network address to its db.) PRBool nsRASAutodial::ShouldDialOnNetworkError() { +#ifndef WINCE // Don't try to dial again within a few seconds of when user pressed cancel. if (mDontRetryUntil) { @@ -161,6 +176,9 @@ PRBool nsRASAutodial::ShouldDialOnNetworkError() return ((mAutodialBehavior == AUTODIAL_ALWAYS) || (mAutodialBehavior == AUTODIAL_ON_NETWORKERROR) || (mAutodialBehavior == AUTODIAL_USE_SERVICE)); +#else + return PR_TRUE; +#endif } @@ -170,6 +188,7 @@ PRBool nsRASAutodial::ShouldDialOnNetworkError() // when there is no network found. int nsRASAutodial::QueryAutodialBehavior() { +#ifndef WINCE if (IsAutodialServiceRunning()) { if (!LoadRASapi32DLL()) @@ -246,8 +265,51 @@ int nsRASAutodial::QueryAutodialBehavior() return AUTODIAL_ALWAYS; } } +#else + return AUTODIAL_DEFAULT; +#endif } + +#ifdef WINCE +static nsresult DoPPCConnection() +{ + HANDLE gConnectionHandle = NULL; + + GUID gNetworkID; + (void) ConnMgrMapURL("http://www.mozilla.org", &gNetworkID, 0); + + DWORD status; + CONNMGR_CONNECTIONINFO conn_info; + memset(&conn_info, 0, sizeof(CONNMGR_CONNECTIONINFO)); + + conn_info.cbSize = sizeof(CONNMGR_CONNECTIONINFO); + conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET; + conn_info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; + conn_info.bExclusive = FALSE; + conn_info.bDisabled = FALSE; + + conn_info.guidDestNet= gNetworkID; + + if(ConnMgrEstablishConnectionSync(&conn_info, &gConnectionHandle, 1000, &status) != S_OK && + gNetworkID != IID_DestNetInternet) + { + conn_info.guidDestNet = IID_DestNetInternet; + + if(ConnMgrEstablishConnectionSync(&conn_info, &gConnectionHandle, 5000, &status) != S_OK) + { + return NS_ERROR_FAILURE; + } + } + + if (status != CONNMGR_STATUS_CONNECTED) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +#endif + // If the RAS autodial service is running, use it. Otherwise, dial // the default RAS connection. There are two possible RAS dialogs: // one that dials a single entry, and one that lets the user choose which @@ -262,6 +324,7 @@ int nsRASAutodial::QueryAutodialBehavior() // all other values indicate that the caller should not retry nsresult nsRASAutodial::DialDefault(const char* hostName) { +#ifndef WINCE mDontRetryUntil = 0; if (mAutodialBehavior == AUTODIAL_NEVER) @@ -370,8 +433,12 @@ nsresult nsRASAutodial::DialDefault(const char* hostName) // Retry because we just established a dialup connection. return NS_OK; +#else + return DoPPCConnection(); +#endif } + // Check to see if RAS is already connected. PRBool nsRASAutodial::IsRASConnected() { @@ -413,7 +480,9 @@ nsresult nsRASAutodial::GetFirstEntryName(char* entryName, int bufferSize) // ERROR_BUFFER_TOO_SMALL is OK because we only need one struct. if (result == ERROR_SUCCESS || result == ERROR_BUFFER_TOO_SMALL) { +#ifndef WINCE strncpy(entryName, rasEntryName.szEntryName, bufferSize); +#endif return NS_OK; } @@ -550,6 +619,7 @@ nsresult nsRASAutodial::GetDefaultEntryName(char* entryName, int bufferSize) // Determine if the autodial service is running on this PC. PRBool nsRASAutodial::IsAutodialServiceRunning() { +#ifndef WINCE SC_HANDLE hSCManager = OpenSCManager(nsnull, SERVICES_ACTIVE_DATABASE, SERVICE_QUERY_STATUS); @@ -580,6 +650,9 @@ PRBool nsRASAutodial::IsAutodialServiceRunning() } return (status.dwCurrentState == SERVICE_RUNNING); +#else + return PR_TRUE; +#endif } // Add the specified address to the autodial directory. diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index c93ee2356bc..45bfec12a2d 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -66,7 +66,7 @@ #include "nsISSLSocketControl.h" #include "nsIPipe.h" -#if defined(XP_WIN) && !defined (WINCE) +#if defined(XP_WIN) #include "nsNativeConnectionHelper.h" #endif @@ -1217,7 +1217,7 @@ nsSocketTransport::RecoverFromError() } } -#if defined(XP_WIN) && !defined (WINCE) +#if defined(XP_WIN) // If not trying next address, try to make a connection using dialup. // Retry if that connection is made. if (!tryAgain) {