don't cache the result of IsAlwaysConnected() and don't call IsOnline() unnecessarily from there
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16235 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -266,10 +266,6 @@ private:
|
|||||||
// this flag tells us if we're online
|
// this flag tells us if we're online
|
||||||
static int ms_isConnected;
|
static int ms_isConnected;
|
||||||
|
|
||||||
// this flag is the result of the call to IsAlwaysOnline() (-1 if not
|
|
||||||
// called yet)
|
|
||||||
static int ms_isAlwaysOnline;
|
|
||||||
|
|
||||||
// this flag tells us whether a call to RasDial() is in progress
|
// this flag tells us whether a call to RasDial() is in progress
|
||||||
static wxDialUpManagerMSW *ms_dialer;
|
static wxDialUpManagerMSW *ms_dialer;
|
||||||
};
|
};
|
||||||
@@ -321,7 +317,6 @@ RASCONNECTIONNOTIFICATION wxDialUpManagerMSW::ms_pfnRasConnectionNotification =
|
|||||||
|
|
||||||
int wxDialUpManagerMSW::ms_userSpecifiedOnlineStatus = -1;
|
int wxDialUpManagerMSW::ms_userSpecifiedOnlineStatus = -1;
|
||||||
int wxDialUpManagerMSW::ms_isConnected = -1;
|
int wxDialUpManagerMSW::ms_isConnected = -1;
|
||||||
int wxDialUpManagerMSW::ms_isAlwaysOnline = -1;
|
|
||||||
wxDialUpManagerMSW *wxDialUpManagerMSW::ms_dialer = NULL;
|
wxDialUpManagerMSW *wxDialUpManagerMSW::ms_dialer = NULL;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -926,14 +921,10 @@ bool wxDialUpManagerMSW::HangUp()
|
|||||||
|
|
||||||
bool wxDialUpManagerMSW::IsAlwaysOnline() const
|
bool wxDialUpManagerMSW::IsAlwaysOnline() const
|
||||||
{
|
{
|
||||||
// we cache the result (presumably this won't change while the program is
|
// assume no permanent connection by default
|
||||||
// running!)
|
bool isAlwaysOnline = FALSE;
|
||||||
if ( ms_isAlwaysOnline != -1 )
|
|
||||||
{
|
|
||||||
return ms_isAlwaysOnline != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to use WinInet function first
|
// try to use WinInet functions
|
||||||
|
|
||||||
// NB: we could probably use wxDynamicLibrary here just as well,
|
// NB: we could probably use wxDynamicLibrary here just as well,
|
||||||
// but we allow multiple instances of wxDialUpManagerMSW so
|
// but we allow multiple instances of wxDialUpManagerMSW so
|
||||||
@@ -956,39 +947,14 @@ bool wxDialUpManagerMSW::IsAlwaysOnline() const
|
|||||||
if ( pfnInternetGetConnectedState(&flags, 0 /* reserved */) )
|
if ( pfnInternetGetConnectedState(&flags, 0 /* reserved */) )
|
||||||
{
|
{
|
||||||
// there is some connection to the net, see of which type
|
// there is some connection to the net, see of which type
|
||||||
ms_isAlwaysOnline = ((flags & INTERNET_CONNECTION_LAN) != 0)
|
isAlwaysOnline = (flags & (INTERNET_CONNECTION_LAN |
|
||||||
|| ((flags & INTERNET_CONNECTION_PROXY) != 0);
|
INTERNET_CONNECTION_PROXY)) != 0;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no Internet connection at all
|
|
||||||
ms_isAlwaysOnline = FALSE;
|
|
||||||
}
|
}
|
||||||
|
//else: no Internet connection at all
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// did we succeed with WinInet? if not, try something else
|
return isAlwaysOnline;
|
||||||
if ( ms_isAlwaysOnline == -1 )
|
|
||||||
{
|
|
||||||
if ( !IsOnline() )
|
|
||||||
{
|
|
||||||
// definitely no permanent connection because we are not connected
|
|
||||||
// now
|
|
||||||
ms_isAlwaysOnline = FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// of course, having a modem doesn't prevent us from having a
|
|
||||||
// permanent connection as well, but we have to guess somehow and
|
|
||||||
// it's probably more common that a system connected via a modem
|
|
||||||
// doesn't have any other net access, so:
|
|
||||||
ms_isAlwaysOnline = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxASSERT_MSG( ms_isAlwaysOnline != -1, wxT("logic error") );
|
|
||||||
|
|
||||||
return ms_isAlwaysOnline != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDialUpManagerMSW::IsOnline() const
|
bool wxDialUpManagerMSW::IsOnline() const
|
||||||
|
Reference in New Issue
Block a user