diff options
100 files changed, 3437 insertions, 3114 deletions
diff --git a/config.tests/mac/corewlan/corewlan.pro b/config.tests/mac/corewlan/corewlan.pro index 54a6c36..8451af3 100644 --- a/config.tests/mac/corewlan/corewlan.pro +++ b/config.tests/mac/corewlan/corewlan.pro @@ -1,4 +1,3 @@ -SOURCES=corewlantest.mm -TARGET=corewlan +SOURCES = corewlantest.mm LIBS += -framework CoreWLAN -framework Foundation -CONFIG-=app_bundle +CONFIG -= app_bundle qt diff --git a/config.tests/mac/corewlan/corewlantest.mm b/config.tests/mac/corewlan/corewlantest.mm index bcddf44..3a29d84 100644 --- a/config.tests/mac/corewlan/corewlantest.mm +++ b/config.tests/mac/corewlan/corewlantest.mm @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the config.tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/config.tests/unix/networkmanager/main.cpp b/config.tests/unix/networkmanager/main.cpp index 6f2bae6..27e6bd1 100644 --- a/config.tests/unix/networkmanager/main.cpp +++ b/config.tests/unix/networkmanager/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the config.tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/config.tests/unix/networkmanager/networkmanager.pro b/config.tests/unix/networkmanager/networkmanager.pro index 554f513..c41204f 100644 --- a/config.tests/unix/networkmanager/networkmanager.pro +++ b/config.tests/unix/networkmanager/networkmanager.pro @@ -1,11 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Oct 19 12:58:26 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp +SOURCES = main.cpp +CONFIG -= qt dylib +mac:CONFIG -= app_bundle @@ -765,6 +765,8 @@ OPT_HELP= CFG_SILENT=no CFG_GRAPHICS_SYSTEM=default CFG_ALSA=auto +CFG_NETWORKMANAGER=auto +CFG_COREWLAN=auto # initalize variables used for installation QT_INSTALL_PREFIX= @@ -5364,6 +5366,14 @@ if [ "$PLATFORM_MAC" = "yes" ]; then # Always enable Phonon (unless it was explicitly disabled) CFG_PHONON=yes fi + + if [ "$CFG_COREWLAN" = "auto" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/corewlan "CoreWlan" $L_FLAGS $I_FLAGS $l_FLAGS; then + CFG_COREWLAN=yes + else + CFG_COREWLAN=no + fi + fi fi # QWS @@ -5820,6 +5830,14 @@ if [ "$CFG_ALSA" = "auto" ]; then fi fi +if [ "$CFG_NETWORKMANAGER" = "auto" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/networkmanager "NetworkManager" $L_FLAGS $I_FLAGS $l_FLAGS; then + CFG_NETWORKMANAGER=yes + else + CFG_NETWORKMANAGER=no + fi +fi + if [ -f "$relpath/src/declarative/declarative.pro" ]; then if [ "$CFG_DECLARATIVE" = "auto" ]; then CFG_DECLARATIVE=yes @@ -6297,6 +6315,14 @@ if [ "$CFG_ALSA" = "yes" ]; then QT_CONFIG="$QT_CONFIG alsa" fi +if [ "$CFG_NETWORKMANAGER" = "yes" ]; then + QT_CONFIG="$QT_CONFIG networkmanager" +fi + +if [ "$CFG_COREWLAN" = "yes" ]; then + QT_CONFIG="$QT_CONFIG corewlan" +fi + # # Some Qt modules are too advanced in C++ for some old compilers # Detect here the platforms where they are known to work. @@ -6997,6 +7023,8 @@ fi [ "$CFG_XRANDR" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XRANDR" [ "$CFG_XINPUT" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XINPUT" [ "$CFG_ALSA" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ALSA" +[ "$CFG_NETWORKMANAGER" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_NETWORKMANAGER" +[ "$CFG_COREWLAN" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_COREWLAN" # sort QCONFIG_FLAGS for neatness if we can [ '!' -z "$AWK" ] && QCONFIG_FLAGS=`echo $QCONFIG_FLAGS | $AWK '{ gsub(" ", "\n"); print }' | sort | uniq` @@ -7332,163 +7360,163 @@ fi if [ "$OPT_VERBOSE" = "yes" ]; then if echo '\c' | grep '\c' >/dev/null; then - echo -n "qmake vars .......... " + echo -n "qmake vars ............. " else - echo "qmake vars .......... \c" + echo "qmake vars ............. \c" fi cat "$QMAKE_VARS_FILE" | tr '\n' ' ' - echo "qmake switches ...... $QMAKE_SWITCHES" + echo "qmake switches ......... $QMAKE_SWITCHES" fi -[ "$CFG_INCREMENTAL" = "yes" ] && [ '!' -z "$INCREMENTAL" ] && echo "Incremental ......... $INCREMENTAL" -echo "Build ............... $CFG_BUILD_PARTS" -echo "Configuration ....... $QMAKE_CONFIG $QT_CONFIG" +[ "$CFG_INCREMENTAL" = "yes" ] && [ '!' -z "$INCREMENTAL" ] && echo "Incremental ............ $INCREMENTAL" +echo "Build .................. $CFG_BUILD_PARTS" +echo "Configuration .......... $QMAKE_CONFIG $QT_CONFIG" if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then - echo "Debug ............... yes (combined)" + echo "Debug .................. yes (combined)" if [ "$CFG_DEBUG" = "yes" ]; then - echo "Default Link ........ debug" + echo "Default Link ........... debug" else - echo "Default Link ........ release" + echo "Default Link ........... release" fi else - echo "Debug ............... $CFG_DEBUG" -fi -echo "Qt 3 compatibility .. $CFG_QT3SUPPORT" -[ "$CFG_DBUS" = "no" ] && echo "QtDBus module ....... no" -[ "$CFG_DBUS" = "yes" ] && echo "QtDBus module ....... yes (run-time)" -[ "$CFG_DBUS" = "linked" ] && echo "QtDBus module ....... yes (linked)" -echo "QtConcurrent code.... $CFG_CONCURRENT" -echo "QtScript module ..... $CFG_SCRIPT" -echo "QtScriptTools module $CFG_SCRIPTTOOLS" -echo "QtXmlPatterns module $CFG_XMLPATTERNS" -echo "Phonon module ....... $CFG_PHONON" -echo "Multimedia module ... $CFG_MULTIMEDIA" -echo "SVG module .......... $CFG_SVG" -echo "WebKit module ....... $CFG_WEBKIT" + echo "Debug .................. $CFG_DEBUG" +fi +echo "Qt 3 compatibility ..... $CFG_QT3SUPPORT" +[ "$CFG_DBUS" = "no" ] && echo "QtDBus module .......... no" +[ "$CFG_DBUS" = "yes" ] && echo "QtDBus module .......... yes (run-time)" +[ "$CFG_DBUS" = "linked" ] && echo "QtDBus module .......... yes (linked)" +echo "QtConcurrent code ...... $CFG_CONCURRENT" +echo "QtScript module ........ $CFG_SCRIPT" +echo "QtScriptTools module ... $CFG_SCRIPTTOOLS" +echo "QtXmlPatterns module ... $CFG_XMLPATTERNS" +echo "Phonon module .......... $CFG_PHONON" +echo "Multimedia module ...... $CFG_MULTIMEDIA" +echo "SVG module ............. $CFG_SVG" +echo "WebKit module .......... $CFG_WEBKIT" if [ "$CFG_WEBKIT" = "yes" ]; then if [ "$CFG_JAVASCRIPTCORE_JIT" = "auto" ]; then - echo "JavaScriptCore JIT .. To be decided by JavaScriptCore" + echo "JavaScriptCore JIT ..... To be decided by JavaScriptCore" else - echo "JavaScriptCore JIT .. $CFG_JAVASCRIPTCORE_JIT" + echo "JavaScriptCore JIT ..... $CFG_JAVASCRIPTCORE_JIT" fi fi -echo "Declarative module .. $CFG_DECLARATIVE" -echo "STL support ......... $CFG_STL" -echo "PCH support ......... $CFG_PRECOMPILE" -echo "MMX/3DNOW/SSE/SSE2.. ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}" +echo "Declarative module ..... $CFG_DECLARATIVE" +echo "STL support ............ $CFG_STL" +echo "PCH support ............ $CFG_PRECOMPILE" +echo "MMX/3DNOW/SSE/SSE2 ..... ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}" if [ "${CFG_ARCH}" = "arm" ]; then - echo "iWMMXt support ...... ${CFG_IWMMXT}" -fi -[ "${PLATFORM_QWS}" != "yes" ] && echo "Graphics System ..... $CFG_GRAPHICS_SYSTEM" -echo "IPv6 support ........ $CFG_IPV6" -echo "IPv6 ifname support . $CFG_IPV6IFNAME" -echo "getaddrinfo support . $CFG_GETADDRINFO" -echo "getifaddrs support .. $CFG_GETIFADDRS" -echo "Accessibility ....... $CFG_ACCESSIBILITY" -echo "NIS support ......... $CFG_NIS" -echo "CUPS support ........ $CFG_CUPS" -echo "Iconv support ....... $CFG_ICONV" -echo "Glib support ........ $CFG_GLIB" -echo "GStreamer support ... $CFG_GSTREAMER" -echo "Large File support .. $CFG_LARGEFILE" -echo "GIF support ......... $CFG_GIF" + echo "iWMMXt support ......... ${CFG_IWMMXT}" +fi +[ "${PLATFORM_QWS}" != "yes" ] && echo "Graphics System ........ $CFG_GRAPHICS_SYSTEM" +echo "IPv6 support ........... $CFG_IPV6" +echo "IPv6 ifname support .... $CFG_IPV6IFNAME" +echo "getaddrinfo support .... $CFG_GETADDRINFO" +echo "getifaddrs support ..... $CFG_GETIFADDRS" +echo "Accessibility .......... $CFG_ACCESSIBILITY" +echo "NIS support ............ $CFG_NIS" +echo "CUPS support ........... $CFG_CUPS" +echo "Iconv support .......... $CFG_ICONV" +echo "Glib support ........... $CFG_GLIB" +echo "GStreamer support ...... $CFG_GSTREAMER" +echo "Large File support ..... $CFG_LARGEFILE" +echo "GIF support ............ $CFG_GIF" if [ "$CFG_TIFF" = "no" ]; then - echo "TIFF support ........ $CFG_TIFF" + echo "TIFF support ........... $CFG_TIFF" else - echo "TIFF support ........ $CFG_TIFF ($CFG_LIBTIFF)" + echo "TIFF support ........... $CFG_TIFF ($CFG_LIBTIFF)" fi if [ "$CFG_JPEG" = "no" ]; then - echo "JPEG support ........ $CFG_JPEG" + echo "JPEG support ........... $CFG_JPEG" else - echo "JPEG support ........ $CFG_JPEG ($CFG_LIBJPEG)" + echo "JPEG support ........... $CFG_JPEG ($CFG_LIBJPEG)" fi if [ "$CFG_PNG" = "no" ]; then - echo "PNG support ......... $CFG_PNG" + echo "PNG support ............ $CFG_PNG" else - echo "PNG support ......... $CFG_PNG ($CFG_LIBPNG)" + echo "PNG support ............ $CFG_PNG ($CFG_LIBPNG)" fi if [ "$CFG_MNG" = "no" ]; then - echo "MNG support ......... $CFG_MNG" + echo "MNG support ............ $CFG_MNG" else - echo "MNG support ......... $CFG_MNG ($CFG_LIBMNG)" + echo "MNG support ............ $CFG_MNG ($CFG_LIBMNG)" fi -echo "zlib support ........ $CFG_ZLIB" -echo "Session management .. $CFG_SM" +echo "zlib support ........... $CFG_ZLIB" +echo "Session management ..... $CFG_SM" if [ "$PLATFORM_QWS" = "yes" ]; then - echo "Embedded support .... $CFG_EMBEDDED" + echo "Embedded support ....... $CFG_EMBEDDED" if [ "$CFG_QWS_FREETYPE" = "auto" ]; then - echo "Freetype2 support ... $CFG_QWS_FREETYPE ($CFG_LIBFREETYPE)" + echo "Freetype2 support ...... $CFG_QWS_FREETYPE ($CFG_LIBFREETYPE)" else - echo "Freetype2 support ... $CFG_QWS_FREETYPE" + echo "Freetype2 support ...... $CFG_QWS_FREETYPE" fi # Normalize the decoration output first CFG_GFX_ON=`echo ${CFG_GFX_ON}` CFG_GFX_PLUGIN=`echo ${CFG_GFX_PLUGIN}` - echo "Graphics (qt) ....... ${CFG_GFX_ON}" - echo "Graphics (plugin) ... ${CFG_GFX_PLUGIN}" + echo "Graphics (qt) .......... ${CFG_GFX_ON}" + echo "Graphics (plugin) ...... ${CFG_GFX_PLUGIN}" CFG_DECORATION_ON=`echo ${CFG_DECORATION_ON}` CFG_DECORATION_PLUGIN=`echo ${CFG_DECORATION_PLUGIN}` - echo "Decorations (qt) .... $CFG_DECORATION_ON" - echo "Decorations (plugin) $CFG_DECORATION_PLUGIN" + echo "Decorations (qt) ....... $CFG_DECORATION_ON" + echo "Decorations (plugin) ... $CFG_DECORATION_PLUGIN" CFG_KBD_ON=`echo ${CFG_KBD_ON}` CFG_KBD_PLUGIN=`echo ${CFG_KBD_PLUGIN}` - echo "Keyboard driver (qt). ${CFG_KBD_ON}" - echo "Keyboard driver (plugin) ${CFG_KBD_PLUGIN}" + echo "Keyboard driver (qt) ... ${CFG_KBD_ON}" + echo "Keyboard driver (plugin) .. ${CFG_KBD_PLUGIN}" CFG_MOUSE_ON=`echo ${CFG_MOUSE_ON}` CFG_MOUSE_PLUGIN=`echo ${CFG_MOUSE_PLUGIN}` - echo "Mouse driver (qt) ... $CFG_MOUSE_ON" - echo "Mouse driver (plugin) $CFG_MOUSE_PLUGIN" + echo "Mouse driver (qt) ...... $CFG_MOUSE_ON" + echo "Mouse driver (plugin) .. $CFG_MOUSE_PLUGIN" fi if [ "$CFG_OPENGL" = "desktop" ]; then - echo "OpenGL support ...... yes (Desktop OpenGL)" + echo "OpenGL support ......... yes (Desktop OpenGL)" elif [ "$CFG_OPENGL" = "es1" ]; then - echo "OpenGL support ...... yes (OpenGL ES 1.x Common profile)" + echo "OpenGL support ......... yes (OpenGL ES 1.x Common profile)" elif [ "$CFG_OPENGL" = "es1cl" ]; then - echo "OpenGL support ...... yes (OpenGL ES 1.x Common Lite profile)" + echo "OpenGL support ......... yes (OpenGL ES 1.x Common Lite profile)" elif [ "$CFG_OPENGL" = "es2" ]; then - echo "OpenGL support ...... yes (OpenGL ES 2.x)" + echo "OpenGL support ......... yes (OpenGL ES 2.x)" else - echo "OpenGL support ...... no" + echo "OpenGL support ......... no" fi if [ "$CFG_EGL" != "no" ]; then if [ "$CFG_EGL_GLES_INCLUDES" != "no" ]; then - echo "EGL support ......... yes <GLES/egl.h>" + echo "EGL support ............ yes <GLES/egl.h>" else - echo "EGL support ......... yes <EGL/egl.h>" + echo "EGL support ............ yes <EGL/egl.h>" fi fi if [ "$CFG_OPENVG" ]; then if [ "$CFG_OPENVG_SHIVA" = "yes" ]; then - echo "OpenVG support ...... ShivaVG" + echo "OpenVG support ......... ShivaVG" else - echo "OpenVG support ...... $CFG_OPENVG" + echo "OpenVG support ......... $CFG_OPENVG" fi fi if [ "$PLATFORM_X11" = "yes" ]; then - echo "NAS sound support ... $CFG_NAS" - echo "XShape support ...... $CFG_XSHAPE" - echo "XSync support ....... $CFG_XSYNC" - echo "Xinerama support .... $CFG_XINERAMA" - echo "Xcursor support ..... $CFG_XCURSOR" - echo "Xfixes support ...... $CFG_XFIXES" - echo "Xrandr support ...... $CFG_XRANDR" - echo "Xrender support ..... $CFG_XRENDER" - echo "Xi support .......... $CFG_XINPUT" - echo "MIT-SHM support ..... $CFG_MITSHM" - echo "FontConfig support .. $CFG_FONTCONFIG" - echo "XKB Support ......... $CFG_XKB" - echo "immodule support .... $CFG_IM" - echo "GTK theme support ... $CFG_QGTKSTYLE" -fi -[ "$CFG_SQL_mysql" != "no" ] && echo "MySQL support ....... $CFG_SQL_mysql" -[ "$CFG_SQL_psql" != "no" ] && echo "PostgreSQL support .. $CFG_SQL_psql" -[ "$CFG_SQL_odbc" != "no" ] && echo "ODBC support ........ $CFG_SQL_odbc" -[ "$CFG_SQL_oci" != "no" ] && echo "OCI support ......... $CFG_SQL_oci" -[ "$CFG_SQL_tds" != "no" ] && echo "TDS support ......... $CFG_SQL_tds" -[ "$CFG_SQL_db2" != "no" ] && echo "DB2 support ......... $CFG_SQL_db2" -[ "$CFG_SQL_ibase" != "no" ] && echo "InterBase support ... $CFG_SQL_ibase" -[ "$CFG_SQL_sqlite2" != "no" ] && echo "SQLite 2 support .... $CFG_SQL_sqlite2" -[ "$CFG_SQL_sqlite" != "no" ] && echo "SQLite support ...... $CFG_SQL_sqlite ($CFG_SQLITE)" + echo "NAS sound support ...... $CFG_NAS" + echo "XShape support ......... $CFG_XSHAPE" + echo "XSync support .......... $CFG_XSYNC" + echo "Xinerama support ....... $CFG_XINERAMA" + echo "Xcursor support ........ $CFG_XCURSOR" + echo "Xfixes support ......... $CFG_XFIXES" + echo "Xrandr support ......... $CFG_XRANDR" + echo "Xrender support ........ $CFG_XRENDER" + echo "Xi support ............. $CFG_XINPUT" + echo "MIT-SHM support ........ $CFG_MITSHM" + echo "FontConfig support ..... $CFG_FONTCONFIG" + echo "XKB Support ............ $CFG_XKB" + echo "immodule support ....... $CFG_IM" + echo "GTK theme support ...... $CFG_QGTKSTYLE" +fi +[ "$CFG_SQL_mysql" != "no" ] && echo "MySQL support .......... $CFG_SQL_mysql" +[ "$CFG_SQL_psql" != "no" ] && echo "PostgreSQL support ..... $CFG_SQL_psql" +[ "$CFG_SQL_odbc" != "no" ] && echo "ODBC support ........... $CFG_SQL_odbc" +[ "$CFG_SQL_oci" != "no" ] && echo "OCI support ............ $CFG_SQL_oci" +[ "$CFG_SQL_tds" != "no" ] && echo "TDS support ............ $CFG_SQL_tds" +[ "$CFG_SQL_db2" != "no" ] && echo "DB2 support ............ $CFG_SQL_db2" +[ "$CFG_SQL_ibase" != "no" ] && echo "InterBase support ...... $CFG_SQL_ibase" +[ "$CFG_SQL_sqlite2" != "no" ] && echo "SQLite 2 support ....... $CFG_SQL_sqlite2" +[ "$CFG_SQL_sqlite" != "no" ] && echo "SQLite support ......... $CFG_SQL_sqlite ($CFG_SQLITE)" OPENSSL_LINKAGE="" if [ "$CFG_OPENSSL" = "yes" ]; then @@ -7496,9 +7524,9 @@ if [ "$CFG_OPENSSL" = "yes" ]; then elif [ "$CFG_OPENSSL" = "linked" ]; then OPENSSL_LINKAGE="(linked)" fi -echo "OpenSSL support ..... $CFG_OPENSSL $OPENSSL_LINKAGE" +echo "OpenSSL support ........ $CFG_OPENSSL $OPENSSL_LINKAGE" -[ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........ $CFG_PTMALLOC" +[ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........... $CFG_PTMALLOC" # complain about not being able to use dynamic plugins if we are using a static build if [ "$CFG_SHARED" = "no" ]; then @@ -7521,7 +7549,9 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" echo "NOTE: Mac OS X frameworks implicitly build debug and release Qt libraries." echo fi -echo "alsa support ........ $CFG_ALSA" +echo "alsa support ........... $CFG_ALSA" +echo "NetworkManager support . $CFG_NETWORKMANAGER" +echo "CoreWlan support ....... $CFG_COREWLAN" echo sepath=`echo "$relpath" | sed -e 's/\\./\\\\./g'` diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp index 182d4ec..27a296d 100644 --- a/examples/network/bearercloud/bearercloud.cpp +++ b/examples/network/bearercloud/bearercloud.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h index c18ffd3..f09cb53 100644 --- a/examples/network/bearercloud/bearercloud.h +++ b/examples/network/bearercloud/bearercloud.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -45,7 +45,7 @@ #include <QMap> #include <QHash> -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class Cloud; diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro index 75e3049..b82857d 100644 --- a/examples/network/bearercloud/bearercloud.pro +++ b/examples/network/bearercloud/bearercloud.pro @@ -11,13 +11,6 @@ TARGET = bearercloud QT = core gui network svg -INCLUDEPATH += ../../src/bearer - -include(../examples.pri) - -CONFIG += mobility -MOBILITY = bearer - CONFIG += console symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp index 61bd88e..81e13a6 100644 --- a/examples/network/bearercloud/cloud.cpp +++ b/examples/network/bearercloud/cloud.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h index b542bf7..38f8aff 100644 --- a/examples/network/bearercloud/cloud.h +++ b/examples/network/bearercloud/cloud.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -43,7 +43,7 @@ #include <qnetworksession.h> #include <QGraphicsItem> -QTM_USE_NAMESPACE +QT_USE_NAMESPACE QT_BEGIN_NAMESPACE class QGraphicsTextItem; diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp index 33c55e9..86ef46f 100644 --- a/examples/network/bearercloud/main.cpp +++ b/examples/network/bearercloud/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 70c8269..5b2bad1 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h index d1f4601..d7025dd 100644 --- a/examples/network/bearermonitor/bearermonitor.h +++ b/examples/network/bearermonitor/bearermonitor.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -50,7 +50,7 @@ #include "ui_bearermonitor_640_480.h" #endif -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class SessionWidget; diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro index acbee71..db1727b 100644 --- a/examples/network/bearermonitor/bearermonitor.pro +++ b/examples/network/bearermonitor/bearermonitor.pro @@ -4,7 +4,7 @@ HEADERS = sessionwidget.h \ SOURCES = main.cpp \ bearermonitor.cpp \ sessionwidget.cpp - + FORMS = bearermonitor_240_320.ui \ bearermonitor_640_480.ui \ sessionwidget.ui @@ -13,15 +13,13 @@ TARGET = bearermonitor QT = core gui network -INCLUDEPATH += ../../src/bearer - -include(../examples.pri) - -CONFIG += mobility -MOBILITY = bearer - -win32:!wince*:LIBS += -lWs2_32 -wince*:LIBS += -lWs2 +win32 { + !wince* { + LIBS += -lWs2_32 + } else { + LIBS += -lWs2 + } +} CONFIG += console diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp index 9685181..b7ac4fe 100644 --- a/examples/network/bearermonitor/main.cpp +++ b/examples/network/bearermonitor/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index 0277d87..d03c5bf 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h index cb6591e..868de3a 100644 --- a/examples/network/bearermonitor/sessionwidget.h +++ b/examples/network/bearermonitor/sessionwidget.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -46,7 +46,7 @@ #include <qnetworksession.h> -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class SessionWidget : public QWidget, public Ui_SessionWidget { diff --git a/examples/network/network.pro b/examples/network/network.pro index c5a97fb..bd632b8 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -11,7 +11,9 @@ SUBDIRS = blockingfortuneclient \ loopback \ threadedfortuneserver \ googlesuggest \ - torrent + torrent \ + bearercloud \ + bearermonitor # no QProcess !vxworks:!qnx:SUBDIRS += network-chat diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri new file mode 100644 index 0000000..4f6c549 --- /dev/null +++ b/src/network/bearer/bearer.pri @@ -0,0 +1,83 @@ +# Qt network bearer management module + +#DEFINES += BEARER_MANAGEMENT_DEBUG + +HEADERS += bearer/qnetworkconfiguration.h \ + bearer/qnetworksession.h \ + bearer/qnetworkconfigmanager.h \ + bearer/qbearerplugin.h + +SOURCES += bearer/qnetworksession.cpp \ + bearer/qnetworkconfigmanager.cpp \ + bearer/qnetworkconfiguration.cpp \ + bearer/qbearerplugin.cpp + +symbian { + exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \ + exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) { + message("Building with SNAP support") + DEFINES += SNAP_FUNCTIONALITY_AVAILABLE + LIBS += -lcmmanager + } else { + message("Building without SNAP support") + LIBS += -lapengine + } + + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + + HEADERS += bearer/qnetworkconfigmanager_s60_p.h \ + bearer/qnetworkconfiguration_s60_p.h \ + bearer/qnetworksession_s60_p.h + SOURCES += bearer/qnetworkconfigmanager_s60_p.cpp \ + bearer/qnetworkconfiguration_s60_p.cpp \ + bearer/qnetworksession_s60_p.cpp + + LIBS += -lcommdb \ + -lapsettingshandlerui \ + -lconnmon \ + -lcentralrepository \ + -lesock \ + -linsock \ + -lecom \ + -lefsrv \ + -lnetmeta +} else:maemo { + QT += dbus + CONFIG += link_pkgconfig + + exists(../debug) { + message("Enabling debug messages.") + DEFINES += BEARER_MANAGEMENT_DEBUG + } + + HEADERS += bearer/qnetworksession_maemo_p.h \ + bearer/qnetworkconfigmanager_maemo_p.h \ + bearer/qnetworkconfiguration_maemo_p.h + + SOURCES += bearer/qnetworkconfigmanager_maemo.cpp \ + bearer/qnetworksession_maemo.cpp + + documentation.path = $$QT_MOBILITY_PREFIX/doc + documentation.files = doc/html + + PKGCONFIG += glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet + + CONFIG += create_pc create_prl + QMAKE_PKGCONFIG_REQUIRES = glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet + pkgconfig.path = $$QT_MOBILITY_LIB/pkgconfig + pkgconfig.files = QtBearer.pc + + INSTALLS += pkgconfig documentation +} else { + HEADERS += bearer/qnetworkconfigmanager_p.h \ + bearer/qnetworkconfiguration_p.h \ + bearer/qnetworksession_p.h \ + bearer/qnetworksessionengine_p.h + + SOURCES += bearer/qnetworkconfigmanager_p.cpp \ + bearer/qnetworksession_p.cpp \ + bearer/qnetworksessionengine.cpp + + contains(QT_CONFIG, networkmanager):DEFINES += BACKEND_NM +} + diff --git a/src/network/bearer/bearer.pro b/src/network/bearer/bearer.pro deleted file mode 100644 index ce39db6..0000000 --- a/src/network/bearer/bearer.pro +++ /dev/null @@ -1,162 +0,0 @@ -# Qt bearer management library -TEMPLATE = lib -TARGET = QtBearer - -QT += network -include (../../common.pri) - -DEFINES += QT_BUILD_BEARER_LIB QT_MAKEDLL - -#DEFINES += BEARER_MANAGEMENT_DEBUG - -PUBLIC_HEADERS += qnetworkconfiguration.h \ - qnetworksession.h \ - qnetworkconfigmanager.h - -HEADERS += $$PUBLIC_HEADERS -SOURCES += qnetworksession.cpp \ - qnetworkconfigmanager.cpp \ - qnetworkconfiguration.cpp - -symbian: { - contains(snap_enabled, yes) { - message("Building with SNAP support") - DEFINES += SNAP_FUNCTIONALITY_AVAILABLE=1 - LIBS += -lcmmanager - } else { - message("Building without SNAP support") - LIBS += -lapengine - } - - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - - HEADERS += qnetworkconfigmanager_s60_p.h \ - qnetworkconfiguration_s60_p.h \ - qnetworksession_s60_p.h - SOURCES += qnetworkconfigmanager_s60_p.cpp \ - qnetworkconfiguration_s60_p.cpp \ - qnetworksession_s60_p.cpp - - LIBS += -lcommdb \ - -lapsettingshandlerui \ - -lconnmon \ - -lcentralrepository \ - -lesock \ - -linsock \ - -lecom \ - -lefsrv \ - -lnetmeta - - TARGET.CAPABILITY = ALL -TCB - TARGET.UID3 = 0x2002AC81 - - deploy.path = $${EPOCROOT} - exportheaders.sources = $$PUBLIC_HEADERS - exportheaders.path = epoc32/include - for(header, exportheaders.sources) { - BLD_INF_RULES.prj_exports += "$$header $$deploy.path$$exportheaders.path/$$basename(header)" - } - - QtBearerManagement.sources = QtBearer.dll - QtBearerManagement.path = /sys/bin - DEPLOYMENT += QtBearerManagement -} else { - maemo6 { - QT += dbus - CONFIG += link_pkgconfig - - exists(../debug) { - message("Enabling debug messages.") - DEFINES += BEARER_MANAGEMENT_DEBUG - } - - HEADERS += qnetworksession_maemo_p.h \ - qnetworkconfigmanager_maemo_p.h \ - qnetworkconfiguration_maemo_p.h - - SOURCES += qnetworkconfigmanager_maemo.cpp \ - qnetworksession_maemo.cpp - - documentation.path = $$QT_MOBILITY_PREFIX/doc - documentation.files = doc/html - - PKGCONFIG += glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet - - CONFIG += create_pc create_prl - QMAKE_PKGCONFIG_REQUIRES = glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet - pkgconfig.path = $$QT_MOBILITY_LIB/pkgconfig - pkgconfig.files = QtBearer.pc - - INSTALLS += pkgconfig documentation - - } else { - - DEFINES += BEARER_ENGINE - - HEADERS += qnetworkconfigmanager_p.h \ - qnetworkconfiguration_p.h \ - qnetworksession_p.h \ - qnetworksessionengine_p.h \ - qgenericengine_p.h - - SOURCES += qnetworkconfigmanager_p.cpp \ - qnetworksession_p.cpp \ - qnetworksessionengine.cpp \ - qgenericengine.cpp - - unix:!mac:contains(networkmanager_enabled, yes) { - contains(QT_CONFIG,dbus) { - DEFINES += BACKEND_NM - QT += dbus - - HEADERS += qnmdbushelper_p.h \ - qnetworkmanagerservice_p.h \ - qnmwifiengine_unix_p.h - - SOURCES += qnmdbushelper.cpp \ - qnetworkmanagerservice_p.cpp \ - qnmwifiengine_unix.cpp - } else { - message("NetworkManager backend requires Qt DBus support") - } - } - - win32: { - HEADERS += qnlaengine_win_p.h \ - qnetworksessionengine_win_p.h - - !wince*:HEADERS += qnativewifiengine_win_p.h - - SOURCES += qnlaengine_win.cpp - - !wince*:SOURCES += qnativewifiengine_win.cpp - - !wince*:LIBS += -lWs2_32 - wince*:LIBS += -lWs2 - } - } - macx: { - HEADERS += qcorewlanengine_mac_p.h - SOURCES+= qcorewlanengine_mac.mm - LIBS += -framework Foundation -framework SystemConfiguration - - contains(corewlan_enabled, yes) { - isEmpty(QMAKE_MAC_SDK) { - SDK6="yes" - } else { - contains(QMAKE_MAC_SDK, "/Developer/SDKs/MacOSX10.6.sdk") { - SDK6="yes" - } - } - - !isEmpty(SDK6) { - LIBS += -framework CoreWLAN - DEFINES += MAC_SDK_10_6 - } - } - - - } -} - -include(../../features/deploy.pri) diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp new file mode 100644 index 0000000..7b81b13 --- /dev/null +++ b/src/network/bearer/qbearerplugin.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbearerplugin.h" + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent) +: QObject(parent) +{ +} + +QBearerEnginePlugin::~QBearerEnginePlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/network/bearer/qbearerplugin.h b/src/network/bearer/qbearerplugin.h new file mode 100644 index 0000000..036d712 --- /dev/null +++ b/src/network/bearer/qbearerplugin.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBEARERPLUGIN_H +#define QBEARERPLUGIN_H + +#include "qnetworksessionengine_p.h" + +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Network) + +struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface +{ + virtual QBearerEngine *create(const QString &key = QString()) const = 0; +}; + +#define QBearerEngineFactoryInterface_iid "com.trolltech.Qt.QBearerEngineFactoryInterface" +Q_DECLARE_INTERFACE(QBearerEngineFactoryInterface, QBearerEngineFactoryInterface_iid) + +class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject, public QBearerEngineFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QBearerEngineFactoryInterface:QFactoryInterface) + +public: + explicit QBearerEnginePlugin(QObject *parent = 0); + virtual ~QBearerEnginePlugin(); + + virtual QStringList keys() const = 0; + virtual QBearerEngine *create(const QString &key = QString()) const = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif + diff --git a/src/network/bearer/qnativewifiengine_win.cpp b/src/network/bearer/qnativewifiengine_win.cpp deleted file mode 100644 index 008a9cf..0000000 --- a/src/network/bearer/qnativewifiengine_win.cpp +++ /dev/null @@ -1,729 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnativewifiengine_win_p.h" -#include "qnetworkconfiguration_p.h" - -#include <QtCore/qmutex.h> -#include <QtCore/private/qmutexpool_p.h> -#include <QtCore/qlibrary.h> -#include <QtCore/qstringlist.h> - -#include <QtCore/qdebug.h> - -#include <wtypes.h> -#undef interface - -QTM_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QNativeWifiEngine, nativeWifiEngine) - -#define WLAN_MAX_NAME_LENGTH 256 -#define WLAN_MAX_PHY_TYPE_NUMBER 8 -#define WLAN_NOTIFICATION_SOURCE_ALL 0x0000ffff -#define WLAN_AVAILABLE_NETWORK_CONNECTED 1 -#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2 -#define DOT11_SSID_MAX_LENGTH 32 - -struct WLAN_NOTIFICATION_DATA { - DWORD NotificationSource; - DWORD NotificationCode; - GUID InterfaceGuid; - DWORD dwDataSize; - PVOID pData; -}; - -enum WLAN_INTERFACE_STATE { - wlan_interface_state_not_ready = 0, - wlan_interface_state_connected, - wlan_interface_state_ad_hoc_network_formed, - wlan_interface_state_disconnecting, - wlan_interface_state_disconnected, - wlan_interface_state_associating, - wlan_interface_state_discovering, - wlan_interface_state_authenticating -}; - -struct WLAN_INTERFACE_INFO { - GUID InterfaceGuid; - WCHAR strInterfaceDescription[WLAN_MAX_NAME_LENGTH]; - WLAN_INTERFACE_STATE isState; -}; - -struct WLAN_INTERFACE_INFO_LIST { - DWORD dwNumberOfItems; - DWORD dwIndex; - WLAN_INTERFACE_INFO InterfaceInfo[1]; -}; - -struct DOT11_SSID { - ULONG uSSIDLength; - UCHAR ucSSID[DOT11_SSID_MAX_LENGTH]; -}; - -struct NDIS_OBJECT_HEADER { - UCHAR Type; - UCHAR Revision; - USHORT Size; -}; - -typedef UCHAR DOT11_MAC_ADDRESS[6]; -struct DOT11_BSSID_LIST { - NDIS_OBJECT_HEADER Header; - ULONG uNumberOfEntries; - ULONG uTotalNumOfEntries; - DOT11_MAC_ADDRESS BSSIDs[1]; -}; - -enum DOT11_BSS_TYPE { - dot11_BSS_type_infrastructure = 1, - dot11_BSS_type_independent = 2, - dot11_BSS_type_any = 3 -}; - -enum DOT11_PHY_TYPE { - dot11_phy_type_unknown = 0, - dot11_phy_type_any = dot11_phy_type_unknown, - dot11_phy_type_fhss = 1, - dot11_phy_type_dsss = 2, - dot11_phy_type_irbaseband = 3, - dot11_phy_type_ofdm = 4, - dot11_phy_type_hrdsss = 5, - dot11_phy_type_erp = 6, - dot11_phy_type_ht = 7, - dot11_phy_type_IHV_start = 0x80000000, - dot11_phy_type_IHV_end = 0xffffffff -}; - -enum DOT11_AUTH_ALGORITHM { - DOT11_AUTH_ALGO_80211_OPEN = 1, - DOT11_AUTH_ALGO_80211_SHARED_KEY = 2, - DOT11_AUTH_ALGO_WPA = 3, - DOT11_AUTH_ALGO_WPA_PSK = 4, - DOT11_AUTH_ALGO_WPA_NONE = 5, - DOT11_AUTH_ALGO_RSNA = 6, - DOT11_AUTH_ALGO_RSNA_PSK = 7, - DOT11_AUTH_ALGO_IHV_START = 0x80000000, - DOT11_AUTH_ALGO_IHV_END = 0xffffffff -}; - -enum DOT11_CIPHER_ALGORITHM { - DOT11_CIPHER_ALGO_NONE = 0x00, - DOT11_CIPHER_ALGO_WEP40 = 0x01, - DOT11_CIPHER_ALGO_TKIP = 0x02, - DOT11_CIPHER_ALGO_CCMP = 0x04, - DOT11_CIPHER_ALGO_WEP104 = 0x05, - DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100, - DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100, - DOT11_CIPHER_ALGO_WEP = 0x101, - DOT11_CIPHER_ALGO_IHV_START = 0x80000000, - DOT11_CIPHER_ALGO_IHV_END = 0xffffffff -}; - -struct WLAN_AVAILABLE_NETWORK { - WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]; - DOT11_SSID dot11Ssid; - DOT11_BSS_TYPE dot11BssType; - ULONG uNumberOfBssids; - BOOL bNetworkConnectable; - DWORD wlanNotConnectableReason; - ULONG uNumberOfPhyTypes; - DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER]; - BOOL bMorePhyTypes; - ULONG wlanSignalQuality; - BOOL bSecurityEnabled; - DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm; - DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm; - DWORD dwFlags; - DWORD dwReserved; -}; - -struct WLAN_AVAILABLE_NETWORK_LIST { - DWORD dwNumberOfItems; - DWORD dwIndex; - WLAN_AVAILABLE_NETWORK Network[1]; -}; - -enum WLAN_INTF_OPCODE { - wlan_intf_opcode_autoconf_start = 0x000000000, - wlan_intf_opcode_autoconf_enabled, - wlan_intf_opcode_background_scan_enabled, - wlan_intf_opcode_media_streaming_mode, - wlan_intf_opcode_radio_state, - wlan_intf_opcode_bss_type, - wlan_intf_opcode_interface_state, - wlan_intf_opcode_current_connection, - wlan_intf_opcode_channel_number, - wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs, - wlan_intf_opcode_supported_adhoc_auth_cipher_pairs, - wlan_intf_opcode_supported_country_or_region_string_list, - wlan_intf_opcode_current_operation_mode, - wlan_intf_opcode_supported_safe_mode, - wlan_intf_opcode_certified_safe_mode, - wlan_intf_opcode_autoconf_end = 0x0fffffff, - wlan_intf_opcode_msm_start = 0x10000100, - wlan_intf_opcode_statistics, - wlan_intf_opcode_rssi, - wlan_intf_opcode_msm_end = 0x1fffffff, - wlan_intf_opcode_security_start = 0x20010000, - wlan_intf_opcode_security_end = 0x2fffffff, - wlan_intf_opcode_ihv_start = 0x30000000, - wlan_intf_opcode_ihv_end = 0x3fffffff -}; - -enum WLAN_OPCODE_VALUE_TYPE { - wlan_opcode_value_type_query_only = 0, - wlan_opcode_value_type_set_by_group_policy, - wlan_opcode_value_type_set_by_user, - wlan_opcode_value_type_invalid -}; - -enum WLAN_CONNECTION_MODE { - wlan_connection_mode_profile = 0, - wlan_connection_mode_temporary_profile, - wlan_connection_mode_discovery_secure, - wlan_connection_mode_discovery_unsecure, - wlan_connection_mode_auto, - wlan_connection_mode_invalid -}; - -struct WLAN_CONNECTION_PARAMETERS { - WLAN_CONNECTION_MODE wlanConnectionMode; - LPCWSTR strProfile; - DOT11_SSID *pDot11Ssid; - DOT11_BSSID_LIST *pDesiredBssidList; - DOT11_BSS_TYPE dot11BssType; - DWORD dwFlags; -}; - -struct WLAN_RAW_DATA { - DWORD dwDataSize; - BYTE DataBlob[1]; -}; - -enum WLAN_NOTIFICATION_ACM { - wlan_notification_acm_start = 0, - wlan_notification_acm_autoconf_enabled, - wlan_notification_acm_autoconf_disabled, - wlan_notification_acm_background_scan_enabled, - wlan_notification_acm_background_scan_disabled, - wlan_notification_acm_bss_type_change, - wlan_notification_acm_power_setting_change, - wlan_notification_acm_scan_complete, - wlan_notification_acm_scan_fail, - wlan_notification_acm_connection_start, - wlan_notification_acm_connection_complete, - wlan_notification_acm_connection_attempt_fail, - wlan_notification_acm_filter_list_change, - wlan_notification_acm_interface_arrival, - wlan_notification_acm_interface_removal, - wlan_notification_acm_profile_change, - wlan_notification_acm_profile_name_change, - wlan_notification_acm_profiles_exhausted, - wlan_notification_acm_network_not_available, - wlan_notification_acm_network_available, - wlan_notification_acm_disconnecting, - wlan_notification_acm_disconnected, - wlan_notification_acm_adhoc_network_state_change, - wlan_notification_acm_end -}; - -struct WLAN_ASSOCIATION_ATTRIBUTES { - DOT11_SSID dot11Ssid; - DOT11_BSS_TYPE dot11BssType; - DOT11_MAC_ADDRESS dot11Bssid; - DOT11_PHY_TYPE dot11PhyType; - ULONG uDot11PhyIndex; - ULONG wlanSignalQuality; - ULONG ulRxRate; - ULONG ulTxRate; -}; - -struct WLAN_SECURITY_ATTRIBUTES { - BOOL bSecurityEnabled; - BOOL bOneXEnabled; - DOT11_AUTH_ALGORITHM dot11AuthAlgorithm; - DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm; -}; - -struct WLAN_CONNECTION_ATTRIBUTES { - WLAN_INTERFACE_STATE isState; - WLAN_CONNECTION_MODE wlanConnectionMode; - WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]; - WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes; - WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes; -}; - -typedef void (WINAPI *WLAN_NOTIFICATION_CALLBACK)(WLAN_NOTIFICATION_DATA *, PVOID); - -typedef DWORD (WINAPI *WlanOpenHandleProto) - (DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle); -typedef DWORD (WINAPI *WlanRegisterNotificationProto) - (HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate, - WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext, - PVOID pReserved, PDWORD pdwPrevNotifSource); -typedef DWORD (WINAPI *WlanEnumInterfacesProto) - (HANDLE hClientHandle, PVOID pReserved, WLAN_INTERFACE_INFO_LIST **ppInterfaceList); -typedef DWORD (WINAPI *WlanGetAvailableNetworkListProto) - (HANDLE hClientHandle, const GUID* pInterfaceGuid, DWORD dwFlags, PVOID pReserved, - WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList); -typedef DWORD (WINAPI *WlanQueryInterfaceProto) - (HANDLE hClientHandle, const GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved, - PDWORD pdwDataSize, PVOID *ppData, WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType); -typedef DWORD (WINAPI *WlanConnectProto) - (HANDLE hClientHandle, const GUID *pInterfaceGuid, - const WLAN_CONNECTION_PARAMETERS *pConnectionParameters, PVOID pReserved); -typedef DWORD (WINAPI *WlanDisconnectProto) - (HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved); -typedef DWORD (WINAPI *WlanScanProto) - (HANDLE hClientHandle, const GUID *pInterfaceGuid, const DOT11_SSID *pDot11Ssid, - const WLAN_RAW_DATA *pIeData, PVOID pReserved); -typedef VOID (WINAPI *WlanFreeMemoryProto)(PVOID pMemory); -typedef DWORD (WINAPI *WlanCloseHandleProto)(HANDLE hClientHandle, PVOID pReserved); - -static WlanOpenHandleProto local_WlanOpenHandle = 0; -static WlanRegisterNotificationProto local_WlanRegisterNotification = 0; -static WlanEnumInterfacesProto local_WlanEnumInterfaces = 0; -static WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList = 0; -static WlanQueryInterfaceProto local_WlanQueryInterface = 0; -static WlanConnectProto local_WlanConnect = 0; -static WlanDisconnectProto local_WlanDisconnect = 0; -static WlanScanProto local_WlanScan = 0; -static WlanFreeMemoryProto local_WlanFreeMemory = 0; -static WlanCloseHandleProto local_WlanCloseHandle = 0; - -static void resolveLibrary() -{ - static volatile bool triedResolve = false; - - if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle)); -#endif - - if (!triedResolve) { - local_WlanOpenHandle = (WlanOpenHandleProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle"); - local_WlanRegisterNotification = (WlanRegisterNotificationProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification"); - local_WlanEnumInterfaces = (WlanEnumInterfacesProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces"); - local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList"); - local_WlanQueryInterface = (WlanQueryInterfaceProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface"); - local_WlanConnect = (WlanConnectProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect"); - local_WlanDisconnect = (WlanDisconnectProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect"); - local_WlanScan = (WlanScanProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan"); - local_WlanFreeMemory = (WlanFreeMemoryProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory"); - local_WlanCloseHandle = (WlanCloseHandleProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle"); - - triedResolve = true; - } - } -} - -void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d) -{ - Q_UNUSED(d); - - switch (data->NotificationCode) { - case wlan_notification_acm_connection_complete: - case wlan_notification_acm_disconnected: - d->emitConfigurationsChanged(); - break; - default: - qDebug() << "wlan unknown notification"; - } -} - -QNativeWifiEngine::QNativeWifiEngine(QObject *parent) -: QNetworkSessionEngine(parent), handle(0) -{ - DWORD clientVersion; - - DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle); - if (result != ERROR_SUCCESS) { - if (result != ERROR_SERVICE_NOT_ACTIVE) - qWarning("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result); - - return; - } - - result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true, - WLAN_NOTIFICATION_CALLBACK(qNotificationCallback), - this, 0, 0); - if (result != ERROR_SUCCESS) - qWarning("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result); - - // On Windows XP SP2 and SP3 only connection and disconnection notifications are available. - // We need to poll for changes in available wireless networks. - connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged())); - pollTimer.setInterval(10000); -} - -QNativeWifiEngine::~QNativeWifiEngine() -{ - local_WlanCloseHandle(handle, 0); -} - -QList<QNetworkConfigurationPrivate *> QNativeWifiEngine::getConfigurations(bool *ok) -{ - if (ok) - *ok = false; - - QList<QNetworkConfigurationPrivate *> foundConfigurations; - - // enumerate interfaces - WLAN_INTERFACE_INFO_LIST *interfaceList; - DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); - return foundConfigurations; - } - - for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { - const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; - - WLAN_AVAILABLE_NETWORK_LIST *networkList; - result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, - 3, 0, &networkList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", - __FUNCTION__, result); - continue; - } - - QStringList seenNetworks; - - for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { - WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; - - QString networkName; - - if (network.strProfileName[0] != 0) { - networkName = QString::fromWCharArray(network.strProfileName); - } else { - networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), - network.dot11Ssid.uSSIDLength); - } - - // don't add duplicate networks - if (seenNetworks.contains(networkName)) - continue; - else - seenNetworks.append(networkName); - - QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate; - - cpPriv->isValid = true; - - cpPriv->name = networkName; - cpPriv->id = QString::number(qHash(QLatin1String("WLAN:") + cpPriv->name)); - - if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE)) - cpPriv->state = QNetworkConfiguration::Undefined; - - if (network.strProfileName[0] != 0) { - if (network.bNetworkConnectable) { - if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED) - cpPriv->state = QNetworkConfiguration::Active; - else - cpPriv->state = QNetworkConfiguration::Discovered; - } else { - cpPriv->state = QNetworkConfiguration::Defined; - } - } - - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->bearer = QLatin1String("WLAN"); - - - foundConfigurations.append(cpPriv); - } - - local_WlanFreeMemory(networkList); - } - - local_WlanFreeMemory(interfaceList); - - if (ok) - *ok = true; - - pollTimer.start(); - - return foundConfigurations; -} - -QString QNativeWifiEngine::getInterfaceFromId(const QString &id) -{ - // enumerate interfaces - WLAN_INTERFACE_INFO_LIST *interfaceList; - DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); - return QString(); - } - - for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { - const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; - - DWORD dataSize; - WLAN_CONNECTION_ATTRIBUTES *connectionAttributes; - result = local_WlanQueryInterface(handle, &interface.InterfaceGuid, - wlan_intf_opcode_current_connection, 0, &dataSize, - reinterpret_cast<PVOID *>(&connectionAttributes), 0); - if (result != ERROR_SUCCESS) { - if (result != ERROR_INVALID_STATE) - qWarning("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result); - - continue; - } - - if (qHash(QLatin1String("WLAN:") + - QString::fromWCharArray(connectionAttributes->strProfileName)) == id.toUInt()) { - QString guid("{%1-%2-%3-%4%5-%6%7%8%9%10%11}"); - - guid = guid.arg(interface.InterfaceGuid.Data1, 8, 16, QChar('0')); - guid = guid.arg(interface.InterfaceGuid.Data2, 4, 16, QChar('0')); - guid = guid.arg(interface.InterfaceGuid.Data3, 4, 16, QChar('0')); - for (int i = 0; i < 8; ++i) - guid = guid.arg(interface.InterfaceGuid.Data4[i], 2, 16, QChar('0')); - - local_WlanFreeMemory(connectionAttributes); - - return guid.toUpper(); - } - - local_WlanFreeMemory(connectionAttributes); - local_WlanFreeMemory(interfaceList); - } - - return QString(); -} - -bool QNativeWifiEngine::hasIdentifier(const QString &id) -{ - // enumerate interfaces - WLAN_INTERFACE_INFO_LIST *interfaceList; - DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); - return false; - } - - for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { - const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; - - WLAN_AVAILABLE_NETWORK_LIST *networkList; - result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, - 3, 0, &networkList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", - __FUNCTION__, result); - continue; - } - - for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { - WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; - - QString networkName; - - if (network.strProfileName[0] != 0) { - networkName = QString::fromWCharArray(network.strProfileName); - } else { - networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), - network.dot11Ssid.uSSIDLength); - } - - if (qHash(QLatin1String("WLAN:") + networkName) == id.toUInt()) { - local_WlanFreeMemory(networkList); - local_WlanFreeMemory(interfaceList); - return true; - } - } - - local_WlanFreeMemory(networkList); - } - - local_WlanFreeMemory(interfaceList); - - return false; -} - -/*QString QNativeWifiEngine::bearerName(const QString &) -{ - return QLatin1String("WLAN"); -}*/ - -void QNativeWifiEngine::connectToId(const QString &id) -{ - WLAN_INTERFACE_INFO_LIST *interfaceList; - DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); - emit connectionError(id, InterfaceLookupError); - return; - } - - QString profile; - - for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { - const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; - - WLAN_AVAILABLE_NETWORK_LIST *networkList; - result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, - 3, 0, &networkList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", - __FUNCTION__, result); - continue; - } - - for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { - WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; - - profile = QString::fromWCharArray(network.strProfileName); - - if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt()) - break; - else - profile.clear(); - } - - local_WlanFreeMemory(networkList); - - if (!profile.isEmpty()) { - WLAN_CONNECTION_PARAMETERS parameters; - parameters.wlanConnectionMode = wlan_connection_mode_profile; - parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16()); - parameters.pDot11Ssid = 0; - parameters.pDesiredBssidList = 0; - parameters.dot11BssType = dot11_BSS_type_any; - parameters.dwFlags = 0; - - DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, ¶meters, 0); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result); - emit connectionError(id, ConnectError); - break; - } - - break; - } - } - - local_WlanFreeMemory(interfaceList); - - if (profile.isEmpty()) - emit connectionError(id, InterfaceLookupError); -} - -void QNativeWifiEngine::disconnectFromId(const QString &id) -{ - QString interface = getInterfaceFromId(id); - - if (interface.isEmpty()) { - emit connectionError(id, InterfaceLookupError); - return; - } - - QStringList split = interface.mid(1, interface.length() - 2).split('-'); - - GUID guid; - guid.Data1 = split.at(0).toUInt(0, 16); - guid.Data2 = split.at(1).toUShort(0, 16); - guid.Data3 = split.at(2).toUShort(0, 16); - guid.Data4[0] = split.at(3).left(2).toUShort(0, 16); - guid.Data4[1] = split.at(3).right(2).toUShort(0, 16); - for (int i = 0; i < 6; ++i) - guid.Data4[i + 2] = split.at(4).mid(i*2, 2).toUShort(0, 16); - - DWORD result = local_WlanDisconnect(handle, &guid, 0); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result); - emit connectionError(id, DisconnectionError); - return; - } -} - -void QNativeWifiEngine::requestUpdate() -{ - // enumerate interfaces - WLAN_INTERFACE_INFO_LIST *interfaceList; - DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); - if (result != ERROR_SUCCESS) { - qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); - return; - } - - for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { - result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0); - if (result != ERROR_SUCCESS) - qWarning("%s: WlanScan failed with error %ld\n", __FUNCTION__, result); - } -} - -QNativeWifiEngine *QNativeWifiEngine::instance() -{ - resolveLibrary(); - - // native wifi dll not available - if (!local_WlanOpenHandle) - return 0; - - QNativeWifiEngine *engine = nativeWifiEngine(); - - // could not initialise subsystem - if (engine && engine->handle == 0) - return 0; - - return engine; -} - -#include "moc_qnativewifiengine_win_p.cpp" - -QTM_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 264f0df..6b73e3c 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -45,12 +45,22 @@ #include "qnetworkconfigmanager_s60_p.h" #else #include "qnetworkconfigmanager_p.h" +#include "qnetworksessionengine_p.h" #endif -QTM_BEGIN_NAMESPACE +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager); +#ifndef Q_OS_SYMBIAN +QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() +{ + return connManager(); +} +#endif + /*! \class QNetworkConfigurationManager @@ -227,28 +237,31 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe { QList<QNetworkConfiguration> result; QNetworkConfigurationManagerPrivate* conPriv = connManager(); - QList<QString> cpsIdents = conPriv->accessPointConfigurations.keys(); - - //find all InternetAccessPoints - foreach( QString ii, cpsIdents) { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p = - conPriv->accessPointConfigurations.value(ii); - if ( (p->state & filter) == filter ) { - QNetworkConfiguration pt; - pt.d = conPriv->accessPointConfigurations.value(ii); - result << pt; + + foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) { + QStringList cpsIdents = engine->accessPointConfigurations.keys(); + + //find all InternetAccessPoints + foreach (const QString &ii, cpsIdents) { + QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p = + engine->accessPointConfigurations.value(ii); + if ((p->state & filter) == filter) { + QNetworkConfiguration pt; + pt.d = engine->accessPointConfigurations.value(ii); + result << pt; + } } - } - //find all service networks - cpsIdents = conPriv->snapConfigurations.keys(); - foreach( QString ii, cpsIdents) { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p = - conPriv->snapConfigurations.value(ii); - if ( (p->state & filter) == filter ) { - QNetworkConfiguration pt; - pt.d = conPriv->snapConfigurations.value(ii); - result << pt; + //find all service networks + cpsIdents = engine->snapConfigurations.keys(); + foreach (const QString &ii, cpsIdents) { + QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p = + engine->snapConfigurations.value(ii); + if ((p->state & filter) == filter) { + QNetworkConfiguration pt; + pt.d = engine->snapConfigurations.value(ii); + result << pt; + } } } @@ -264,15 +277,23 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString& identifier) const { QNetworkConfigurationManagerPrivate* conPriv = connManager(); + QNetworkConfiguration item; - if (conPriv->accessPointConfigurations.contains(identifier)) - item.d = conPriv->accessPointConfigurations.value(identifier); - else if (conPriv->snapConfigurations.contains(identifier)) - item.d = conPriv->snapConfigurations.value(identifier); - else if (conPriv->userChoiceConfigurations.contains(identifier)) - item.d = conPriv->userChoiceConfigurations.value(identifier); - return item; + foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) { + if (engine->accessPointConfigurations.contains(identifier)) + item.d = engine->accessPointConfigurations.value(identifier); + else if (engine->snapConfigurations.contains(identifier)) + item.d = engine->snapConfigurations.value(identifier); + else if (engine->userChoiceConfigurations.contains(identifier)) + item.d = engine->userChoiceConfigurations.value(identifier); + else + continue; + + return item; + } + + return item; } /*! @@ -329,5 +350,5 @@ void QNetworkConfigurationManager::updateConfigurations() #include "moc_qnetworkconfigmanager.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h index 98641f6..b7ab72b 100644 --- a/src/network/bearer/qnetworkconfigmanager.h +++ b/src/network/bearer/qnetworkconfigmanager.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,17 +42,15 @@ #ifndef QNETWORKCONFIGURATIONMANAGER_H #define QNETWORKCONFIGURATIONMANAGER_H -#include "qmobilityglobal.h" - #include <QtCore/qobject.h> #include "qnetworkconfiguration.h" QT_BEGIN_HEADER -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationManagerPrivate; -class Q_BEARER_EXPORT QNetworkConfigurationManager : public QObject +class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject { Q_OBJECT @@ -93,7 +91,7 @@ Q_SIGNALS: Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities) -QTM_END_NAMESPACE +QT_END_NAMESPACE QT_END_HEADER diff --git a/src/network/bearer/qnetworkconfigmanager_maemo.cpp b/src/network/bearer/qnetworkconfigmanager_maemo.cpp index 795b054..2188d61 100644 --- a/src/network/bearer/qnetworkconfigmanager_maemo.cpp +++ b/src/network/bearer/qnetworkconfigmanager_maemo.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,7 +53,7 @@ #include <iapconf.h> #include <iapmonitor.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE #define IAP "/system/osso/connectivity/IAP" static int iap_prefix_len; @@ -757,4 +757,4 @@ void QNetworkConfigurationManagerPrivate::configChanged(QNetworkConfigurationPri #include "qnetworkconfigmanager_maemo.moc" #include "moc_qnetworkconfigmanager_maemo_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager_maemo_p.h b/src/network/bearer/qnetworkconfigmanager_maemo_p.h index e182495..5cc99c2 100644 --- a/src/network/bearer/qnetworkconfigmanager_maemo_p.h +++ b/src/network/bearer/qnetworkconfigmanager_maemo_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -60,7 +60,7 @@ #include <QHash> #include <QStringList> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationManagerPrivate : public QObject @@ -136,6 +136,6 @@ Q_SIGNALS: void onlineStateChanged(bool isOnline); }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 39426d0..cb83789 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -40,73 +40,48 @@ ****************************************************************************/ #include "qnetworkconfigmanager_p.h" -#include "qgenericengine_p.h" +#include "qbearerplugin.h" -#ifdef Q_OS_WIN -#include "qnlaengine_win_p.h" -#endif -#ifdef Q_OS_WIN32 -#include "qnativewifiengine_win_p.h" -#endif -#if defined(BACKEND_NM) -#include "qnmwifiengine_unix_p.h" -#endif -#ifdef Q_OS_DARWIN -#include "qcorewlanengine_mac_p.h" -#endif +#include <QtCore/private/qfactoryloader_p.h> #include <QtCore/qdebug.h> #include <QtCore/qtimer.h> #include <QtCore/qstringlist.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QBearerEngineFactoryInterface_iid, QLatin1String("/bearer"))) + +QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() +{ + while (!sessionEngines.isEmpty()) + delete sessionEngines.takeFirst(); +} void QNetworkConfigurationManagerPrivate::registerPlatformCapabilities() { capFlags = QNetworkConfigurationManager::ForcedRoaming; } -void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivate *cpPriv, QNetworkSessionEngine *engine) +void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr) { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(new QNetworkConfigurationPrivate); - - ptr.data()->isValid = cpPriv->isValid; - ptr.data()->name = cpPriv->name; - ptr.data()->id = cpPriv->id; - ptr.data()->state = cpPriv->state; - ptr.data()->type = cpPriv->type; - ptr.data()->roamingSupported = cpPriv->roamingSupported; - ptr.data()->purpose = cpPriv->purpose; - ptr.data()->internet = cpPriv->internet; - ptr.data()->bearer = cpPriv->bearer; - - accessPointConfigurations.insert(cpPriv->id, ptr); - configurationEngine.insert(cpPriv->id, engine); - if (!firstUpdate) { QNetworkConfiguration item; item.d = ptr; emit configurationAdded(item); } - if (ptr.data()->state == QNetworkConfiguration::Active) { - ++onlineConfigurations; - if (!firstUpdate && onlineConfigurations == 1) + if (ptr->state == QNetworkConfiguration::Active) { + onlineConfigurations.insert(ptr); + if (!firstUpdate && onlineConfigurations.count() == 1) emit onlineStateChanged(true); } } -void QNetworkConfigurationManagerPrivate::configurationRemoved(const QString &id) +void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigurationPrivatePointer ptr) { - if (!accessPointConfigurations.contains(id)) - return; - - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = - accessPointConfigurations.take(id); - - configurationEngine.remove(id); - - ptr.data()->isValid = false; + ptr->isValid = false; if (!firstUpdate) { QNetworkConfiguration item; @@ -114,66 +89,36 @@ void QNetworkConfigurationManagerPrivate::configurationRemoved(const QString &id emit configurationRemoved(item); } - if (ptr.data()->state == QNetworkConfiguration::Active) { - --onlineConfigurations; - if (!firstUpdate && onlineConfigurations == 0) - emit onlineStateChanged(false); - } + onlineConfigurations.remove(ptr); + if (!firstUpdate && onlineConfigurations.isEmpty()) + emit onlineStateChanged(false); } -void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivate *cpPriv) +void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivatePointer ptr) { - if (!accessPointConfigurations.contains(cpPriv->id)) - return; + if (!firstUpdate) { + QNetworkConfiguration item; + item.d = ptr; + emit configurationChanged(item); + } - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = - accessPointConfigurations.value(cpPriv->id); - - if (ptr.data()->isValid != cpPriv->isValid || - ptr.data()->name != cpPriv->name || - ptr.data()->id != cpPriv->id || - ptr.data()->state != cpPriv->state || - ptr.data()->type != cpPriv->type || - ptr.data()->roamingSupported != cpPriv->roamingSupported || - ptr.data()->purpose != cpPriv->purpose || - ptr.data()->bearer != cpPriv->bearer || - ptr.data()->internet != cpPriv->internet) { - - const QNetworkConfiguration::StateFlags oldState = ptr.data()->state; - - ptr.data()->isValid = cpPriv->isValid; - ptr.data()->name = cpPriv->name; - ptr.data()->id = cpPriv->id; - ptr.data()->state = cpPriv->state; - ptr.data()->type = cpPriv->type; - ptr.data()->roamingSupported = cpPriv->roamingSupported; - ptr.data()->purpose = cpPriv->purpose; - ptr.data()->internet = cpPriv->internet; - ptr.data()->bearer = cpPriv->bearer; + bool previous = !onlineConfigurations.isEmpty(); - if (!firstUpdate) { - QNetworkConfiguration item; - item.d = ptr; - emit configurationChanged(item); - } + if (ptr->state == QNetworkConfiguration::Active) + onlineConfigurations.insert(ptr); + else + onlineConfigurations.remove(ptr); - if (ptr.data()->state == QNetworkConfiguration::Active && oldState != ptr.data()->state) { - // configuration went online - ++onlineConfigurations; - if (!firstUpdate && onlineConfigurations == 1) - emit onlineStateChanged(true); - } else if (ptr.data()->state != QNetworkConfiguration::Active && oldState == QNetworkConfiguration::Active) { - // configuration went offline - --onlineConfigurations; - if (!firstUpdate && onlineConfigurations == 0) - emit onlineStateChanged(false); - } - } + bool online = !onlineConfigurations.isEmpty(); + + if (!firstUpdate && online != previous) + emit onlineStateChanged(online); } void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration() { - if (!snapConfigurations.contains(QLatin1String("Internet Service Network"))) { +#if 0 + if (!generic->snapConfigurations.contains(QLatin1String("Internet Service Network"))) { QNetworkConfigurationPrivate *serviceNetwork = new QNetworkConfigurationPrivate; serviceNetwork->name = tr("Internet"); serviceNetwork->isValid = true; @@ -183,7 +128,7 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration() QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(serviceNetwork); - snapConfigurations.insert(serviceNetwork->id, ptr); + generic->snapConfigurations.insert(serviceNetwork->id, ptr); if (!firstUpdate) { QNetworkConfiguration item; @@ -193,15 +138,15 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration() } QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = - snapConfigurations.value(QLatin1String("Internet Service Network")); + generic->snapConfigurations.value(QLatin1String("Internet Service Network")); QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers; QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i = - accessPointConfigurations.constBegin(); + generic->accessPointConfigurations.constBegin(); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; - while (i != accessPointConfigurations.constEnd()) { + while (i != generic->accessPointConfigurations.constEnd()) { QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> child = i.value(); if (child.data()->internet && ((child.data()->state & QNetworkConfiguration::Defined) @@ -223,148 +168,128 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration() item.d = ptr; emit configurationChanged(item); } +#endif } void QNetworkConfigurationManagerPrivate::updateConfigurations() { if (firstUpdate) { - updateState = NotUpdating; - onlineConfigurations = 0; - -#if defined (Q_OS_DARWIN) - coreWifi = QCoreWlanEngine::instance(); - if (coreWifi) { - connect(coreWifi, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); - } -#else -#if defined(BACKEND_NM) - nmWifi = QNmWifiEngine::instance(); - if (nmWifi) { - connect(nmWifi, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); - } else { -#endif - generic = QGenericEngine::instance(); - if (generic) { - connect(generic, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); + updating = false; + + QFactoryLoader *l = loader(); + QStringList keys = l->keys(); + + if (keys.contains(QLatin1String("corewlan"))) { + QBearerEnginePlugin *coreWlanPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("corewlan"))); + if (coreWlanPlugin) { + QNetworkSessionEngine *coreWifi = coreWlanPlugin->create(QLatin1String("corewlan")); + if (coreWifi) { + sessionEngines.append(coreWifi); + connect(coreWifi, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(coreWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(coreWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(coreWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + } } -#if defined(BACKEND_NM) } -#endif -#endif -#ifdef Q_OS_WIN - nla = QNlaEngine::instance(); - if (nla) { - connect(nla, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); + if (keys.contains(QLatin1String("networkmanager"))) { + QBearerEnginePlugin *nmPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("networkmanager"))); + if (nmPlugin) { + QNetworkSessionEngine *nmWifi = nmPlugin->create(QLatin1String("networkmanager")); + if (nmWifi) { + sessionEngines.append(nmWifi); + connect(nmWifi, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(nmWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(nmWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(nmWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + } } -#endif - -#ifdef Q_OS_WIN32 - nativeWifi = QNativeWifiEngine::instance(); - if (nativeWifi) { - connect(nativeWifi, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); + } - capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces; + if (keys.contains(QLatin1String("generic"))) { + QBearerEnginePlugin *genericPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("generic"))); + if (genericPlugin) { + QNetworkSessionEngine *generic = genericPlugin->create(QLatin1String("generic")); + if (generic) { + sessionEngines.append(generic); + connect(generic, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(generic, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(generic, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(generic, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + } } -#endif - } - - QNetworkSessionEngine *engine = qobject_cast<QNetworkSessionEngine *>(sender()); - if (updateState & Updating && engine) { -#if defined (Q_OS_DARWIN) - if (engine == coreWifi) - updateState &= ~CoreWifiUpdating; -#else -#if defined(BACKEND_NM) - if (engine == nmWifi) - updateState &= ~NmUpdating; - else if (engine == generic) - updateState &= ~GenericUpdating; -#else - if (engine == generic) - updateState &= ~GenericUpdating; -#endif -#endif - -#ifdef Q_OS_WIN - else if (engine == nla) - updateState &= ~NlaUpdating; -#ifdef Q_OS_WIN32 - else if (engine == nativeWifi) - updateState &= ~NativeWifiUpdating; -#endif -#endif - } - QList<QNetworkSessionEngine *> engines; - if (firstUpdate) { -#if defined (Q_OS_DARWIN) - if (coreWifi) - engines << coreWifi; -#else -#if defined(BACKEND_NM) - if (nmWifi) - engines << nmWifi; - else if (generic) - engines << generic; -#else - if (generic) - engines << generic; -#endif -#endif - -#ifdef Q_OS_WIN - if (nla) - engines << nla; -#ifdef Q_OS_WIN32 - if (nativeWifi) - engines << nativeWifi; -#endif -#endif - } else if (engine) { - engines << engine; - } - - while (!engines.isEmpty()) { - engine = engines.takeFirst(); - - bool ok; - QList<QNetworkConfigurationPrivate *> foundConfigurations = engine->getConfigurations(&ok); - - // Find removed configurations. - QList<QString> removedIdentifiers = configurationEngine.keys(); - for (int i = 0; i < foundConfigurations.count(); ++i) - removedIdentifiers.removeOne(foundConfigurations.at(i)->id); - - // Update or add configurations. - while (!foundConfigurations.isEmpty()) { - QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst(); - - if (accessPointConfigurations.contains(cpPriv->id)) - configurationChanged(cpPriv); - else - configurationAdded(cpPriv, engine); - - delete cpPriv; } - // Remove configurations. - while (!removedIdentifiers.isEmpty()) { - const QString id = removedIdentifiers.takeFirst(); + if (keys.contains(QLatin1String("nla"))) { + QBearerEnginePlugin *nlaPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nla"))); + if (nlaPlugin) { + QNetworkSessionEngine *nla = nlaPlugin->create(QLatin1String("nla")); + if (nla) { + sessionEngines.append(nla); + connect(nla, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(nla, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(nla, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(nla, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + } + } + } - if (configurationEngine.value(id) == engine) - configurationRemoved(id); + if (keys.contains(QLatin1String("nativewifi"))) { + QBearerEnginePlugin *nativeWifiPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nativewifi"))); + if (nativeWifiPlugin) { + QNetworkSessionEngine *nativeWifi = + nativeWifiPlugin->create(QLatin1String("nativewifi")); + if (nativeWifi) { + sessionEngines.append(nativeWifi); + connect(nativeWifi, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(nativeWifi, + SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(nativeWifi, + SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(nativeWifi, + SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + + capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces; + } + } } } - updateInternetServiceConfiguration(); + QNetworkSessionEngine *engine = qobject_cast<QNetworkSessionEngine *>(sender()); + if (!updatingEngines.isEmpty() && engine) { + int index = sessionEngines.indexOf(engine); + if (index >= 0) + updatingEngines.remove(index); + } - if (updateState == Updating) { - updateState = NotUpdating; + if (updating && updatingEngines.isEmpty()) { + updating = false; emit configurationUpdateComplete(); } @@ -380,22 +305,25 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() */ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> firstActive; - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> firstDiscovered; + QNetworkConfigurationPrivatePointer firstActive; + QNetworkConfigurationPrivatePointer firstDiscovered; - QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i = - accessPointConfigurations.constBegin(); - while (i != accessPointConfigurations.constEnd()) { - QNetworkConfigurationPrivate *priv = i.value().data(); + foreach (QNetworkSessionEngine *engine, sessionEngines) { + QHash<QString, QNetworkConfigurationPrivatePointer>::const_iterator i = + engine->accessPointConfigurations.constBegin(); - if (!firstActive && priv->isValid && - (priv->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) - firstActive = i.value(); - if (!firstDiscovered && priv->isValid && - (priv->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) - firstDiscovered = i.value(); + while (i != engine->accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer priv = i.value(); - ++i; + if (!firstActive && priv->isValid && + (priv->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) + firstActive = priv; + if (!firstDiscovered && priv->isValid && + (priv->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) + firstDiscovered = priv; + + ++i; + } } QNetworkConfiguration item; @@ -410,44 +338,12 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() { - updateState = Updating; -#if defined (Q_OS_DARWIN) - if (coreWifi) { - updateState |= CoreWifiUpdating; - coreWifi->requestUpdate(); - } -#else -#if defined(BACKEND_NM) - if (nmWifi) { - updateState |= NmUpdating; - nmWifi->requestUpdate(); - } else if (generic) { - updateState |= GenericUpdating; - generic->requestUpdate(); - } -#else - if (generic) { - updateState |= GenericUpdating; - generic->requestUpdate(); - } -#endif -#endif -#ifdef Q_OS_WIN - if (nla) { - updateState |= NlaUpdating; - nla->requestUpdate(); - } -#endif + updating = true; -#ifdef Q_OS_WIN32 - if (nativeWifi) { - updateState |= NativeWifiUpdating; - nativeWifi->requestUpdate(); + for (int i = 0; i < sessionEngines.count(); ++i) { + updatingEngines.insert(i); + sessionEngines.at(i)->requestUpdate(); } -#endif } -#include "moc_qnetworkconfigmanager_p.cpp" - -QTM_END_NAMESPACE - +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 0c42f9b..a45d534 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -56,20 +56,9 @@ #include "qnetworkconfigmanager.h" #include "qnetworkconfiguration_p.h" -#include <QHash> -#include <QStringList> +QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE - -#ifdef BEARER_ENGINE class QNetworkSessionEngine; -class QGenericEngine; -class QNlaEngine; -class QNativeWifiEngine; -class QNmWifiEngine; -class QCoreWlanEngine; -#endif - class QNetworkConfigurationManagerPrivate : public QObject { @@ -82,22 +71,7 @@ public: updateConfigurations(); } - virtual ~QNetworkConfigurationManagerPrivate() - { - QList<QString> configIdents = snapConfigurations.keys(); - foreach(const QString oldIface, configIdents) { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = snapConfigurations.take(oldIface); - priv->isValid = false; - priv->id.clear(); - } - - configIdents = accessPointConfigurations.keys(); - foreach(const QString oldIface, configIdents) { - QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.take(oldIface); - priv->isValid = false; - priv->id.clear(); - } - } + virtual ~QNetworkConfigurationManagerPrivate(); QNetworkConfiguration defaultConfiguration(); @@ -106,15 +80,6 @@ public: void performAsyncConfigurationUpdate(); - //this table contains an up to date list of all configs at any time. - //it must be updated if configurations change, are added/removed or - //the members of ServiceNetworks change - QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > accessPointConfigurations; - QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > snapConfigurations; - QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > userChoiceConfigurations; -#ifdef BEARER_ENGINE - QHash<QString, QNetworkSessionEngine *> configurationEngine; -#endif bool firstUpdate; public slots: @@ -128,51 +93,27 @@ Q_SIGNALS: void onlineStateChanged(bool isOnline); private: -#ifdef BEARER_ENGINE void updateInternetServiceConfiguration(); void abort(); -#endif - -#ifdef BEARER_ENGINE - QGenericEngine *generic; -#ifdef Q_OS_WIN - QNlaEngine *nla; -#ifndef Q_OS_WINCE - QNativeWifiEngine *nativeWifi; -#endif -#endif -#ifdef BACKEND_NM - QNmWifiEngine *nmWifi; -#endif -#ifdef Q_OS_DARWIN - QCoreWlanEngine *coreWifi; -#endif - - uint onlineConfigurations; - - enum EngineUpdate { - NotUpdating = 0x00, - Updating = 0x01, - GenericUpdating = 0x02, - NlaUpdating = 0x04, - NativeWifiUpdating = 0x08, - NmUpdating = 0x20, - CoreWifiUpdating = 0x40, - }; - Q_DECLARE_FLAGS(EngineUpdateState, EngineUpdate) - - EngineUpdateState updateState; -#endif + +public: + QList<QNetworkSessionEngine *> sessionEngines; + +private: + QSet<QNetworkConfigurationPrivatePointer> onlineConfigurations; + + bool updating; + QSet<int> updatingEngines; private Q_SLOTS: -#ifdef BEARER_ENGINE - void configurationAdded(QNetworkConfigurationPrivate *cpPriv, QNetworkSessionEngine *engine); - void configurationRemoved(const QString &id); - void configurationChanged(QNetworkConfigurationPrivate *cpPriv); -#endif + void configurationAdded(QNetworkConfigurationPrivatePointer ptr); + void configurationRemoved(QNetworkConfigurationPrivatePointer ptr); + void configurationChanged(QNetworkConfigurationPrivatePointer ptr); }; -QTM_END_NAMESPACE +QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate(); + +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp b/src/network/bearer/qnetworkconfigmanager_s60_p.cpp index 760a194..b5bd4d2 100644 --- a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_s60_p.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -58,7 +58,7 @@ #include <aputils.h> #endif -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE static const int KValueThatWillBeAddedToSNAPId = 1000; static const int KUserChoiceIAPId = 0; @@ -971,4 +971,4 @@ void AccessPointsAvailabilityScanner::RunL() } } #include "moc_qnetworkconfigmanager_s60_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.h b/src/network/bearer/qnetworkconfigmanager_s60_p.h index 679fa6c..568803d 100644 --- a/src/network/bearer/qnetworkconfigmanager_s60_p.h +++ b/src/network/bearer/qnetworkconfigmanager_s60_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE class QTimer; QT_END_NAMESPACE -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkSessionPrivate; class AccessPointsAvailabilityScanner; @@ -180,6 +180,6 @@ private: // Data TConnMonIapInfoBuf iIapBuf; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index 56907c3..e1b2828 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -47,7 +47,7 @@ #include "qnetworkconfiguration_p.h" #endif -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE /*! \class QNetworkConfiguration @@ -395,5 +395,5 @@ QString QNetworkConfiguration::bearerName() const } -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index 860be4b..dede2b1 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,18 +42,17 @@ #ifndef QNETWORKCONFIGURATION_H #define QNETWORKCONFIGURATION_H -#include "qmobilityglobal.h" - +#include <QtCore/qglobal.h> #include <QtCore/qshareddata.h> #include <QtCore/qstring.h> #include <QtCore/qlist.h> QT_BEGIN_HEADER -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; -class Q_BEARER_EXPORT QNetworkConfiguration +class Q_NETWORK_EXPORT QNetworkConfiguration { public: QNetworkConfiguration(); @@ -107,7 +106,7 @@ private: QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE QT_END_HEADER diff --git a/src/network/bearer/qnetworkconfiguration_maemo_p.h b/src/network/bearer/qnetworkconfiguration_maemo_p.h index 2597605..3b43312 100644 --- a/src/network/bearer/qnetworkconfiguration_maemo_p.h +++ b/src/network/bearer/qnetworkconfiguration_maemo_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -57,7 +57,7 @@ #include <QtCore/qshareddata.h> #include <QNetworkInterface> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate : public QSharedData { @@ -117,6 +117,6 @@ private: QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other); }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONPRIVATE_H diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index c2834e6..68d6ba4 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -55,20 +55,18 @@ #include "qnetworkconfiguration.h" #include <QtCore/qshareddata.h> -#include <QNetworkInterface> +#include <QtNetwork/QNetworkInterface> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE +typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationPrivatePointer; class QNetworkConfigurationPrivate : public QSharedData { public: QNetworkConfigurationPrivate () - : isValid(false), type(QNetworkConfiguration::Invalid), - roamingSupported(false), purpose(QNetworkConfiguration::UnknownPurpose) + : isValid(false), type(QNetworkConfiguration::Invalid), + roamingSupported(false), purpose(QNetworkConfiguration::UnknownPurpose), internet(false) { -#ifdef BEARER_ENGINE - internet = false; -#endif } ~QNetworkConfigurationPrivate() @@ -91,11 +89,9 @@ public: bool roamingSupported; QNetworkConfiguration::Purpose purpose; -#ifdef BEARER_ENGINE bool internet; -#endif - QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers; + QList<QNetworkConfigurationPrivatePointer> serviceNetworkMembers; QNetworkInterface serviceInterface; private: @@ -105,6 +101,6 @@ private: QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other); }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONPRIVATE_H diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.cpp b/src/network/bearer/qnetworkconfiguration_s60_p.cpp index 02115d9..3064840 100644 --- a/src/network/bearer/qnetworkconfiguration_s60_p.cpp +++ b/src/network/bearer/qnetworkconfiguration_s60_p.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -41,7 +41,7 @@ #include "qnetworkconfiguration_s60_p.h" -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE QNetworkConfigurationPrivate::QNetworkConfigurationPrivate() : isValid(false), type(QNetworkConfiguration::Invalid), @@ -73,4 +73,4 @@ QString QNetworkConfigurationPrivate::bearerName() const } -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.h b/src/network/bearer/qnetworkconfiguration_s60_p.h index 6c87200..0973152 100644 --- a/src/network/bearer/qnetworkconfiguration_s60_p.h +++ b/src/network/bearer/qnetworkconfiguration_s60_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -56,7 +56,7 @@ #include <qnetworkconfiguration.h> #include <QtCore/qshareddata.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate : public QSharedData { @@ -103,7 +103,7 @@ private: QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other); }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKCONFIGURATIONPRIVATE_H diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 6171350..74b9787 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -52,7 +52,7 @@ #include "qnetworksession_p.h" #endif -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE /*! \class QNetworkSession @@ -525,14 +525,14 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const if (!d->publicConfig.isValid()) return QVariant(); - if (key == "ActiveConfiguration") { + if (key == QLatin1String("ActiveConfiguration")) { if (!d->isOpen) return QString(); else return d->activeConfig.identifier(); } - if (key == "UserChoiceConfiguration") { + if (key == QLatin1String("UserChoiceConfiguration")) { if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice) return QString(); @@ -555,9 +555,10 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const */ void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value) { - if (key == "ActiveConfiguration" - || key == "UserChoiceConfiguration") + if (key == QLatin1String("ActiveConfiguration") || + key == QLatin1String("UserChoiceConfiguration")) { return; + } d->setSessionProperty(key, value); } @@ -700,4 +701,4 @@ void QNetworkSession::disconnectNotify(const char *signal) #include "moc_qnetworksession.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h index 7e52674..6138166 100644 --- a/src/network/bearer/qnetworksession.h +++ b/src/network/bearer/qnetworksession.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,8 +42,6 @@ #ifndef QNETWORKSESSION_H #define QNETWORKSESSION_H -#include "qmobilityglobal.h" - #include <QtCore/qobject.h> #include <QtCore/qshareddata.h> #include <QtCore/qstring.h> @@ -54,10 +52,10 @@ QT_BEGIN_HEADER -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkSessionPrivate; -class Q_BEARER_EXPORT QNetworkSession : public QObject +class Q_NETWORK_EXPORT QNetworkSession : public QObject { Q_OBJECT public: @@ -127,7 +125,7 @@ private: friend class QNetworkSessionPrivate; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE QT_END_HEADER diff --git a/src/network/bearer/qnetworksession_maemo.cpp b/src/network/bearer/qnetworksession_maemo.cpp index b3afc77..6fb4453 100644 --- a/src/network/bearer/qnetworksession_maemo.cpp +++ b/src/network/bearer/qnetworksession_maemo.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -54,7 +54,7 @@ #include <netinet/in.h> #include <arpa/inet.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE static QHash<QString, QVariant> properties; @@ -1161,4 +1161,4 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const #include "qnetworksession_maemo.moc" #include "moc_qnetworksession_maemo_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession_maemo_p.h b/src/network/bearer/qnetworksession_maemo_p.h index 892262d..6febce4 100644 --- a/src/network/bearer/qnetworksession_maemo_p.h +++ b/src/network/bearer/qnetworksession_maemo_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -62,7 +62,7 @@ #include <icd/dbus_api.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkSessionPrivate : public QObject { @@ -159,7 +159,7 @@ private: void cleanupSession(void); }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKSESSIONPRIVATE_H diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp index 1dfc949..b615797 100644 --- a/src/network/bearer/qnetworksession_p.cpp +++ b/src/network/bearer/qnetworksession_p.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,73 +42,24 @@ #include "qnetworksession_p.h" #include "qnetworksession.h" #include "qnetworksessionengine_p.h" -#include "qgenericengine_p.h" +#include "qnetworkconfigmanager_p.h" -#ifdef Q_OS_WIN -#include "qnlaengine_win_p.h" -#endif -#ifdef Q_OS_WIN32 -#include "qnativewifiengine_win_p.h" -#endif -#ifdef Q_OS_DARWIN -#include "qcorewlanengine_mac_p.h" -#endif #include <QtCore/qstringlist.h> #include <QtCore/qdebug.h> #include <QtCore/qmutex.h> #include <QtNetwork/qnetworkinterface.h> -#if defined(BACKEND_NM) -#include "qnmwifiengine_unix_p.h" -#endif - -QTM_BEGIN_NAMESPACE - -#if defined(BACKEND_NM) -static bool NetworkManagerAvailable() -{ - QDBusConnection dbusConnection = QDBusConnection::systemBus(); - if (dbusConnection.isConnected()) { - QDBusConnectionInterface *dbiface = dbusConnection.interface(); - QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager"); - if (reply.isValid()) - return reply.value(); - } - return false; -} -#endif +QT_BEGIN_NAMESPACE static QNetworkSessionEngine *getEngineFromId(const QString &id) { -#ifdef Q_OS_WIN - QNlaEngine *nla = QNlaEngine::instance(); - if (nla && nla->hasIdentifier(id)) - return nla; -#endif + QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate(); -#ifdef Q_OS_WIN32 - QNativeWifiEngine *nativeWifi = QNativeWifiEngine::instance(); - if (nativeWifi && nativeWifi->hasIdentifier(id)) - return nativeWifi; -#endif - -#if defined(BACKEND_NM) - if(NetworkManagerAvailable()) { - QNmWifiEngine *nmwiifi = QNmWifiEngine::instance(); - if (nmwiifi && nmwiifi->hasIdentifier(id)) - return nmwiifi; + foreach (QNetworkSessionEngine *engine, priv->sessionEngines) { + if (engine->hasIdentifier(id)) + return engine; } -#endif -#ifdef Q_OS_DARWIN - QCoreWlanEngine *coreWifi = QCoreWlanEngine::instance(); - if (coreWifi && coreWifi->hasIdentifier(id)) - return coreWifi; - -#endif - QGenericEngine *generic = QGenericEngine::instance(); - if (generic && generic->hasIdentifier(id)) - return generic; return 0; } @@ -154,6 +105,7 @@ void QNetworkSessionPrivate::syncStateWithInterface() this, SLOT(forcedSessionClose(QNetworkConfiguration))); opened = false; + isOpen = false; state = QNetworkSession::Invalid; lastError = QNetworkSession::UnknownSessionError; @@ -320,7 +272,7 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const quint64 QNetworkSessionPrivate::bytesWritten() const { -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) { if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { foreach (const QNetworkConfiguration &config, publicConfig.children()) { @@ -338,7 +290,7 @@ quint64 QNetworkSessionPrivate::bytesWritten() const quint64 QNetworkSessionPrivate::bytesReceived() const { -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) { if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { foreach (const QNetworkConfiguration &config, publicConfig.children()) { @@ -391,6 +343,7 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork() } state = QNetworkSession::Connected; + qDebug() << oldState << "->" << state; if (state != oldState) emit q->stateChanged(state); @@ -402,31 +355,22 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork() else state = QNetworkSession::Disconnected; + qDebug() << oldState << "->" << state; if (state != oldState) emit q->stateChanged(state); } void QNetworkSessionPrivate::updateStateFromActiveConfig() { - QNetworkSession::State oldState = state; + if (!engine) + return; - bool newActive = false; + QNetworkSession::State oldState = state; - if (!activeConfig.isValid()) { - state = QNetworkSession::Invalid; - } else if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - state = QNetworkSession::Connected; - newActive = opened; - } else if ((activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { - state = QNetworkSession::Disconnected; - } else if ((activeConfig.state() & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { - state = QNetworkSession::NotAvailable; - } else if ((activeConfig.state() & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined) { - state = QNetworkSession::NotAvailable; - } + state = engine->sessionStateForId(activeConfig.identifier()); bool oldActive = isOpen; - isOpen = newActive; + isOpen = (state == QNetworkSession::Connected) ? opened : false; if (!oldActive && isOpen) emit quitPendingWaitsForOpened(); @@ -443,7 +387,7 @@ void QNetworkSessionPrivate::networkConfigurationsChanged() updateStateFromServiceNetwork(); else updateStateFromActiveConfig(); -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 setActiveTimeStamp(); #endif } @@ -490,7 +434,7 @@ void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionE } } -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 void QNetworkSessionPrivate::setActiveTimeStamp() { if(NetworkManagerAvailable()) { @@ -537,6 +481,4 @@ if(serviceName.isEmpty()) } #endif -#include "moc_qnetworksession_p.cpp" -QTM_END_NAMESPACE - +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h index 09fcfca..cd73c9a 100644 --- a/src/network/bearer/qnetworksession_p.h +++ b/src/network/bearer/qnetworksession_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -55,18 +55,15 @@ #include "qnetworkconfigmanager_p.h" #include "qnetworksession.h" -#ifdef BEARER_ENGINE #include "qnetworksessionengine_p.h" -#endif #include "qnetworksession.h" #include <QNetworkInterface> #include <QDateTime> -QTM_BEGIN_NAMESPACE -#ifdef BEARER_ENGINE +QT_BEGIN_NAMESPACE + class QNetworkSessionEngine; -#endif class QNetworkSessionPrivate : public QObject { @@ -116,12 +113,10 @@ Q_SIGNALS: void quitPendingWaitsForOpened(); private Q_SLOTS: -#ifdef BEARER_ENGINE void networkConfigurationsChanged(); void configurationChanged(const QNetworkConfiguration &config); void forcedSessionClose(const QNetworkConfiguration &config); void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error); -#endif private: QNetworkConfigurationManager manager; @@ -145,23 +140,22 @@ private: QNetworkSession::State state; bool isOpen; -#ifdef BEARER_ENGINE bool opened; QNetworkSessionEngine *engine; -#endif + QNetworkSession::SessionError lastError; QNetworkSession* q; friend class QNetworkSession; -#if defined(BEARER_ENGINE) && defined(BACKEND_NM) +#if defined(BACKEND_NM) QDateTime startTime; void setActiveTimeStamp(); #endif }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKSESSIONPRIVATE_H diff --git a/src/network/bearer/qnetworksession_s60_p.cpp b/src/network/bearer/qnetworksession_s60_p.cpp index f9cb09f..4d427c8 100644 --- a/src/network/bearer/qnetworksession_s60_p.cpp +++ b/src/network/bearer/qnetworksession_s60_p.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -49,7 +49,7 @@ #include <stdapis/sys/socket.h> #include <stdapis/net/if.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE QNetworkSessionPrivate::QNetworkSessionPrivate() : CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid), @@ -1131,4 +1131,4 @@ void ConnectionProgressNotifier::RunL() #include "moc_qnetworksession_s60_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession_s60_p.h b/src/network/bearer/qnetworksession_s60_p.h index ed322dd..9ac5ed8 100644 --- a/src/network/bearer/qnetworksession_s60_p.h +++ b/src/network/bearer/qnetworksession_s60_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -67,7 +67,7 @@ typedef int(*TOpenCSetdefaultifFunction)(const struct ifreq*); -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class ConnectionProgressNotifier; @@ -206,7 +206,7 @@ private: // Data }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKSESSIONPRIVATE_H diff --git a/src/network/bearer/qnetworksessionengine.cpp b/src/network/bearer/qnetworksessionengine.cpp index 55fc4f3..0aa9d19 100644 --- a/src/network/bearer/qnetworksessionengine.cpp +++ b/src/network/bearer/qnetworksessionengine.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -41,7 +41,7 @@ #include "qnetworksessionengine_p.h" -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE QNetworkSessionEngine::QNetworkSessionEngine(QObject *parent) : QObject(parent) @@ -50,8 +50,19 @@ QNetworkSessionEngine::QNetworkSessionEngine(QObject *parent) QNetworkSessionEngine::~QNetworkSessionEngine() { + foreach (const QString &oldIface, snapConfigurations.keys()) { + QNetworkConfigurationPrivatePointer priv = snapConfigurations.take(oldIface); + priv->isValid = false; + priv->id.clear(); + } + + foreach (const QString &oldIface, accessPointConfigurations.keys()) { + QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.take(oldIface); + priv->isValid = false; + priv->id.clear(); + } } #include "moc_qnetworksessionengine_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h index 3977b15..202a7dc 100644 --- a/src/network/bearer/qnetworksessionengine_p.h +++ b/src/network/bearer/qnetworksessionengine_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,16 +53,21 @@ // We mean it. // -#include <qmobilityglobal.h> +#include "qnetworkconfiguration_p.h" +#include "qnetworksession.h" + #include <QtCore/qobject.h> #include <QtCore/qglobal.h> #include <QtCore/qlist.h> #include <QtCore/qstring.h> +#include <QtCore/qhash.h> +#include <QtCore/qsharedpointer.h> + +QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE +class QNetworkConfiguration; -class QNetworkConfigurationPrivate; -class QNetworkSessionEngine : public QObject +class Q_NETWORK_EXPORT QNetworkSessionEngine : public QObject { Q_OBJECT @@ -77,7 +82,6 @@ public: QNetworkSessionEngine(QObject *parent = 0); virtual ~QNetworkSessionEngine(); - virtual QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0) = 0; virtual QString getInterfaceFromId(const QString &id) = 0; virtual bool hasIdentifier(const QString &id) = 0; @@ -88,11 +92,28 @@ public: virtual void requestUpdate() = 0; + virtual QNetworkSession::State sessionStateForId(const QString &id) = 0; + +public: + //this table contains an up to date list of all configs at any time. + //it must be updated if configurations change, are added/removed or + //the members of ServiceNetworks change + QHash<QString, QNetworkConfigurationPrivatePointer> accessPointConfigurations; + QHash<QString, QNetworkConfigurationPrivatePointer> snapConfigurations; + QHash<QString, QNetworkConfigurationPrivatePointer> userChoiceConfigurations; + Q_SIGNALS: - void configurationsChanged(); + void configurationAdded(QNetworkConfigurationPrivatePointer config); + void configurationRemoved(QNetworkConfigurationPrivatePointer config); + void configurationChanged(QNetworkConfigurationPrivatePointer config); + + void updateCompleted(); + void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error); }; -QTM_END_NAMESPACE +typedef QNetworkSessionEngine QBearerEngine; + +QT_END_NAMESPACE #endif diff --git a/src/network/bearer/qnmwifiengine_unix.cpp b/src/network/bearer/qnmwifiengine_unix.cpp deleted file mode 100644 index 2444919..0000000 --- a/src/network/bearer/qnmwifiengine_unix.cpp +++ /dev/null @@ -1,906 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnmwifiengine_unix_p.h" -#include "qnetworkconfiguration_p.h" -#include <qnetworkconfiguration.h> - -#include <QtCore/qstringlist.h> -#include <QScopedPointer> - -#include <QtNetwork/qnetworkinterface.h> -#include <NetworkManager/NetworkManager.h> -#include <qnetworkmanagerservice_p.h> - -#include <QNetworkInterface> - - - -QTM_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QNmWifiEngine, nmWifiEngine) -typedef QList<QList<uint> > QNmSettingsAddressMap; -QTM_END_NAMESPACE - -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsAddressMap)) - -QTM_BEGIN_NAMESPACE - -QNmWifiEngine::QNmWifiEngine(QObject *parent) -: QNetworkSessionEngine(parent) -{ - iface = new QNetworkManagerInterface(this); - if(!iface->isValid()) { - return; - } - iface->setConnections(); - connect(iface,SIGNAL(deviceAdded(QDBusObjectPath)), - this,SLOT(addDevice(QDBusObjectPath))); - connect(iface,SIGNAL(deviceRemoved(QDBusObjectPath)), - this,SLOT(removeDevice(QDBusObjectPath))); - connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), - this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*))); - - QList<QDBusObjectPath> list = iface->getDevices(); - - foreach(QDBusObjectPath path, list) { - addDevice(path); - } - - QStringList connectionServices; - connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; - connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; - QNetworkManagerSettings *settingsiface; - foreach (QString service, connectionServices) { - settingsiface = new QNetworkManagerSettings(service, this); - settingsiface->setConnections(); - connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)), - this,(SLOT(newConnection(QDBusObjectPath)))); - } - - updated = false; -} - -QNmWifiEngine::~QNmWifiEngine() -{ -} - -QString QNmWifiEngine::getNameForConfiguration(QNetworkManagerInterfaceDevice *devIface) -{ - QString newname; - if (devIface->state() == NM_DEVICE_STATE_ACTIVATED) { - QString path = devIface->ip4config().path(); - QNetworkManagerIp4Config * ipIface; - ipIface = new QNetworkManagerIp4Config(path); - newname = ipIface->domains().join(" "); - delete ipIface; - } - //fallback to interface name - if(newname.isEmpty()) - newname = devIface->interface().name(); - return newname; -} - - -QList<QNetworkConfigurationPrivate *> QNmWifiEngine::getConfigurations(bool *ok) -{ - if (ok) - *ok = false; - - if(!updated) { - foundConfigurations.clear(); - if(knownSsids.isEmpty()) - updateKnownSsids(); // list of ssids that have user configurations. - - scanForAccessPoints(); - updateActiveConnectionsPaths(); - knownConnections(); - - accessPointConnections(); - -// findConnections(); - //add access points - updated = true; - } - return foundConfigurations; -} - -void QNmWifiEngine::knownConnections() -{ - //// connections - QStringList connectionServices; - connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; - connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; - - QString connPath; - - QScopedPointer<QNetworkManagerSettings> settingsiface; - foreach (QString service, connectionServices) { - QString ident; - settingsiface.reset(new QNetworkManagerSettings(service)); - QList<QDBusObjectPath> list = settingsiface->listConnections(); - - QNetworkManagerSettingsConnection *sysIface; - foreach(QDBusObjectPath path, list) { //for each connection path - ident = path.path(); - bool addIt = false; - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - sysIface = new QNetworkManagerSettingsConnection(service, path.path(), this); - sysIface->setConnections(); - connect(sysIface, SIGNAL(removed(QString)), - this,SLOT(settingsConnectionRemoved(QString))); - - cpPriv->name = sysIface->getId(); - cpPriv->isValid = true; - cpPriv->id = sysIface->getUuid(); - cpPriv->internet = true; - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->state = getStateForId(cpPriv->id); - - cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; - - - if(sysIface->getType() == DEVICE_TYPE_802_3_ETHERNET) { - QString mac = sysIface->getMacAddress(); - if(!mac.length() > 2) { - QString devPath; - devPath = deviceConnectionPath(mac); - - QNetworkManagerInterfaceDevice devIface(devPath); - cpPriv->serviceInterface = devIface.interface(); - QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface; - devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(devIface.connectionInterface()->path())); - cpPriv->internet = devWiredIface->carrier(); - - // use this mac addy - } else { - cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_3_ETHERNET, cpPriv->id); - } - - cpPriv->internet = true;//sysIface->isAutoConnect(); - - addIt = true; - } else if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) { - QString mac = sysIface->getMacAddress();; - if(!mac.length() > 2) { - QString devPath; - devPath = deviceConnectionPath(mac); - - QNetworkManagerInterfaceDevice devIface(devPath); - cpPriv->serviceInterface = devIface.interface(); - // use this mac addy - } else { - cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_11_WIRELESS, cpPriv->id); - } - addIt = true; - // get the wifi interface state first.. do we need this? - // QString activeAPPath = devWirelessIface->activeAccessPoint().path(); - } - if(addIt) { - foundConfigurations.append(cpPriv); - configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name(); - cpPriv->bearer = bearerName(cpPriv->id); - } - } //end each connection service - } -} - -void QNmWifiEngine::accessPointConnections() -{ - QList<QDBusObjectPath> list = iface->getDevices(); - QScopedPointer<QNetworkManagerInterfaceDevice> devIface; - foreach(QDBusObjectPath path, list) { - devIface.reset(new QNetworkManagerInterfaceDevice(path.path())); - if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) { - QList<QString> apList = availableAccessPoints.uniqueKeys(); - - QList<QString>::const_iterator i; - for (i = apList.constBegin(); i != apList.constEnd(); ++i) { - QNetworkConfigurationPrivate* cpPriv; - cpPriv = addAccessPoint( devIface->connectionInterface()->path(), availableAccessPoints[*i]); - if(cpPriv->isValid) { - foundConfigurations.append(cpPriv); - configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name(); - cpPriv->bearer = bearerName(cpPriv->id); - } - } - } - } -} - -QString QNmWifiEngine::getInterfaceFromId(const QString &id) -{ - return configurationInterface.value(id); -} - -bool QNmWifiEngine::hasIdentifier(const QString &id) -{ - if (configurationInterface.contains(id)) - return true; - - return false; -} - -QString QNmWifiEngine::bearerName(const QString &id) -{ - QString interface = getInterfaceFromId(id); - QScopedPointer<QNetworkManagerInterfaceDevice> devIface; - QList<QDBusObjectPath> list = iface->getDevices(); - foreach(QDBusObjectPath path, list) { - devIface.reset(new QNetworkManagerInterfaceDevice(path.path())); - - if(interface == devIface->interface().name()) { - - switch(devIface->deviceType()) { - case DEVICE_TYPE_802_3_ETHERNET/*NM_DEVICE_TYPE_ETHERNET*/: - return QLatin1String("Ethernet"); - break; - case DEVICE_TYPE_802_11_WIRELESS/*NM_DEVICE_TYPE_WIFI*/: - return QLatin1String("WLAN"); - break; - case DEVICE_TYPE_GSM/*NM_DEVICE_TYPE_GSM*/: - return QLatin1String("2G"); - break; - case DEVICE_TYPE_CDMA/*NM_DEVICE_TYPE_CDMA*/: - return QLatin1String("CDMA2000"); - break; - default: - break; - } - } - } - return QLatin1String("Unknown"); -} - -void QNmWifiEngine::connectToId(const QString &id) -{ - activatingConnectionPath = id; - QStringList connectionSettings = getConnectionPathForId(id); - if(connectionSettings.isEmpty()) { - emit connectionError(id, OperationNotSupported); - return; - } - - QDBusObjectPath connectionPath(connectionSettings.at(1)); - QString interface = getInterfaceFromId(id); - - interface = QNetworkInterface::interfaceFromName(interface).hardwareAddress().toLower(); - QString devPath; - devPath = deviceConnectionPath(interface); - QDBusObjectPath devicePath(devPath); - - iface->activateConnection( - connectionSettings.at(0), - connectionPath, - devicePath, - connectionPath); -} - -void QNmWifiEngine::disconnectFromId(const QString &id) -{ - QString activeConnectionPath = getActiveConnectionPath(id); - - if (!activeConnectionPath.isEmpty()) { - QScopedPointer<QNetworkManagerConnectionActive> activeCon; - activeCon.reset(new QNetworkManagerConnectionActive(activeConnectionPath)); - QScopedPointer<QNetworkManagerSettingsConnection> settingsCon; - settingsCon.reset(new QNetworkManagerSettingsConnection(activeCon->serviceName(), activeCon->connection().path())); - - if(settingsCon->getType() == DEVICE_TYPE_802_3_ETHERNET /*NM_DEVICE_TYPE_ETHERNET*/) { //use depreciated value for now - emit connectionError(id, OperationNotSupported); - } else { - QDBusObjectPath dbpath(activeConnectionPath); - iface->deactivateConnection(dbpath); - activatingConnectionPath = ""; - } - } -} - -void QNmWifiEngine::requestUpdate() -{ - updated = false; - knownSsids.clear(); - availableAccessPoints.clear(); - emitConfigurationsChanged(); -} - -QNmWifiEngine *QNmWifiEngine::instance() -{ - QDBusConnection dbusConnection = QDBusConnection::systemBus(); - if (dbusConnection.isConnected()) { - QDBusConnectionInterface *dbiface = dbusConnection.interface(); - QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager"); - if (reply.isValid() && reply.value()) - return nmWifiEngine(); - } - - return 0; -} - -void QNmWifiEngine::updateKnownSsids() -{ - QStringList connectionServices; - connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; - connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; - - QScopedPointer<QNetworkManagerSettings> settingsiface; - foreach (QString service, connectionServices) { - settingsiface.reset(new QNetworkManagerSettings(service)); - QList<QDBusObjectPath> list = settingsiface->listConnections(); - foreach(QDBusObjectPath path, list) { - QNetworkManagerSettingsConnection sysIface(service, path.path()); - knownSsids << sysIface.getSsid(); - } - } -} - -void QNmWifiEngine::updateActiveConnectionsPaths() -{ //need to know which connection paths are currently active/connected - QScopedPointer<QNetworkManagerInterface> dbIface; - activeConnectionPaths.clear(); - dbIface.reset(new QNetworkManagerInterface); - QList <QDBusObjectPath> connections = dbIface->activeConnections(); - foreach(QDBusObjectPath conpath, connections) { - activeConnectionPaths << conpath.path(); - } -} - -QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPath, QDBusObjectPath path) -{ - - QScopedPointer<QNetworkManagerInterfaceDevice> devIface(new QNetworkManagerInterfaceDevice(iPath)); - QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface(new QNetworkManagerInterfaceDeviceWireless(iPath)); - - QString activeAPPath = devWirelessIface->activeAccessPoint().path(); - - QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface(new QNetworkManagerInterfaceAccessPoint(path.path())); - - QString ident = accessPointIface->connectionInterface()->path(); - quint32 nmState = devIface->state(); - - QString ssid = accessPointIface->ssid(); - QString hwAddy = accessPointIface->hwAddress(); - QString sInterface = devIface->interface().name(); - - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - bool addIt = true; - -// if(availableAccessPoints.contains(ssid)) { -// addIt = false; -// -// } -// foreach (QNetworkConfigurationPrivate *cpPriv, foundConfigurations) { -// if (cpPriv->name == ssid) { //weed out duplicate ssid's ?? -// addIt = false; -// break; -// } -// } - - if(addIt) { - - cpPriv->name = ssid; - cpPriv->isValid = true; - cpPriv->id = ident; - cpPriv->internet = true; - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->serviceInterface = devIface->interface(); - - cpPriv->state = getAPState(nmState, knownSsids.contains(cpPriv->name)); - - if(activeAPPath == accessPointIface->connectionInterface()->path()) { - cpPriv->state = ( cpPriv->state | QNetworkConfiguration::Active); - } - if(accessPointIface->flags() == NM_802_11_AP_FLAGS_PRIVACY) - cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; - else - cpPriv->purpose = QNetworkConfiguration::PublicPurpose; - return cpPriv; - } else { - cpPriv->isValid = false; - } - return cpPriv; -} - - - QNetworkConfiguration::StateFlags QNmWifiEngine::getAPState(qint32 nmState, bool isKnown) -{ - QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; - // this is the state of the wifi device interface - if(isKnown) - state = ( QNetworkConfiguration::Defined); - - switch(nmState) { //device interface state, not AP state - case NM_DEVICE_STATE_UNKNOWN: - case NM_DEVICE_STATE_UNMANAGED: - case NM_DEVICE_STATE_UNAVAILABLE: - state = (QNetworkConfiguration::Undefined); - break; - case NM_DEVICE_STATE_DISCONNECTED: - { - if(isKnown) - state = ( state | QNetworkConfiguration::Discovered); - } - break; - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: - case NM_DEVICE_STATE_IP_CONFIG: - if(isKnown) - state = ( state | QNetworkConfiguration::Discovered); - break; - case NM_DEVICE_STATE_ACTIVATED: - { - if(isKnown) - state = ( state | QNetworkConfiguration::Discovered); - } - break; - }; - return state; -} - -QString QNmWifiEngine::getActiveConnectionPath(const QString &id) -{ - QStringList connectionSettings = getConnectionPathForId(id); - QNetworkManagerInterface ifaceD; - QList<QDBusObjectPath> connections = ifaceD.activeConnections(); - QScopedPointer<QNetworkManagerConnectionActive> conDetailsD; - foreach(QDBusObjectPath path, connections) { - conDetailsD.reset(new QNetworkManagerConnectionActive( path.path())); - if(conDetailsD->connection().path() == connectionSettings.at(1) - && conDetailsD->serviceName() == connectionSettings.at(0)) - return path.path(); - } - return QString(); -} - - QNetworkConfiguration::StateFlags QNmWifiEngine::getStateFlag(quint32 nmstate) - { - QNetworkConfiguration::StateFlags flag; - switch (nmstate) { - case NM_DEVICE_STATE_UNKNOWN: - case NM_DEVICE_STATE_FAILED: - case NM_DEVICE_STATE_UNMANAGED: - flag = (QNetworkConfiguration::Undefined); - break; - case NM_DEVICE_STATE_PREPARE: - case NM_DEVICE_STATE_CONFIG: - case NM_DEVICE_STATE_NEED_AUTH: - case NM_DEVICE_STATE_IP_CONFIG: - case NM_DEVICE_STATE_UNAVAILABLE: - flag = (QNetworkConfiguration::Defined); - break; - case NM_DEVICE_STATE_DISCONNECTED: - flag = ( flag | QNetworkConfiguration::Discovered ); - break; - case NM_DEVICE_STATE_ACTIVATED: - { - flag = ( flag | QNetworkConfiguration::Discovered - | QNetworkConfiguration::Active ); - } - break; - default: - flag = ( QNetworkConfiguration::Defined); - break; - }; - return flag; - } - -void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32 nmState) -{ - if(nmState == NM_DEVICE_STATE_ACTIVATED - || nmState == NM_DEVICE_STATE_DISCONNECTED - || nmState == NM_DEVICE_STATE_UNAVAILABLE - || nmState == NM_DEVICE_STATE_FAILED) { - -/* InterfaceLookupError = 0, - ConnectError, - OperationNotSupported, - DisconnectionError, -*/ - QNetworkConfiguration::StateFlags state = (QNetworkConfiguration::Defined); - switch (nmState) { - case NM_DEVICE_STATE_UNKNOWN: - case NM_DEVICE_STATE_FAILED: - state = (QNetworkConfiguration::Undefined); - emit connectionError(activatingConnectionPath, ConnectError); - requestUpdate(); - break; - case NM_DEVICE_STATE_UNAVAILABLE: - state = (QNetworkConfiguration::Defined); -// emit connectionError(activatingConnectionPath, ConnectError); - requestUpdate(); - break; - case NM_DEVICE_STATE_DISCONNECTED: - state = ( state | QNetworkConfiguration::Discovered ); - requestUpdate(); - break; - case NM_DEVICE_STATE_ACTIVATED: - { - state = ( state | QNetworkConfiguration::Discovered - | QNetworkConfiguration::Active ); - requestUpdate(); - } - break; - default: - state = ( QNetworkConfiguration::Defined); - break; - }; - } -} - -void QNmWifiEngine::addDevice(QDBusObjectPath path) -{ - QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path(), this); - devIface->setConnections(); - connect(devIface,SIGNAL(stateChanged(const QString &, quint32)), - this, SLOT(updateDeviceInterfaceState(const QString&, quint32))); - - if(!devicePaths.contains(path.path())) - devicePaths << path.path(); - - switch(devIface->deviceType()) { - case DEVICE_TYPE_802_3_ETHERNET: - { - QNetworkManagerInterfaceDeviceWired * devWiredIface; - devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path(), this); - devWiredIface->setConnections(); - connect(devWiredIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)), - this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>))); - requestUpdate(); - } - break; - case DEVICE_TYPE_802_11_WIRELESS: - { - QNetworkManagerInterfaceDeviceWireless *devWirelessIface; - devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path(), this); - devWirelessIface->setConnections(); - - connect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)), - this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>))); - - connect(devWirelessIface, SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)), - this,SLOT(accessPointAdded(const QString &,QDBusObjectPath))); - - connect(devWirelessIface, SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)), - this,SLOT(accessPointRemoved(const QString &,QDBusObjectPath))); - requestUpdate(); - - } - break; - default: - break; - }; -} - -void QNmWifiEngine::removeDevice(QDBusObjectPath /*path*/) -{ -// qWarning() << Q_FUNC_INFO << path.path(); -// disconnect(devIface,SIGNAL(stateChanged(const QString &, quint32)), -// this, SLOT(updateDeviceInterfaceState(const QString&, quint32))); -// -// if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) { -// // devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path()); -// // devWirelessIface->setConnections(); -// -// disconnect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)), -// this,SIGNAL(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>))); -// -// disconnect(devWirelessIface, SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)), -// this,SIGNAL(accessPointAdded(const QString &,QDBusObjectPath))); -// -// disconnect(devWirelessIface, SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)), -// this,SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath))); -// -// } -} -void QNmWifiEngine::cmpPropertiesChanged(const QString &path, QMap<QString,QVariant> map) -{ - QMapIterator<QString, QVariant> i(map); - while (i.hasNext()) { - i.next(); - if( i.key() == "State") { //only applies to device interfaces - updateDeviceInterfaceState(path, i.value().toUInt()); - } - if( i.key() == "ActiveAccessPoint") { - } - if( i.key() == "Carrier") { //someone got plugged in - // requestUpdate(); - } - } -} - -void QNmWifiEngine::accessPointRemoved( const QString &aPath, QDBusObjectPath /*oPath*/) -{ - if(aPath.contains("devices")) { - requestUpdate(); - } -} - -void QNmWifiEngine::accessPointAdded( const QString &aPath, QDBusObjectPath oPath) -{ - /*QNetworkConfigurationPrivate* cpPriv; - cpPriv = addAccessPoint( aPath, oPath);*/ - requestUpdate(); -} - -QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id) -{ - bool isAvailable = false; - QStringList conPath = getConnectionPathForId(id); - QString aconpath = getActiveConnectionPath(id); - - if(!aconpath.isEmpty()) { - //active connection - QNetworkManagerConnectionActive aConn(aconpath); - - QList <QDBusObjectPath> devs = aConn.devices(); - - QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice; - QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface; - foreach(QDBusObjectPath dev, devs) { - ifaceDevice.reset(new QNetworkManagerInterfaceDevice(dev.path())); - - if(ifaceDevice->deviceType() == DEVICE_TYPE_802_3_ETHERNET) { - - if(isAddressOfConnection(id, ifaceDevice->ip4Address())) { - // this is it! - return getStateFlag(ifaceDevice->state()); - } else { - continue; - } - - if(ifaceDevice->state() == NM_DEVICE_STATE_UNAVAILABLE || - ifaceDevice->state() == NM_DEVICE_STATE_DISCONNECTED) { - isAvailable = true; - - devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(ifaceDevice->connectionInterface()->path())); - if(!devWiredIface->carrier()) - return QNetworkConfiguration::Defined; - } //end eth - } else if(ifaceDevice->deviceType() == DEVICE_TYPE_802_11_WIRELESS) { - qWarning() << "FIXME!!!!!!!!!!!!!!!!!"; - } - - return getStateFlag(ifaceDevice->state()); - } - } else { - // not active - QScopedPointer<QNetworkManagerSettingsConnection> sysIface; - sysIface.reset(new QNetworkManagerSettingsConnection(conPath.at(0),conPath.at(1))); - if(sysIface->isValid()) { - if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) { - QString ssid = sysIface->getSsid(); - bool ok = false; - - if(knownSsids.contains(ssid, Qt::CaseSensitive)) { - foreach(QString onessid, knownSsids) { - if(onessid == ssid && availableAccessPoints.contains(ssid)) { - ok = true; - break; - } - } - } - if(ok) - return getStateFlag(NM_DEVICE_STATE_DISCONNECTED); - else - return getStateFlag(NM_DEVICE_STATE_UNAVAILABLE); - } - } - } - - return QNetworkConfiguration::Defined; //not active, but we know this connection so just fake it -} - -bool QNmWifiEngine::isAddressOfConnection(const QString &id, quint32 ipaddress) -{ - QStringList conPath = getConnectionPathForId(id); - QString aConPath = getActiveConnectionPath(id); - if(aConPath.isEmpty()) { - // not active - return false; - } - - QScopedPointer<QNetworkManagerConnectionActive> aConn; - aConn.reset(new QNetworkManagerConnectionActive(aConPath)); - QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice; - QList<QDBusObjectPath> devices = aConn->devices(); - foreach(QDBusObjectPath device, devices) { - ifaceDevice.reset(new QNetworkManagerInterfaceDevice(device.path())); - if(ifaceDevice->ip4Address() == ipaddress) { - return true; - } - } - return false; -} - -QNetworkInterface QNmWifiEngine::getBestInterface( quint32 type, const QString &id) -{ - // check active connections first. - QStringList conIdPath = getConnectionPathForId(id); - - QNetworkInterface interface; - QScopedPointer<QNetworkManagerConnectionActive> aConn; - - foreach(QString conpath, activeConnectionPaths) { - aConn.reset(new QNetworkManagerConnectionActive(conpath)); - if(aConn->connection().path() == conIdPath.at(1) - && aConn->serviceName() == conIdPath.at(0)) { - - QList <QDBusObjectPath> devs = aConn->devices(); - QNetworkManagerInterfaceDevice ifaceDevice(devs[0].path()); //just take the first one - return ifaceDevice.interface(); - } - } - - //try guessing - QList<QDBusObjectPath> list = iface->getDevices(); - QScopedPointer<QNetworkManagerInterfaceDevice> devIface; - foreach(QDBusObjectPath path, list) { - devIface.reset(new QNetworkManagerInterfaceDevice(path.path())); - if(devIface->deviceType() == type /*&& devIface->managed()*/) { - if(devIface->state() == NM_STATE_DISCONNECTED) { - return devIface->interface(); - } - } - } - return QNetworkInterface(); -} - -quint64 QNmWifiEngine::receivedDataForId(const QString &id) const -{ - if(configurationInterface.count() > 1) - return 0; - quint64 result = 0; - - QString devFile; - devFile = configurationInterface.value(id); - QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); - if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&rx); - in >> result; - rx.close(); - } - return result; -} - -quint64 QNmWifiEngine::sentDataForId(const QString &id) const -{ - if(configurationInterface.count() > 1) - return 0; - quint64 result = 0; - QString devFile; - devFile = configurationInterface.value(id); - - QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); - if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&tx); - in >> result; - tx.close(); - } - return result; -} - -void QNmWifiEngine::newConnection(QDBusObjectPath /*path*/) -{ - requestUpdate(); -} - -void QNmWifiEngine::settingsConnectionRemoved(const QString &/*path*/) -{ - requestUpdate(); -} - -void QNmWifiEngine::slotActivationFinished(QDBusPendingCallWatcher *openCall) -{ - QDBusPendingReply<QDBusObjectPath> reply = *openCall; - if (reply.isError()) { - qWarning() <<"Error" << reply.error().name() << reply.error().message() - <<activatingConnectionPath; - emit connectionError(activatingConnectionPath, ConnectError); - } /*else { - QDBusObjectPath result = reply.value(); - }*/ -} - -void QNmWifiEngine::scanForAccessPoints() -{ - availableAccessPoints.clear(); - QList<QDBusObjectPath> list = iface->getDevices(); - - QScopedPointer<QNetworkManagerInterfaceDevice> devIface; - QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface; - QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface; - foreach(QDBusObjectPath path, list) { - devIface.reset(new QNetworkManagerInterfaceDevice(path.path())); - - if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) { - - devWirelessIface.reset(new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path())); - ////////////// AccessPoints - QList<QDBusObjectPath> apList = devWirelessIface->getAccessPoints(); - - foreach(QDBusObjectPath path, apList) { - accessPointIface.reset(new QNetworkManagerInterfaceAccessPoint(path.path())); - QString ssid = accessPointIface->ssid(); - availableAccessPoints.insert(ssid, path); - } - } - } -} - -QString QNmWifiEngine::deviceConnectionPath(const QString &mac) -{ -// qWarning() << __FUNCTION__ << mac; - QString newMac = mac; - newMac = newMac.replace(":","_").toLower(); - //device object path might not contain just mac address - //might contain extra numbers on the end. thanks HAL - foreach(QString device, devicePaths) { - if(device.contains(newMac)) { - newMac = device; - break; - } - } - return newMac; -} - -QStringList QNmWifiEngine::getConnectionPathForId(const QString &uuid) -{ - QStringList connectionServices; - connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; - connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; - QScopedPointer<QNetworkManagerSettings> settingsiface; - foreach (QString service, connectionServices) { - settingsiface.reset(new QNetworkManagerSettings(service)); - QList<QDBusObjectPath> list = settingsiface->listConnections(); - QScopedPointer<QNetworkManagerSettingsConnection> sysIface; - foreach(QDBusObjectPath path, list) { - sysIface.reset(new QNetworkManagerSettingsConnection(service, path.path())); - if(sysIface->getUuid() == uuid) - return QStringList() << service << sysIface->connectionInterface()->path(); - } - } - return QStringList(); -} - -#include "moc_qnmwifiengine_unix_p.cpp" - -QTM_END_NAMESPACE - diff --git a/src/network/bearer/qnmwifiengine_unix_p.h b/src/network/bearer/qnmwifiengine_unix_p.h deleted file mode 100644 index 470c8d3..0000000 --- a/src/network/bearer/qnmwifiengine_unix_p.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNMWIFIENGINE_P_H -#define QNMWIFIENGINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -//#include <QtCore/qtimer.h> - -#include <QHash> -#include <QDBusPendingCallWatcher> -#include <QExplicitlySharedDataPointer> -#include <qnetworkmanagerservice_p.h> - -#include "qnetworksessionengine_p.h" -#include <qnetworksession.h> -#include <qnetworkconfiguration.h> -#include <qnetworkconfigmanager_p.h> - - - -QTM_BEGIN_NAMESPACE - -class QNetworkConfigurationPrivate; - -class QNmWifiEngine : public QNetworkSessionEngine -{ - Q_OBJECT - -public: - QNmWifiEngine(QObject *parent = 0); - ~QNmWifiEngine(); - - QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0); - QString getInterfaceFromId(const QString &id); - bool hasIdentifier(const QString &id); - - QString bearerName(const QString &id); - - void connectToId(const QString &id); - void disconnectFromId(const QString &id); - - void requestUpdate(); - - static QNmWifiEngine *instance(); - - QStringList knownSsids; - inline void emitConfigurationsChanged() { emit configurationsChanged(); } - QNetworkConfigurationPrivate * addAccessPoint(const QString &, QDBusObjectPath ); - - QStringList getConnectionPathForId(const QString &uuid); - //QString getConnectionPathForId(const QString &name = QString()); - quint64 sentDataForId(const QString &id) const; - quint64 receivedDataForId(const QString &id) const; - -private: - bool updated; - QString activatingConnectionPath; - QStringList activeConnectionPaths; - - - QMap<QString,QDBusObjectPath> availableAccessPoints; - void scanForAccessPoints(); - - QStringList devicePaths; - - void updateActiveConnectionsPaths(); - void updateKnownSsids(); - void accessPointConnections(); - void knownConnections(); - QString deviceConnectionPath(const QString &mac); - - QList<QNetworkConfigurationPrivate *> foundConfigurations; - // QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > allConfigurations; - - QNetworkManagerInterface *iface; - - QNetworkConfiguration::StateFlags getAPState(qint32 vState, bool isKnown); - QNetworkConfiguration::StateFlags getStateFlag(quint32 nmstate); - - QString getActiveConnectionPath(const QString &identifier); - QString getNameForConfiguration(QNetworkManagerInterfaceDevice *devIface); - - QNetworkConfiguration::StateFlags getStateForId(const QString &id); - - QNetworkInterface getBestInterface(quint32 type, const QString &conPath); - - QMap<QString, QString> configurationInterface; - - bool isAddressOfConnection(const QString &conPath, quint32 ipaddress); - -private slots: - void updateDeviceInterfaceState(const QString &, quint32); - void addDevice(QDBusObjectPath path); - void removeDevice(QDBusObjectPath path); - -Q_SIGNALS: - void configurationChanged(const QNetworkConfiguration& config); - -private slots: - void accessPointAdded( const QString &aPath, QDBusObjectPath oPath); - void accessPointRemoved( const QString &aPath, QDBusObjectPath oPath); - void cmpPropertiesChanged(const QString &, QMap<QString,QVariant> map); - void newConnection(QDBusObjectPath); - void settingsConnectionRemoved(const QString &); - void slotActivationFinished(QDBusPendingCallWatcher*); -}; - -QTM_END_NAMESPACE - -#endif - - diff --git a/src/network/network.pro b/src/network/network.pro index e890b94..8582d8a 100644 --- a/src/network/network.pro +++ b/src/network/network.pro @@ -17,6 +17,7 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore include(../qbase.pri) include(access/access.pri) +include(bearer/bearer.pri) include(kernel/kernel.pri) include(socket/socket.pri) include(ssl/ssl.pri) diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro new file mode 100644 index 0000000..58d2613 --- /dev/null +++ b/src/plugins/bearer/bearer.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +SUBDIRS += generic +contains(QT_CONFIG, dbus):contains(QT_CONFIG, networkmanager):SUBDIRS += networkmanager +win32:SUBDIRS += nla +win32:!wince*:SUBDIRS += nativewifi +macx:SUBDIRS += corewlan diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro new file mode 100644 index 0000000..ac04e95 --- /dev/null +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -0,0 +1,19 @@ +TARGET = qcorewlanbearer +include(../../qpluginbase.pri) + +QT += network +LIBS += -framework Foundation -framework SystemConfiguration + +contains(QT_CONFIG, corewlan) { + isEmpty(QMAKE_MAC_SDK)|contains(QMAKE_MAC_SDK, "/Developer/SDKs/MacOSX10.6.sdk") { + LIBS += -framework CoreWLAN + DEFINES += MAC_SDK_10_6 + } +} + +HEADERS += qcorewlanengine.h +SOURCES += qcorewlanengine.mm main.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/plugins/bearer/corewlan/main.cpp b/src/plugins/bearer/corewlan/main.cpp new file mode 100644 index 0000000..ce0611e --- /dev/null +++ b/src/plugins/bearer/corewlan/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcorewlanengine.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QCoreWlanEnginePlugin : public QBearerEnginePlugin +{ +public: + QCoreWlanEnginePlugin(); + ~QCoreWlanEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QCoreWlanEnginePlugin::QCoreWlanEnginePlugin() +{ +} + +QCoreWlanEnginePlugin::~QCoreWlanEnginePlugin() +{ +} + +QStringList QCoreWlanEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("corewlan"); +} + +QBearerEngine *QCoreWlanEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("corewlan")) + return new QCoreWlanEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QCoreWlanEnginePlugin) +Q_EXPORT_PLUGIN2(qcorewlanbearer, QCoreWlanEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/network/bearer/qcorewlanengine_mac_p.h b/src/plugins/bearer/corewlan/qcorewlanengine.h index 6ad093a..57906ca 100644 --- a/src/network/bearer/qcorewlanengine_mac_p.h +++ b/src/plugins/bearer/corewlan/qcorewlanengine.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,24 +39,15 @@ ** ****************************************************************************/ -#ifndef QCOREWLANENGINE_P_H -#define QCOREWLANENGINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qnetworksessionengine_p.h" +#ifndef QCOREWLANENGINE_H +#define QCOREWLANENGINE_H + +#include <QtNetwork/private/qnetworksessionengine_p.h> + #include <QMap> #include <QTimer> -QTM_BEGIN_NAMESPACE + +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; @@ -68,7 +59,6 @@ public: QCoreWlanEngine(QObject *parent = 0); ~QCoreWlanEngine(); - QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0); QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); @@ -79,14 +69,18 @@ public: void requestUpdate(); - static QCoreWlanEngine *instance(); + QNetworkSession::State sessionStateForId(const QString &id); + static bool getAllScInterfaces(); +private Q_SLOTS: + void doRequestUpdate(); + private: bool isWifiReady(const QString &dev); - QMap<uint, QString> configurationInterface; + QMap<QString, QString> configurationInterface; QTimer pollTimer; - QList<QNetworkConfigurationPrivate *> scanForSsids(const QString &interfaceName); + QStringList scanForSsids(const QString &interfaceName); QList<QNetworkConfigurationPrivate *> getWlanProfiles(const QString &interfaceName); @@ -95,7 +89,7 @@ private: }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif diff --git a/src/network/bearer/qcorewlanengine_mac.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 41ec79a..e07d7b4 100644 --- a/src/network/bearer/qcorewlanengine_mac.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,8 +39,9 @@ ** ****************************************************************************/ -#include "qcorewlanengine_mac_p.h" -#include "qnetworkconfiguration_p.h" +#include "qcorewlanengine.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> #include <QtCore/qthread.h> #include <QtCore/qmutex.h> @@ -63,9 +64,7 @@ #include <SystemConfiguration/SCNetworkConfiguration.h> QMap <QString, QString> networkInterfaces; -QTM_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QCoreWlanEngine, coreWlanEngine) +QT_BEGIN_NAMESPACE inline QString cfstringRefToQstring(CFStringRef cfStringRef) { // return QString([cfStringRef UTF8String]); @@ -108,97 +107,25 @@ static QString qGetInterfaceType(const QString &interfaceString) QCoreWlanEngine::QCoreWlanEngine(QObject *parent) : QNetworkSessionEngine(parent) { - getAllScInterfaces(); - connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged())); + connect(&pollTimer, SIGNAL(timeout()), this, SLOT(doRequestUpdate())); pollTimer.setInterval(10000); + doRequestUpdate(); } QCoreWlanEngine::~QCoreWlanEngine() { - QNetworkConfigurationPrivate* cpPriv = 0; - foundConfigurations.clear(); - while(!foundConfigurations.isEmpty()) { - cpPriv = foundConfigurations.takeFirst(); - delete cpPriv; - } -} - -QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getConfigurations(bool *ok) -{ - if (ok) - *ok = true; - foundConfigurations.clear(); - - uint identifier; - QMapIterator<QString, QString> i(networkInterfaces); - QNetworkConfigurationPrivate* cpPriv = 0; - while (i.hasNext()) { - i.next(); - if (i.value() == "WLAN") { - QList<QNetworkConfigurationPrivate *> fetchedConfigurations = scanForSsids(i.key()); - for (int i = 0; i < fetchedConfigurations.count(); ++i) { - - QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate(); - cpPriv = fetchedConfigurations.at(i); - config->name = cpPriv->name; - config->isValid = cpPriv->isValid; - config->id = cpPriv->id; - - config->state = cpPriv->state; - config->type = cpPriv->type; - config->roamingSupported = cpPriv->roamingSupported; - config->purpose = cpPriv->purpose; - config->internet = cpPriv->internet; - config->serviceInterface = cpPriv->serviceInterface; - config->bearer = cpPriv->bearer; - - identifier = config->name.toUInt(); - configurationInterface[identifier] = config->serviceInterface.name(); - foundConfigurations.append(config); - delete cpPriv; - } - } - - QNetworkInterface interface = QNetworkInterface::interfaceFromName(i.key()); - QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate(); - const QString humanReadableName = interface.humanReadableName(); - cpPriv->name = humanReadableName.isEmpty() ? interface.name() : humanReadableName; - cpPriv->isValid = true; - - if (interface.index()) - identifier = interface.index(); - else - identifier = qHash(interface.hardwareAddress()); - - cpPriv->id = QString::number(identifier); - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->state = QNetworkConfiguration::Undefined; - - if (interface.flags() & QNetworkInterface::IsRunning) { - cpPriv->state = QNetworkConfiguration::Defined; - cpPriv->internet = true; - } - if ( !interface.addressEntries().isEmpty()) { - cpPriv->state |= QNetworkConfiguration::Active; - cpPriv->internet = true; - } - configurationInterface[identifier] = interface.name(); - cpPriv->bearer = interface.name().isEmpty()? QLatin1String("Unknown") : qGetInterfaceType(interface.name()); - foundConfigurations.append(cpPriv); - } - - pollTimer.start(); - return foundConfigurations; + while (!foundConfigurations.isEmpty()) + delete foundConfigurations.takeFirst(); } QString QCoreWlanEngine::getInterfaceFromId(const QString &id) { - return configurationInterface.value(id.toUInt()); + return configurationInterface.value(id); } bool QCoreWlanEngine::hasIdentifier(const QString &id) { - return configurationInterface.contains(id.toUInt()); + return configurationInterface.contains(id); } void QCoreWlanEngine::connectToId(const QString &id) @@ -297,18 +224,112 @@ void QCoreWlanEngine::disconnectFromId(const QString &id) void QCoreWlanEngine::requestUpdate() { - getAllScInterfaces(); - emit configurationsChanged(); + pollTimer.stop(); + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); } -QCoreWlanEngine *QCoreWlanEngine::instance() +void QCoreWlanEngine::doRequestUpdate() { - return coreWlanEngine(); + getAllScInterfaces(); + + QStringList previous = accessPointConfigurations.keys(); + + QMapIterator<QString, QString> i(networkInterfaces); + while (i.hasNext()) { + i.next(); + if (i.value() == QLatin1String("WLAN")) { + QStringList added = scanForSsids(i.key()); + while (!added.isEmpty()) { + previous.removeAll(added.takeFirst()); + } + } + + QNetworkInterface interface = QNetworkInterface::interfaceFromName(i.key()); + + if (!interface.isValid()) + continue; + + uint identifier; + if (interface.index()) + identifier = qHash(QLatin1String("corewlan:") + QString::number(interface.index())); + else + identifier = qHash(QLatin1String("corewlan:") + interface.hardwareAddress()); + + const QString id = QString::number(identifier); + + previous.removeAll(id); + + QString name = interface.humanReadableName(); + if (name.isEmpty()) + name = interface.name(); + + QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; + + if (interface.flags() && QNetworkInterface::IsRunning) + state = QNetworkConfiguration::Defined; + + if (!interface.addressEntries().isEmpty()) + state = QNetworkConfiguration::Active; + + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + bool changed = false; + + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } + + if (ptr->name != name) { + ptr->name = name; + changed = true; + } + + if (ptr->id != id) { + ptr->id = id; + changed = true; + } + + if (ptr->state != state) { + ptr->state = state; + changed = true; + } + + if (changed) + emit configurationChanged(ptr); + } else { + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + + ptr->name = name; + ptr->isValid = true; + ptr->id = id; + ptr->state = state; + ptr->type = QNetworkConfiguration::InternetAccessPoint; + + accessPointConfigurations.insert(id, ptr); + configurationInterface.insert(id, interface.name()); + + emit configurationAdded(ptr); + } + } + + while (!previous.isEmpty()) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); + + configurationInterface.remove(ptr->id); + emit configurationRemoved(ptr); + } + + pollTimer.start(); + + emit updateCompleted(); } -QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QString &interfaceName) +QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName) { - QList<QNetworkConfigurationPrivate *> foundConfigs; + QStringList found; + #if defined(MAC_SDK_10_6) NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; @@ -318,41 +339,69 @@ QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QStrin NSArray* apArray = [NSMutableArray arrayWithArray:[currentInterface scanForNetworksWithParameters:parametersDict error:&err]]; CWNetwork *apNetwork; - if(!err) { + if (!err) { for(uint row=0; row < [apArray count]; row++ ) { NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init]; apNetwork = [apArray objectAtIndex:row]; - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - QString networkSsid = nsstringToQString([apNetwork ssid]); - cpPriv->name = networkSsid; - cpPriv->isValid = true; - cpPriv->id = networkSsid; - cpPriv->internet = true; - cpPriv->bearer = QLatin1String("WLAN"); - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->serviceInterface = QNetworkInterface::interfaceFromName(interfaceName); - - if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { - QString interfaceSsidString = nsstringToQString( [currentInterface ssid]); - if( cpPriv->name == interfaceSsidString) { - cpPriv->state |= QNetworkConfiguration::Active; - } + + const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid)); + found.append(id); + + QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; + + if ([currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { + if (networkSsid == nsstringToQString([currentInterface ssid])) + state = QNetworkConfiguration::Active; } else { - if(isKnownSsid(cpPriv->serviceInterface.name(), networkSsid)) { - cpPriv->state = QNetworkConfiguration::Discovered; - } else { - cpPriv->state = QNetworkConfiguration::Defined; - } + if (isKnownSsid(interfaceName, networkSsid)) + state = QNetworkConfiguration::Discovered; + else + state = QNetworkConfiguration::Defined; } - if(!cpPriv->state) { - cpPriv->state = QNetworkConfiguration::Undefined; + + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + bool changed = false; + + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } + + if (ptr->name != networkSsid) { + ptr->name = networkSsid; + changed = true; + } + + if (ptr->id != id) { + ptr->id = id; + changed = true; + } + + if (ptr->state != state) { + ptr->state = state; + changed = true; + } + + if (changed) + emit configurationChanged(ptr); + } else { + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + + ptr->name = networkSsid; + ptr->isValid = true; + ptr->id = id; + ptr->state = state; + ptr->type = QNetworkConfiguration::InternetAccessPoint; + ptr->bearer = QLatin1String("WLAN"); + + accessPointConfigurations.insert(id, ptr); + configurationInterface.insert(id, interfaceName); + + emit configurationAdded(ptr); } - if([[apNetwork securityMode ] intValue]== kCWSecurityModeOpen) - cpPriv->purpose = QNetworkConfiguration::PublicPurpose; - else - cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; - foundConfigs.append(cpPriv); [looppool release]; } } else { @@ -364,7 +413,7 @@ QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QStrin #else Q_UNUSED(interfaceName); #endif - return foundConfigs; + return found; } bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName) @@ -448,7 +497,28 @@ bool QCoreWlanEngine::getAllScInterfaces() return true; } -#include "moc_qcorewlanengine_mac_p.cpp" +QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id) +{ + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + return QNetworkSession::Connected; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } -QTM_END_NAMESPACE + return QNetworkSession::Invalid; +} +QT_END_NAMESPACE diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro new file mode 100644 index 0000000..0015041 --- /dev/null +++ b/src/plugins/bearer/generic/generic.pro @@ -0,0 +1,12 @@ +TARGET = qgenericbearer +include(../../qpluginbase.pri) + +QT += network + +HEADERS += qgenericengine.h \ + ../platformdefs_win.h +SOURCES += qgenericengine.cpp main.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp new file mode 100644 index 0000000..a7df023 --- /dev/null +++ b/src/plugins/bearer/generic/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgenericengine.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QGenericEnginePlugin : public QBearerEnginePlugin +{ +public: + QGenericEnginePlugin(); + ~QGenericEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QGenericEnginePlugin::QGenericEnginePlugin() +{ +} + +QGenericEnginePlugin::~QGenericEnginePlugin() +{ +} + +QStringList QGenericEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("generic"); +} + +QBearerEngine *QGenericEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("generic")) + return new QGenericEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QGenericEnginePlugin) +Q_EXPORT_PLUGIN2(qgenericbearer, QGenericEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/network/bearer/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 10cea0c..9294fad 100644 --- a/src/network/bearer/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,8 +39,9 @@ ** ****************************************************************************/ -#include "qgenericengine_p.h" -#include "qnetworkconfiguration_p.h" +#include "qgenericengine.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> #include <QtCore/qthread.h> #include <QtCore/qmutex.h> @@ -50,7 +51,7 @@ #include <QtCore/qdebug.h> #ifdef Q_OS_WIN -#include "qnetworksessionengine_win_p.h" +#include "../platformdefs_win.h" #endif #ifdef Q_OS_LINUX @@ -60,9 +61,6 @@ #include <net/if_arp.h> #endif -QTM_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QGenericEngine, genericEngine) static QString qGetInterfaceType(const QString &interface) { @@ -144,21 +142,53 @@ static QString qGetInterfaceType(const QString &interface) QGenericEngine::QGenericEngine(QObject *parent) : QNetworkSessionEngine(parent) { - connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged())); + connect(&pollTimer, SIGNAL(timeout()), this, SLOT(doRequestUpdate())); pollTimer.setInterval(10000); + doRequestUpdate(); } QGenericEngine::~QGenericEngine() { } -QList<QNetworkConfigurationPrivate *> QGenericEngine::getConfigurations(bool *ok) +QString QGenericEngine::getInterfaceFromId(const QString &id) +{ + return configurationInterface.value(id); +} + +bool QGenericEngine::hasIdentifier(const QString &id) +{ + return configurationInterface.contains(id); +} + +/*QString QGenericEngine::bearerName(const QString &id) +{ + QString interface = getInterfaceFromId(id); + + if (interface.isEmpty()) + return QLatin1String("Unknown"); + + return qGetInterfaceType(interface); +}*/ + +void QGenericEngine::connectToId(const QString &id) +{ + emit connectionError(id, OperationNotSupported); +} + +void QGenericEngine::disconnectFromId(const QString &id) { - if (ok) - *ok = true; + emit connectionError(id, OperationNotSupported); +} - QList<QNetworkConfigurationPrivate *> foundConfigurations; +void QGenericEngine::requestUpdate() +{ + pollTimer.stop(); + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); +} +void QGenericEngine::doRequestUpdate() +{ // Immediately after connecting with a wireless access point // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a // second time results in a non-empty list. If we loose interfaces we will end up removing @@ -167,6 +197,8 @@ QList<QNetworkConfigurationPrivate *> QGenericEngine::getConfigurations(bool *ok if (interfaces.isEmpty()) interfaces = QNetworkInterface::allInterfaces(); + QStringList previous = accessPointConfigurations.keys(); + // create configuration for each interface while (!interfaces.isEmpty()) { QNetworkInterface interface = interfaces.takeFirst(); @@ -179,81 +211,108 @@ QList<QNetworkConfigurationPrivate *> QGenericEngine::getConfigurations(bool *ok continue; // ignore WLAN interface handled in seperate engine - if (qGetInterfaceType(interface.name()) == "WLAN") + if (qGetInterfaceType(interface.name()) == QLatin1String("WLAN")) continue; - QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate; - const QString humanReadableName = interface.humanReadableName(); - cpPriv->name = humanReadableName.isEmpty() ? interface.name() : humanReadableName; - cpPriv->isValid = true; - uint identifier; if (interface.index()) - identifier = qHash(QLatin1String("NLA:") + QString::number(interface.index())); + identifier = qHash(QLatin1String("generic:") + QString::number(interface.index())); else - identifier = qHash(QLatin1String("NLA:") + interface.hardwareAddress()); + identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress()); - cpPriv->id = QString::number(identifier); - cpPriv->state = QNetworkConfiguration::Discovered; - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - if (interface.name().isEmpty()) - cpPriv->bearer = QLatin1String("Unknown"); - else - cpPriv->bearer = qGetInterfaceType(interface.name()); + const QString id = QString::number(identifier); - if (interface.flags() & QNetworkInterface::IsUp) - cpPriv->state |= QNetworkConfiguration::Active; + previous.removeAll(id); - configurationInterface[identifier] = interface.name(); + QString name = interface.humanReadableName(); + if (name.isEmpty()) + name = interface.name(); - foundConfigurations.append(cpPriv); + QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Discovered; + if (interface.flags() & QNetworkInterface::IsUp) + state |= QNetworkConfiguration::Active; + + if (accessPointConfigurations.contains(id)) { + QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = + accessPointConfigurations.value(id); + + bool changed = false; + + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } + + if (ptr->name != name) { + ptr->name = name; + changed = true; + } + + if (ptr->id != id) { + ptr->id = id; + changed = true; + } + + if (ptr->state != state) { + ptr->state = state; + changed = true; + } + + if (changed) + emit configurationChanged(ptr); + } else { + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + + ptr->name = name; + ptr->isValid = true; + ptr->id = id; + ptr->state = state; + ptr->type = QNetworkConfiguration::InternetAccessPoint; + ptr->bearer = qGetInterfaceType(interface.name()); + + accessPointConfigurations.insert(id, ptr); + configurationInterface.insert(id, interface.name()); + + emit configurationAdded(ptr); + } } - pollTimer.start(); - - return foundConfigurations; -} - -QString QGenericEngine::getInterfaceFromId(const QString &id) -{ - return configurationInterface.value(id.toUInt()); -} - -bool QGenericEngine::hasIdentifier(const QString &id) -{ - return configurationInterface.contains(id.toUInt()); -} + while (!previous.isEmpty()) { + QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = + accessPointConfigurations.take(previous.takeFirst()); -/*QString QGenericEngine::bearerName(const QString &id) -{ - QString interface = getInterfaceFromId(id); - - if (interface.isEmpty()) - return QLatin1String("Unknown"); - - return qGetInterfaceType(interface); -}*/ + configurationInterface.remove(ptr->id); + emit configurationRemoved(ptr); + } -void QGenericEngine::connectToId(const QString &id) -{ - emit connectionError(id, OperationNotSupported); -} + pollTimer.start(); -void QGenericEngine::disconnectFromId(const QString &id) -{ - emit connectionError(id, OperationNotSupported); + emit updateCompleted(); } -void QGenericEngine::requestUpdate() +QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id) { - emit configurationsChanged(); -} + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + return QNetworkSession::Connected; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } -QGenericEngine *QGenericEngine::instance() -{ - return genericEngine(); + return QNetworkSession::Invalid; } -#include "moc_qgenericengine_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qgenericengine_p.h b/src/plugins/bearer/generic/qgenericengine.h index 5c08aa2..a671ceb 100644 --- a/src/network/bearer/qgenericengine_p.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,26 +39,15 @@ ** ****************************************************************************/ -#ifndef QGENERICENGINE_P_H -#define QGENERICENGINE_P_H +#ifndef QGENERICENGINE_H +#define QGENERICENGINE_H -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qnetworksessionengine_p.h" +#include <QtNetwork/private/qnetworksessionengine_p.h> #include <QMap> #include <QTimer> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; @@ -70,25 +59,27 @@ public: QGenericEngine(QObject *parent = 0); ~QGenericEngine(); - QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0); QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - //QString bearerName(const QString &id); + QString bearerName(const QString &id); void connectToId(const QString &id); void disconnectFromId(const QString &id); void requestUpdate(); - static QGenericEngine *instance(); + QNetworkSession::State sessionStateForId(const QString &id); + +private Q_SLOTS: + void doRequestUpdate(); private: - QMap<uint, QString> configurationInterface; + QMap<QString, QString> configurationInterface; QTimer pollTimer; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp new file mode 100644 index 0000000..64ed73d --- /dev/null +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnativewifiengine.h" +#include "platformdefs.h" + +#include <QtCore/qmutex.h> +#include <QtCore/private/qmutexpool_p.h> +#include <QtCore/qlibrary.h> + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +static void resolveLibrary() +{ + static volatile bool triedResolve = false; + + if (!triedResolve) { +#ifndef QT_NO_THREAD + QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle)); +#endif + + if (!triedResolve) { + local_WlanOpenHandle = (WlanOpenHandleProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle"); + local_WlanRegisterNotification = (WlanRegisterNotificationProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification"); + local_WlanEnumInterfaces = (WlanEnumInterfacesProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces"); + local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList"); + local_WlanQueryInterface = (WlanQueryInterfaceProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface"); + local_WlanConnect = (WlanConnectProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect"); + local_WlanDisconnect = (WlanDisconnectProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect"); + local_WlanScan = (WlanScanProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan"); + local_WlanFreeMemory = (WlanFreeMemoryProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory"); + local_WlanCloseHandle = (WlanCloseHandleProto) + QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle"); + + triedResolve = true; + } + } +} + +class QNativeWifiEnginePlugin : public QBearerEnginePlugin +{ +public: + QNativeWifiEnginePlugin(); + ~QNativeWifiEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QNativeWifiEnginePlugin::QNativeWifiEnginePlugin() +{ +} + +QNativeWifiEnginePlugin::~QNativeWifiEnginePlugin() +{ +} + +QStringList QNativeWifiEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("nativewifi"); +} + +QBearerEngine *QNativeWifiEnginePlugin::create(const QString &key) const +{ + if (key != QLatin1String("nativewifi")) + return 0; + + resolveLibrary(); + + // native wifi dll not available + if (!local_WlanOpenHandle) + return 0; + + QNativeWifiEngine *engine = new QNativeWifiEngine; + + // could not initialise subsystem + if (engine && !engine->available()) { + delete engine; + return 0; + } + + return engine; +} + +Q_EXPORT_STATIC_PLUGIN(QNativeWifiEnginePlugin) +Q_EXPORT_PLUGIN2(qnativewifibearer, QNativeWifiEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro new file mode 100644 index 0000000..583edd4 --- /dev/null +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -0,0 +1,11 @@ +TARGET = qnativewifibearer +include(../../qpluginbase.pri) + +QT += network + +HEADERS += qnativewifiengine.h platformdefs.h +SOURCES += qnativewifiengine.cpp main.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/plugins/bearer/nativewifi/platformdefs.h b/src/plugins/bearer/nativewifi/platformdefs.h new file mode 100644 index 0000000..38fbae4 --- /dev/null +++ b/src/plugins/bearer/nativewifi/platformdefs.h @@ -0,0 +1,322 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PLATFORMDEFS_H +#define PLATFORMDEFS_H + +#include <wtypes.h> +#undef interface + +#define WLAN_MAX_NAME_LENGTH 256 +#define WLAN_MAX_PHY_TYPE_NUMBER 8 +#define WLAN_NOTIFICATION_SOURCE_ALL 0x0000ffff +#define WLAN_AVAILABLE_NETWORK_CONNECTED 1 +#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2 +#define DOT11_SSID_MAX_LENGTH 32 + +struct WLAN_NOTIFICATION_DATA { + DWORD NotificationSource; + DWORD NotificationCode; + GUID InterfaceGuid; + DWORD dwDataSize; + PVOID pData; +}; + +enum WLAN_INTERFACE_STATE { + wlan_interface_state_not_ready = 0, + wlan_interface_state_connected, + wlan_interface_state_ad_hoc_network_formed, + wlan_interface_state_disconnecting, + wlan_interface_state_disconnected, + wlan_interface_state_associating, + wlan_interface_state_discovering, + wlan_interface_state_authenticating +}; + +struct WLAN_INTERFACE_INFO { + GUID InterfaceGuid; + WCHAR strInterfaceDescription[WLAN_MAX_NAME_LENGTH]; + WLAN_INTERFACE_STATE isState; +}; + +struct WLAN_INTERFACE_INFO_LIST { + DWORD dwNumberOfItems; + DWORD dwIndex; + WLAN_INTERFACE_INFO InterfaceInfo[1]; +}; + +struct DOT11_SSID { + ULONG uSSIDLength; + UCHAR ucSSID[DOT11_SSID_MAX_LENGTH]; +}; + +struct NDIS_OBJECT_HEADER { + UCHAR Type; + UCHAR Revision; + USHORT Size; +}; + +typedef UCHAR DOT11_MAC_ADDRESS[6]; +struct DOT11_BSSID_LIST { + NDIS_OBJECT_HEADER Header; + ULONG uNumberOfEntries; + ULONG uTotalNumOfEntries; + DOT11_MAC_ADDRESS BSSIDs[1]; +}; + +enum DOT11_BSS_TYPE { + dot11_BSS_type_infrastructure = 1, + dot11_BSS_type_independent = 2, + dot11_BSS_type_any = 3 +}; + +enum DOT11_PHY_TYPE { + dot11_phy_type_unknown = 0, + dot11_phy_type_any = dot11_phy_type_unknown, + dot11_phy_type_fhss = 1, + dot11_phy_type_dsss = 2, + dot11_phy_type_irbaseband = 3, + dot11_phy_type_ofdm = 4, + dot11_phy_type_hrdsss = 5, + dot11_phy_type_erp = 6, + dot11_phy_type_ht = 7, + dot11_phy_type_IHV_start = 0x80000000, + dot11_phy_type_IHV_end = 0xffffffff +}; + +enum DOT11_AUTH_ALGORITHM { + DOT11_AUTH_ALGO_80211_OPEN = 1, + DOT11_AUTH_ALGO_80211_SHARED_KEY = 2, + DOT11_AUTH_ALGO_WPA = 3, + DOT11_AUTH_ALGO_WPA_PSK = 4, + DOT11_AUTH_ALGO_WPA_NONE = 5, + DOT11_AUTH_ALGO_RSNA = 6, + DOT11_AUTH_ALGO_RSNA_PSK = 7, + DOT11_AUTH_ALGO_IHV_START = 0x80000000, + DOT11_AUTH_ALGO_IHV_END = 0xffffffff +}; + +enum DOT11_CIPHER_ALGORITHM { + DOT11_CIPHER_ALGO_NONE = 0x00, + DOT11_CIPHER_ALGO_WEP40 = 0x01, + DOT11_CIPHER_ALGO_TKIP = 0x02, + DOT11_CIPHER_ALGO_CCMP = 0x04, + DOT11_CIPHER_ALGO_WEP104 = 0x05, + DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100, + DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100, + DOT11_CIPHER_ALGO_WEP = 0x101, + DOT11_CIPHER_ALGO_IHV_START = 0x80000000, + DOT11_CIPHER_ALGO_IHV_END = 0xffffffff +}; + +struct WLAN_AVAILABLE_NETWORK { + WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]; + DOT11_SSID dot11Ssid; + DOT11_BSS_TYPE dot11BssType; + ULONG uNumberOfBssids; + BOOL bNetworkConnectable; + DWORD wlanNotConnectableReason; + ULONG uNumberOfPhyTypes; + DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER]; + BOOL bMorePhyTypes; + ULONG wlanSignalQuality; + BOOL bSecurityEnabled; + DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm; + DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm; + DWORD dwFlags; + DWORD dwReserved; +}; + +struct WLAN_AVAILABLE_NETWORK_LIST { + DWORD dwNumberOfItems; + DWORD dwIndex; + WLAN_AVAILABLE_NETWORK Network[1]; +}; + +enum WLAN_INTF_OPCODE { + wlan_intf_opcode_autoconf_start = 0x000000000, + wlan_intf_opcode_autoconf_enabled, + wlan_intf_opcode_background_scan_enabled, + wlan_intf_opcode_media_streaming_mode, + wlan_intf_opcode_radio_state, + wlan_intf_opcode_bss_type, + wlan_intf_opcode_interface_state, + wlan_intf_opcode_current_connection, + wlan_intf_opcode_channel_number, + wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs, + wlan_intf_opcode_supported_adhoc_auth_cipher_pairs, + wlan_intf_opcode_supported_country_or_region_string_list, + wlan_intf_opcode_current_operation_mode, + wlan_intf_opcode_supported_safe_mode, + wlan_intf_opcode_certified_safe_mode, + wlan_intf_opcode_autoconf_end = 0x0fffffff, + wlan_intf_opcode_msm_start = 0x10000100, + wlan_intf_opcode_statistics, + wlan_intf_opcode_rssi, + wlan_intf_opcode_msm_end = 0x1fffffff, + wlan_intf_opcode_security_start = 0x20010000, + wlan_intf_opcode_security_end = 0x2fffffff, + wlan_intf_opcode_ihv_start = 0x30000000, + wlan_intf_opcode_ihv_end = 0x3fffffff +}; + +enum WLAN_OPCODE_VALUE_TYPE { + wlan_opcode_value_type_query_only = 0, + wlan_opcode_value_type_set_by_group_policy, + wlan_opcode_value_type_set_by_user, + wlan_opcode_value_type_invalid +}; + +enum WLAN_CONNECTION_MODE { + wlan_connection_mode_profile = 0, + wlan_connection_mode_temporary_profile, + wlan_connection_mode_discovery_secure, + wlan_connection_mode_discovery_unsecure, + wlan_connection_mode_auto, + wlan_connection_mode_invalid +}; + +struct WLAN_CONNECTION_PARAMETERS { + WLAN_CONNECTION_MODE wlanConnectionMode; + LPCWSTR strProfile; + DOT11_SSID *pDot11Ssid; + DOT11_BSSID_LIST *pDesiredBssidList; + DOT11_BSS_TYPE dot11BssType; + DWORD dwFlags; +}; + +struct WLAN_RAW_DATA { + DWORD dwDataSize; + BYTE DataBlob[1]; +}; + +enum WLAN_NOTIFICATION_ACM { + wlan_notification_acm_start = 0, + wlan_notification_acm_autoconf_enabled, + wlan_notification_acm_autoconf_disabled, + wlan_notification_acm_background_scan_enabled, + wlan_notification_acm_background_scan_disabled, + wlan_notification_acm_bss_type_change, + wlan_notification_acm_power_setting_change, + wlan_notification_acm_scan_complete, + wlan_notification_acm_scan_fail, + wlan_notification_acm_connection_start, + wlan_notification_acm_connection_complete, + wlan_notification_acm_connection_attempt_fail, + wlan_notification_acm_filter_list_change, + wlan_notification_acm_interface_arrival, + wlan_notification_acm_interface_removal, + wlan_notification_acm_profile_change, + wlan_notification_acm_profile_name_change, + wlan_notification_acm_profiles_exhausted, + wlan_notification_acm_network_not_available, + wlan_notification_acm_network_available, + wlan_notification_acm_disconnecting, + wlan_notification_acm_disconnected, + wlan_notification_acm_adhoc_network_state_change, + wlan_notification_acm_end +}; + +struct WLAN_ASSOCIATION_ATTRIBUTES { + DOT11_SSID dot11Ssid; + DOT11_BSS_TYPE dot11BssType; + DOT11_MAC_ADDRESS dot11Bssid; + DOT11_PHY_TYPE dot11PhyType; + ULONG uDot11PhyIndex; + ULONG wlanSignalQuality; + ULONG ulRxRate; + ULONG ulTxRate; +}; + +struct WLAN_SECURITY_ATTRIBUTES { + BOOL bSecurityEnabled; + BOOL bOneXEnabled; + DOT11_AUTH_ALGORITHM dot11AuthAlgorithm; + DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm; +}; + +struct WLAN_CONNECTION_ATTRIBUTES { + WLAN_INTERFACE_STATE isState; + WLAN_CONNECTION_MODE wlanConnectionMode; + WCHAR strProfileName[WLAN_MAX_NAME_LENGTH]; + WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes; + WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes; +}; + +typedef void (WINAPI *WLAN_NOTIFICATION_CALLBACK)(WLAN_NOTIFICATION_DATA *, PVOID); + +typedef DWORD (WINAPI *WlanOpenHandleProto) + (DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle); +typedef DWORD (WINAPI *WlanRegisterNotificationProto) + (HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate, + WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext, + PVOID pReserved, PDWORD pdwPrevNotifSource); +typedef DWORD (WINAPI *WlanEnumInterfacesProto) + (HANDLE hClientHandle, PVOID pReserved, WLAN_INTERFACE_INFO_LIST **ppInterfaceList); +typedef DWORD (WINAPI *WlanGetAvailableNetworkListProto) + (HANDLE hClientHandle, const GUID* pInterfaceGuid, DWORD dwFlags, PVOID pReserved, + WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList); +typedef DWORD (WINAPI *WlanQueryInterfaceProto) + (HANDLE hClientHandle, const GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved, + PDWORD pdwDataSize, PVOID *ppData, WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType); +typedef DWORD (WINAPI *WlanConnectProto) + (HANDLE hClientHandle, const GUID *pInterfaceGuid, + const WLAN_CONNECTION_PARAMETERS *pConnectionParameters, PVOID pReserved); +typedef DWORD (WINAPI *WlanDisconnectProto) + (HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved); +typedef DWORD (WINAPI *WlanScanProto) + (HANDLE hClientHandle, const GUID *pInterfaceGuid, const DOT11_SSID *pDot11Ssid, + const WLAN_RAW_DATA *pIeData, PVOID pReserved); +typedef VOID (WINAPI *WlanFreeMemoryProto)(PVOID pMemory); +typedef DWORD (WINAPI *WlanCloseHandleProto)(HANDLE hClientHandle, PVOID pReserved); + +extern WlanOpenHandleProto local_WlanOpenHandle; +extern WlanRegisterNotificationProto local_WlanRegisterNotification; +extern WlanEnumInterfacesProto local_WlanEnumInterfaces; +extern WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList; +extern WlanQueryInterfaceProto local_WlanQueryInterface; +extern WlanConnectProto local_WlanConnect; +extern WlanDisconnectProto local_WlanDisconnect; +extern WlanScanProto local_WlanScan; +extern WlanFreeMemoryProto local_WlanFreeMemory; +extern WlanCloseHandleProto local_WlanCloseHandle; + +#endif // PLATFORMDEFS_H diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp new file mode 100644 index 0000000..0050770 --- /dev/null +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -0,0 +1,464 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnativewifiengine.h" +#include "platformdefs.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> + +#include <QtCore/qstringlist.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +WlanOpenHandleProto local_WlanOpenHandle = 0; +WlanRegisterNotificationProto local_WlanRegisterNotification = 0; +WlanEnumInterfacesProto local_WlanEnumInterfaces = 0; +WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList = 0; +WlanQueryInterfaceProto local_WlanQueryInterface = 0; +WlanConnectProto local_WlanConnect = 0; +WlanDisconnectProto local_WlanDisconnect = 0; +WlanScanProto local_WlanScan = 0; +WlanFreeMemoryProto local_WlanFreeMemory = 0; +WlanCloseHandleProto local_WlanCloseHandle = 0; + +void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d) +{ + Q_UNUSED(d); + + switch (data->NotificationCode) { + case wlan_notification_acm_connection_complete: + case wlan_notification_acm_disconnected: + QMetaObject::invokeMethod(d, "scanComplete", Qt::QueuedConnection); + break; + default: + qDebug() << "wlan unknown notification"; + } +} + +QNativeWifiEngine::QNativeWifiEngine(QObject *parent) +: QNetworkSessionEngine(parent), handle(0) +{ + DWORD clientVersion; + + DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle); + if (result != ERROR_SUCCESS) { + if (result != ERROR_SERVICE_NOT_ACTIVE) + qWarning("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result); + + return; + } + + result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true, + WLAN_NOTIFICATION_CALLBACK(qNotificationCallback), + this, 0, 0); + if (result != ERROR_SUCCESS) + qWarning("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result); + + // On Windows XP SP2 and SP3 only connection and disconnection notifications are available. + // We need to poll for changes in available wireless networks. + connect(&pollTimer, SIGNAL(timeout()), this, SLOT(scanComplete())); + pollTimer.setInterval(10000); + scanComplete(); +} + +QNativeWifiEngine::~QNativeWifiEngine() +{ + local_WlanCloseHandle(handle, 0); +} + +void QNativeWifiEngine::scanComplete() +{ + QStringList previous = accessPointConfigurations.keys(); + + // enumerate interfaces + WLAN_INTERFACE_INFO_LIST *interfaceList; + DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); + return; + } + + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { + const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; + + WLAN_AVAILABLE_NETWORK_LIST *networkList; + result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, + 3, 0, &networkList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", + __FUNCTION__, result); + continue; + } + + QStringList seenNetworks; + + for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { + WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; + + QString networkName; + + if (network.strProfileName[0] != 0) { + networkName = QString::fromWCharArray(network.strProfileName); + } else { + networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), + network.dot11Ssid.uSSIDLength); + } + + const QString id = QString::number(qHash(QLatin1String("WLAN:") + networkName)); + + previous.removeAll(id); + + QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; + + if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE)) + state = QNetworkConfiguration::Undefined; + + if (network.strProfileName[0] != 0) { + if (network.bNetworkConnectable) { + if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED) + state = QNetworkConfiguration::Active; + else + state = QNetworkConfiguration::Discovered; + } else { + state = QNetworkConfiguration::Defined; + } + } + + if (seenNetworks.contains(networkName)) + continue; + else + seenNetworks.append(networkName); + + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + bool changed = false; + + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } + + if (ptr->name != networkName) { + ptr->name = networkName; + changed = true; + } + + if (ptr->state != state) { + ptr->state = state; + changed = true; + } + + if (changed) + emit configurationChanged(ptr); + } else { + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + + ptr->name = networkName; + ptr->isValid = true; + ptr->id = id; + ptr->state = state; + ptr->type = QNetworkConfiguration::InternetAccessPoint; + ptr->bearer = QLatin1String("WLAN"); + + accessPointConfigurations.insert(id, ptr); + + emit configurationAdded(ptr); + } + } + + local_WlanFreeMemory(networkList); + } + + local_WlanFreeMemory(interfaceList); + + while (!previous.isEmpty()) { + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.take(previous.takeFirst()); + + emit configurationRemoved(ptr); + } + + pollTimer.start(); + + emit updateCompleted(); +} + +QString QNativeWifiEngine::getInterfaceFromId(const QString &id) +{ + // enumerate interfaces + WLAN_INTERFACE_INFO_LIST *interfaceList; + DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); + return QString(); + } + + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { + const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; + + DWORD dataSize; + WLAN_CONNECTION_ATTRIBUTES *connectionAttributes; + result = local_WlanQueryInterface(handle, &interface.InterfaceGuid, + wlan_intf_opcode_current_connection, 0, &dataSize, + reinterpret_cast<PVOID *>(&connectionAttributes), 0); + if (result != ERROR_SUCCESS) { + if (result != ERROR_INVALID_STATE) + qWarning("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result); + + continue; + } + + if (qHash(QLatin1String("WLAN:") + + QString::fromWCharArray(connectionAttributes->strProfileName)) == id.toUInt()) { + QString guid("{%1-%2-%3-%4%5-%6%7%8%9%10%11}"); + + guid = guid.arg(interface.InterfaceGuid.Data1, 8, 16, QChar('0')); + guid = guid.arg(interface.InterfaceGuid.Data2, 4, 16, QChar('0')); + guid = guid.arg(interface.InterfaceGuid.Data3, 4, 16, QChar('0')); + for (int i = 0; i < 8; ++i) + guid = guid.arg(interface.InterfaceGuid.Data4[i], 2, 16, QChar('0')); + + local_WlanFreeMemory(connectionAttributes); + local_WlanFreeMemory(interfaceList); + + return guid.toUpper(); + } + + local_WlanFreeMemory(connectionAttributes); + } + + local_WlanFreeMemory(interfaceList); + + return QString(); +} + +bool QNativeWifiEngine::hasIdentifier(const QString &id) +{ + // enumerate interfaces + WLAN_INTERFACE_INFO_LIST *interfaceList; + DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); + return false; + } + + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { + const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; + + WLAN_AVAILABLE_NETWORK_LIST *networkList; + result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, + 3, 0, &networkList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", + __FUNCTION__, result); + continue; + } + + for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { + WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; + + QString networkName; + + if (network.strProfileName[0] != 0) { + networkName = QString::fromWCharArray(network.strProfileName); + } else { + networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), + network.dot11Ssid.uSSIDLength); + } + + if (qHash(QLatin1String("WLAN:") + networkName) == id.toUInt()) { + local_WlanFreeMemory(networkList); + local_WlanFreeMemory(interfaceList); + return true; + } + } + + local_WlanFreeMemory(networkList); + } + + local_WlanFreeMemory(interfaceList); + + return false; +} + +/*QString QNativeWifiEngine::bearerName(const QString &) +{ + return QLatin1String("WLAN"); +}*/ + +void QNativeWifiEngine::connectToId(const QString &id) +{ + WLAN_INTERFACE_INFO_LIST *interfaceList; + DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); + emit connectionError(id, InterfaceLookupError); + return; + } + + QString profile; + + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { + const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; + + WLAN_AVAILABLE_NETWORK_LIST *networkList; + result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, + 3, 0, &networkList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n", + __FUNCTION__, result); + continue; + } + + for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { + WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; + + profile = QString::fromWCharArray(network.strProfileName); + + if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt()) + break; + else + profile.clear(); + } + + local_WlanFreeMemory(networkList); + + if (!profile.isEmpty()) { + WLAN_CONNECTION_PARAMETERS parameters; + parameters.wlanConnectionMode = wlan_connection_mode_profile; + parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16()); + parameters.pDot11Ssid = 0; + parameters.pDesiredBssidList = 0; + parameters.dot11BssType = dot11_BSS_type_any; + parameters.dwFlags = 0; + + DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, ¶meters, 0); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result); + emit connectionError(id, ConnectError); + break; + } + + break; + } + } + + local_WlanFreeMemory(interfaceList); + + if (profile.isEmpty()) + emit connectionError(id, InterfaceLookupError); +} + +void QNativeWifiEngine::disconnectFromId(const QString &id) +{ + QString interface = getInterfaceFromId(id); + + if (interface.isEmpty()) { + emit connectionError(id, InterfaceLookupError); + return; + } + + QStringList split = interface.mid(1, interface.length() - 2).split('-'); + + GUID guid; + guid.Data1 = split.at(0).toUInt(0, 16); + guid.Data2 = split.at(1).toUShort(0, 16); + guid.Data3 = split.at(2).toUShort(0, 16); + guid.Data4[0] = split.at(3).left(2).toUShort(0, 16); + guid.Data4[1] = split.at(3).right(2).toUShort(0, 16); + for (int i = 0; i < 6; ++i) + guid.Data4[i + 2] = split.at(4).mid(i*2, 2).toUShort(0, 16); + + DWORD result = local_WlanDisconnect(handle, &guid, 0); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result); + emit connectionError(id, DisconnectionError); + return; + } +} + +void QNativeWifiEngine::requestUpdate() +{ + // enumerate interfaces + WLAN_INTERFACE_INFO_LIST *interfaceList; + DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); + if (result != ERROR_SUCCESS) { + qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); + return; + } + + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { + result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0); + if (result != ERROR_SUCCESS) + qWarning("%s: WlanScan failed with error %ld\n", __FUNCTION__, result); + } + + local_WlanFreeMemory(interfaceList); +} + +QNetworkSession::State QNativeWifiEngine::sessionStateForId(const QString &id) +{ + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + return QNetworkSession::Connected; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } + + return QNetworkSession::Invalid; +} + +QT_END_NAMESPACE diff --git a/src/network/bearer/qnativewifiengine_win_p.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h index e911746..511a6a4 100644 --- a/src/network/bearer/qnativewifiengine_win_p.h +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,13 +53,14 @@ // We mean it. // -#include "qnetworksessionengine_p.h" +#include <QtNetwork/private/qnetworksessionengine_p.h> #include <QtCore/qtimer.h> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; +struct WLAN_NOTIFICATION_DATA; class QNativeWifiEngine : public QNetworkSessionEngine { @@ -69,7 +70,6 @@ public: QNativeWifiEngine(QObject *parent = 0); ~QNativeWifiEngine(); - QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0); QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); @@ -80,9 +80,12 @@ public: void requestUpdate(); - inline void emitConfigurationsChanged() { emit configurationsChanged(); } + QNetworkSession::State sessionStateForId(const QString &id); - static QNativeWifiEngine *instance(); + inline bool available() const { return handle != 0; } + +public Q_SLOTS: + void scanComplete(); private: QTimer pollTimer; @@ -90,6 +93,6 @@ private: Qt::HANDLE handle; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp new file mode 100644 index 0000000..b561415 --- /dev/null +++ b/src/plugins/bearer/networkmanager/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnetworkmanagerengine.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QNetworkManagerEnginePlugin : public QBearerEnginePlugin +{ +public: + QNetworkManagerEnginePlugin(); + ~QNetworkManagerEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QNetworkManagerEnginePlugin::QNetworkManagerEnginePlugin() +{ +} + +QNetworkManagerEnginePlugin::~QNetworkManagerEnginePlugin() +{ +} + +QStringList QNetworkManagerEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("networkmanager"); +} + +QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("networkmanager")) + return new QNetworkManagerEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin) +Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro new file mode 100644 index 0000000..57f7ca7 --- /dev/null +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -0,0 +1,19 @@ +TARGET = qnmbearer +include(../../qpluginbase.pri) + +QT += network dbus + +DEFINES += BACKEND_NM + +HEADERS += qnmdbushelper.h \ + qnetworkmanagerservice.h \ + qnetworkmanagerengine.h + +SOURCES += main.cpp \ + qnmdbushelper.cpp \ + qnetworkmanagerservice.cpp \ + qnetworkmanagerengine.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp new file mode 100644 index 0000000..20dee1f --- /dev/null +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -0,0 +1,671 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnetworkmanagerengine.h" +#include "qnetworkmanagerservice.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> + +#include <QtNetwork/qnetworksession.h> + +#include <QtCore/qdebug.h> + +#include <NetworkManager/NetworkManager.h> +#include <QtDBus> +#include <QDBusConnection> +#include <QDBusError> +#include <QDBusInterface> +#include <QDBusMessage> +#include <QDBusReply> + +QT_BEGIN_NAMESPACE + +QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent) +: QNetworkSessionEngine(parent), + interface(new QNetworkManagerInterface(this)), + systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)), + userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this)) +{ + interface->setConnections(); + connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)), + this, SLOT(deviceAdded(QDBusObjectPath))); + connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)), + this, SLOT(deviceRemoved(QDBusObjectPath))); +#if 0 + connect(interface, SIGNAL(stateChanged(const QString,quint32)), + this, SIGNAL(configurationsChanged())); +#endif + connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), + this, SLOT(activationFinished(QDBusPendingCallWatcher*))); + connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), + this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>))); + + qDBusRegisterMetaType<QNmSettingsMap>(); + + systemSettings->setConnections(); + connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)), + this, SLOT(newConnection(QDBusObjectPath))); + + userSettings->setConnections(); + connect(userSettings, SIGNAL(newConnection(QDBusObjectPath)), + this, SLOT(newConnection(QDBusObjectPath))); + + // Get current list of access points. + foreach (const QDBusObjectPath &devicePath, interface->getDevices()) + deviceAdded(devicePath); + + // Get connections. + foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) + newConnection(settingsPath, systemSettings); + foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) + newConnection(settingsPath, userSettings); + + // Get active connections. + foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { + QNetworkManagerConnectionActive *activeConnection = + new QNetworkManagerConnectionActive(acPath.path()); + activeConnections.insert(acPath.path(), activeConnection); + + activeConnection->setConnections(); + connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), + this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>))); + } +} + +QNetworkManagerEngine::~QNetworkManagerEngine() +{ +} + +void QNetworkManagerEngine::doRequestUpdate() +{ + emit updateCompleted(); +} + +QString QNetworkManagerEngine::getInterfaceFromId(const QString &id) +{ + foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { + QNetworkManagerConnectionActive activeConnection(acPath.path()); + + const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' + + activeConnection.connection().path())); + + if (id == identifier) { + QList<QDBusObjectPath> devices = activeConnection.devices(); + + if (devices.isEmpty()) + continue; + + if (devices.count() > 1) + qDebug() << "multiple network interfaces for" << id; + + QNetworkManagerInterfaceDevice device(devices.at(0).path()); + return device.interface().name(); + } + } + + return QString(); +} + +bool QNetworkManagerEngine::hasIdentifier(const QString &id) +{ + if (connectionFromId(id)) + return true; + + for (int i = 0; i < accessPoints.count(); ++i) { + QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); + + const QString identifier = + QString::number(qHash(accessPoint->connectionInterface()->path())); + + if (id == identifier) + return true; + } + + return false; +} + +QString QNetworkManagerEngine::bearerName(const QString &id) +{ + QNetworkManagerSettingsConnection *connection = connectionFromId(id); + + if (!connection) + return QString(); + + QNmSettingsMap map = connection->getSettings(); + const QString connectionType = map.value("connection").value("type").toString(); + + if (connectionType == "802-3-ethernet") + return QLatin1String("Ethernet"); + else if (connectionType == "802-11-wireless") + return QLatin1String("WLAN"); + else if (connectionType == "gsm") + return QLatin1String("2G"); + else if (connectionType == "cdma") + return QLatin1String("CDMA2000"); + else + return QString(); +} + +void QNetworkManagerEngine::connectToId(const QString &id) +{ + QNetworkManagerSettingsConnection *connection = connectionFromId(id); + + if (!connection) + return; + + QNmSettingsMap map = connection->getSettings(); + const QString connectionType = map.value("connection").value("type").toString(); + + QString dbusDevicePath; + foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { + QNetworkManagerInterfaceDevice device(devicePath.path()); + if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET && + connectionType == QLatin1String("802-3-ethernet")) { + dbusDevicePath = devicePath.path(); + break; + } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS && + connectionType == QLatin1String("802-11-wireless")) { + dbusDevicePath = devicePath.path(); + break; + } + } + + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + + interface->activateConnection(service, QDBusObjectPath(settingsPath), + QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/")); +} + +void QNetworkManagerEngine::disconnectFromId(const QString &id) +{ + foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { + QNetworkManagerConnectionActive activeConnection(acPath.path()); + + const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' + + activeConnection.connection().path())); + + if (id == identifier && accessPointConfigurations.contains(id)) { + interface->deactivateConnection(acPath); + break; + } + } +} + +void QNetworkManagerEngine::requestUpdate() +{ + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); +} + +void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties) +{ + QMapIterator<QString, QVariant> i(properties); + while (i.hasNext()) { + i.next(); + + if (i.key() == QLatin1String("ActiveConnections")) { + // Active connections changed, update configurations. + + QList<QDBusObjectPath> activeConnections = + qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>()); + + QStringList identifiers = accessPointConfigurations.keys(); + foreach (const QString &id, identifiers) + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + QStringList priorActiveConnections = this->activeConnections.keys(); + + foreach (const QDBusObjectPath &acPath, activeConnections) { + priorActiveConnections.removeOne(acPath.path()); + QNetworkManagerConnectionActive *activeConnection = + this->activeConnections.value(acPath.path()); + if (!activeConnection) { + activeConnection = new QNetworkManagerConnectionActive(acPath.path()); + this->activeConnections.insert(acPath.path(), activeConnection); + + activeConnection->setConnections(); + connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), + this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>))); + } + + const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' + + activeConnection->connection().path())); + + identifiers.removeOne(id); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + if (ptr) { + if (activeConnection->state() == 2 && + ptr->state != QNetworkConfiguration::Active) { + ptr->state = QNetworkConfiguration::Active; + emit configurationChanged(ptr); + } + } + } + + while (!priorActiveConnections.isEmpty()) + delete this->activeConnections.take(priorActiveConnections.takeFirst()); + + while (!identifiers.isEmpty()) { + // These configurations are not active + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.value(identifiers.takeFirst()); + + if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + ptr->state = QNetworkConfiguration::Discovered; + emit configurationChanged(ptr); + } + } + } + } +} + +void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties) +{ + QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path); + + if (!activeConnection) + return; + + const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' + + activeConnection->connection().path())); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + if (ptr) { + if (activeConnection->state() == 2 && + ptr->state != QNetworkConfiguration::Active) { + ptr->state = QNetworkConfiguration::Active; + emit configurationChanged(ptr); + } + } +} + +void QNetworkManagerEngine::devicePropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties) +{ + qDebug() << Q_FUNC_INFO << path; + qDebug() << properties; +} + +void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) +{ + QNetworkManagerInterfaceDevice device(path.path()); + if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) { + QNetworkManagerInterfaceDeviceWireless *wirelessDevice = + new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path()); + wirelessDevices.insert(path.path(), wirelessDevice); + + wirelessDevice->setConnections(); + connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)), + this, SLOT(newAccessPoint(QString,QDBusObjectPath))); + connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)), + this, SLOT(removeAccessPoint(QString,QDBusObjectPath))); + connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), + this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>))); + + foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints()) + newAccessPoint(QString(), apPath); + } +} + +void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path) +{ + delete wirelessDevices.value(path.path()); +} + +void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, + QNetworkManagerSettings *settings) +{ + if (!settings) + settings = qobject_cast<QNetworkManagerSettings *>(sender()); + + if (!settings) + return; + + QNetworkManagerSettingsConnection *connection = + new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(), + path.path()); + connections.append(connection); + + connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString))); + connect(connection, SIGNAL(updated(const QNmSettingsMap&)), + this, SLOT(updateConnection(const QNmSettingsMap&))); + + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + + QNetworkConfigurationPrivate *cpPriv = + parseConnection(service, settingsPath, connection->getSettings()); + + // Check if connection is active. + foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { + QNetworkManagerConnectionActive activeConnection(acPath.path()); + + if (activeConnection.serviceName() == service && + activeConnection.connection().path() == settingsPath && + activeConnection.state() == 2) { + cpPriv->state |= QNetworkConfiguration::Active; + break; + } + } + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + emit configurationAdded(ptr); +} + +void QNetworkManagerEngine::removeConnection(const QString &path) +{ + QNetworkManagerSettingsConnection *connection = + qobject_cast<QNetworkManagerSettingsConnection *>(sender()); + if (!connection) + return; + + connections.removeAll(connection); + + const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' + + connection->connectionInterface()->path())); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); + ptr->isValid = false; + emit configurationRemoved(ptr); +} + +void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings) +{ + QNetworkManagerSettingsConnection *connection = + qobject_cast<QNetworkManagerSettingsConnection *>(sender()); + if (!connection) + return; + + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + + qDebug() << "Should parse connection directly into existing configuration"; + QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings); + + // Check if connection is active. + foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { + QNetworkManagerConnectionActive activeConnection(acPath.path()); + + if (activeConnection.serviceName() == service && + activeConnection.connection().path() == settingsPath && + activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { + cpPriv->state |= QNetworkConfiguration::Active; + break; + } + } + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id); + + ptr->isValid = cpPriv->isValid; + ptr->name = cpPriv->name; + ptr->id = cpPriv->id; + ptr->state = cpPriv->state; + + emit configurationChanged(ptr); + delete cpPriv; +} + +void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher) +{ + QDBusPendingReply<QDBusObjectPath> reply = *watcher; + if (reply.isError()) { + qDebug() << "error connecting NM connection"; + } else { + QDBusObjectPath result = reply.value(); + + QNetworkManagerConnectionActive activeConnection(result.path()); + + const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' + + activeConnection.connection().path())); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + if (ptr) { + if (activeConnection.state() == 2 && + ptr->state != QNetworkConfiguration::Active) { + ptr->state = QNetworkConfiguration::Active; + emit configurationChanged(ptr); + } + } + } +} + +void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath) +{ + QNetworkManagerInterfaceAccessPoint *accessPoint = + new QNetworkManagerInterfaceAccessPoint(objectPath.path()); + accessPoints.append(accessPoint); + + accessPoint->setConnections(); + connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), + this, SLOT(updateAccessPoint(QMap<QString,QVariant>))); + + // Check if configuration for this SSID already exists. + for (int i = 0; i < accessPoints.count(); ++i) { + if (accessPoint != accessPoints.at(i) && + accessPoint->ssid() == accessPoints.at(i)->ssid()) { + return; + } + } + + // Check if configuration exists for connection. + for (int i = 0; i < connections.count(); ++i) { + QNetworkManagerSettingsConnection *connection = connections.at(i); + + if (accessPoint->ssid() == connection->getSsid()) { + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); + + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.value(connectionId); + ptr->state = QNetworkConfiguration::Discovered; + emit configurationChanged(ptr); + return; + } + } + + // New access point. + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + + ptr->name = accessPoint->ssid(); + ptr->isValid = true; + ptr->id = QString::number(qHash(objectPath.path())); + ptr->type = QNetworkConfiguration::InternetAccessPoint; + ptr->purpose = QNetworkConfiguration::PublicPurpose; + ptr->state = QNetworkConfiguration::Undefined; + ptr->bearer = QLatin1String("WLAN"); + + accessPointConfigurations.insert(ptr->id, ptr); + emit configurationAdded(ptr); +} + +void QNetworkManagerEngine::removeAccessPoint(const QString &path, + const QDBusObjectPath &objectPath) +{ + for (int i = 0; i < accessPoints.count(); ++i) { + QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); + + if (accessPoint->connectionInterface()->path() == objectPath.path()) { + accessPoints.removeOne(accessPoint); + + if (configuredAccessPoints.contains(accessPoint)) { + // find connection and change state to Defined + configuredAccessPoints.removeOne(accessPoint); + qDebug() << "At least one connection is no longer discovered."; + } else { + // emit configurationRemoved(cpPriv); + qDebug() << "An unconfigured wifi access point was removed."; + } + + break; + } + } +} + +void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map) +{ + QNetworkManagerInterfaceAccessPoint *accessPoint = + qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender()); + if (!accessPoint) + return; + + qDebug() << "update access point" << accessPoint; +} + +QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service, + const QString &settingsPath, + const QNmSettingsMap &map) +{ + QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate; + cpPriv->name = map.value("connection").value("id").toString(); + cpPriv->isValid = true; + cpPriv->id = QString::number(qHash(service + ' ' + settingsPath)); + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + + cpPriv->state = QNetworkConfiguration::Defined; + + const QString connectionType = map.value("connection").value("type").toString(); + + if (connectionType == QLatin1String("802-3-ethernet")) { + cpPriv->bearer = QLatin1String("Ethernet"); + + foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { + QNetworkManagerInterfaceDevice device(devicePath.path()); + if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) { + QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path()); + if (wiredDevice.carrier()) { + cpPriv->state |= QNetworkConfiguration::Discovered; + break; + } + + } + } + } else if (connectionType == QLatin1String("802-11-wireless")) { + cpPriv->bearer = QLatin1String("WLAN"); + + const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString(); + + for (int i = 0; i < accessPoints.count(); ++i) { + if (connectionSsid == accessPoints.at(i)->ssid()) { + cpPriv->state |= QNetworkConfiguration::Discovered; + if (!configuredAccessPoints.contains(accessPoints.at(i))) { + configuredAccessPoints.append(accessPoints.at(i)); + + const QString accessPointId = + QString::number(qHash(accessPoints.at(i)->connectionInterface()->path())); + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.take(accessPointId); + emit configurationRemoved(ptr); + } + break; + } + } + } else if (connectionType == "gsm") { + cpPriv->bearer = QLatin1String("2G"); + } else if (connectionType == "cdma") { + cpPriv->bearer = QLatin1String("CDMA2000"); + } + + return cpPriv; +} + +QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const +{ + for (int i = 0; i < connections.count(); ++i) { + QNetworkManagerSettingsConnection *connection = connections.at(i); + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + + const QString identifier = QString::number(qHash(service + ' ' + settingsPath)); + + if (id == identifier) + return connection; + } + + return 0; +} + +QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id) +{ + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) + return QNetworkSession::Invalid; + + foreach (const QString &acPath, activeConnections.keys()) { + QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath); + + const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' + + activeConnection->connection().path())); + + if (id == identifier) { + switch (activeConnection->state()) { + case 0: + return QNetworkSession::Disconnected; + case 1: + return QNetworkSession::Connecting; + case 2: + return QNetworkSession::Connected; + } + } + } + + if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) + return QNetworkSession::Disconnected; + else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) + return QNetworkSession::NotAvailable; + else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined) + return QNetworkSession::NotAvailable; + + return QNetworkSession::Invalid; +} + +QT_END_NAMESPACE + diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h new file mode 100644 index 0000000..1636c91 --- /dev/null +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETWORKMANAGERENGINE_P_H +#define QNETWORKMANAGERENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qnetworksessionengine_p.h> + +#include "qnetworkmanagerservice.h" + +#include <QMap> +#include <QVariant> + +QT_BEGIN_NAMESPACE + +class QNetworkManagerEngine : public QNetworkSessionEngine +{ + Q_OBJECT + +public: + QNetworkManagerEngine(QObject *parent = 0); + ~QNetworkManagerEngine(); + + QString getInterfaceFromId(const QString &id); + bool hasIdentifier(const QString &id); + + QString bearerName(const QString &id); + + void connectToId(const QString &id); + void disconnectFromId(const QString &id); + + void requestUpdate(); + + QNetworkSession::State sessionStateForId(const QString &id); + +private Q_SLOTS: + void interfacePropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties); + void activeConnectionPropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties); + void devicePropertiesChanged(const QString &path, + const QMap<QString, QVariant> &properties); + + void deviceAdded(const QDBusObjectPath &path); + void deviceRemoved(const QDBusObjectPath &path); + + void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0); + void removeConnection(const QString &path); + void updateConnection(const QNmSettingsMap &settings); + void activationFinished(QDBusPendingCallWatcher *watcher); + + void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath); + void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath); + void updateAccessPoint(const QMap<QString, QVariant> &map); + + void doRequestUpdate(); + +private: + QNetworkConfigurationPrivate *parseConnection(const QString &service, + const QString &settingsPath, + const QNmSettingsMap &map); + QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const; + +private: + QNetworkManagerInterface *interface; + QNetworkManagerSettings *systemSettings; + QNetworkManagerSettings *userSettings; + QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices; + QHash<QString, QNetworkManagerConnectionActive *> activeConnections; + QList<QNetworkManagerSettingsConnection *> connections; + QList<QNetworkManagerInterfaceAccessPoint *> accessPoints; + QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/network/bearer/qnetworkmanagerservice_p.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 5804686..3843f27 100644 --- a/src/network/bearer/qnetworkmanagerservice_p.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,11 +53,11 @@ #include <NetworkManager/NetworkManager.h> -#include <qnmdbushelper_p.h> -#include "qnetworkmanagerservice_p.h" +#include "qnmdbushelper.h" +#include "qnetworkmanagerservice.h" //Q_DECLARE_METATYPE(QList<uint>) -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE static QDBusConnection dbusConnection = QDBusConnection::systemBus(); //static QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbusConnection); @@ -718,9 +718,12 @@ bool QNetworkManagerSettingsConnection::setConnections() bool allOk = false; if(!dbusConnection.connect(d->service, d->path, - NM_DBUS_IFACE_SETTINGS_CONNECTION, "NewConnection", + NM_DBUS_IFACE_SETTINGS_CONNECTION, "Updated", this, SIGNAL(updated(QNmSettingsMap)))) { allOk = true; + } else { + QDBusError error = dbusConnection.lastError(); + qDebug() << error.name() << error.message() << error.type(); } if (nmDBusHelper) @@ -1042,6 +1045,4 @@ QStringList QNetworkManagerIp4Config::domains() const return d->connectionInterface->property("Domains").toStringList(); } -#include "moc_qnetworkmanagerservice_p.cpp" - -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkmanagerservice_p.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index 8569e71..dbed01e 100644 --- a/src/network/bearer/qnetworkmanagerservice_p.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -64,19 +64,16 @@ #include <QDBusPendingCallWatcher> -#include <qnmdbushelper_p.h> +#include "qnmdbushelper.h" +QT_BEGIN_NAMESPACE -QTM_BEGIN_NAMESPACE typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap; typedef QList<quint32> ServerThing; -QTM_END_NAMESPACE -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsMap)) -Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(ServerThing)) +Q_DECLARE_METATYPE(QNmSettingsMap) +Q_DECLARE_METATYPE(ServerThing) - -QTM_BEGIN_NAMESPACE class QNetworkManagerInterfacePrivate; class QNetworkManagerInterface : public QObject { @@ -332,8 +329,8 @@ public: Q_SIGNALS: - void updated(QMap< QString, QMap<QString,QVariant> > s); - void removed(const QString &); + void updated(const QNmSettingsMap &settings); + void removed(const QString &path); private: QNmDBusHelper *nmDBusHelper; @@ -395,6 +392,6 @@ public: }; //// -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif //QNETWORKMANAGERSERVICE_H diff --git a/src/network/bearer/qnmdbushelper.cpp b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp index 3b780f6..f93a63d 100644 --- a/src/network/bearer/qnmdbushelper.cpp +++ b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -41,20 +41,18 @@ // this class is for helping qdbus get stuff -#include "qnmdbushelper_p.h" +#include "qnmdbushelper.h" -#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC) #include <NetworkManager/NetworkManager.h> #include <QDBusError> #include <QDBusInterface> #include <QDBusMessage> #include <QDBusReply> -#endif #include <QDebug> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE void QNmDBusHelper::deviceStateChanged(quint32 state) { @@ -98,11 +96,14 @@ void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map) emit pathForPropertiesChanged( msg.path(), map); } } else if( i.key() == "ActiveAccessPoint") { + emit pathForPropertiesChanged(msg.path(), map); // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path(); // } else if( i.key() == "Strength") // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt(); // else // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value(); + } else if (i.key() == "ActiveConnections") { + emit pathForPropertiesChanged(msg.path(), map); } } } @@ -113,5 +114,4 @@ void QNmDBusHelper::slotSettingsRemoved() emit pathForSettingsRemoved(msg.path()); } -#include "moc_qnmdbushelper_p.cpp" -QTM_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/network/bearer/qnmdbushelper_p.h b/src/plugins/bearer/networkmanager/qnmdbushelper.h index f0248dc..410b69f 100644 --- a/src/network/bearer/qnmdbushelper_p.h +++ b/src/plugins/bearer/networkmanager/qnmdbushelper.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,27 +42,11 @@ #ifndef QNMDBUSHELPERPRIVATE_H #define QNMDBUSHELPERPRIVATE_H -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <qmobilityglobal.h> -#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC) #include <QDBusObjectPath> #include <QDBusContext> #include <QMap> -#endif - -QTM_BEGIN_NAMESPACE -#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC) +QT_BEGIN_NAMESPACE class QNmDBusHelper: public QObject, protected QDBusContext { @@ -83,8 +67,7 @@ Q_SIGNALS: void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>); void pathForSettingsRemoved(const QString &); }; -#endif -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif// QNMDBUSHELPERPRIVATE_H diff --git a/src/plugins/bearer/nla/main.cpp b/src/plugins/bearer/nla/main.cpp new file mode 100644 index 0000000..541d2c5 --- /dev/null +++ b/src/plugins/bearer/nla/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnlaengine.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QNlaEnginePlugin : public QBearerEnginePlugin +{ +public: + QNlaEnginePlugin(); + ~QNlaEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QNlaEnginePlugin::QNlaEnginePlugin() +{ +} + +QNlaEnginePlugin::~QNlaEnginePlugin() +{ +} + +QStringList QNlaEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("nla"); +} + +QBearerEngine *QNlaEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("nla")) + return new QNlaEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QNlaEnginePlugin) +Q_EXPORT_PLUGIN2(qnlabearer, QNlaEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro new file mode 100644 index 0000000..62a920a --- /dev/null +++ b/src/plugins/bearer/nla/nla.pro @@ -0,0 +1,18 @@ +TARGET = qnlabearer +include(../../qpluginbase.pri) + +QT += network + +!wince* { + LIBS += -lWs2_32 +} else { + LIBS += -lWs2 +} + +HEADERS += qnlaengine.h \ + ../platformdefs_win.h +SOURCES += qnlaengine.cpp main.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/network/bearer/qnlaengine_win.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index a3f6017..be1cd28 100644 --- a/src/network/bearer/qnlaengine_win.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qnlaengine_win_p.h" -#include "qnetworkconfiguration_p.h" +#include "qnlaengine.h" +#include <QtNetwork/private/qnetworkconfiguration_p.h> #include <QtCore/qthread.h> #include <QtCore/qmutex.h> @@ -49,13 +49,11 @@ #include <QtCore/qdebug.h> -#include "qnetworksessionengine_win_p.h" +#include "../platformdefs_win.h" -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QNlaEngine, nlaEngine) - -QWindowsSockInit::QWindowsSockInit() +QWindowsSockInit2::QWindowsSockInit2() : version(0) { //### should we try for 2.2 on all platforms ?? @@ -69,7 +67,7 @@ QWindowsSockInit::QWindowsSockInit() } } -QWindowsSockInit::~QWindowsSockInit() +QWindowsSockInit2::~QWindowsSockInit2() { WSACleanup(); } @@ -130,8 +128,8 @@ static QString qGetInterfaceType(const QString &interface) NDIS_MEDIUM medium; NDIS_PHYSICAL_MEDIUM physicalMedium; - HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0, - FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + HANDLE handle = CreateFile((TCHAR *)QString(QLatin1String("\\\\.\\%1")).arg(interface).utf16(), + 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (handle == INVALID_HANDLE_VALUE) return QLatin1String("Unknown"); @@ -240,24 +238,8 @@ QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations() { QMutexLocker locker(&mutex); - QList<QNetworkConfigurationPrivate *> foundConfigurations; - - for (int i = 0; i < fetchedConfigurations.count(); ++i) { - QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate; - config->name = fetchedConfigurations.at(i)->name; - config->isValid = fetchedConfigurations.at(i)->isValid; - config->id = fetchedConfigurations.at(i)->id; - config->state = fetchedConfigurations.at(i)->state; - config->type = fetchedConfigurations.at(i)->type; - config->roamingSupported = fetchedConfigurations.at(i)->roamingSupported; - config->purpose = fetchedConfigurations.at(i)->purpose; - config->internet = fetchedConfigurations.at(i)->internet; - if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) { - config->bearer = engine->bearerName(config->id); - } - - foundConfigurations.append(config); - } + QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations; + fetchedConfigurations.clear(); return foundConfigurations; } @@ -329,7 +311,10 @@ void QNlaThread::run() #ifndef Q_OS_WINCE // Not interested in unrelated IO completion events // although we also don't want to block them - while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION) {} + while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION && + handle) + { + } #else WaitForSingleObject(changeEvent, WSA_INFINITE); #endif @@ -380,7 +365,7 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv cpPriv->state = QNetworkConfiguration::Active; if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) { engine->configurationInterface[cpPriv->id.toUInt()] = - QString(blob->data.interfaceData.adapterName); + QString::fromLatin1(blob->data.interfaceData.adapterName); } break; case NLA_802_1X_LOCATION: @@ -421,6 +406,8 @@ QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *query cpPriv->id = QString::number(qHash(QLatin1String("NLA:") + cpPriv->name)); cpPriv->state = QNetworkConfiguration::Defined; cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) + config->bearer = engine->bearerName(config->id); #ifdef BEARER_MANAGEMENT_DEBUG qDebug() << "size:" << querySet->dwSize; @@ -520,7 +507,7 @@ QNlaEngine::QNlaEngine(QObject *parent) { nlaThread = new QNlaThread(this); connect(nlaThread, SIGNAL(networksChanged()), - this, SIGNAL(configurationsChanged())); + this, SLOT(networksChanged())); nlaThread->start(); qApp->processEvents(QEventLoop::ExcludeUserInputEvents); @@ -531,12 +518,57 @@ QNlaEngine::~QNlaEngine() delete nlaThread; } -QList<QNetworkConfigurationPrivate *> QNlaEngine::getConfigurations(bool *ok) +void QNlaEngine::networksChanged() { - if (ok) - *ok = true; + QStringList previous = accessPointConfigurations.keys(); + + QList<QNetworkConfigurationPrivate *> foundConfigurations = nlaThread->getConfigurations(); + while (!foundConfigurations.isEmpty()) { + QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst(); - return nlaThread->getConfigurations(); + previous.removeAll(cpPriv->id); + + if (accessPointConfigurations.contains(cpPriv->id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id); + + bool changed = false; + + if (ptr->isValid != cpPriv->isValid) { + ptr->isValid = cpPriv->isValid; + changed = true; + } + + if (ptr->name != cpPriv->name) { + ptr->name = cpPriv->name; + changed = true; + } + + if (ptr->state != cpPriv->state) { + ptr->state = cpPriv->state; + changed = true; + } + + if (changed) + emit configurationChanged(ptr); + + delete cpPriv; + } else { + QNetworkConfigurationPrivatePointer ptr(cpPriv); + + accessPointConfigurations.insert(ptr->id, ptr); + + emit configurationAdded(ptr); + } + } + + while (!previous.isEmpty()) { + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.take(previous.takeFirst()); + + emit configurationRemoved(ptr); + } + + emit updateCompleted(); } QString QNlaEngine::getInterfaceFromId(const QString &id) @@ -546,20 +578,7 @@ QString QNlaEngine::getInterfaceFromId(const QString &id) bool QNlaEngine::hasIdentifier(const QString &id) { - if (configurationInterface.contains(id.toUInt())) - return true; - - bool result = false; - QList<QNetworkConfigurationPrivate *> l = nlaThread->getConfigurations(); - while (!l.isEmpty()) { - QNetworkConfigurationPrivate* cpPriv = l.takeFirst(); - if (!result && cpPriv->id == id) { - result = true; - } - delete cpPriv; - } - - return result; + return configurationInterface.contains(id.toUInt()); } QString QNlaEngine::bearerName(const QString &id) @@ -587,14 +606,30 @@ void QNlaEngine::requestUpdate() nlaThread->forceUpdate(); } -QNlaEngine *QNlaEngine::instance() +QNetworkSession::State QNlaEngine::sessionStateForId(const QString &id) { - return nlaEngine(); -} - -#include "qnlaengine_win.moc" -#include "moc_qnlaengine_win_p.cpp" -QTM_END_NAMESPACE + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + return QNetworkSession::Connected; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } + return QNetworkSession::Invalid; +} +#include "qnlaengine.moc" +QT_END_NAMESPACE diff --git a/src/network/bearer/qnlaengine_win_p.h b/src/plugins/bearer/nla/qnlaengine.h index 394b8cf..dd038d1 100644 --- a/src/network/bearer/qnlaengine_win_p.h +++ b/src/plugins/bearer/nla/qnlaengine.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,20 +53,21 @@ // We mean it. // -#include "qnetworksessionengine_p.h" +#include <QtNetwork/private/qnetworksessionengine_p.h> +#include <QtNetwork/private/qnativesocketengine_p.h> #include <QMap> -QTM_BEGIN_NAMESPACE +QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; class QNlaThread; -class QWindowsSockInit +class QWindowsSockInit2 { public: - QWindowsSockInit(); - ~QWindowsSockInit(); + QWindowsSockInit2(); + ~QWindowsSockInit2(); int version; }; @@ -80,7 +81,6 @@ public: QNlaEngine(QObject *parent = 0); ~QNlaEngine(); - QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0); QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); @@ -91,14 +91,17 @@ public: void requestUpdate(); - static QNlaEngine *instance(); + QNetworkSession::State sessionStateForId(const QString &id); + +private Q_SLOTS: + void networksChanged(); private: - QWindowsSockInit winSock; + QWindowsSockInit2 winSock; QNlaThread *nlaThread; QMap<uint, QString> configurationInterface; }; -QTM_END_NAMESPACE +QT_END_NAMESPACE #endif diff --git a/src/network/bearer/qnetworksessionengine_win_p.h b/src/plugins/bearer/platformdefs_win.h index cf01719..f2f44a1 100644 --- a/src/network/bearer/qnetworksessionengine_win_p.h +++ b/src/plugins/bearer/platformdefs_win.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,19 +39,8 @@ ** ****************************************************************************/ -#ifndef QNETWORKSESSIONENGINE_WIN_P_H -#define QNETWORKSESSIONENGINE_WIN_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#ifndef QPLATFORMDEFS_WIN_H +#define QPLATFORMDEFS_WIN_H #include <winsock2.h> #include <mswsock.h> @@ -142,4 +131,4 @@ enum NDIS_PHYSICAL_MEDIUM { #define IOCTL_NDIS_QUERY_GLOBAL_STATS \ CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, 0, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) -#endif // QNETWORKSESSIONENGINE_WIN_P_H +#endif diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 004b816..d6a426f 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS *= accessible imageformats sqldrivers iconengines script +SUBDIRS *= accessible imageformats sqldrivers iconengines script bearer unix:!symbian { contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv):SUBDIRS *= codecs } else { diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d5d72a7..176cc3a 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -434,7 +434,10 @@ SUBDIRS += \ qmargins \ qnetworkaddressentry \ qnetworkcachemetadata \ + qnetworkconfigmanager \ + qnetworkconfiguration \ qnetworkdiskcache \ + qnetworksession \ qobjectperformance \ qpainterpathstroker \ qplugin \ diff --git a/tests/auto/qbearertestcommon.h b/tests/auto/qbearertestcommon.h index 3356bd6..0bfe622 100644 --- a/tests/auto/qbearertestcommon.h +++ b/tests/auto/qbearertestcommon.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro b/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro index bdd4926..05d17f1 100644 --- a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro +++ b/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro @@ -1,16 +1,9 @@ +load(qttest_p4) SOURCES += tst_qnetworkconfigmanager.cpp HEADERS += ../qbearertestcommon.h -TARGET = tst_qnetworkconfigurationmanager -CONFIG += testcase QT = core network -INCLUDEPATH += ../../../src/bearer - -include(../../../common.pri) -CONFIG += mobility -MOBILITY = bearer - symbian { TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData } diff --git a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp index 6ab0e6f..3052330 100644 --- a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp +++ b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -49,7 +49,7 @@ #include <iapconf.h> #endif -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class tst_QNetworkConfigurationManager : public QObject { Q_OBJECT diff --git a/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro b/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro index c5a08b3..ce11cc7 100644 --- a/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro +++ b/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro @@ -1,16 +1,9 @@ +load(qttest_p4) SOURCES += tst_qnetworkconfiguration.cpp HEADERS += ../qbearertestcommon.h -TARGET = tst_qnetworkconfiguration -CONFIG += testcase QT = core network -INCLUDEPATH += ../../../src/bearer - -include(../../../common.pri) -CONFIG += mobility -MOBILITY = bearer - symbian { TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData } diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index e929a61..70f4447 100644 --- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -49,7 +49,7 @@ #include <iapconf.h> #endif -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class tst_QNetworkConfiguration : public QObject { Q_OBJECT diff --git a/tests/auto/qnetworksession/lackey/lackey.pro b/tests/auto/qnetworksession/lackey/lackey.pro index b8a006b..6cc1b43 100644 --- a/tests/auto/qnetworksession/lackey/lackey.pro +++ b/tests/auto/qnetworksession/lackey/lackey.pro @@ -1,13 +1,4 @@ SOURCES += main.cpp TARGET = qnetworksessionlackey -INCLUDEPATH += ../../../../src/bearer -DEPENDPATH += ../../../../src/bearer QT = core network - -CONFIG+= testcase - -include(../../../../common.pri) - -CONFIG += mobility -MOBILITY = bearer diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp index f3a7a07..a84021d 100644 --- a/tests/auto/qnetworksession/lackey/main.cpp +++ b/tests/auto/qnetworksession/lackey/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -48,7 +48,7 @@ #include <QDebug> -QTM_USE_NAMESPACE +QT_USE_NAMESPACE #define NO_DISCOVERED_CONFIGURATIONS_ERROR 1 diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp index 86b3e46..061108a 100644 --- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -51,7 +51,7 @@ #include <iapconf.h> #endif -QTM_USE_NAMESPACE +QT_USE_NAMESPACE Q_DECLARE_METATYPE(QNetworkConfiguration) Q_DECLARE_METATYPE(QNetworkSession::State); @@ -170,7 +170,7 @@ void tst_QNetworkSession::initTestCase() dbus_send.waitForFinished(); #endif - inProcessSessionManagementCount = 0; + inProcessSessionManagementCount = -1; QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); @@ -426,6 +426,8 @@ void tst_QNetworkSession::sessionOpenCloseStop_data() QTest::newRow((name + QLatin1String(" stop")).toLocal8Bit().constData()) << config << true; } + + inProcessSessionManagementCount = 0; } void tst_QNetworkSession::sessionOpenCloseStop() @@ -817,7 +819,7 @@ void tst_QNetworkSession::outOfProcessSession() output = oopSocket->readLine().trimmed(); if (output.startsWith("Started session ")) { - QString identifier = QString::fromLocal8Bit(output.mid(16).constData()); + QString identifier = QString::fromLocal8Bit(output.mid(20).constData()); QNetworkConfiguration changed; diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro index ccc405e..85aa5aa 100644 --- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro +++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro @@ -1,22 +1,9 @@ +load(qttest_p4) SOURCES += tst_qnetworksession.cpp HEADERS += ../../qbearertestcommon.h -TARGET = tst_qnetworksession -CONFIG += testcase QT = core network -INCLUDEPATH += ../../../../src/bearer - -include(../../../../common.pri) -CONFIG += mobility -MOBILITY = bearer - -wince* { - LACKEY.sources = $$OUTPUT_DIR/build/tests/bin/qnetworksessionlackey.exe - LACKEY.path = . - DEPLOYMENT += LACKEY -} - symbian { TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData -} +}
\ No newline at end of file diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index f62d8d2..19246a2 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "bearerex.h" #include <QtNetwork> diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h index b8a2393..2875d6a 100644 --- a/tests/manual/bearerex/bearerex.h +++ b/tests/manual/bearerex/bearerex.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef ACCESSPOINTMANAGEREX_H #define ACCESSPOINTMANAGEREX_H @@ -57,7 +58,7 @@ QT_END_NAMESPACE class SessionTab; -QTM_USE_NAMESPACE +QT_USE_NAMESPACE class BearerEx : public QMainWindow, public Ui::BearerExMainWindow { diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro index e480d43..927f982 100644 --- a/tests/manual/bearerex/bearerex.pro +++ b/tests/manual/bearerex/bearerex.pro @@ -8,13 +8,6 @@ QT += core \ FORMS += sessiondialog.ui \ bearerex.ui \ detailedinfodialog.ui -include(../../common.pri) -#not really a test case but deployment happens same way -CONFIG += testcase - -DEPENDPATH += . -INCLUDEPATH += . \ - ../../src/bearer # Example headers and sources HEADERS += bearerex.h \ @@ -24,6 +17,4 @@ SOURCES += bearerex.cpp \ main.cpp \ xqlistwidget.cpp -CONFIG += mobility -MOBILITY = bearer -symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData +symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
\ No newline at end of file diff --git a/tests/manual/bearerex/main.cpp b/tests/manual/bearerex/main.cpp index e13a494..20b167e 100644 --- a/tests/manual/bearerex/main.cpp +++ b/tests/manual/bearerex/main.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include <QApplication> #include "bearerex.h" diff --git a/tests/manual/bearerex/xqlistwidget.cpp b/tests/manual/bearerex/xqlistwidget.cpp index 0618725..8104779 100644 --- a/tests/manual/bearerex/xqlistwidget.cpp +++ b/tests/manual/bearerex/xqlistwidget.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "xqlistwidget.h" XQListWidget::XQListWidget(QWidget* parent) : QListWidget(parent) diff --git a/tests/manual/bearerex/xqlistwidget.h b/tests/manual/bearerex/xqlistwidget.h index 1053328..0649c2b 100644 --- a/tests/manual/bearerex/xqlistwidget.h +++ b/tests/manual/bearerex/xqlistwidget.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef XQLISTWIDGET_H #define XQLISTWIDGET_H diff --git a/tests/manual/networkmanager/networkmanager.pro b/tests/manual/networkmanager/networkmanager.pro index 7ff370a..84289d3 100644 --- a/tests/manual/networkmanager/networkmanager.pro +++ b/tests/manual/networkmanager/networkmanager.pro @@ -4,17 +4,6 @@ TARGET = tst_networkmanagertest QT = core network dbus gui -#not really a test case but deployment happens same way -CONFIG += testcase - requires(contains(QT_CONFIG,dbus)) -INCLUDEPATH += ../../src/bearer -include(../../common.pri) - -CONFIG += mobility -MOBILITY = bearer - -#MOC_DIR = .moc -#OBJECTS_DIR = .obj FORMS += dialog.ui diff --git a/tests/manual/networkmanager/networkmanagertest.cpp b/tests/manual/networkmanager/networkmanagertest.cpp index a39b041..8a6c5fa 100644 --- a/tests/manual/networkmanager/networkmanagertest.cpp +++ b/tests/manual/networkmanager/networkmanagertest.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/manual/networkmanager/nmview.cpp b/tests/manual/networkmanager/nmview.cpp index fde5cae..9e28ff0 100644 --- a/tests/manual/networkmanager/nmview.cpp +++ b/tests/manual/networkmanager/nmview.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -68,7 +68,7 @@ #include <qnetworkconfiguration.h> #include <qnetworkconfigmanager.h> #include <qnetworksession.h> -#include <qnetworkmanagerservice_p.h> +#include <QtNetwork/private/qnetworkmanagerservice_p.h> //static QDBusConnection dbc = QDBusConnection::systemBus(); //typedef QMap< QString, QMap<QString,QVariant> > SettingsMap; diff --git a/tests/manual/networkmanager/nmview.h b/tests/manual/networkmanager/nmview.h index e15aacd..41ee04f 100644 --- a/tests/manual/networkmanager/nmview.h +++ b/tests/manual/networkmanager/nmview.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -47,7 +47,7 @@ #include "ui_dialog.h" -QTM_USE_NAMESPACE +QT_USE_NAMESPACE QT_BEGIN_NAMESPACE class QListWidget; diff --git a/tests/manual/networkmanager/startdlg.cpp b/tests/manual/networkmanager/startdlg.cpp index 4720932..e34b5e9 100644 --- a/tests/manual/networkmanager/startdlg.cpp +++ b/tests/manual/networkmanager/startdlg.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "startdlg.h" #include <NetworkManager/NetworkManager.h> diff --git a/tests/manual/networkmanager/startdlg.h b/tests/manual/networkmanager/startdlg.h index a9f1e7c..32c8557 100644 --- a/tests/manual/networkmanager/startdlg.h +++ b/tests/manual/networkmanager/startdlg.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the Qt Mobility Components. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include <QDialog> #include <QtDBus> #include <QtGui> |