diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index 9b20cf109a83..9e53dfc245b7 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -70,6 +70,10 @@ #include "nsNetUtil.h" #include "nsThreadUtils.h" +#if defined(XP_WIN) +#include "nsNativeConnectionHelper.h" +#endif + #define PORT_PREF_PREFIX "network.security.ports." #define PORT_PREF(x) PORT_PREF_PREFIX x #define AUTODIAL_PREF "network.autodial-helper.enabled" @@ -913,10 +917,21 @@ nsIOService::TrackNetworkLinkStatusForOffline() if (mSocketTransportService) { PRBool autodialEnabled = PR_FALSE; mSocketTransportService->GetAutodialEnabled(&autodialEnabled); - // If autodialing-on-link-down is enabled, then pretend the link is + // If autodialing-on-link-down is enabled, check if the OS auto dial + // option is set to always autodial. If so, then we are // always up for the purposes of offline management. - if (autodialEnabled) + if (autodialEnabled) { +#if defined(XP_WIN) + // On Windows, need to do some registry checking to see if + // autodial is enabled at the OS level. Only if that is + // enabled are we always up for the purposes of offline + // management. + if(nsNativeConnectionHelper::IsAutodialEnabled()) + return SetOffline(PR_FALSE); +#else return SetOffline(PR_FALSE); +#endif + } } PRBool isUp; diff --git a/netwerk/base/src/nsNativeConnectionHelper.cpp b/netwerk/base/src/nsNativeConnectionHelper.cpp index 7f758543e736..b528d0e87d40 100644 --- a/netwerk/base/src/nsNativeConnectionHelper.cpp +++ b/netwerk/base/src/nsNativeConnectionHelper.cpp @@ -53,3 +53,11 @@ nsNativeConnectionHelper::OnConnectionFailed(const char* hostName) else return PR_FALSE; } + +PRBool +nsNativeConnectionHelper::IsAutodialEnabled() +{ + nsRASAutodial autodial; + + return autodial.Init() == NS_OK && autodial.ShouldDialOnNetworkError(); +} diff --git a/netwerk/base/src/nsNativeConnectionHelper.h b/netwerk/base/src/nsNativeConnectionHelper.h index adf6dda34c98..f86010786f4c 100644 --- a/netwerk/base/src/nsNativeConnectionHelper.h +++ b/netwerk/base/src/nsNativeConnectionHelper.h @@ -51,6 +51,13 @@ public: * Return PR_TRUE if the connection should be re-attempted. */ static PRBool OnConnectionFailed(const char* hostName); + + /** + * IsAutoDialEnabled + * + * Return PR_TRUE if autodial is enabled in the operating system. + */ + static PRBool IsAutodialEnabled(); }; #endif // !nsNativeConnectionHelper_h__