mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 482897 - AutoDialer support on Windows Mobile. r=blassey r=jduell.mcbugs
This commit is contained in:
parent
2a342ebe12
commit
8e25baac65
@ -101,9 +101,11 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += nsURLHelperWin.cpp
|
||||
ifneq ($(OS_ARCH), WINCE)
|
||||
CPPSRCS += nsNativeConnectionHelper.cpp
|
||||
ifneq ($(OS_ARCH), WINCE)
|
||||
CPPSRCS += nsAutodialWin.cpp
|
||||
else
|
||||
CPPSRCS += nsAutodialWinCE.cpp
|
||||
endif
|
||||
else
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
|
@ -47,17 +47,7 @@
|
||||
#include "nsAutodialWin.h"
|
||||
#include "prlog.h"
|
||||
|
||||
#ifdef WINCE
|
||||
#include <objbase.h>
|
||||
#include <initguid.h>
|
||||
#include <connmgr.h>
|
||||
#endif
|
||||
|
||||
#ifdef WINCE
|
||||
#define AUTODIAL_DEFAULT AUTODIAL_ALWAYS
|
||||
#else
|
||||
#define AUTODIAL_DEFAULT AUTODIAL_NEVER
|
||||
#endif
|
||||
|
||||
//
|
||||
// Log module for autodial logging...
|
||||
@ -152,7 +142,6 @@ 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)
|
||||
{
|
||||
@ -168,9 +157,6 @@ PRBool nsRASAutodial::ShouldDialOnNetworkError()
|
||||
return ((mAutodialBehavior == AUTODIAL_ALWAYS)
|
||||
|| (mAutodialBehavior == AUTODIAL_ON_NETWORKERROR)
|
||||
|| (mAutodialBehavior == AUTODIAL_USE_SERVICE));
|
||||
#else
|
||||
return PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +166,6 @@ PRBool nsRASAutodial::ShouldDialOnNetworkError()
|
||||
// when there is no network found.
|
||||
int nsRASAutodial::QueryAutodialBehavior()
|
||||
{
|
||||
#ifndef WINCE
|
||||
if (IsAutodialServiceRunning())
|
||||
{
|
||||
if (!LoadRASapi32DLL())
|
||||
@ -257,59 +242,8 @@ int nsRASAutodial::QueryAutodialBehavior()
|
||||
return AUTODIAL_ALWAYS;
|
||||
}
|
||||
}
|
||||
#else
|
||||
return AUTODIAL_DEFAULT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef WINCE
|
||||
static nsresult DoPPCConnection()
|
||||
{
|
||||
static HANDLE gConnectionHandle = NULL;
|
||||
|
||||
// Make the connection to the new network
|
||||
CONNMGR_CONNECTIONINFO conn_info;
|
||||
memset(&conn_info, 0, sizeof(conn_info));
|
||||
|
||||
conn_info.cbSize = sizeof(conn_info);
|
||||
conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET;
|
||||
conn_info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
|
||||
conn_info.guidDestNet = IID_DestNetInternet;
|
||||
conn_info.bExclusive = FALSE;
|
||||
conn_info.bDisabled = FALSE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#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
|
||||
@ -324,7 +258,6 @@ static nsresult DoPPCConnection()
|
||||
// all other values indicate that the caller should not retry
|
||||
nsresult nsRASAutodial::DialDefault(const PRUnichar* hostName)
|
||||
{
|
||||
#ifndef WINCE
|
||||
mDontRetryUntil = 0;
|
||||
|
||||
if (mAutodialBehavior == AUTODIAL_NEVER)
|
||||
@ -432,10 +365,6 @@ nsresult nsRASAutodial::DialDefault(const PRUnichar* hostName)
|
||||
|
||||
// Retry because we just established a dialup connection.
|
||||
return NS_OK;
|
||||
|
||||
#else
|
||||
return DoPPCConnection();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -618,7 +547,6 @@ nsresult nsRASAutodial::GetDefaultEntryName(PRUnichar* 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);
|
||||
|
||||
@ -649,9 +577,6 @@ PRBool nsRASAutodial::IsAutodialServiceRunning()
|
||||
}
|
||||
|
||||
return (status.dwCurrentState == SERVICE_RUNNING);
|
||||
#else
|
||||
return PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add the specified address to the autodial directory.
|
||||
|
110
netwerk/base/src/nsAutodialWinCE.cpp
Normal file
110
netwerk/base/src/nsAutodialWinCE.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Steve Meredith <smeredith@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <objbase.h>
|
||||
#include <connmgr.h>
|
||||
|
||||
#include "nsAutodialWinCE.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
||||
// pulled from the header so that we do not get multiple define errors during link
|
||||
static const GUID ras_DestNetInternet =
|
||||
{ 0x436ef144, 0xb4fb, 0x4863, { 0xa0, 0x41, 0x8f, 0x90, 0x5a, 0x62, 0xc5, 0x72 } };
|
||||
|
||||
nsRASAutodial::nsRASAutodial()
|
||||
{
|
||||
}
|
||||
|
||||
nsRASAutodial::~nsRASAutodial()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRASAutodial::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRASAutodial::DialDefault(const PRUnichar* /* hostName */)
|
||||
{
|
||||
HANDLE connectionHandle;
|
||||
|
||||
// Make the connection to the new network
|
||||
CONNMGR_CONNECTIONINFO conn_info;
|
||||
memset(&conn_info, 0, sizeof(conn_info));
|
||||
|
||||
conn_info.cbSize = sizeof(conn_info);
|
||||
conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET;
|
||||
conn_info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
|
||||
conn_info.guidDestNet = ras_DestNetInternet;
|
||||
conn_info.bExclusive = FALSE;
|
||||
conn_info.bDisabled = FALSE;
|
||||
|
||||
DWORD status;
|
||||
HRESULT result = ConnMgrEstablishConnectionSync(&conn_info,
|
||||
&connectionHandle,
|
||||
60000,
|
||||
&status);
|
||||
if (result != S_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 defaultCacheTime = 1; // 1 second according to msdn
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRInt32 t;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("network.autodial.cacheTime", &t)))
|
||||
defaultCacheTime = t;
|
||||
}
|
||||
|
||||
ConnMgrReleaseConnection(connectionHandle, defaultCacheTime);
|
||||
|
||||
if (status != CONNMGR_STATUS_CONNECTED)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsRASAutodial::ShouldDialOnNetworkError()
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
69
netwerk/base/src/nsAutodialWinCE.h
Normal file
69
netwerk/base/src/nsAutodialWinCE.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Steve Meredith <smeredith@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsAutodialWin_h__
|
||||
#define nsAutodialWin_h__
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nscore.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
class nsRASAutodial
|
||||
{
|
||||
public:
|
||||
|
||||
// ctor
|
||||
nsRASAutodial();
|
||||
|
||||
// dtor
|
||||
virtual ~nsRASAutodial();
|
||||
|
||||
// Get the autodial info from the OS and init this obj with it. Call it any
|
||||
// time to refresh the object's settings from the OS.
|
||||
nsresult Init();
|
||||
|
||||
// Dial the default RAS dialup connection.
|
||||
nsresult DialDefault(const PRUnichar* hostName);
|
||||
|
||||
// Should we try to dial on network error?
|
||||
PRBool ShouldDialOnNetworkError();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -959,7 +959,7 @@ nsIOService::TrackNetworkLinkStatusForOffline()
|
||||
// option is set to always autodial. If so, then we are
|
||||
// always up for the purposes of offline management.
|
||||
if (autodialEnabled) {
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
#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
|
||||
|
@ -37,7 +37,11 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsNativeConnectionHelper.h"
|
||||
#ifdef WINCE
|
||||
#include "nsAutodialWinCE.h"
|
||||
#else
|
||||
#include "nsAutodialWin.h"
|
||||
#endif
|
||||
#include "nsIOService.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1265,7 +1265,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) {
|
||||
|
@ -83,6 +83,11 @@ ifeq ($(OS_ARCH),WINNT)
|
||||
../system/win32/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINCE)
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
../system/wince/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
../system/mac/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
|
||||
@ -105,6 +110,10 @@ ifeq ($(OS_ARCH),WINNT)
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../system/win32
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINCE)
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../system/wince
|
||||
endif
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../system/mac
|
||||
endif
|
||||
|
@ -281,7 +281,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURI)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
#if defined(XP_WIN)
|
||||
#include "nsNotifyAddrListener.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
@ -1135,7 +1135,7 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
|
||||
},
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
#if defined(XP_WIN)
|
||||
{ NS_NETWORK_LINK_SERVICE_CLASSNAME,
|
||||
NS_NETWORK_LINK_SERVICE_CID,
|
||||
NS_NETWORK_LINK_SERVICE_CONTRACTID,
|
||||
|
@ -48,6 +48,10 @@ ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += win32
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINCE)
|
||||
DIRS += wince
|
||||
endif
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
DIRS += mac
|
||||
endif
|
||||
|
59
netwerk/system/wince/Makefile.in
Normal file
59
netwerk/system/wince/Makefile.in
Normal file
@ -0,0 +1,59 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Juan Lang
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = necko
|
||||
LIBRARY_NAME = neckosystem_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
pref \
|
||||
$(NULL)
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
CPPSRCS += nsNotifyAddrListener.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DIMPL_NS_NET
|
105
netwerk/system/wince/nsNotifyAddrListener.cpp
Normal file
105
netwerk/system/wince/nsNotifyAddrListener.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "nsNotifyAddrListener.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
#include <objbase.h>
|
||||
#include <connmgr.h>
|
||||
|
||||
// pulled from the header so that we do not get multiple define errors during link
|
||||
static const GUID nal_DestNetInternet =
|
||||
{ 0x436ef144, 0xb4fb, 0x4863, { 0xa0, 0x41, 0x8f, 0x90, 0x5a, 0x62, 0xc5, 0x72 } };
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsNotifyAddrListener,
|
||||
nsINetworkLinkService,
|
||||
nsITimerCallback)
|
||||
|
||||
nsNotifyAddrListener::nsNotifyAddrListener()
|
||||
: mLinkUp(PR_FALSE) // assume false by default
|
||||
, mStatusKnown(PR_FALSE)
|
||||
, mConnectionHandle(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsNotifyAddrListener::~nsNotifyAddrListener()
|
||||
{
|
||||
if (mConnectionHandle)
|
||||
ConnMgrReleaseConnection(mConnectionHandle, 0);
|
||||
|
||||
if (mTimer)
|
||||
mTimer->Cancel();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNotifyAddrListener::Init(void)
|
||||
{
|
||||
CONNMGR_CONNECTIONINFO conn_info;
|
||||
memset(&conn_info, 0, sizeof(conn_info));
|
||||
|
||||
conn_info.cbSize = sizeof(conn_info);
|
||||
conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET;
|
||||
conn_info.dwPriority = CONNMGR_PRIORITY_LOWBKGND;
|
||||
conn_info.guidDestNet = nal_DestNetInternet;
|
||||
conn_info.bExclusive = FALSE;
|
||||
conn_info.bDisabled = FALSE;
|
||||
|
||||
ConnMgrEstablishConnection(&conn_info,
|
||||
&mConnectionHandle);
|
||||
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (mTimer)
|
||||
mTimer->InitWithCallback(this,
|
||||
15*1000, // every 15 seconds
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNotifyAddrListener::GetIsLinkUp(PRBool *aIsUp)
|
||||
{
|
||||
*aIsUp = mLinkUp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNotifyAddrListener::GetLinkStatusKnown(PRBool *aIsUp)
|
||||
{
|
||||
*aIsUp = mStatusKnown;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNotifyAddrListener::Notify(nsITimer* aTimer)
|
||||
{
|
||||
DWORD status;
|
||||
HRESULT result = ConnMgrConnectionStatus(mConnectionHandle, &status);
|
||||
|
||||
if (FAILED(result)) {
|
||||
mLinkUp = PR_FALSE;
|
||||
mStatusKnown = PR_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLinkUp = (status==CONNMGR_STATUS_CONNECTED);
|
||||
mStatusKnown = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
|
||||
if (!observerService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
const char *event;
|
||||
if (!mStatusKnown)
|
||||
event = NS_NETWORK_LINK_DATA_UNKNOWN;
|
||||
else
|
||||
event = mLinkUp ? NS_NETWORK_LINK_DATA_UP
|
||||
: NS_NETWORK_LINK_DATA_DOWN;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsINetworkLinkService*>(this),
|
||||
NS_NETWORK_LINK_TOPIC,
|
||||
NS_ConvertASCIItoUTF16(event).get());
|
||||
return NS_OK;
|
||||
}
|
32
netwerk/system/wince/nsNotifyAddrListener.h
Normal file
32
netwerk/system/wince/nsNotifyAddrListener.h
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef NSNOTIFYADDRLISTENER_H_
|
||||
#define NSNOTIFYADDRLISTENER_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "nsITimer.h"
|
||||
#include "nsINetworkLinkService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
class nsNotifyAddrListener : public nsINetworkLinkService, nsITimerCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSINETWORKLINKSERVICE
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
nsNotifyAddrListener();
|
||||
virtual ~nsNotifyAddrListener();
|
||||
|
||||
nsresult Init(void);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
PRPackedBool mLinkUp;
|
||||
PRPackedBool mStatusKnown;
|
||||
HANDLE mConnectionHandle;
|
||||
};
|
||||
|
||||
#endif /* NSNOTIFYADDRLISTENER_H_ */
|
Loading…
Reference in New Issue
Block a user