Bug 586836 - Support Meego Network Managment. r=doug.turner a=blocking-fennec
authorjeremias bosch <jeremias.bosch@gmail.com>
Mon, 30 Aug 2010 23:23:35 -0700
changeset 51789 fdf35ea63a85e14baa0f496fd4f1478ad01ef300
parent 51788 2acd956c4d0493a2b8a5eda237e3d2c68051042b
child 51790 da862772518d25f780a0d0e989da31449c8f935a
push idunknown
push userunknown
push dateunknown
reviewersdoug, blocking-fennec
bugs586836
milestone2.0b6pre
Bug 586836 - Support Meego Network Managment. r=doug.turner a=blocking-fennec
config/autoconf.mk.in
configure.in
netwerk/base/src/Makefile.in
netwerk/base/src/nsAutodialQt.cpp
netwerk/base/src/nsAutodialQt.h
netwerk/base/src/nsIOService.cpp
netwerk/base/src/nsNativeConnectionHelper.cpp
netwerk/base/src/nsSocketTransport2.cpp
netwerk/build/Makefile.in
netwerk/build/nsNetModule.cpp
netwerk/system/Makefile.in
netwerk/system/qt/Makefile.in
netwerk/system/qt/nsQtNetworkLinkService.cpp
netwerk/system/qt/nsQtNetworkLinkService.h
netwerk/system/qt/nsQtNetworkManager.cpp
netwerk/system/qt/nsQtNetworkManager.h
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -525,16 +525,17 @@ MOZ_ENABLE_DWRITE_FONT	= @MOZ_ENABLE_DWR
 MOZ_ENABLE_D2D_SURFACE	= @MOZ_ENABLE_D2D_SURFACE@
 MOZ_ENABLE_D3D9_LAYER	= @MOZ_ENABLE_D3D9_LAYER@
 
 MOZ_GTK2_CFLAGS		= @MOZ_GTK2_CFLAGS@
 MOZ_GTK2_LIBS		= @MOZ_GTK2_LIBS@
 
 MOZ_QT_CFLAGS		= @MOZ_QT_CFLAGS@
 MOZ_QT_LIBS		= @MOZ_QT_LIBS@
+MOZ_ENABLE_QTNETWORK    = @MOZ_ENABLE_QTNETWORK@
 MOZ_ENABLE_MEEGOTOUCH   = @MOZ_ENABLE_MEEGOTOUCH@
 
 MOZ_DBUS_CFLAGS         = @MOZ_DBUS_CFLAGS@
 MOZ_DBUS_LIBS           = @MOZ_DBUS_LIBS@
 MOZ_DBUS_GLIB_CFLAGS    = @MOZ_DBUS_GLIB_CFLAGS@
 MOZ_DBUS_GLIB_LIBS      = @MOZ_DBUS_GLIB_LIBS@
 MOZ_ENABLE_DBUS         = @MOZ_ENABLE_DBUS@
 
--- a/configure.in
+++ b/configure.in
@@ -5314,25 +5314,36 @@ then
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
         HOST_MOC="$QTDIR/bin/moc"
     fi
     if test -z "$HOST_MOC"; then
         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
 incorrect])
     fi
     MOC=$HOST_MOC
+
+    MOZ_ENABLE_QTNETWORK=
+    PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
+                      MOZ_ENABLE_QTNETWORK=1,
+                      MOZ_ENABLE_QTNETWORK=)
+
+    if test "$MOZ_ENABLE_QTNETWORK"; then
+      MOZ_ENABLE_QTNETWORK=1
+      AC_DEFINE(MOZ_ENABLE_QTNETWORK)
+    fi
 fi
 
 AC_SUBST(GTK_CONFIG)
 AC_SUBST(TK_CFLAGS)
 AC_SUBST(TK_LIBS)
 
 AC_SUBST(MOZ_ENABLE_GTK2)
 AC_SUBST(MOZ_ENABLE_PHOTON)
 AC_SUBST(MOZ_ENABLE_QT)
+AC_SUBST(MOZ_ENABLE_QTNETWORK)
 AC_SUBST(MOZ_ENABLE_XREMOTE)
 AC_SUBST(MOZ_GTK2_CFLAGS)
 AC_SUBST(MOZ_GTK2_LIBS)
 AC_SUBST(MOZ_QT_CFLAGS)
 AC_SUBST(MOZ_QT_LIBS)
 AC_SUBST(MOZ_ENABLE_MEEGOTOUCH)
 
 AC_SUBST(MOC)
@@ -6794,19 +6805,27 @@ dnl = Disable zipwriter
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(zipwriter,
 [  --disable-zipwriter     Disable zipwriter component],
     MOZ_ZIPWRITER=,
     MOZ_ZIPWRITER=1 )
 AC_SUBST(MOZ_ZIPWRITER)
 
 dnl ========================================================
-dnl = Disable libconic
-dnl ========================================================
+dnl = libconic
+dnl ========================================================
+dnl superseded by QtNetwork starting from 4.7
 MOZ_ENABLE_LIBCONIC=1
+
+if test -n "$MOZ_ENABLE_QT"; then
+  if test "$MOZ_ENABLE_QTNETWORK"; then
+    MOZ_ENABLE_LIBCONIC=
+  fi
+fi
+
 MOZ_ARG_DISABLE_BOOL(libconic,
 [  --disable-libconic      Disable libconic],
     MOZ_ENABLE_LIBCONIC=,
     MOZ_ENABLE_LIBCONIC=1 )
 
 if test -n "$MOZ_ENABLE_LIBCONIC"; then
     PKG_CHECK_MODULES(LIBCONIC, conic,
                       MOZ_ENABLE_LIBCONIC=1,
--- a/netwerk/base/src/Makefile.in
+++ b/netwerk/base/src/Makefile.in
@@ -92,21 +92,16 @@ CPPSRCS		= \
 		nsBase64Encoder.cpp \
 		nsSerializationHelper.cpp \
 		nsDNSPrefetch.cpp \
 		$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 	CPPSRCS += nsURLHelperOS2.cpp
 else
-ifdef MOZ_ENABLE_LIBCONIC
-	CPPSRCS += nsAutodialMaemo.cpp
-	CPPSRCS += nsNativeConnectionHelper.cpp
-	LOCAL_INCLUDES += -I$(srcdir)/../../system/maemo
-endif
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 	CPPSRCS += nsURLHelperWin.cpp
 	CPPSRCS += nsNativeConnectionHelper.cpp
 ifneq ($(OS_ARCH), WINCE)
 	CPPSRCS += nsAutodialWin.cpp
 else
 	CPPSRCS += nsAutodialWinCE.cpp
 endif
@@ -114,16 +109,28 @@ else
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	CPPSRCS += nsURLHelperOSX.cpp
 else
 	CPPSRCS += nsURLHelperUnix.cpp
 endif
 endif
 endif
 
+ifdef MOZ_PLATFORM_MAEMO
+	CPPSRCS += nsNativeConnectionHelper.cpp
+ifdef MOZ_ENABLE_LIBCONIC
+	CPPSRCS += nsAutodialMaemo.cpp
+	LOCAL_INCLUDES += -I$(srcdir)/../../system/maemo
+endif
+ifdef MOZ_ENABLE_QTNETWORK
+	CPPSRCS += nsAutodialQt.cpp
+	LOCAL_INCLUDES += -I$(srcdir)/../../system/qt
+endif
+endif
+
 EXTRA_COMPONENTS = \
 		$(srcdir)/nsProxyAutoConfig.js \
 		$(srcdir)/nsProxyAutoConfig.manifest \
 		$(NULL)
 
 EXTRA_JS_MODULES = \
 		NetUtil.jsm \
 		$(NULL)
new file mode 100644
--- /dev/null
+++ b/netwerk/base/src/nsAutodialQt.cpp
@@ -0,0 +1,77 @@
+/* ***** 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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 "nsAutodialQt.h"
+#include "nsNetCID.h"
+#include "nsCOMPtr.h"
+#include "nsIPrefBranch.h"
+#include "nsIPrefService.h"
+#include "nsIServiceManager.h"
+#include "nsQtNetworkManager.h"
+
+
+nsAutodial::nsAutodial()
+{
+}
+
+nsAutodial::~nsAutodial()
+{
+}
+
+nsresult
+nsAutodial::Init()
+{
+  return NS_OK;
+}
+
+nsresult
+nsAutodial::DialDefault(const PRUnichar* hostName)
+{
+  if (nsQtNetworkManager::OpenConnectionSync())
+    return NS_OK;
+
+  return NS_ERROR_FAILURE;
+}
+
+PRBool
+nsAutodial::ShouldDialOnNetworkError()
+{
+  if (nsQtNetworkManager::IsConnected())
+    return PR_FALSE;
+
+  return PR_TRUE;
+}
new file mode 100644
--- /dev/null
+++ b/netwerk/base/src/nsAutodialQt.h
@@ -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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 NSAUTODIALQT
+#define NSAUTODIALQT
+
+#include "nspr.h"
+#include "nscore.h"
+
+class nsAutodial
+{
+public:
+    nsAutodial();
+    ~nsAutodial();
+
+    nsresult Init();
+
+    // Dial the default RAS dialup connection.
+    nsresult DialDefault(const PRUnichar* hostName);
+
+    // Should we try to dial on network error?
+    PRBool ShouldDialOnNetworkError();
+};
+
+#endif /* NSAUTODIALQT */
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -73,17 +73,17 @@
 #include "nsIPermissionManager.h"
 #include "nsTArray.h"
 #include "nsIConsoleService.h"
 #include "nsIUploadChannel2.h"
 #include "nsXULAppAPI.h"
 
 #include "mozilla/FunctionTimer.h"
 
-#if defined(XP_WIN) || defined(MOZ_ENABLE_LIBCONIC)
+#if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
 #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"
 #define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status"
 
@@ -1072,17 +1072,17 @@ nsIOService::TrackNetworkLinkStatusForOf
     // check to make sure this won't collide with Autodial
     if (mSocketTransportService) {
         PRBool autodialEnabled = PR_FALSE;
         mSocketTransportService->GetAutodialEnabled(&autodialEnabled);
         // 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 defined(XP_WIN) || defined(MOZ_ENABLE_LIBCONIC)
+#if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
             // On Windows and Maemo (libconic) we should first check with the OS
             // to see if autodial is enabled.  If it is enabled then we are
             // allowed to manage the offline state.
             if(nsNativeConnectionHelper::IsAutodialEnabled()) 
                 return SetOffline(PR_FALSE);
 #else
             return SetOffline(PR_FALSE);
 #endif
--- a/netwerk/base/src/nsNativeConnectionHelper.cpp
+++ b/netwerk/base/src/nsNativeConnectionHelper.cpp
@@ -33,17 +33,17 @@
  * 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 "nsNativeConnectionHelper.h"
 
-#if defined(MOZ_ENABLE_LIBCONIC)
+#if defined(MOZ_PLATFORM_MAEMO)
 #include "nsAutodialMaemo.h"
 #elif defined(WINCE)
 #include "nsAutodialWinCE.h"
 #else
 #include "nsAutodialWin.h"
 #endif
 
 #include "nsIOService.h"
@@ -54,17 +54,17 @@
 
 PRBool
 nsNativeConnectionHelper::OnConnectionFailed(const PRUnichar* hostName)
 {
   // On mobile platforms, instead of relying on the link service, we
   // should ask the dialer directly.  This allows the dialer to update
   // link status more forcefully rather than passively watching link
   // status changes.
-#if !defined(MOZ_ENABLE_LIBCONIC) && !defined(WINCE_WINDOWS_MOBILE)
+#if !defined(MOZ_PLATFORM_MAEMO) && !defined(WINCE_WINDOWS_MOBILE)
     if (gIOService->IsLinkUp())
         return PR_FALSE;
 #endif
 
     nsAutodial autodial;
     if (autodial.ShouldDialOnNetworkError())
         return NS_SUCCEEDED(autodial.DialDefault(hostName));
 
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -66,17 +66,17 @@
 #include "nsISocketProviderService.h"
 #include "nsISocketProvider.h"
 #include "nsISSLSocketControl.h"
 #include "nsINSSErrorsService.h"
 #include "nsIPipe.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsIClassInfoImpl.h"
 
-#if defined(XP_WIN) || defined(MOZ_ENABLE_LIBCONIC)
+#if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
 #include "nsNativeConnectionHelper.h"
 #endif
 
 //-----------------------------------------------------------------------------
 
 static NS_DEFINE_CID(kSocketProviderServiceCID, NS_SOCKETPROVIDERSERVICE_CID);
 static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
 
@@ -1267,17 +1267,17 @@ nsSocketTransport::RecoverFromError()
     if (mState == STATE_CONNECTING && mDNSRecord) {
         nsresult rv = mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr);
         if (NS_SUCCEEDED(rv)) {
             LOG(("  trying again with next ip address\n"));
             tryAgain = PR_TRUE;
         }
     }
 
-#if defined(XP_WIN) || defined(MOZ_ENABLE_LIBCONIC)
+#if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
     // If not trying next address, try to make a connection using dialup. 
     // Retry if that connection is made.
     if (!tryAgain) {
         PRBool autodialEnabled;
         gSocketTransportService->GetAutodialEnabled(&autodialEnabled);
         if (autodialEnabled) {
           tryAgain = nsNativeConnectionHelper::OnConnectionFailed(
                        NS_ConvertUTF8toUTF16(SocketHost()).get());
--- a/netwerk/build/Makefile.in
+++ b/netwerk/build/Makefile.in
@@ -85,16 +85,21 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
         ../system/mac/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
 endif
 
 ifdef MOZ_ENABLE_LIBCONIC
     SHARED_LIBRARY_LIBS += \
         ../system/maemo/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
 endif
 
+ifdef MOZ_ENABLE_QTNETWORK
+    SHARED_LIBRARY_LIBS += \
+        ../system/qt/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
+endif
+
 LOCAL_INCLUDES = \
   -I$(srcdir)/../base/src \
   -I$(srcdir)/../dns \
   -I$(srcdir)/../socket \
   -I$(srcdir)/../streamconv/src \
   -I$(srcdir)/../streamconv/converters \
   -I$(srcdir)/../mime \
   -I$(srcdir)/../cache \
@@ -114,16 +119,20 @@ endif
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
     LOCAL_INCLUDES += -I$(srcdir)/../system/mac
 endif
 
 ifdef MOZ_ENABLE_LIBCONIC
     LOCAL_INCLUDES += -I$(srcdir)/../system/maemo
 endif
 
+ifdef MOZ_ENABLE_QTNETWORK
+    LOCAL_INCLUDES += -I$(srcdir)/../system/qt
+endif
+
 ifdef NECKO_COOKIES
 SHARED_LIBRARY_LIBS += \
   ../cookie/$(LIB_PREFIX)neckocookie_s.$(LIB_SUFFIX) \
   $(NULL)
 LOCAL_INCLUDES += -I$(srcdir)/../cookie
 endif
 
 ifdef NECKO_WIFI
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -298,16 +298,19 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsID
 #include "nsNotifyAddrListener.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
 #elif defined(MOZ_WIDGET_COCOA)
 #include "nsNetworkLinkService.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init)
 #elif defined(MOZ_ENABLE_LIBCONIC)
 #include "nsMaemoNetworkLinkService.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMaemoNetworkLinkService, Init)
+#elif defined(MOZ_ENABLE_QTNETWORK)
+#include "nsQtNetworkLinkService.h"
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsQtNetworkLinkService, Init)
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #ifdef NECKO_PROTOCOL_ftp
 #include "nsFTPDirListingConv.h"
 nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
 #endif
@@ -718,16 +721,18 @@ NS_DEFINE_NAMED_CID(NS_DEVICEPROTOCOLHAN
 NS_DEFINE_NAMED_CID(NS_VIEWSOURCEHANDLER_CID);
 #endif
 #if defined(XP_WIN)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #elif defined(MOZ_WIDGET_COCOA)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #elif defined(MOZ_ENABLE_LIBCONIC)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
+#elif defined(MOZ_ENABLE_QTNETWORK)
+NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #endif
 
 static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
     { &kNS_IOSERVICE_CID, false, NULL, nsIOServiceConstructor },
     { &kNS_STREAMTRANSPORTSERVICE_CID, false, NULL, nsStreamTransportServiceConstructor },
     { &kNS_SOCKETTRANSPORTSERVICE_CID, false, NULL, nsSocketTransportServiceConstructor },
     { &kNS_SERVERSOCKET_CID, false, NULL, nsServerSocketConstructor },
     { &kNS_SOCKETPROVIDERSERVICE_CID, false, NULL, nsSocketProviderService::Create },
@@ -836,16 +841,18 @@ static const mozilla::Module::CIDEntry k
     { &kNS_VIEWSOURCEHANDLER_CID, false, NULL, nsViewSourceHandlerConstructor },
 #endif
 #if defined(XP_WIN)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsNotifyAddrListenerConstructor },
 #elif defined(MOZ_WIDGET_COCOA)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsNetworkLinkServiceConstructor },
 #elif defined(MOZ_ENABLE_LIBCONIC)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsMaemoNetworkLinkServiceConstructor },
+#elif defined(MOZ_ENABLE_QTNETWORK)
+    { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsQtNetworkLinkServiceConstructor },
 #endif
     { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
     { NS_IOSERVICE_CONTRACTID, &kNS_IOSERVICE_CID },
     { NS_NETUTIL_CONTRACTID, &kNS_IOSERVICE_CID },
     { NS_STREAMTRANSPORTSERVICE_CONTRACTID, &kNS_STREAMTRANSPORTSERVICE_CID },
@@ -961,16 +968,18 @@ static const mozilla::Module::ContractID
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source", &kNS_VIEWSOURCEHANDLER_CID },
 #endif
 #if defined(XP_WIN)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #elif defined(MOZ_WIDGET_COCOA)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #elif defined(MOZ_ENABLE_LIBCONIC)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
+#elif defined(MOZ_ENABLE_QTNETWORK)
+    { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #endif
     { NULL }
 };
 
 static const mozilla::Module kNeckoModule = {
     mozilla::Module::kVersion,
     kNeckoCIDs,
     kNeckoContracts,
--- a/netwerk/system/Makefile.in
+++ b/netwerk/system/Makefile.in
@@ -55,9 +55,13 @@ endif
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
     DIRS += mac
 endif
 
 ifdef MOZ_ENABLE_LIBCONIC
     DIRS += maemo
 endif
 
+ifdef MOZ_ENABLE_QTNETWORK
+    DIRS += qt
+endif
+
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/netwerk/system/qt/Makefile.in
@@ -0,0 +1,62 @@
+#
+# ***** 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 Nokia Corporation Code.
+#
+# The Initial Developer of the Original Code is
+# Nokia Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Jeremias Bosch <jeremias.bosch@gmail.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 *****
+
+DEPTH		= ../../..
+topsrcdir	= @top_srcdir@
+srcdir	 = @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE         = necko
+LIBRARY_NAME   = neckosystem_s
+LIBXUL_LIBRARY = 1
+
+FORCE_STATIC_LIB = 1
+
+CPPSRCS += \
+	nsQtNetworkLinkService.cpp \
+	nsQtNetworkManager.cpp \
+	$(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+DEFINES += -DIMPL_NS_NET
+
+OS_INCLUDES += $(GLIB_CFLAGS) $(MOZ_QT_CFLAGS)
+LOCAL_INCLUDES += -I$(srcdir)/../../base/src
new file mode 100644
--- /dev/null
+++ b/netwerk/system/qt/nsQtNetworkLinkService.cpp
@@ -0,0 +1,106 @@
+/* ***** 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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 "nsQtNetworkLinkService.h"
+#include "nsCOMPtr.h"
+#include "nsIObserverService.h"
+#include "nsServiceManagerUtils.h"
+#include "nsString.h"
+#include "nsQtNetworkManager.h"
+#include "mozilla/Services.h"
+
+NS_IMPL_ISUPPORTS2(nsQtNetworkLinkService,
+                   nsINetworkLinkService,
+                   nsIObserver)
+
+nsQtNetworkLinkService::nsQtNetworkLinkService()
+{
+}
+
+nsQtNetworkLinkService::~nsQtNetworkLinkService()
+{
+}
+
+NS_IMETHODIMP
+nsQtNetworkLinkService::GetIsLinkUp(PRBool *aIsUp)
+{
+  *aIsUp = nsQtNetworkManager::IsConnected();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsQtNetworkLinkService::GetLinkStatusKnown(PRBool *aIsKnown)
+{
+  *aIsKnown = nsQtNetworkManager::GetLinkStatusKnown();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsQtNetworkLinkService::Observe(nsISupports* aSubject,
+                                const char* aTopic,
+                                const PRUnichar* aData)
+{
+  if (!strcmp(aTopic, "xpcom-shutdown"))
+    Shutdown();
+
+  return NS_OK;
+}
+
+nsresult
+nsQtNetworkLinkService::Init(void)
+{
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  if (!observerService)
+    return NS_ERROR_FAILURE;
+
+  nsresult rv = observerService->AddObserver(this, "xpcom-shutdown", PR_FALSE);
+  if (NS_FAILED(rv))
+    return NS_ERROR_FAILURE;
+
+  if (!nsQtNetworkManager::Startup())
+    return NS_ERROR_FAILURE;
+
+  return NS_OK;
+}
+
+nsresult
+nsQtNetworkLinkService::Shutdown()
+{
+  nsQtNetworkManager::Shutdown();
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/netwerk/system/qt/nsQtNetworkLinkService.h
@@ -0,0 +1,61 @@
+/* ***** 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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 NSQTNETWORKLINKSERVICE_H_
+#define NSQTNETWORKLINKSERVICE_H_
+
+#include "nsINetworkLinkService.h"
+#include "nsIObserver.h"
+
+class nsQtNetworkLinkService: public nsINetworkLinkService,
+                              public nsIObserver
+{
+
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSINETWORKLINKSERVICE
+  NS_DECL_NSIOBSERVER
+
+  nsQtNetworkLinkService();
+  virtual ~nsQtNetworkLinkService();
+
+  nsresult Init();
+  nsresult Shutdown();
+
+};
+
+#endif /* NSQTNETWORKLINKSERVICE_H_ */
new file mode 100644
--- /dev/null
+++ b/netwerk/system/qt/nsQtNetworkManager.cpp
@@ -0,0 +1,163 @@
+/* ***** 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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 ***** */
+
+//order is important - mozilla redefine qt macros
+#include <QNetworkConfigurationManager>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+
+#include "nsQtNetworkManager.h"
+
+#include "nsCOMPtr.h"
+#include "nsThreadUtils.h"
+
+#include "nsINetworkLinkService.h"
+
+#include "nsIWindowMediator.h"
+#include "nsISimpleEnumerator.h"
+
+#include "nsIOService.h"
+#include "nsIObserverService.h"
+#include "nsIOService.h"
+
+#include "nsINetworkLinkService.h"
+
+static QNetworkConfigurationManager* sNetworkConfig = 0;
+
+PRBool
+nsQtNetworkManager::OpenConnectionSync()
+{
+    if (!sNetworkConfig)
+        return PR_FALSE;
+
+    //do not request when we are online...
+    if (sNetworkConfig->isOnline())
+        return PR_FALSE;
+
+    //Check that there is atleast one XUL window. If there isn't just return
+    //without establishing connectivity
+    nsresult rv;
+    nsCOMPtr <nsIWindowMediator> windowMediator =
+            do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
+
+    NS_ENSURE_SUCCESS (rv,PR_FALSE);
+
+    nsCOMPtr <nsISimpleEnumerator> windowEnumerator;
+
+    rv = windowMediator->GetXULWindowEnumerator(nsnull,
+                                                getter_AddRefs(windowEnumerator));
+
+    NS_ENSURE_SUCCESS (rv,PR_FALSE);
+
+    PRBool moreElements = PR_FALSE;
+    windowEnumerator->HasMoreElements(&moreElements);
+    if (!moreElements) {
+        return PR_FALSE;
+    }
+
+    //Window found -> we can continue
+
+    if (!(sNetworkConfig->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces))
+        return PR_FALSE;
+
+    // Is there default access point, use it
+    QNetworkConfiguration default_cfg = sNetworkConfig->defaultConfiguration();
+
+    if (!default_cfg.isValid())
+    {
+        NS_WARNING("default configuration is not valid. Looking for any other:");
+        foreach (QNetworkConfiguration cfg, sNetworkConfig->allConfigurations())
+        {
+            if (cfg.isValid())
+                default_cfg = cfg;
+        }
+
+        if (!default_cfg.isValid())
+        {
+            NS_WARNING("No valid configuration found. Giving up.");
+            return PR_FALSE;
+        }
+    }
+
+    //do use pointer here, it will be deleted after connected!
+    //Creation on stack cause appearing issues and segfaults of the connectivity dialog
+    QNetworkSession* session = new QNetworkSession(default_cfg);
+    QObject::connect(session, SIGNAL(opened()),
+                     session, SLOT(deleteLater()));
+    QObject::connect(session, SIGNAL(error(QNetworkSession::SessionError)),
+                     session, SLOT(deleteLater()));
+    session->open();
+    return session->waitForOpened(-1);
+}
+
+void
+nsQtNetworkManager::CloseConnection()
+{
+    NS_WARNING("nsQtNetworkManager::CloseConnection() Not implemented by QtNetwork.");
+}
+
+PRBool
+nsQtNetworkManager::IsConnected()
+{
+    NS_ASSERTION(sNetworkConfig, "Network not initialized");
+    return sNetworkConfig->isOnline();
+}
+
+PRBool
+nsQtNetworkManager::GetLinkStatusKnown()
+{
+    return IsConnected();
+}
+
+PRBool
+nsQtNetworkManager::Startup()
+{
+    //Dont do it if already there
+    if (sNetworkConfig)
+        return PR_FALSE;
+
+    sNetworkConfig = new QNetworkConfigurationManager();
+
+    return PR_TRUE;
+}
+
+void
+nsQtNetworkManager::Shutdown()
+{
+    delete sNetworkConfig;
+    sNetworkConfig = nsnull;
+}
new file mode 100644
--- /dev/null
+++ b/netwerk/system/qt/nsQtNetworkManager.h
@@ -0,0 +1,58 @@
+/* ***** 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 Nokia Corporation Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Nokia Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Jeremias Bosch <jeremias.bosch@gmail.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 NSQTNETWORKMANAGER_H_
+#define NSQTNETWORKMANAGER_H_
+
+#include "nscore.h"
+
+class nsQtNetworkManager
+{
+public:
+  // Can be called from any thread, most likely the socket transport thread
+  static PRBool OpenConnectionSync();
+  static void CloseConnection();
+
+  static PRBool IsConnected();
+  static PRBool GetLinkStatusKnown();
+
+  // Called from the nsQtNetworkLinkService (main thread only)
+  static PRBool Startup();
+  static void Shutdown();
+};
+
+#endif /* NSQTNETWORKMANAGER_H_ */