Index: .
===================================================================
diff --git a/trunk/dports/_resources/port1.0/group/qt5-1.0.tcl b/trunk/dports/_resources/port1.0/group/qt5-1.0.tcl
--- a/trunk/dports/_resources/port1.0/group/qt5-1.0.tcl	(revision 131485)
+++ b/trunk/dports/_resources/port1.0/group/qt5-1.0.tcl	(working copy)
@@ -59,86 +59,133 @@
     }
 }
 
+variant exclusive description {Builds and installs Qt5-mac the older way, such that other Qt versions can NOT be installed alongside it} {}
+
 # standard Qt5 name
 global qt_name
 set qt_name             qt5
 
 # standard install directory
-global qt_dir
-set qt_dir              ${prefix}
-
+    global qt_dir
+    global qt_dir_rel
 # standard Qt documents directory
-global qt_docs_dir
-set qt_docs_dir         ${qt_dir}/share/doc/${qt_name}
-
+    global qt_docs_dir
 # standard Qt plugins directory
-global qt_plugins_dir
-set qt_plugins_dir      ${qt_dir}/share/${qt_name}/plugins
-
+    global qt_plugins_dir
 # standard Qt mkspecs directory
-global qt_mkspecs_dir
-set qt_mkspecs_dir      ${qt_dir}/share/${qt_name}/mkspecs
-
+    global qt_mkspecs_dir
 # standard Qt imports directory
-global qt_imports_dir
-set qt_imports_dir      ${qt_dir}/share/${qt_name}/imports
-
+    global qt_imports_dir
 # standard Qt qml directory
-global qt_qml_dir
-set qt_qml_dir          ${qt_dir}/share/${qt_name}/qml
-
+    global qt_qml_dir
 # standard Qt includes directory
-global qt_includes_dir
-set qt_includes_dir     ${qt_dir}/include
-
+    global qt_includes_dir
 # standard Qt libraries directory
-global qt_libs_dir
-set qt_libs_dir         ${qt_dir}/lib
-
+    global qt_libs_dir
 # standard Qt libraries directory
-global qt_frameworks_dir
-set qt_frameworks_dir   ${qt_dir}/Library/Frameworks
-
+    global qt_frameworks_dir
+    global qt_frameworks_dir_rel
 # standard Qt non-.app executables directory
-global qt_bins_dir
-set qt_bins_dir         ${qt_dir}/bin
-
-# standard Qt .app executables directory, if created
-global qt_apps_dir
-set qt_apps_dir         ${applications_dir}/Qt5
-
+    global qt_bins_dir
 # standard Qt data directory
-global qt_data_dir
-set qt_data_dir         ${qt_dir}/share/${qt_name}
-
+    global qt_data_dir
 # standard Qt translations directory
-global qt_translations_dir
-set qt_translations_dir ${qt_dir}/share/${qt_name}/translations
-
+    global qt_translations_dir
 # standard Qt sysconf directory
-global qt_sysconf_dir
-set qt_sysconf_dir      ${qt_dir}/etc/${qt_name}
-
+    global qt_sysconf_dir
 # standard Qt examples directory
-global qt_examples_dir
-set qt_examples_dir     ${qt_dir}/share/${qt_name}/examples
-
+    global qt_examples_dir
 # standard Qt tests directory
-global qt_tests_dir
-set qt_tests_dir     ${qt_dir}/share/${qt_name}/tests
-
+    global qt_tests_dir
 # standard Qt demos directory
-global qt_demos_dir
-set qt_demos_dir        ${qt_dir}/share/${qt_name}/demos
-
+    global qt_demos_dir
 # standard CMake module directory for Qt-related files
-global qt_cmake_module_dir
-set qt_cmake_module_dir ${qt_libs_dir}/cmake
-
+    global qt_cmake_module_dir
 # standard qmake command location
-global qt_qmake_cmd
-set qt_qmake_cmd        ${qt_dir}/bin/qmake
+    global qt_qmake_cmd
+# standard moc command location
+    global qt_moc_cmd
+# standard uic command location
+    global qt_uic_cmd
+# standard lrelease command location
+    global qt_lrelease_cmd
 
+global qt5_is_concurrent
+if {![variant_isset exclusive]} {
+    # check if we're building qt5 itself
+    if {![info exists building_qt5] || ![info exists name] || ${name} ne "qt5-mac"} {
+        # no, this must be a dependent port: check the qt5 install:
+        if {[file exists ${prefix}/libexec/${qt_name}/bin/qmake]} {
+            # we have a "concurrent" install, which means we must look for the various components
+            # in different locations (esp. qmake)
+            set qt5_is_concurrent   1
+            set auto_concurrent     1
+            ui_msg "NB:\nQt5 has been installed in concurrent mode\n"
+        }
+    } else {
+        # we're building qt5-mac or one of its subports
+        if {![info exists qt5_is_concurrent]} {
+            ui_msg "NB:\nQt5 has been or will be installed in concurrent mode\n"
+        }
+        # we're asking for the standard concurrent install. No need to guess anything, give the user what s/he wants
+        set qt5_is_concurrent   1
+        set auto_concurrent     1
+    }
+}
+
+if {[info exists qt5_is_concurrent]} {
+    set qt_dir              ${prefix}/libexec/${qt_name}
+    set qt_dir_rel          libexec/${qt_name}
+    set qt_docs_dir         ${prefix}/share/doc/${qt_name}
+    set qt_plugins_dir      ${prefix}/share/${qt_name}/plugins
+    set qt_mkspecs_dir      ${prefix}/share/${qt_name}/mkspecs
+    set qt_imports_dir      ${prefix}/share/${qt_name}/imports
+    set qt_qml_dir          ${prefix}/share/${qt_name}/qml
+    set qt_includes_dir     ${prefix}/include/${qt_name}
+    set qt_libs_dir         ${qt_dir}/lib
+    set qt_frameworks_dir   ${qt_dir}/Library/Frameworks
+    set qt_bins_dir         ${qt_dir}/bin
+    set qt_data_dir         ${prefix}/share/${qt_name}
+    set qt_translations_dir ${prefix}/share/${qt_name}/translations
+    set qt_sysconf_dir      ${prefix}/etc/${qt_name}
+    set qt_examples_dir     ${prefix}/share/${qt_name}/examples
+    set qt_tests_dir        ${prefix}/share/${qt_name}/tests
+    set qt_demos_dir        ${prefix}/share/${qt_name}/demos
+    set qt_cmake_module_dir ${prefix}/lib/cmake
+    set qt_qmake_cmd        ${qt_dir}/bin/qmake
+    set qt_moc_cmd          ${qt_dir}/bin/moc
+    set qt_uic_cmd          ${qt_dir}/bin/uic
+    set qt_lrelease_cmd     ${qt_dir}/bin/lrelease
+} else {
+    set qt_dir              ${prefix}
+    set qt_dir_rel          ""
+    set qt_docs_dir         ${qt_dir}/share/doc/${qt_name}
+    set qt_plugins_dir      ${qt_dir}/share/${qt_name}/plugins
+    set qt_mkspecs_dir      ${qt_dir}/share/${qt_name}/mkspecs
+    set qt_imports_dir      ${qt_dir}/share/${qt_name}/imports
+    set qt_qml_dir          ${qt_dir}/share/${qt_name}/qml
+    set qt_includes_dir     ${qt_dir}/include
+    set qt_libs_dir         ${qt_dir}/lib
+    set qt_frameworks_dir   ${qt_dir}/Library/Frameworks
+    set qt_bins_dir         ${qt_dir}/bin
+    set qt_data_dir         ${qt_dir}/share/${qt_name}
+    set qt_translations_dir ${qt_dir}/share/${qt_name}/translations
+    set qt_sysconf_dir      ${qt_dir}/etc/${qt_name}
+    set qt_examples_dir     ${qt_dir}/share/${qt_name}/examples
+    set qt_tests_dir        ${qt_dir}/share/${qt_name}/tests
+    set qt_demos_dir        ${qt_dir}/share/${qt_name}/demos
+    set qt_cmake_module_dir ${qt_libs_dir}/cmake
+    set qt_qmake_cmd        ${qt_dir}/bin/qmake
+    set qt_moc_cmd          ${qt_dir}/bin/moc
+    set qt_uic_cmd          ${qt_dir}/bin/uic
+    set qt_lrelease_cmd     ${qt_dir}/bin/lrelease
+}
+set qt_frameworks_dir_rel   ${qt_dir_rel}/Library/Frameworks
+
+# standard Qt .app executables directory, if created
+global qt_apps_dir
+set qt_apps_dir         ${applications_dir}/Qt5
+
 # standard qmake spec
 # configure script prefers clang (but "[a]dvertise[s] g++ as an alternative on Lion and below").
 # According to http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations,
@@ -162,25 +209,13 @@
     set qt_qmake_spec ""
 }
 
-# standard moc command location
-global qt_moc_cmd
-set qt_moc_cmd          ${qt_dir}/bin/moc
-
-# standard uic command location
-global qt_uic_cmd
-set qt_uic_cmd          ${qt_dir}/bin/uic
-
-# standard lrelease command location
-global qt_lrelease_cmd
-set qt_lrelease_cmd     ${qt_dir}/bin/lrelease
-
 # standard PKGCONFIG path
 global qt_pkg_config_dir
-set qt_pkg_config_dir   ${qt_libs_dir}/pkgconfig
+set qt_pkg_config_dir   ${prefix}/lib/pkgconfig
 
 # data used by qmake
 global qt_host_data_dir
-set qt_host_data_dir   ${qt_dir}/share/${qt_name} 
+set qt_host_data_dir   ${prefix}/share/${qt_name} 
 
 # standard cmake info for Qt5
 global qt_cmake_defines
@@ -198,10 +233,18 @@
         # see if the framework install exists, and if so depend on it;
         # if not, depend on the library version
 
-        if {[file exists ${qt_frameworks_dir}/QtCore/QtCore]} {
-            depends_lib-append path:Library/Frameworks/QtCore/QtCore:qt5-mac
+        if {[info exists qt5_is_concurrent]} {
+            if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
+                depends_lib-append path:libexec/${qt_name}/Library/Frameworks/QtCore.framework/QtCore:qt5-mac
+            } else {
+                depends_lib-append path:libexec/${qt_name}/lib/libQtCore.5.dylib:qt5-mac
+            }
         } else {
-            depends_lib-append path:lib/libQtCore.5.dylib:qt5-mac
+            if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
+                depends_lib-append path:Library/Frameworks/QtCore.framework/QtCore:qt5-mac
+            } else {
+                depends_lib-append path:lib/libQtCore.5.dylib:qt5-mac
+            }
         }
     }
 }
Index: Portfile
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/Portfile b/trunk/dports/aqua/qt5-mac/Portfile
--- a/trunk/dports/aqua/qt5-mac/Portfile	(revision 131485)
+++ b/trunk/dports/aqua/qt5-mac/Portfile	(working copy)
@@ -1,435 +1,14 @@
 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
 # $Id$
+# $Id$
 
 PortSystem          1.0
 
 name                qt5-mac
 version             5.3.2
-revision            1
-set branch          [join [lrange [split ${version} .] 0 1] .]
+revision            3
 
-categories          aqua
-platforms           macosx
-maintainers         mcalhoun openmaintainer
-license             {LGPL-2.1 GPL-3}
-
-homepage            http://qt-project.org
-description         Qt Tool Kit
-long_description    Qt Tool Kit: A cross-platform framework \
-    (headers, data, and libraries) for writing \
-    cross-platform GUI-based applications.
-
-distname            qt-everywhere-opensource-src-${version}
-
-master_sites        http://download.qt-project.org/official_releases/qt/${branch}/${version}/single/
-
-checksums           rmd160  5cd61acc2fbfba2597a386a09d83710ed2fdf483 \
-                    sha256  c8d3fd2ead30705c6673c5e4af6c6f3973346b4fb2bd6079c7be0943a5b0282d
-
-if { ${os.major} < 10 } {
-    pre-fetch {
-        ui_error "OS X prior to 10.7 (Lion) is not a Reference Configuration for Qt."
-        ui_error "OS X prior to 10.6 (Snow Leopard) is not even tested."
-        ui_error "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
-        return -code error "unsupported OS"
-    }
-} elseif { ${os.major} == 10 } {
-    pre-fetch {
-        ui_warn "OS X prior to 10.7 (Lion) is not a Reference Configuration for Qt."
-        if { [variant_isset universal] } {
-            ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\" but ONLY in 32-bit mode."
-            ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
-        } else {
-            if { ${build_arch} eq "i386" } {
-                ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\"."
-                ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
-            } else {
-                ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\" but ONLY in 32-bit mode."
-                ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
-            }
-        }
-        ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
-    }
-} elseif { ${os.major} > 13 } {
-    pre-fetch {
-        ui_warn "OS X subsequent to 10.9 (Mavericks) is not a Reference Configuration for Qt."
-        ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
-    }
-} else {
-    # 11 <= ${os.major} <= 13
-    if { [variant_isset universal] } {
-        pre-fetch {
-            ui_warn "Multiple architectures is not a Reference Configuration for Qt."
-            ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
-        }
-    } else {
-        if { ${build_arch} eq "i386" } {
-            pre-fetch {
-                ui_warn "32-bit mode is not a Reference Configuration for Qt."
-                ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
-            }
-        }
-    }
+if {[catch {source "${portpath}/Portfile.qt5"} err]} {
+    puts stderr "Error reading Portfile.qt5: $err"
+    return 1;
 }
-
-if { ${subport} eq "${name}-docs"  } {
-    universal_variant no
-}
-
-if { ${subport} eq ${name} || ${subport} eq "${name}-docs" } {
-    # use the qt5 group; set 'building_qt5' so that the portgroup
-    # does not include certain parts
-    set building_qt5    1
-    PortGroup           conflicts_build 1.0
-    PortGroup           qt5 1.0
-    PortGroup           xcodeversion 1.0
-
-    conflicts           qt3 qt3-mac qt4-mac
-
-    minimum_xcodeversions   {10 3.2}
-
-    # See https://bugreports.qt-project.org/browse/QTBUG-34902
-    conflicts_build-append  qt4-mac
-
-    # Kuba states in https://trac.macports.org/ticket/44207#comment:7 
-    #  "There's no reason to have parallel building disabled. Really."
-    #use_parallel_build no 
-
-    # header file QtCore/private/qmachparser_p.h is included only if "defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O)"
-    #     code from header is used only "ifdef Q_OF_MACH_O"
-    #     the two must be consistent
-    #     assume the header include code is correct
-    patchfiles-append patch-tst_qpluginloader.diff
-
-    # When testing, ensure that a universal object file is not inadvertently created.
-    patchfiles-append patch-machtest.diff
-
-    # On testing of 32-bit systems,
-    #  Pre-patch: QCOMPARE(unsigned long const&, unsigned int const&
-    # Post-patch: QCOMPARE(unsigned int  const&, unsigned int const&
-    # Function template is only instantiated for same first and second arguments.
-    patchfiles-append patch-tst_qarraydata.diff
-
-    # see http://stackoverflow.com/questions/14506151/invalid-symbol-redefinition-in-inline-asm-on-llvm
-    patchfiles-append patch-tst_benchlibcallgrind.diff
-
-    # During testing, NSStringFromRect requires NSRect.
-    patchfiles-append patch-tst_qaccessibilitymac_helpers.diff
-
-    # see #44934 (and #35067 for the qt4-mac version)
-    patchfiles-append patch-shared.diff
-
-    # see https://bugreports.qt-project.org/browse/QTBUG-41136
-    patchfiles-append patch-avfmediaplayersession.diff
-
-    # see https://bugreports.qt-project.org/browse/QTBUG-41367
-    patchfiles-append patch-qmacstyle_mac.diff
-
-    # --prefix is not recognized.
-    configure.pre_args-delete       --prefix=${prefix}
-
-    # --disable-dependency-tracking is not recognized.
-    configure.universal_args-delete --disable-dependency-tracking
-
-    if {${configure.sdkroot} ne ""} {
-        configure.args-append \
-            -sdk [string tolower [join [lrange [split [lindex [split ${configure.sdkroot} "/"] end] "."] 0 end-1] "."]]
-    }
-
-    configure.args-append                      \
-        -prefix         ${qt_dir}              \
-        -docdir         ${qt_docs_dir}         \
-        -headerdir      ${qt_includes_dir}     \
-        -plugindir      ${qt_plugins_dir}      \
-        -importdir      ${qt_imports_dir}      \
-        -qmldir         ${qt_qml_dir}          \
-        -datadir        ${qt_data_dir}         \
-        -libdir         ${qt_frameworks_dir}   \
-        -bindir         ${qt_bins_dir}         \
-        -translationdir ${qt_translations_dir} \
-        -sysconfdir     ${qt_sysconf_dir}      \
-        -examplesdir    ${qt_examples_dir}     \
-        -testsdir       ${qt_tests_dir}        \
-        -hostdatadir    ${qt_host_data_dir}
-
-    # Configure options:
-    configure.args-append \
-        -release          \
-        -opensource       \
-        -confirm-license  \
-        -shared           \
-        -process
-
-    # Third Party Libraries:
-    configure.args-append \
-        -no-mtdev         \
-        -no-harfbuzz      \
-        -openssl-linked   \
-        -no-xinput2       \
-        -no-xcb-xlib
-
-    # configure options that don't show up in configure --help
-    configure.args-append \
-        -no-libudev       \
-        -no-egl
-
-    # Additional options:
-    configure.args-append    \
-        {-make libs}         \
-        {-make tools}        \
-        {-nomake examples}   \
-        {-nomake tests}      \
-        -verbose             \
-        -no-optimized-qmake  \
-        -nis                 \
-        -cups                \
-        -iconv               \
-        -no-evdev            \
-        -icu                 \
-        -fontconfig          \
-        -strip               \
-        -no-pch              \
-        -dbus-linked         \
-        -no-xcb              \
-        -glib                \
-        -directfb            \
-        -no-linuxfb          \
-        -no-kms              \
-        -no-system-proxies   \
-        -framework
-
-    foreach driver { db2 ibase mysql oci odbc psql sqlite sqlite2 tds } {
-        configure.args-append -no-sql-${driver}
-    }
-
-    if { ![variant_isset universal] } {
-        configure.args-append "-platform ${qt_qmake_spec}"
-    } else {
-        set merger_configure_args(i386)   "-platform ${qt_qmake_spec_32}"
-        set merger_configure_args(x86_64) "-platform ${qt_qmake_spec_64}"
-    }
-
-    # configure options that don't show up in configure --help
-    configure.args-append \
-        -no-openvg
-
-    # Qt builds part of the system using environment provided my MacPorts.
-    # It builds the rest using its own internal environment.
-    # For consistency, clear MacPorts environment.
-    configure.cxx_stdlib
-    configure.sdkroot
-    configure.cc_archflags
-    configure.cxx_archflags
-    configure.objc_archflags
-    configure.objcxx_archflags
-    configure.ld_archflags
-    configure.cppflags
-    configure.cflags
-    configure.cxxflags
-    configure.objcflags
-    configure.objcxxflags
-    configure.ldflags
-    configure.pipe  no
-    if { [variant_isset universal] } {
-        set merger_arch_flag no
-    }
-    configure.march
-    configure.mtune
-    configure.universal_ldflags
-    configure.universal_cflags
-    configure.universal_cxxflags
-    configure.universal_cppflags
-}
-
-if { ${subport} eq ${name} } {
-    depends_lib                              \
-        port:zlib                            \
-        port:libpng                          \
-        port:jpeg                            \
-        port:freetype                        \
-        path:bin/dbus-daemon:dbus            \
-        port:openssl                         \
-        port:tiff                            \
-        port:libmng                          \
-        path:lib/pkgconfig/glib-2.0.pc:glib2 \
-        port:icu                             \
-        port:pcre                            \
-        port:libiconv
-
-    # see https://bugreports.qt-project.org/browse/QTBUG-35514
-    build.target
-
-    if { [variant_isset universal] } {
-        merger-post-destroot {
-            foreach arch ${universal_archs_to_use} {
-                set dir ${destroot}-${arch}
-
-                reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_frameworks_dir}/pkgconfig/Qt5WebKit.pc
-
-                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.framework/*.prl] {
-                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
-                }
-
-                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.prl] {
-                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
-                }
-
-                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.framework/*.prl] {
-                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
-                }
-
-                reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_mkspecs_dir}/modules/qt_lib_bootstrap_private.pri
-
-                reinplace \
-                    "s|^set(_qt5_corelib_extra_includes \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang.*\")$|set(_qt5_corelib_extra_includes \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang-32\" \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang\")|" \
-                    ${dir}${qt_frameworks_dir}/cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake
-            }
-        }
-
-        post-destroot {
-            # delete preprocessor comments surrounding QT_CPU_FEATURES.i386 and QT_CPU_FEATURES.x86_64
-            reinplace "/^#ifndef.*$/d" ${destroot}${qt_mkspecs_dir}/qmodule.pri
-            reinplace "/^#else.*$/d"   ${destroot}${qt_mkspecs_dir}/qmodule.pri
-            reinplace "/^#endif.*$/d"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
-        }
-
-        # The file ${prefix}/share/qt5/mkspecs/qconfig.pri is still not properly merged
-        # The solution is ???.
-    }
-
-    post-destroot {
-
-        # see #44204
-        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/pkgconfig *.pc] {
-            set framework [file rootname [file tail ${f}]]
-            set incname   [string map {Qt5 Qt} ${framework}]
-            reinplace "s|-I\${includedir}/${incname}|-I\${includedir}|g" ${f}
-            reinplace "s|includedir=\${prefix}/include|includedir=\${libdir}/${framework}/Headers|g" ${f}
-        }
-
-        # move items out of the Frameworks directory that are more appropriate to lib directory
-        xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}
-        foreach d [glob -tails -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake *] {
-            xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}/${d}
-            foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake/${d} *.cmake] {
-                # ${qt_frameworks_dir} is  ${qt_dir}/Library/Frameworks while
-                # ${qt_libs_dir}       is  ${qt_dir}/lib
-                # unless modified, cmake files will point to a directory that is too high in the directory hierarchy
-                reinplace "s|/../../../../|/../../../|g" ${f}
-                file rename ${f} ${destroot}${qt_cmake_module_dir}/${d}/
-            }
-        }
-        xinstall -m 775 -d ${destroot}${qt_pkg_config_dir}
-        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/pkgconfig *.pc] {
-            file rename ${f} ${destroot}${qt_pkg_config_dir}
-        }
-        xinstall -m 775 -d ${destroot}${qt_libs_dir}/
-        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir} *.{a,prl,la}] {
-            file rename ${f} ${destroot}${qt_libs_dir}/
-        }
-
-        # move items out of the bin directory that are more appropriate to the Applications directory
-        xinstall -m 775 -d ${destroot}${qt_apps_dir}
-        foreach f [glob -nocomplain -directory ${destroot}${qt_bins_dir} *.app] {
-            file rename ${f} ${destroot}${qt_apps_dir}/
-        }
-    }
-
-    variant harfbuzz description {(experimental) Use HarfBuzz-NG to do text shaping} {
-        depends_lib-append port:harfbuzz
-        configure.args-replace \
-            -no-harfbuzz       \
-            -system-harfbuzz
-    }
-
-    variant tests description {Enable tests} {
-        configure.args-replace {-nomake tests} {-make tests}
-    }
-
-    variant examples description {Build examples} {
-        configure.args-replace {-nomake examples} {-make examples}
-    }
-
-    variant debug description {Build both release and debug library} {
-        configure.args-replace -release -debug-and-release
-    }
-}
-
-subport ${name}-docs {
-    depends_lib-append \
-        path:${prefix}/bin/qdoc:${name} \
-        path:${qt_plugins_dir}/sqldrivers/libqsqlite.dylib:${name}-sqlite3-plugin
-
-    supported_archs   noarch
-
-    build.target      docs
-    destroot.target   install_docs
-
-    post-extract {
-        # For the most part, generated makefiles use ${prefix}/bin/qdoc.
-        # There are a couple of places that look in ${worksrcpath}/qtbase/src/tools/qdoc/.
-        ln -s ${prefix}/bin/qdoc ${worksrcpath}/qtbase/src/tools/qdoc/
-        ln -s ${prefix}/bin/qdoc ${worksrcpath}/qtbase/bin
-
-        # Similarly, location of qhelpgenerator is expected in ${worksrcpath}
-        xinstall -d -m 755 ${worksrcpath}/qttools/bin/
-        ln -s ${prefix}/bin/qhelpgenerator ${worksrcpath}/qttools/bin/
-
-        # Without this file, the makefile ${worksrcpath}/qtwebkit/Source/WebCore/Makefile.WebCore.Target
-        #    keeps generating itself over and over again.
-        # This file is only created when the library is being built, however.
-        xinstall -d -m 755 ${worksrcpath}/qtwebkit/Source/WebCore/generated
-        touch ${worksrcpath}/qtwebkit/Source/WebCore/generated/InspectorBackendCommands.qrc
-    }
-}
-
-# See http://qt-project.org/doc/qt-5/sql-driver.html for info on building SQL Database Drivers
-
-subport ${name}-sqlite3-plugin {
-    PortGroup           qmake5 1.0
-
-    depends_lib-append port:sqlite3
-
-    # for single architecture, easier to use
-    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/sqlite,
-    #    but doesn't work for universal build
-    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/sqlite
-    build.dir     ${configure.dir}
-    destroot.dir  ${configure.dir}
-
-    configure.args-append "INCLUDEPATH+=${prefix}/include" "LIBS+=\"-L${prefix}/lib -lsqlite3\""
-}
-
-subport ${name}-psql84-plugin {
-    PortGroup           qmake5 1.0
-
-    depends_lib-append port:postgresql84
-
-    # for single architecture, easier to use
-    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/psql,
-    #    but doesn't work for universal build
-    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/psql
-    build.dir     ${configure.dir}
-    destroot.dir  ${configure.dir}
-
-    configure.args-append "INCLUDEPATH+=${prefix}/include/postgresql84" "LIBS+=\"-L${prefix}/lib/postgresql84 -lpq\""
-}
-
-subport ${name}-mysql56-plugin {
-    PortGroup           qmake5 1.0
-
-    depends_lib-append port:mysql56
-
-    # for single architecture, easier to use
-    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/mysql,
-    #    but doesn't work for universal build
-    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/mysql
-    build.dir     ${configure.dir}
-    destroot.dir  ${configure.dir}
-
-    configure.args-append "INCLUDEPATH+=${prefix}/include/mysql56/mysql" "LIBS+=\"-L${prefix}/lib/mysql56/mysql -lmysqlclient_r\""
-}
-
-livecheck.type      regex
-livecheck.url       http://qt-project.org/downloads
-livecheck.regex     "Qt (5(?:\\.\\d+)*) for Mac"
Index: Portfile.qt5
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/Portfile.qt5 b/trunk/dports/aqua/qt5-mac/Portfile.qt5
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/Portfile.qt5	(working copy)
@@ -0,0 +1,613 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id: port=qt5 1 2014-12-08 18:51:13Z rjvbertin@gmail.com, mcalhoun@macports.org $
+
+# set building_qt5 immediately!
+set building_qt5    1
+
+PortGroup           qt5 1.0
+set branch          [join [lrange [split ${version} .] 0 1] .]
+
+categories          aqua
+platforms           macosx
+maintainers         mcalhoun openmaintainer
+license             {LGPL-2.1 GPL-3}
+
+homepage            http://qt-project.org
+description         Qt Tool Kit 5.3
+long_description    Qt Tool Kit: A cross-platform framework \
+                    (headers, data, and libraries) for writing \
+                    cross-platform GUI-based applications. \
+                    Installs to ${qt_dir}
+
+distname            qt-everywhere-opensource-src-${version}
+
+master_sites        http://download.qt-project.org/official_releases/qt/${branch}/${version}/single/
+
+checksums           rmd160  5cd61acc2fbfba2597a386a09d83710ed2fdf483 \
+                    sha256  c8d3fd2ead30705c6673c5e4af6c6f3973346b4fb2bd6079c7be0943a5b0282d
+
+if { ${os.major} < 10 } {
+    pre-fetch {
+        ui_error "OS X prior to 10.7 (Lion) is not a Reference Configuration for Qt."
+        ui_error "OS X prior to 10.6 (Snow Leopard) is not even tested."
+        ui_error "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
+        return -code error "unsupported OS"
+    }
+} elseif { ${os.major} == 10 } {
+    pre-fetch {
+        ui_warn "OS X prior to 10.7 (Lion) is not a Reference Configuration for Qt."
+        if { [variant_isset universal] } {
+            ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\" but ONLY in 32-bit mode."
+            ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
+        } else {
+            if { ${build_arch} eq "i386" } {
+                ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\"."
+                ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
+            } else {
+                ui_warn "OS X 10.6 (Snow Leopard) is \"occasionally tested\" but ONLY in 32-bit mode."
+                ui_warn "OS X 10.6 (Snow Leopard) is deprecated and scheduled for removal in Qt 5.4."
+            }
+        }
+        ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
+    }
+} elseif { ${os.major} > 13 } {
+    pre-fetch {
+        ui_warn "OS X subsequent to 10.9 (Mavericks) is not a Reference Configuration for Qt."
+        ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
+    }
+} else {
+    # 11 <= ${os.major} <= 13
+    if { [variant_isset universal] } {
+        pre-fetch {
+            ui_warn "Multiple architectures is not a Reference Configuration for Qt."
+            ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
+        }
+    } else {
+        if { ${build_arch} eq "i386" } {
+            pre-fetch {
+                ui_warn "32-bit mode is not a Reference Configuration for Qt."
+                ui_warn "See http://qt-project.org/doc/qt-5/supported-platforms.html#reference-configurations"
+            }
+        }
+    }
+}
+
+if { ${subport} eq "${name}-docs"  } {
+    universal_variant no
+}
+
+if {[info exists env(QTDIR)]} {
+    ui_msg "unsetting \$QTDIR"
+    unset env(QTDIR)
+}
+
+if { ${subport} eq ${name} || ${subport} eq "${name}-docs" } {
+    # use the qt5 group; set 'building_qt5' so that the portgroup
+    # does not include certain parts
+    PortGroup           conflicts_build 1.0
+    conflicts           qt3 qt3-mac
+    PortGroup           xcodeversion 1.0
+
+
+    minimum_xcodeversions   {10 3.2}
+
+    if {[variant_isset exclusive]} {
+        conflicts-append        qt4-mac
+        # See https://bugreports.qt-project.org/browse/QTBUG-34902
+        conflicts_build-append  qt4-mac
+    }
+    # else: the concurrent qt5-mac version ought to be able to co-exist with any qt4-mac version.
+
+    # Kuba states in https://trac.macports.org/ticket/44207#comment:7 
+    #  "There's no reason to have parallel building disabled. Really."
+    #use_parallel_build no 
+
+    # header file QtCore/private/qmachparser_p.h is included only if "defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O)"
+    #     code from header is used only "ifdef Q_OF_MACH_O"
+    #     the two must be consistent
+    #     assume the header include code is correct
+    patchfiles-append patch-tst_qpluginloader.diff
+
+    # When testing, ensure that a universal object file is not inadvertently created.
+    patchfiles-append patch-machtest.diff
+
+    # On testing of 32-bit systems,
+    #  Pre-patch: QCOMPARE(unsigned long const&, unsigned int const&
+    # Post-patch: QCOMPARE(unsigned int  const&, unsigned int const&
+    # Function template is only instantiated for same first and second arguments.
+    patchfiles-append patch-tst_qarraydata.diff
+
+    # see http://stackoverflow.com/questions/14506151/invalid-symbol-redefinition-in-inline-asm-on-llvm
+    patchfiles-append patch-tst_benchlibcallgrind.diff
+
+    # During testing, NSStringFromRect requires NSRect.
+    patchfiles-append patch-tst_qaccessibilitymac_helpers.diff
+
+    # see #44934 (and #35067 for the qt4-mac version)
+    patchfiles-append patch-shared.diff
+
+    # see https://bugreports.qt-project.org/browse/QTBUG-41136
+    patchfiles-append patch-avfmediaplayersession.diff
+
+    # see https://bugreports.qt-project.org/browse/QTBUG-41367
+    patchfiles-append patch-qmacstyle_mac.diff
+
+    # avoid leaving zombies when starting an inexisting executable through QProcess
+    patchfiles-append qprocess-nozombies.patch
+
+    # add (prepend) ${prefix}/share to the standard search paths so they become XDG-compliant
+    patchfiles-append fix-qstandardpaths.patch
+
+    variant KDE description {Include a number of patches tailoring Qt5 for use with KDE, and enable useful backtraces into Qt code for debugging} {
+        patchfiles-append       correct-systraymenu-iconhandling.patch \
+                                deactivate-menurole-heuristics.patch \
+                                debug-negative-qtimerint.patch
+        configure.args-append   -force-debug-info -no-strip -no-separate-debug-info
+    }
+
+    # patches from Ubuntu 5.3.2+dfsg-4ubuntu8 (from Vivid Velvet)
+    # TODO : check Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch and Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch
+    # for relevance for qstandard_mac.?
+    patchfiles-append           remove_icon_from_example.patch \
+                                gnukfreebsd.diff \
+                                fix_bug_in_internal_comparison_operator.patch \
+                                fix_sparc_atomics.patch \
+                                remove_google_adsense.patch \
+                                load_testability_from_env_var.patch \
+                                Add-workaround-for-GL-on-Android-emulator.patch \
+                                dbus_correct_signal_name_disconnect.patch \
+                                Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch \
+                                Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch \
+                                Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch \
+                                disable-generic-plugin-when-others-available.patch \
+                                update-QtBearer-NetworkManager-backend-API.patch \
+                                Reset-QNAM-s-NetworkConfiguration-when-state-changes.patch \
+                                Use-a-property-cache-to-cut-down-on-blocking-calls.patch \
+                                QtBearer-networkmanager-make-sure-to-set-flag-Active.patch \
+                                Always-lock-the-DBus-dispatcher-before-dbus_connecti.patch \
+                                QDBusConnection-Merge-the-dispatch-and-the-watch-and.patch \
+                                Partially-revert-Fix-a-deadlock-introduced-by-the-ra.patch \
+                                Break-after-handling-the-read-write.patch
+
+    # --prefix is not recognised.
+    configure.pre_args-delete       --prefix=${prefix}
+
+    # --disable-dependency-tracking is not recognised.
+    configure.universal_args-delete --disable-dependency-tracking
+
+    if {${configure.sdkroot} ne ""} {
+        configure.args-append \
+            -sdk [string tolower [join [lrange [split [lindex [split ${configure.sdkroot} "/"] end] "."] 0 end-1] "."]]
+    }
+
+    # NB: -prefix->${prefix} !
+    configure.args-append                      \
+        -prefix         ${prefix}              \
+        -archdatadir    ${qt_dir}              \
+        -docdir         ${qt_docs_dir}         \
+        -headerdir      ${qt_includes_dir}     \
+        -plugindir      ${qt_plugins_dir}      \
+        -importdir      ${qt_imports_dir}      \
+        -qmldir         ${qt_qml_dir}          \
+        -datadir        ${qt_data_dir}         \
+        -libdir         ${qt_frameworks_dir}   \
+        -bindir         ${qt_bins_dir}         \
+        -libexecdir     ${qt_dir}/libexec      \
+        -translationdir ${qt_translations_dir} \
+        -sysconfdir     ${qt_sysconf_dir}      \
+        -examplesdir    ${qt_examples_dir}     \
+        -testsdir       ${qt_tests_dir}        \
+        -hostbindir     ${qt_bins_dir}         \
+        -hostlibdir     ${qt_frameworks_dir}   \
+        -hostdatadir    ${qt_host_data_dir}
+
+    # Configure options:
+    configure.args-append \
+        -v                \
+        -release          \
+        -opensource       \
+        -confirm-license  \
+        -shared           \
+        -process
+
+    # Third Party Libraries:
+    configure.args-append \
+        -no-mtdev         \
+        -no-harfbuzz      \
+        -openssl-linked   \
+        -no-xinput2       \
+        -no-xcb-xlib
+
+    # configure options that don't show up in configure --help
+    configure.args-append \
+        -no-libudev       \
+        -no-egl
+
+    # Additional options:
+    configure.args-append    \
+        {-make libs}         \
+        {-make tools}        \
+        {-nomake examples}   \
+        {-nomake tests}      \
+        -verbose             \
+        -nis                 \
+        -cups                \
+        -iconv               \
+        -no-evdev            \
+        -icu                 \
+        -fontconfig          \
+        -no-pch              \
+        -dbus-linked         \
+        -no-xcb              \
+        -glib                \
+        -directfb            \
+        -no-linuxfb          \
+        -no-kms              \
+        -framework
+
+    if {[variant_isset exclusive]} {
+        configure.args-append   -no-optimized-qmake
+    } else {
+        configure.args-append   -optimized-qmake
+    }
+
+    foreach driver { db2 ibase mysql oci odbc psql sqlite sqlite2 tds } {
+        configure.args-append -no-sql-${driver}
+    }
+
+    if { ![variant_isset universal] } {
+        configure.args-append "-platform ${qt_qmake_spec}"
+    } else {
+        set merger_configure_args(i386)   "-platform ${qt_qmake_spec_32}"
+        set merger_configure_args(x86_64) "-platform ${qt_qmake_spec_64}"
+    }
+
+    # configure options that don't show up in configure --help
+    # openvg makes sense only when using X11 ...
+    configure.args-append -no-openvg
+
+    # Qt builds part of the system using environment provided by MacPorts.
+    # It builds the rest using its own internal environment.
+    # For consistency, clear MacPorts environment.
+    configure.cxx_stdlib
+    configure.sdkroot
+    configure.cc_archflags
+    configure.cxx_archflags
+    configure.objc_archflags
+    configure.objcxx_archflags
+    configure.ld_archflags
+    configure.cppflags
+    if {[variant_isset exclusive]} {
+        configure.cflags
+        configure.cxxflags
+        configure.objcflags
+        configure.objcxxflags
+        configure.ldflags
+    } else {
+        configure.objcflags-append  "-g"
+        configure.objcxxflags-append  "-g"
+    }
+    configure.pipe  no
+    if { [variant_isset universal] } {
+        set merger_arch_flag no
+    }
+    configure.march
+    configure.mtune
+    configure.universal_ldflags
+    configure.universal_cflags
+    configure.universal_cxxflags
+    configure.universal_cppflags
+}
+
+if { ${subport} eq ${name} } {
+    depends_lib                              \
+        port:zlib                            \
+        port:libpng                          \
+        port:jpeg                            \
+        port:freetype                        \
+        path:bin/dbus-daemon:dbus            \
+        port:openssl                         \
+        port:tiff                            \
+        port:libmng                          \
+        path:lib/pkgconfig/glib-2.0.pc:glib2 \
+        port:icu                             \
+        port:pcre                            \
+        port:libiconv
+
+    # see https://bugreports.qt-project.org/browse/QTBUG-35514
+    build.target
+
+    post-patch {
+        #reinplace "s|//opt//local//|${prefix}/|g" ${worksrcpath}/qtbase/src/corelib/io/qstandardpaths_mac.cpp
+    }
+
+    if { [variant_isset universal] } {
+        merger-post-destroot {
+            foreach arch ${universal_archs_to_use} {
+                set dir ${destroot}-${arch}
+
+                reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_frameworks_dir}/pkgconfig/Qt5WebKit.pc
+
+                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.framework/*.prl] {
+                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
+                }
+
+                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.prl] {
+                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
+                }
+
+                foreach prlfl [glob ${dir}${qt_frameworks_dir}/*.framework/*.prl] {
+                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${prlfl}
+                }
+
+                reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_mkspecs_dir}/modules/qt_lib_bootstrap_private.pri
+
+                reinplace \
+                    "s|^set(_qt5_corelib_extra_includes \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang.*\")$|set(_qt5_corelib_extra_includes \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang-32\" \"\${_qt5Core_install_prefix}/share/qt5//mkspecs/macx-clang\")|" \
+                    ${dir}${qt_frameworks_dir}/cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake
+            }
+        }
+
+        post-destroot {
+            # delete preprocessor comments surrounding QT_CPU_FEATURES.i386 and QT_CPU_FEATURES.x86_64
+            reinplace "/^#ifndef.*$/d" ${destroot}${qt_mkspecs_dir}/qmodule.pri
+            reinplace "/^#else.*$/d"   ${destroot}${qt_mkspecs_dir}/qmodule.pri
+            reinplace "/^#endif.*$/d"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
+        }
+
+        # The file ${prefix}/share/qt5/mkspecs/qconfig.pri is still not properly merged
+        # The solution is ???.
+    }
+
+    post-destroot {
+
+        # see #44204
+        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/pkgconfig *.pc] {
+            set framework [file rootname [file tail ${f}]]
+            set incname   [string map {Qt5 Qt} ${framework}]
+            reinplace "s|-I\${includedir}/${incname}|-I\${includedir}|g" ${f}
+            reinplace "s|includedir=\${prefix}/include|includedir=\${libdir}/${framework}/Headers|g" ${f}
+        }
+
+        # move items out of the Frameworks directory that are more appropriate to lib directory
+        xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}
+        foreach d [glob -tails -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake *] {
+            xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}/${d}
+            foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake/${d} *.cmake] {
+                # ${qt_frameworks_dir} is  ${qt_dir}/Library/Frameworks while
+                # ${qt_libs_dir}       is  ${qt_dir}/lib
+                # unless modified, cmake files will point to a directory that is too high in the directory hierarchy
+                reinplace "s|/../../../../|/../../../${qt_dir_rel}/|g" ${f}
+                file rename ${f} ${destroot}${qt_cmake_module_dir}/${d}/
+            }
+        }
+
+        if {![variant_isset exclusive]} {
+            # get Qt's version numbers
+
+            set qt_vers [split ${version} "."]
+            set qt_major [lindex ${qt_vers} 0]
+            set qt_minor [lindex ${qt_vers} 1]
+            set qt_patch [lindex ${qt_vers} 2]
+
+            # link includes and libraries for each actual installed framework
+
+            # make sure that the target directories exist
+            exec mkdir -p ${destroot}${qt_includes_dir} ${destroot}${qt_libs_dir}
+            foreach fixfile [exec find ${destroot}${qt_frameworks_dir} \
+                                 -name "*.framework" | \
+                                 sed -e "s@${destroot}@@g"] {
+
+                set tf_full [strsed ${fixfile} {s@\\.framework@@}]
+                set tf [strsed ${tf_full} {g@.*\/@@}]
+
+                # special for QtWebKit entries
+
+                set t_minor ${qt_minor}
+                set is_QtWebKit 0
+                if {[string compare ${tf} QtWebKit] == 0} {
+                    set t_minor 9
+                    set is_QtWebKit 1
+                }
+
+                # link headers into ${qt_includes_dir}, removing directories
+                # if they are already there first
+
+                set inc_file ${destroot}${qt_includes_dir}/${tf}
+                if {[file exists ${inc_file}]} {
+                    file delete -force ${inc_file}
+                }
+                ln -s ${tf_full}.framework/Headers ${inc_file}
+
+                # link libraries into ${qt_libs_dir}, all 4 number variants
+
+                set dr_qt_libs_dir ${destroot}${qt_libs_dir}
+
+                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.dylib
+                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.dylib
+                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.dylib
+                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib
+
+                # copy .prl file, then correct it for library usage
+
+                copy ${destroot}${tf_full}.framework/${tf}.prl ${dr_qt_libs_dir}/lib${tf}.prl
+
+                # fix TARGET in .prl file
+
+                reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}.prl
+
+                # fix PRL_LIBS -F -> -L in .prl file
+
+                reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}.prl
+
+                # fix "-framework Qt*" -> "-lQt*" in .prl file
+
+                reinplace "/QMAKE_PRL_LIBS/s|-framework Qt|-lQt|g" \
+                    ${dr_qt_libs_dir}/lib${tf}.prl
+
+                # remove the QMAKE_PRL_BUILD_DIR line from the .prl file
+                reinplace "/QMAKE_PRL_BUILD_DIR/d" ${dr_qt_libs_dir}/lib${tf}.prl
+
+                # deal with debug files
+
+                # RJVB: I have *not* tested the block below!
+                if {[variant_isset debug]} {
+
+                    # but not if QtWebKit and +universal, since that one does
+                    # not exist (the 32-bit version of the debug library is
+                    # larger than fits into the 32-bit filespace).
+
+                    if {[variant_isset debug] && ${is_QtWebKit}} {
+                        continue
+                    }
+
+                    # link libraries into ${qt_libs_dir}, all 4 number variants
+
+                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.dylib
+                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.dylib
+                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.dylib
+                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib
+
+                    # copy .prl file, then correct it for library usage
+
+                    copy ${destroot}${tf_full}.framework/${tf}_debug.prl ${dr_qt_libs_dir}/lib${tf}_debug.prl
+
+                    # fix TARGET in .prl file
+
+                    reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
+
+                    # fix PRL_LIBS -F -> -L in .prl file
+
+                    reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
+
+                    # fix "-framework Qt*" -> "-lQt*_debug" in .prl file
+
+                    reinplace "/QMAKE_PRL_LIBS/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.prl
+                }
+            }
+
+            ln -s ${qt_qmake_cmd} ${destroot}/${prefix}/bin/qmake-qt${qt_major}
+            ln -s ${qt_moc_cmd} ${destroot}/${prefix}/bin/moc-qt${qt_major}
+            ln -s ${qt_uic_cmd} ${destroot}/${prefix}/bin/uic-qt${qt_major}
+            ln -s ${qt_lrelease_cmd} ${destroot}/${prefix}/bin/lrelease-qt${qt_major}
+        }
+
+        xinstall -m 775 -d ${destroot}${qt_pkg_config_dir}
+        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/pkgconfig *.pc] {
+            file rename ${f} ${destroot}${qt_pkg_config_dir}
+        }
+        xinstall -m 775 -d ${destroot}${qt_libs_dir}/
+        foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir} *.{a,prl,la}] {
+            file rename ${f} ${destroot}${qt_libs_dir}/
+        }
+
+        # move items out of the bin directory that are more appropriate to the Applications directory
+        xinstall -m 775 -d ${destroot}${qt_apps_dir}
+        foreach f [glob -nocomplain -directory ${destroot}${qt_bins_dir} *.app] {
+            file rename ${f} ${destroot}${qt_apps_dir}/
+        }
+
+        if {[variant_isset KDE]} {
+            # expose KF5 styles to Qt5 ... once we know where those styles are stored and if it's still required.
+            #ln -s ${prefix}/lib/kf5??/plugins/styles ${destroot}${qt_plugins_dir}/
+        }
+    }
+
+    variant harfbuzz description {(experimental) Use HarfBuzz-NG to do text shaping} {
+        depends_lib-append port:harfbuzz
+        configure.args-replace \
+            -no-harfbuzz       \
+            -system-harfbuzz
+    }
+
+    variant tests description {Enable tests} {
+        configure.args-replace {-nomake tests} {-make tests}
+    }
+
+    variant examples description {Build examples} {
+        configure.args-replace {-nomake examples} {-make examples}
+    }
+
+    variant debug description {Build both release and debug library} {
+        configure.args-replace -release -debug-and-release
+    }
+}
+
+subport ${name}-docs {
+    depends_lib-append \
+        path:${prefix}/bin/qdoc:${name} \
+        path:${qt_plugins_dir}/sqldrivers/libqsqlite.dylib:${name}-sqlite3-plugin
+
+    supported_archs   noarch
+
+    build.target      docs
+    destroot.target   install_docs
+
+    post-extract {
+        # For the most part, generated makefiles use ${prefix}/bin/qdoc.
+        # There are a couple of places that look in ${worksrcpath}/qtbase/src/tools/qdoc/.
+        ln -s ${prefix}/bin/qdoc ${worksrcpath}/qtbase/src/tools/qdoc/
+        ln -s ${prefix}/bin/qdoc ${worksrcpath}/qtbase/bin
+
+        # Similarly, location of qhelpgenerator is expected in ${worksrcpath}
+        xinstall -d -m 755 ${worksrcpath}/qttools/bin/
+        ln -s ${prefix}/bin/qhelpgenerator ${worksrcpath}/qttools/bin/
+
+        # Without this file, the makefile ${worksrcpath}/qtwebkit/Source/WebCore/Makefile.WebCore.Target
+        #    keeps generating itself over and over again.
+        # This file is only created when the library is being built, however.
+        xinstall -d -m 755 ${worksrcpath}/qtwebkit/Source/WebCore/generated
+        touch ${worksrcpath}/qtwebkit/Source/WebCore/generated/InspectorBackendCommands.qrc
+    }
+}
+
+# See http://qt-project.org/doc/qt-5/sql-driver.html for info on building SQL Database Drivers
+
+subport ${name}-sqlite3-plugin {
+    PortGroup           qmake5 1.0
+
+    depends_lib-append port:sqlite3
+
+    # for single architecture, easier to use
+    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/sqlite,
+    #    but doesn't work for universal build
+    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/sqlite
+    build.dir     ${configure.dir}
+    destroot.dir  ${configure.dir}
+
+    configure.args-append "INCLUDEPATH+=${prefix}/include" "LIBS+=\"-L${prefix}/lib -lsqlite3\""
+}
+
+subport ${name}-psql84-plugin {
+    PortGroup           qmake5 1.0
+
+    depends_lib-append port:postgresql84
+
+    # for single architecture, easier to use
+    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/psql,
+    #    but doesn't work for universal build
+    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/psql
+    build.dir     ${configure.dir}
+    destroot.dir  ${configure.dir}
+
+    configure.args-append "INCLUDEPATH+=${prefix}/include/postgresql84" "LIBS+=\"-L${prefix}/lib/postgresql84 -lpq\""
+}
+
+subport ${name}-mysql56-plugin {
+    PortGroup           qmake5 1.0
+
+    depends_lib-append port:mysql56
+
+    # for single architecture, easier to use
+    #    worksrcdir ${worksrcdir}/qtbase/src/plugins/sqldrivers/mysql,
+    #    but doesn't work for universal build
+    configure.dir ${worksrcpath}/qtbase/src/plugins/sqldrivers/mysql
+    build.dir     ${configure.dir}
+    destroot.dir  ${configure.dir}
+
+    configure.args-append "INCLUDEPATH+=${prefix}/include/mysql56/mysql" "LIBS+=\"-L${prefix}/lib/mysql56/mysql -lmysqlclient_r\""
+}
+
+livecheck.type      regex
+livecheck.url       http://download.qt.io/archive/qt/5.4/
+livecheck.regex     (\\d+(\\.\\d+)+)
Index: files/Add-workaround-for-GL-on-Android-emulator.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Add-workaround-for-GL-on-Android-emulator.patch b/trunk/dports/aqua/qt5-mac/files/Add-workaround-for-GL-on-Android-emulator.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Add-workaround-for-GL-on-Android-emulator.patch	(working copy)
@@ -0,0 +1,35 @@
+From cbf649ff92e7d3416cb9d03609648f96efdf76dd Mon Sep 17 00:00:00 2001
+From: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
+Date: Mon, 17 Mar 2014 19:43:41 -0300
+Subject: [PATCH] Add workaround for GL on Android emulator
+
+On the Android Emulator, the shaders will be compiled by a desktop
+GL driver, since the GL driver in the emulator is just a thin
+wrapper. The GL driver does not necessarily support the precision
+qualifiers, which can cause applications to break. We detect this
+at runtime in the platform plugin and set a workaround flag to
+
+Upstream (9eeb1bd) just enabled the workaround when the android
+backend is used, which is not true in our case (traditional desktop).
+As a consequence, we also need a similar check in order to have
+a functional Ubuntu Touch emulator.
+
+Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
+---
+ src/gui/kernel/qopenglcontext.cpp | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- qtbase/src/gui/kernel/qopenglcontext.cpp
++++ qtbase/src/gui/kernel/qopenglcontext.cpp
+@@ -815,6 +815,11 @@
+ 
+         d->shareGroup->d_func()->deletePendingResources(this);
+ 
++        const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
++        if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) {
++            QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(this);
++            ctx_d->workaround_missingPrecisionQualifiers = true;
++        }
+ #ifndef QT_NO_DEBUG
+         QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
+ #endif
Index: files/Always-lock-the-DBus-dispatcher-before-dbus_connecti.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Always-lock-the-DBus-dispatcher-before-dbus_connecti.patch b/trunk/dports/aqua/qt5-mac/files/Always-lock-the-DBus-dispatcher-before-dbus_connecti.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Always-lock-the-DBus-dispatcher-before-dbus_connecti.patch	(working copy)
@@ -0,0 +1,88 @@
+From 6a2bdc4ee2dc49b5d89d09a1f255a7a0e2f18acf Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Tue, 28 Oct 2014 17:23:09 -0700
+Subject: [PATCH 1/3] Always lock the DBus dispatcher before
+ dbus_connection_send*
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We lock it before dbus_connection_send_with_reply (the async version) in
+QDBusConnectionPrivate::sendWithReplyAsync. We weren't locking it before
+send_with_reply_and_block and we apparently should. The locking around
+the dbus_connection_send function might not be necessary, but let's do
+it to be safe.
+
+The lock now needs to be recursive because we may be inside
+QDBusConnectionPrivate::doDispatch.
+
+Task-number: QTBUG-42189
+Change-Id: I7b6b350909359817ea8b3f9c693bced042c9779a
+Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
+Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
+---
+ src/dbus/qdbusintegrator.cpp  | 19 +++++++++++++++----
+ src/dbus/qdbusthreaddebug_p.h |  3 +++
+ 2 files changed, 18 insertions(+), 4 deletions(-)
+
+--- qtbase/src/dbus/qdbusintegrator.cpp
++++ qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1017,7 +1017,7 @@
+ 
+ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
+     : QObject(p), ref(1), capabilities(0), mode(InvalidMode), connection(0), server(0), busService(0),
+-      watchAndTimeoutLock(QMutex::Recursive),
++      watchAndTimeoutLock(QMutex::Recursive), dispatchLock(QMutex::Recursive),
+       rootNode(QString(QLatin1Char('/'))),
+       anonymousAuthenticationAllowed(false)
+ {
+@@ -1266,7 +1266,10 @@
+     //qDBusDebug() << "Emitting signal" << message;
+     //qDBusDebug() << "for paths:";
+     q_dbus_message_set_no_reply(msg, true); // the reply would not be delivered to anything
+-    huntAndEmit(connection, msg, obj, rootNode, isScriptable, isAdaptor);
++    {
++        QDBusDispatchLocker locker(HuntAndEmitAction, this);
++        huntAndEmit(connection, msg, obj, rootNode, isScriptable, isAdaptor);
++    }
+     q_dbus_message_unref(msg);
+ }
+ 
+@@ -1923,7 +1926,11 @@
+ 
+     qDBusDebug() << this << "sending message (no reply):" << message;
+     checkThread();
+-    bool isOk = q_dbus_connection_send(connection, msg, 0);
++    bool isOk;
++    {
++        QDBusDispatchLocker locker(SendMessageAction, this);
++        isOk = q_dbus_connection_send(connection, msg, 0);
++    }
+     int serial = 0;
+     if (isOk)
+         serial = q_dbus_message_get_serial(msg);
+@@ -1955,7 +1962,11 @@
+ 
+         qDBusDebug() << this << "sending message (blocking):" << message;
+         QDBusErrorInternal error;
+-        DBusMessage *reply = q_dbus_connection_send_with_reply_and_block(connection, msg, timeout, error);
++        DBusMessage *reply;
++        {
++            QDBusDispatchLocker locker(SendWithReplyAndBlockAction, this);
++            reply = q_dbus_connection_send_with_reply_and_block(connection, msg, timeout, error);
++        }
+ 
+         q_dbus_message_unref(msg);
+ 
+--- qtbase/src/dbus/qdbusthreaddebug_p.h
++++ qtbase/src/dbus/qdbusthreaddebug_p.h
+@@ -94,6 +94,9 @@
+     MessageResultReceivedAction = 26,
+     ActivateSignalAction = 27,
+     PendingCallBlockAction = 28,
++    SendMessageAction = 29,
++    SendWithReplyAndBlockAction = 30,
++    HuntAndEmitAction = 31,
+ 
+     AddTimeoutAction = 50,
+     RealAddTimeoutAction = 51,
Index: files/Break-after-handling-the-read-write.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Break-after-handling-the-read-write.patch b/trunk/dports/aqua/qt5-mac/files/Break-after-handling-the-read-write.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Break-after-handling-the-read-write.patch	(working copy)
@@ -0,0 +1,36 @@
+From 2a733b9bf62df746fb538d37ba1b150ada70c0b0 Mon Sep 17 00:00:00 2001
+From: Albert Astals Cid <albert.astals@canonical.com>
+Date: Thu, 27 Nov 2014 13:27:06 +0100
+Subject: [PATCH] Break after handling the read/write
+
+The loop is there because watchers may have two Watcher for the same
+fd, one for read and one for write, but after we're processed the
+correct one we don't need to keep looping.
+
+This fixes a crash since it's possible that while in processing
+q_dbus_watch_handle we get a watch added/remove this invalidating
+the iterator and crashing
+
+Change-Id: Icb61deae272d2f237a4c616fae598404d419df90
+---
+ src/dbus/qdbusintegrator.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- qtbase/src/dbus/qdbusintegrator.cpp
++++ qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1185,6 +1185,7 @@
+         if (it->watch && it->read && it->read->isEnabled()) {
+             if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_READABLE))
+                 qDebug("OUT OF MEM");
++            break;
+         }
+         ++it;
+     }
+@@ -1199,6 +1200,7 @@
+         if (it->watch && it->write && it->write->isEnabled()) {
+             if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_WRITABLE))
+                 qDebug("OUT OF MEM");
++            break;
+         }
+         ++it;
+     }
Index: files/Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch b/trunk/dports/aqua/qt5-mac/files/Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Don-t-always-chmod-the-XDG_RUNTIME_DIR.patch	(working copy)
@@ -0,0 +1,29 @@
+From 5f6d7003c4be42477c92b79b7eb73272c31b1585 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Thu, 2 Oct 2014 11:49:55 -0700
+Subject: [PATCH] Don't always chmod the XDG_RUNTIME_DIR
+
+Since the current user is the owner of the dir, we'll get 0x7700 as
+permissions, not just 0x700. With the wrong check, we were always doing
+an unnecessary chmod.
+
+Task-number: QTBUG-41735
+Change-Id: Ib1fc258fef4bf526baa9c71201f9b78d36f5454f
+---
+ src/corelib/io/qstandardpaths_unix.cpp | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- qtbase/src/corelib/io/qstandardpaths_unix.cpp
++++ qtbase/src/corelib/io/qstandardpaths_unix.cpp
+@@ -138,8 +138,10 @@
+             return QString();
+         }
+         // "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
++        // since the current user is the owner, set both xxxUser and xxxOwner
+         QFile file(xdgRuntimeDir);
+-        const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
++        const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
++                                               | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
+         if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) {
+             qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir));
+             return QString();
Index: files/Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch b/trunk/dports/aqua/qt5-mac/files/Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Fix-crash-in-QNetworkAccessCacheBackend-closeDownstr.patch	(working copy)
@@ -0,0 +1,82 @@
+From 020fc9e9dcd19ef515e48c96e83fd6f75d52684a Mon Sep 17 00:00:00 2001
+From: Albert Astals Cid <albert.astals@canonical.com>
+Date: Thu, 18 Sep 2014 17:59:51 +0200
+Subject: [PATCH] Fix crash in
+ QNetworkAccessCacheBackend::closeDownstreamChannel
+
+device is private, always null and class has no friends, so no need to have it at all
+
+Change-Id: I320d47f1a712a3202c08b494563533e29d185501
+---
+ src/network/access/qnetworkaccesscachebackend.cpp           |  6 ------
+ src/network/access/qnetworkaccesscachebackend_p.h           |  1 -
+ .../qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp     | 13 +++++++++++++
+ 3 files changed, 13 insertions(+), 7 deletions(-)
+
+--- qtbase/src/network/access/qnetworkaccesscachebackend.cpp
++++ qtbase/src/network/access/qnetworkaccesscachebackend.cpp
+@@ -52,7 +52,6 @@
+ 
+ QNetworkAccessCacheBackend::QNetworkAccessCacheBackend()
+     : QNetworkAccessBackend()
+-    , device(0)
+ {
+ }
+ 
+@@ -125,11 +124,6 @@
+ 
+ void QNetworkAccessCacheBackend::closeDownstreamChannel()
+ {
+-    if (operation() == QNetworkAccessManager::GetOperation) {
+-        device->close();
+-        delete device;
+-        device = 0;
+-    }
+ }
+ 
+ void QNetworkAccessCacheBackend::closeUpstreamChannel()
+--- qtbase/src/network/access/qnetworkaccesscachebackend_p.h
++++ qtbase/src/network/access/qnetworkaccesscachebackend_p.h
+@@ -75,7 +75,6 @@
+ 
+ private:
+     bool sendCacheContents();
+-    QIODevice *device;
+ 
+ };
+ 
+--- qtbase/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
++++ qtbase/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp
+@@ -42,6 +42,7 @@
+ #include <QtTest/QtTest>
+ 
+ #include <QtNetwork/QNetworkAccessManager>
++#include <QtNetwork/QNetworkReply>
+ #ifndef QT_NO_BEARERMANAGEMENT
+ #include <QtNetwork/QNetworkConfigurationManager>
+ #endif
+@@ -61,6 +62,7 @@
+ 
+ private slots:
+     void networkAccessible();
++    void alwaysCacheRequest();
+ };
+ 
+ tst_QNetworkAccessManager::tst_QNetworkAccessManager()
+@@ -126,5 +128,16 @@
+ #endif
+ }
+ 
++void tst_QNetworkAccessManager::alwaysCacheRequest()
++{
++    QNetworkAccessManager manager;
++
++    QNetworkRequest req;
++    req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
++    QNetworkReply *reply = manager.get(req);
++    reply->close();
++    delete reply;
++}
++
+ QTEST_MAIN(tst_QNetworkAccessManager)
+ #include "tst_qnetworkaccessmanager.moc"
Index: files/Partially-revert-Fix-a-deadlock-introduced-by-the-ra.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Partially-revert-Fix-a-deadlock-introduced-by-the-ra.patch b/trunk/dports/aqua/qt5-mac/files/Partially-revert-Fix-a-deadlock-introduced-by-the-ra.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Partially-revert-Fix-a-deadlock-introduced-by-the-ra.patch	(working copy)
@@ -0,0 +1,85 @@
+From 73a1e8c60d894701f34806cc4b847aa2814bf389 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Tue, 28 Oct 2014 19:34:01 -0700
+Subject: [PATCH 3/3] Partially revert "Fix a deadlock introduced by the race
+ condition fix"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The commit was 9361be58f47ec256bf920c378479a02501219c1f (2008-11-17),
+referring to the race condition fix that was applied in commit
+d47c05b1889bb4f06203bbc65f4660b8d0128954 (2008-10-08). The fix for the
+deadlock reintroduced the race condition and the commit message noted
+it.
+
+The workaround is no longer necessary since we've fixed the original race
+condition differently now (see the previous two commits).
+
+Task-number: QTBUG-42189
+Change-Id: I5a83249597a83c4d4caa2ae57964ad3cc61c1d70
+Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
+Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
+Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
+---
+ src/dbus/qdbusintegrator.cpp | 40 ++++++++++++++--------------------------
+ 1 file changed, 14 insertions(+), 26 deletions(-)
+
+--- qtbase/src/dbus/qdbusintegrator.cpp
++++ qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1179,41 +1179,29 @@
+ 
+ void QDBusConnectionPrivate::socketRead(int fd)
+ {
+-    QVarLengthArray<DBusWatch *, 2> pendingWatches;
+-
+-    {
+-        QDBusDispatchLocker locker(SocketReadAction, this);
+-        WatcherHash::ConstIterator it = watchers.constFind(fd);
+-        while (it != watchers.constEnd() && it.key() == fd) {
+-            if (it->watch && it->read && it->read->isEnabled())
+-                pendingWatches.append(it.value().watch);
+-            ++it;
++    QDBusDispatchLocker locker(SocketReadAction, this);
++    WatcherHash::ConstIterator it = watchers.constFind(fd);
++    while (it != watchers.constEnd() && it.key() == fd) {
++        if (it->watch && it->read && it->read->isEnabled()) {
++            if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_READABLE))
++                qDebug("OUT OF MEM");
+         }
++        ++it;
+     }
+-
+-    for (int i = 0; i < pendingWatches.size(); ++i)
+-        if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_READABLE))
+-            qDebug("OUT OF MEM");
+     doDispatch();
+ }
+ 
+ void QDBusConnectionPrivate::socketWrite(int fd)
+ {
+-    QVarLengthArray<DBusWatch *, 2> pendingWatches;
+-
+-    {
+-        QDBusDispatchLocker locker(SocketWriteAction, this);
+-        WatcherHash::ConstIterator it = watchers.constFind(fd);
+-        while (it != watchers.constEnd() && it.key() == fd) {
+-            if (it->watch && it->write && it->write->isEnabled())
+-                pendingWatches.append(it.value().watch);
+-            ++it;
++    QDBusDispatchLocker locker(SocketWriteAction, this);
++    WatcherHash::ConstIterator it = watchers.constFind(fd);
++    while (it != watchers.constEnd() && it.key() == fd) {
++        if (it->watch && it->write && it->write->isEnabled()) {
++            if (!q_dbus_watch_handle(it.value().watch, DBUS_WATCH_WRITABLE))
++                qDebug("OUT OF MEM");
+         }
++        ++it;
+     }
+-
+-    for (int i = 0; i < pendingWatches.size(); ++i)
+-        if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_WRITABLE))
+-            qDebug("OUT OF MEM");
+ }
+ 
+ void QDBusConnectionPrivate::objectDestroyed(QObject *obj)
Index: files/QDBusConnection-Merge-the-dispatch-and-the-watch-and.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/QDBusConnection-Merge-the-dispatch-and-the-watch-and.patch b/trunk/dports/aqua/qt5-mac/files/QDBusConnection-Merge-the-dispatch-and-the-watch-and.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/QDBusConnection-Merge-the-dispatch-and-the-watch-and.patch	(working copy)
@@ -0,0 +1,178 @@
+From eb99c28861f5e841f306cfe8689627fe0e9bf2e8 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Tue, 28 Oct 2014 19:26:17 -0700
+Subject: [PATCH 2/3] QDBusConnection: Merge the dispatch and the
+ watch-and-timeout locks
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+We don't need two anymore because they now protect the same thing: the
+state of the DBusConnection. The difference existed when it was possible
+for two threads to access the DBusConnection at the same time: one doing
+dispatching and one doing something else. Unfortunately, even though
+DBusConnection supports this, QtDBus doesn't.
+
+From d47c05b1889bb4f06203bbc65f4660b8d0128954 (2008-10-08):
+   Details:  if we're removing a timer or a watcher from our list,
+   there's a race condition: one thread (not the QDBusConnection thread)
+   could be asking for the removal (which causes an event to be sent),
+   then deletes the pointer. In the meantime, QDBusConnection will
+   process the timers and socket notifiers and could end up calling
+   lidbus-1 with deleted pointers.
+
+That commit fixed the race condition but introduced a deadlock.
+
+Task-number: QTBUG-42189
+Change-Id: I034038f763cbad3a67398909defd31a23c27c965
+Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
+Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
+Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
+---
+ src/dbus/qdbusconnection_p.h  | 16 +++++-----------
+ src/dbus/qdbusintegrator.cpp  | 22 +++++++++++-----------
+ src/dbus/qdbusthreaddebug_p.h |  7 -------
+ 3 files changed, 16 insertions(+), 29 deletions(-)
+
+--- qtbase/src/dbus/qdbusconnection_p.h
++++ qtbase/src/dbus/qdbusconnection_p.h
+@@ -290,24 +290,18 @@
+     QStringList serverConnectionNames;
+ 
+     ConnectionMode mode;
++    QDBusConnectionInterface *busService;
+ 
+-    // members accessed in unlocked mode (except for deletion)
+-    // connection and server provide their own locking mechanisms
+-    // busService doesn't have state to be changed
++    // the dispatch lock protects everything related to the DBusConnection or DBusServer
++    // including the timeouts and watches
++    QMutex dispatchLock;
+     DBusConnection *connection;
+     DBusServer *server;
+-    QDBusConnectionInterface *busService;
+-
+-    // watchers and timeouts are accessed from any thread
+-    // but the corresponding timer and QSocketNotifier must be handled
+-    // only in the object's thread
+-    QMutex watchAndTimeoutLock;
+     WatcherHash watchers;
+     TimeoutHash timeouts;
+     PendingTimeoutList timeoutsPendingAdd;
+ 
+-    // members accessed through a lock
+-    QMutex dispatchLock;
++    // the master lock protects our own internal state
+     QReadWriteLock lock;
+     QDBusError lastError;
+ 
+--- qtbase/src/dbus/qdbusintegrator.cpp
++++ qtbase/src/dbus/qdbusintegrator.cpp
+@@ -155,7 +155,7 @@
+     if (!q_dbus_timeout_get_enabled(timeout))
+         return true;
+ 
+-    QDBusWatchAndTimeoutLocker locker(AddTimeoutAction, d);
++    QDBusDispatchLocker locker(AddTimeoutAction, d);
+     if (QCoreApplication::instance() && QThread::currentThread() == d->thread()) {
+         // correct thread
+         return qDBusRealAddTimeout(d, timeout, q_dbus_timeout_get_interval(timeout));
+@@ -190,7 +190,7 @@
+ 
+     QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
+ 
+-    QDBusWatchAndTimeoutLocker locker(RemoveTimeoutAction, d);
++    QDBusDispatchLocker locker(RemoveTimeoutAction, d);
+ 
+     // is it pending addition?
+     QDBusConnectionPrivate::PendingTimeoutList::iterator pit = d->timeoutsPendingAdd.begin();
+@@ -263,7 +263,7 @@
+ {
+     QDBusConnectionPrivate::Watcher watcher;
+ 
+-    QDBusWatchAndTimeoutLocker locker(AddWatchAction, d);
++    QDBusDispatchLocker locker(AddWatchAction, d);
+     if (flags & DBUS_WATCH_READABLE) {
+         //qDebug("addReadWatch %d", fd);
+         watcher.watch = watch;
+@@ -297,7 +297,7 @@
+     QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data);
+     int fd = q_dbus_watch_get_unix_fd(watch);
+ 
+-    QDBusWatchAndTimeoutLocker locker(RemoveWatchAction, d);
++    QDBusDispatchLocker locker(RemoveWatchAction, d);
+     QDBusConnectionPrivate::WatcherHash::iterator i = d->watchers.find(fd);
+     while (i != d->watchers.end() && i.key() == fd) {
+         if (i.value().watch == watch) {
+@@ -341,7 +341,7 @@
+ 
+ static void qDBusRealToggleWatch(QDBusConnectionPrivate *d, DBusWatch *watch, int fd)
+ {
+-    QDBusWatchAndTimeoutLocker locker(ToggleWatchAction, d);
++    QDBusDispatchLocker locker(ToggleWatchAction, d);
+ 
+     QDBusConnectionPrivate::WatcherHash::iterator i = d->watchers.find(fd);
+     while (i != d->watchers.end() && i.key() == fd) {
+@@ -1016,8 +1016,8 @@
+ extern bool qDBusInitThreads();
+ 
+ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
+-    : QObject(p), ref(1), capabilities(0), mode(InvalidMode), connection(0), server(0), busService(0),
+-      watchAndTimeoutLock(QMutex::Recursive), dispatchLock(QMutex::Recursive),
++    : QObject(p), ref(1), capabilities(0), mode(InvalidMode), busService(0),
++      dispatchLock(QMutex::Recursive), connection(0), server(0),
+       rootNode(QString(QLatin1Char('/'))),
+       anonymousAuthenticationAllowed(false)
+ {
+@@ -1127,7 +1127,7 @@
+ void QDBusConnectionPrivate::timerEvent(QTimerEvent *e)
+ {
+     {
+-        QDBusWatchAndTimeoutLocker locker(TimerEventAction, this);
++        QDBusDispatchLocker locker(TimerEventAction, this);
+         DBusTimeout *timeout = timeouts.value(e->timerId(), 0);
+         if (timeout)
+             q_dbus_timeout_handle(timeout);
+@@ -1146,7 +1146,7 @@
+     switch (ev->subtype)
+     {
+     case QDBusConnectionCallbackEvent::AddTimeout: {
+-        QDBusWatchAndTimeoutLocker locker(RealAddTimeoutAction, this);
++        QDBusDispatchLocker locker(RealAddTimeoutAction, this);
+         while (!timeoutsPendingAdd.isEmpty()) {
+             QPair<DBusTimeout *, int> entry = timeoutsPendingAdd.takeFirst();
+             qDBusRealAddTimeout(this, entry.first, entry.second);
+@@ -1182,7 +1182,7 @@
+     QVarLengthArray<DBusWatch *, 2> pendingWatches;
+ 
+     {
+-        QDBusWatchAndTimeoutLocker locker(SocketReadAction, this);
++        QDBusDispatchLocker locker(SocketReadAction, this);
+         WatcherHash::ConstIterator it = watchers.constFind(fd);
+         while (it != watchers.constEnd() && it.key() == fd) {
+             if (it->watch && it->read && it->read->isEnabled())
+@@ -1202,7 +1202,7 @@
+     QVarLengthArray<DBusWatch *, 2> pendingWatches;
+ 
+     {
+-        QDBusWatchAndTimeoutLocker locker(SocketWriteAction, this);
++        QDBusDispatchLocker locker(SocketWriteAction, this);
+         WatcherHash::ConstIterator it = watchers.constFind(fd);
+         while (it != watchers.constEnd() && it.key() == fd) {
+             if (it->watch && it->write && it->write->isEnabled())
+--- qtbase/src/dbus/qdbusthreaddebug_p.h
++++ qtbase/src/dbus/qdbusthreaddebug_p.h
+@@ -207,13 +207,6 @@
+     { }
+ };
+ 
+-struct QDBusWatchAndTimeoutLocker: QDBusMutexLocker
+-{
+-    inline QDBusWatchAndTimeoutLocker(ThreadAction a, QDBusConnectionPrivate *s)
+-        : QDBusMutexLocker(a, s, &s->watchAndTimeoutLock)
+-    { }
+-};
+-
+ #if QDBUS_THREAD_DEBUG
+ # define SEM_ACQUIRE(action, sem)                                       \
+     do {                                                                \
Index: files/QtBearer-networkmanager-make-sure-to-set-flag-Active.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/QtBearer-networkmanager-make-sure-to-set-flag-Active.patch b/trunk/dports/aqua/qt5-mac/files/QtBearer-networkmanager-make-sure-to-set-flag-Active.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/QtBearer-networkmanager-make-sure-to-set-flag-Active.patch	(working copy)
@@ -0,0 +1,600 @@
+From dedb8c1c928edbbb4408a0c5889353b142b20d1c Mon Sep 17 00:00:00 2001
+From: Lorn Potter <lorn.potter@gmail.com>
+Date: Thu, 13 Nov 2014 13:06:49 +1000
+Subject: [PATCH] QtBearer networkmanager make sure to set flag Active
+
+Also, no need to create objects to get properties, when the properties
+can be had for free.
+
+Make plugin more robust to network-manager or ofono crashes
+
+Change-Id: Ibadb46bd51aa27f130f8d245e8c50aa7bff5f9c8
+---
+ .../bearer/linux_common/qofonoservice_linux.cpp    |  12 +
+ .../bearer/linux_common/qofonoservice_linux_p.h    |   2 +
+ src/plugins/bearer/networkmanager/main.cpp         |   5 +-
+ .../networkmanager/qnetworkmanagerengine.cpp       | 310 ++++++++++++++-------
+ .../bearer/networkmanager/qnetworkmanagerengine.h  |  13 +
+ .../networkmanager/qnetworkmanagerservice.cpp      |  22 ++
+ .../bearer/networkmanager/qnetworkmanagerservice.h |   2 +
+ 7 files changed, 263 insertions(+), 103 deletions(-)
+
+--- qtbase/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
++++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+@@ -269,6 +269,18 @@
+     return contextList;
+ }
+ 
++PathPropertiesList QOfonoDataConnectionManagerInterface::contextsWithProperties()
++{
++    if (contextListProperties.isEmpty()) {
++        QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts"));
++        reply.waitForFinished();
++        if (!reply.isError()) {
++            contextListProperties = reply.value();
++        }
++    }
++    return contextListProperties;
++}
++
+ bool QOfonoDataConnectionManagerInterface::roamingAllowed()
+ {
+     QVariant var = getProperty(QStringLiteral("RoamingAllowed"));
+--- qtbase/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
++++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
+@@ -153,6 +153,7 @@
+     ~QOfonoDataConnectionManagerInterface();
+ 
+     QStringList contexts();
++    PathPropertiesList contextsWithProperties();
+     bool roamingAllowed();
+     QVariant getProperty(const QString &);
+     QString bearer();
+@@ -162,6 +163,7 @@
+     QVariantMap getProperties();
+     QVariantMap propertiesMap;
+     QStringList contextList;
++    PathPropertiesList contextListProperties;
+ private slots:
+     void propertyChanged(const QString &, const QDBusVariant &value);
+ };
+--- qtbase/src/plugins/bearer/networkmanager/main.cpp
++++ qtbase/src/plugins/bearer/networkmanager/main.cpp
+@@ -66,10 +66,7 @@
+ {
+     if (key == QLatin1String("networkmanager")) {
+         QNetworkManagerEngine *engine = new QNetworkManagerEngine;
+-        if (engine->networkManagerAvailable())
+-            return engine;
+-        else
+-            delete engine;
++        return engine;
+     }
+ 
+     return 0;
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+@@ -56,29 +56,34 @@
+ 
+ QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
+ :   QBearerEngineImpl(parent),
+-    managerInterface(new QNetworkManagerInterface(this)),
+-    systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this)),
+-    ofonoManager(new QOfonoManagerInterface(this))
++    managerInterface(NULL),
++    systemSettings(NULL),
++    ofonoManager(NULL),
++    nmAvailable(false)
+ {
+-
+-    if (!managerInterface->isValid())
+-        return;
+-
+     qDBusRegisterMetaType<QNmSettingsMap>();
+ 
+-    connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)),
+-            this, SLOT(deviceAdded(QDBusObjectPath)));
+-    connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)),
+-            this, SLOT(deviceRemoved(QDBusObjectPath)));
+-    connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
+-            this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
+-    connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
+-            this, SLOT(interfacePropertiesChanged(QMap<QString,QVariant>)));
+-    managerInterface->setConnections();
++    nmWatcher = new QDBusServiceWatcher(NM_DBUS_SERVICE,QDBusConnection::systemBus(),
++            QDBusServiceWatcher::WatchForRegistration |
++            QDBusServiceWatcher::WatchForUnregistration, this);
++    connect(nmWatcher, SIGNAL(serviceRegistered(QString)),
++            this, SLOT(nmRegistered(QString)));
++    connect(nmWatcher, SIGNAL(serviceUnregistered(QString)),
++            this, SLOT(nmUnRegistered(QString)));
++
++    ofonoWatcher = new QDBusServiceWatcher("org.ofono",QDBusConnection::systemBus(),
++            QDBusServiceWatcher::WatchForRegistration |
++            QDBusServiceWatcher::WatchForUnregistration, this);
++    connect(ofonoWatcher, SIGNAL(serviceRegistered(QString)),
++            this, SLOT(ofonoRegistered(QString)));
++    connect(ofonoWatcher, SIGNAL(serviceUnregistered(QString)),
++            this, SLOT(ofonoUnRegistered(QString)));
+ 
+-    connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
+-            this, SLOT(newConnection(QDBusObjectPath)));
+-    systemSettings->setConnections();
++    if (QDBusConnection::systemBus().interface()->isServiceRegistered("org.ofono"))
++        ofonoRegistered();
++
++    if (QDBusConnection::systemBus().interface()->isServiceRegistered(NM_DBUS_SERVICE))
++        nmRegistered();
+ }
+ 
+ QNetworkManagerEngine::~QNetworkManagerEngine()
+@@ -105,15 +110,13 @@
+ 
+ void QNetworkManagerEngine::initialize()
+ {
+-    QMutexLocker locker(&mutex);
++    if (nmAvailable)
++        setupConfigurations();
++}
+ 
+-    if (ofonoManager->isValid()) {
+-        Q_FOREACH (const QString &modem, ofonoManager->getModems()) {
+-            QOfonoDataConnectionManagerInterface *ofonoContextManager
+-                    = new QOfonoDataConnectionManagerInterface(modem,this);
+-            ofonoContextManagers.insert(modem, ofonoContextManager);
+-        }
+-    }
++void QNetworkManagerEngine::setupConfigurations()
++{
++    QMutexLocker locker(&mutex);
+     // Get active connections.
+     foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
+ 
+@@ -151,7 +154,7 @@
+ 
+ bool QNetworkManagerEngine::networkManagerAvailable() const
+ {
+-    return managerInterface->isValid();
++    return nmAvailable;
+ }
+ 
+ QString QNetworkManagerEngine::getInterfaceFromId(const QString &settingsPath)
+@@ -180,6 +183,9 @@
+     const QString settingsPath = connection->connectionInterface()->path();
+     QString specificPath = configuredAccessPoints.key(settingsPath);
+ 
++    if (isConnectionActive(settingsPath))
++        return;
++
+     QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices);
+     while (i.hasNext()) {
+         i.next();
+@@ -229,7 +235,7 @@
+ 
+ void QNetworkManagerEngine::requestUpdate()
+ {
+-    if (managerInterface->wirelessEnabled()) {
++    if (managerInterface && managerInterface->wirelessEnabled()) {
+         QHashIterator<QString, QNetworkManagerInterfaceDeviceWireless *> i(wirelessDevices);
+         while (i.hasNext()) {
+             i.next();
+@@ -282,8 +288,9 @@
+                 if (ptr) {
+                     ptr->mutex.lock();
+                     if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
+-                        ptr->state != QNetworkConfiguration::Active) {
+-                        ptr->state = QNetworkConfiguration::Active;
++                            (ptr->state & QNetworkConfiguration::Active) != QNetworkConfiguration::Active) {
++
++                        ptr->state |= QNetworkConfiguration::Active;
+ 
+                         if (activeConnectionsList.value(id) && activeConnectionsList.value(id)->defaultRoute()
+                                 && managerInterface->state() < QNetworkManagerInterface::NM_STATE_CONNECTED_GLOBAL) {
+@@ -339,23 +346,25 @@
+ 
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+     if (ptr) {
+-        ptr->mutex.lock();
+-        if (properties.value("State").toUInt() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+-            QStringList devices = activeConnection->devices();
+-            if (!devices.isEmpty()) {
+-                QNetworkManagerInterfaceDevice device(devices.at(0),this);
+-                connectionInterfaces.insert(id,device.networkInterface());
+-            }
+-
+-            ptr->state |= QNetworkConfiguration::Active;
+-            ptr->mutex.unlock();
+-
+-            locker.unlock();
+-            emit configurationChanged(ptr);
+-            locker.relock();
+-        } else {
+-            connectionInterfaces.remove(id);
+-            ptr->mutex.unlock();
++        if (properties.contains(QStringLiteral("State"))) {
++            ptr->mutex.lock();
++            if (properties.value("State").toUInt() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
++                QStringList devices = activeConnection->devices();
++                if (!devices.isEmpty()) {
++                    QNetworkManagerInterfaceDevice device(devices.at(0),this);
++                    connectionInterfaces.insert(id,device.networkInterface());
++                }
++
++                ptr->state |= QNetworkConfiguration::Active;
++                ptr->mutex.unlock();
++
++                locker.unlock();
++                emit configurationChanged(ptr);
++                locker.relock();
++            } else {
++                connectionInterfaces.remove(id);
++                ptr->mutex.unlock();
++            }
+         }
+     }
+ }
+@@ -403,9 +412,6 @@
+         connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished()));
+         wirelessDevice->setConnections();
+ 
+-        foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
+-            newAccessPoint(apPath.path());
+-
+         wirelessDevices.insert(path.path(), wirelessDevice);
+     }
+ 
+@@ -518,14 +524,9 @@
+         parseConnection(settingsPath, connection->getSettings());
+ 
+     // Check if connection is active.
+-    QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
+-    while (i.hasNext()) {
+-        i.next();
+-        if (i.value()->connection().path() == settingsPath) {
+-            cpPriv->state |= QNetworkConfiguration::Active;
+-            break;
+-        }
+-    }
++    if (isConnectionActive(settingsPath))
++        cpPriv->state |= QNetworkConfiguration::Active;
++
+     if (deviceType == DEVICE_TYPE_ETHERNET) {
+         QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices);
+         while (i.hasNext()) {
+@@ -539,12 +540,36 @@
+              }
+          }
+      }
++
+     QNetworkConfigurationPrivatePointer ptr(cpPriv);
+     accessPointConfigurations.insert(ptr->id, ptr);
+     locker.unlock();
+     emit configurationAdded(ptr);
+ }
+ 
++bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath)
++{
++    QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
++    while (i.hasNext()) {
++        i.next();
++        if (i.value()->connection().path() == settingsPath) {
++            if (i.value()->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
++                    || i.value()->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
++                return true;
++            } else {
++                break;
++            }
++        }
++    }
++
++    QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath);
++    if (settingsConnection->getType() == DEVICE_TYPE_MODEM) {
++        return isActiveContext(settingsConnection->connectionInterface()->path());
++    }
++
++    return false;
++}
++
+ void QNetworkManagerEngine::removeConnection(const QString &path)
+ {
+     QMutexLocker locker(&mutex);
+@@ -652,7 +677,6 @@
+ void QNetworkManagerEngine::newAccessPoint(const QString &path)
+ {
+     QMutexLocker locker(&mutex);
+-
+     QNetworkManagerInterfaceAccessPoint *accessPoint =
+         new QNetworkManagerInterfaceAccessPoint(path,this);
+ 
+@@ -683,6 +707,9 @@
+                 ptr->mutex.lock();
+                 QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+                 ptr->state = (flag | QNetworkConfiguration::Discovered);
++
++                if (isConnectionActive(settingsPath))
++                    ptr->state = (flag | QNetworkConfiguration::Active);
+                 ptr->mutex.unlock();
+ 
+                 locker.unlock();
+@@ -762,7 +789,6 @@
+     QMutexLocker locker(&mutex);
+     QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
+     cpPriv->name = map.value("connection").value("id").toString();
+-
+     cpPriv->isValid = true;
+     cpPriv->id = settingsPath;
+     cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
+@@ -811,18 +837,46 @@
+         }
+     } else if (connectionType == QLatin1String("gsm")) {
+ 
+-        const QString contextPath = map.value("connection").value("id").toString();
+-        cpPriv->name = contextName(contextPath);
+-        cpPriv->bearerType = currentBearerType(contextPath);
+-
+-        if (map.value("connection").contains("timestamp")) {
+-            cpPriv->state |= QNetworkConfiguration::Discovered;
++        const QString connectionPath = map.value("connection").value("id").toString();
++        cpPriv->name = contextName(connectionPath);
++        cpPriv->bearerType = currentBearerType(connectionPath);
++
++        if (ofonoManager && ofonoManager->isValid()) {
++            const QString contextPart = connectionPath.section('/', -1);
++            QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++            while (i.hasNext()) {
++                i.next();
++                const QString path = i.key() +"/"+contextPart;
++                if (isActiveContext(path)) {
++                    cpPriv->state |= QNetworkConfiguration::Active;
++                    break;
++                }
++            }
+         }
+     }
+ 
+     return cpPriv;
+ }
+ 
++bool QNetworkManagerEngine::isActiveContext(const QString &contextPath)
++{
++    if (ofonoManager && ofonoManager->isValid()) {
++        const QString contextPart = contextPath.section('/', -1);
++        QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++        while (i.hasNext()) {
++            i.next();
++            PathPropertiesList list = i.value()->contextsWithProperties();
++            for (int i = 0; i < list.size(); ++i) {
++                if (list.at(i).path.path().contains(contextPart)) {
++                    return list.at(i).properties.value(QStringLiteral("Active")).toBool();
++
++                }
++            }
++        }
++    }
++    return false;
++}
++
+ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const
+ {
+     for (int i = 0; i < connections.count(); ++i) {
+@@ -967,53 +1021,111 @@
+ 
+ QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id)
+ {
+-    if (ofonoManager->isValid()) {
+-        QString contextPart = id.section('/', -1);
++    QString contextPart = id.section('/', -1);
++    QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++    while (i.hasNext()) {
++        i.next();
++        QString contextPath = i.key() +"/"+contextPart;
+ 
+-        QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
+-        while (i.hasNext()) {
+-            i.next();
+-            QString contextPath = i.key() +"/"+contextPart;
+-            if (i.value()->contexts().contains(contextPath)) {
++        if (i.value()->contexts().contains(contextPath)) {
+ 
+-                QString bearer = i.value()->bearer();
+-                if (bearer == QStringLiteral("gsm")) {
+-                    return QNetworkConfiguration::Bearer2G;
+-                } else if (bearer == QStringLiteral("edge")) {
+-                    return QNetworkConfiguration::Bearer2G;
+-                } else if (bearer == QStringLiteral("umts")) {
+-                    return QNetworkConfiguration::BearerWCDMA;
+-                } else if (bearer == QStringLiteral("hspa")
+-                           || bearer == QStringLiteral("hsdpa")
+-                           || bearer == QStringLiteral("hsupa")) {
+-                    return QNetworkConfiguration::BearerHSPA;
+-                } else if (bearer == QStringLiteral("lte")) {
+-                    return QNetworkConfiguration::BearerLTE;
+-                }
++            QString bearer = i.value()->bearer();
++
++            if (bearer == QStringLiteral("gsm")) {
++                return QNetworkConfiguration::Bearer2G;
++            } else if (bearer == QStringLiteral("edge")) {
++                return QNetworkConfiguration::Bearer2G;
++            } else if (bearer == QStringLiteral("umts")) {
++                return QNetworkConfiguration::BearerWCDMA;
++            } else if (bearer == QStringLiteral("hspa")
++                       || bearer == QStringLiteral("hsdpa")
++                       || bearer == QStringLiteral("hsupa")) {
++                return QNetworkConfiguration::BearerHSPA;
++            } else if (bearer == QStringLiteral("lte")) {
++                return QNetworkConfiguration::BearerLTE;
+             }
+         }
+     }
++
+     return QNetworkConfiguration::BearerUnknown;
+ }
+ 
+ QString QNetworkManagerEngine::contextName(const QString &path)
+ {
+-    if (ofonoManager->isValid()) {
+-        QString contextPart = path.section('/', -1);
+-        QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
+-        while (i.hasNext()) {
+-            i.next();
+-            Q_FOREACH (const QString &oContext, i.value()->contexts()) {
+-                if (oContext.contains(contextPart)) {
+-                    QOfonoConnectionContextInterface contextInterface(oContext,this);
+-                    return contextInterface.name();
+-                }
++    QString contextPart = path.section('/', -1);
++    QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++    while (i.hasNext()) {
++        i.next();
++        PathPropertiesList list = i.value()->contextsWithProperties();
++        for (int i = 0; i < list.size(); ++i) {
++            if (list.at(i).path.path().contains(contextPart)) {
++                return list.at(i).properties.value(QStringLiteral("Name")).toString();
+             }
+         }
+     }
+     return path;
+ }
+ 
++void QNetworkManagerEngine::nmRegistered(const QString &)
++{
++    if (ofonoManager) {
++        delete ofonoManager;
++        ofonoManager = NULL;
++    }
++    managerInterface = new QNetworkManagerInterface(this);
++    systemSettings = new QNetworkManagerSettings(NM_DBUS_SERVICE, this);
++
++    connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)),
++            this, SLOT(deviceAdded(QDBusObjectPath)));
++    connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)),
++            this, SLOT(deviceRemoved(QDBusObjectPath)));
++    connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
++            this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
++    connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
++            this, SLOT(interfacePropertiesChanged(QMap<QString,QVariant>)));
++    managerInterface->setConnections();
++
++    connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
++            this, SLOT(newConnection(QDBusObjectPath)));
++    systemSettings->setConnections();
++    nmAvailable = true;
++
++    setupConfigurations();
++}
++
++void QNetworkManagerEngine::nmUnRegistered(const QString &)
++{
++    if (systemSettings) {
++        delete systemSettings;
++        systemSettings = NULL;
++    }
++    if (managerInterface) {
++        delete managerInterface;
++        managerInterface = NULL;
++    }
++}
++
++void QNetworkManagerEngine::ofonoRegistered(const QString &)
++{
++    if (ofonoManager) {
++        delete ofonoManager;
++        ofonoManager = NULL;
++    }
++    ofonoManager = new QOfonoManagerInterface(this);
++    if (ofonoManager && ofonoManager->isValid()) {
++        Q_FOREACH (const QString &modem, ofonoManager->getModems()) {
++            QOfonoDataConnectionManagerInterface *ofonoContextManager
++                    = new QOfonoDataConnectionManagerInterface(modem,this);
++            ofonoContextManagers.insert(modem, ofonoContextManager);
++        }
++    }
++}
++
++void QNetworkManagerEngine::ofonoUnRegistered(const QString &)
++{
++    ofonoContextManagers.clear();
++}
++
+ QT_END_NAMESPACE
+ 
+ #endif // QT_NO_DBUS
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+@@ -109,6 +109,12 @@
+ 
+     void wiredCarrierChanged(bool);
+ 
++    void nmRegistered(const QString &serviceName = QString());
++    void nmUnRegistered(const QString &serviceName = QString());
++
++    void ofonoRegistered(const QString &serviceName = QString());
++    void ofonoUnRegistered(const QString &serviceName = QString());
++
+ private:
+     QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath,
+                                                   const QNmSettingsMap &map);
+@@ -132,6 +138,13 @@
+     QNetworkConfiguration::BearerType currentBearerType(const QString &id);
+     QString contextName(const QString &path);
+ 
++    bool isConnectionActive(const QString &settingsPath);
++    QDBusServiceWatcher *ofonoWatcher;
++    QDBusServiceWatcher *nmWatcher;
++
++    bool isActiveContext(const QString &contextPath);
++    bool nmAvailable;
++    void setupConfigurations();
+ };
+ 
+ QT_END_NAMESPACE
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+@@ -688,6 +688,15 @@
+                                   QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+                                   QLatin1String("PropertiesChanged"),
+                                   this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
++
++    QDBusPendingReply<QList<QDBusObjectPath> > reply
++            = d->connectionInterface->asyncCall(QLatin1String("GetAccessPoints"));
++
++    QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply);
++    connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
++                     this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*)));
++
++
+     d->valid = true;
+ }
+ 
+@@ -749,6 +758,19 @@
+     return allOk;
+ }
+ 
++void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCallWatcher *watcher)
++{
++    QDBusPendingReply<QList<QDBusObjectPath> > reply(*watcher);
++    watcher->deleteLater();
++    if (!reply.isError()) {
++        accessPointsList = reply.value();
++    }
++
++    for (int i = 0; i < accessPointsList.size(); i++) {
++        Q_EMIT accessPointAdded(accessPointsList.at(i).path());
++    }
++}
++
+ QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const
+ {
+     return d->connectionInterface;
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+@@ -369,6 +369,8 @@
+     void slotAccessPointAdded(QDBusObjectPath);
+     void slotAccessPointRemoved(QDBusObjectPath);
+ 
++    void accessPointsFinished(QDBusPendingCallWatcher *watcher);
++
+ private:
+     QNetworkManagerInterfaceDeviceWirelessPrivate *d;
+     QVariantMap propertyMap;
Index: files/Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch b/trunk/dports/aqua/qt5-mac/files/Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Report-the-system-error-on-why-chmod-2-failed-in-XDG.patch	(working copy)
@@ -0,0 +1,27 @@
+From ee10fbaa5ee61fe289d630732c443c7c475f4e94 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Thu, 2 Oct 2014 11:56:22 -0700
+Subject: [PATCH] Report the system error on why chmod(2) failed in
+ XDG_RNTIME_DIR
+
+Why would chmod(2) fail if the current user is the owner of the file? The
+only reason I can think of is EROFS.
+
+Task-number: QTBUG-41735
+Change-Id: I8f8bac763bf5a6e575ed59dac55bd265e5b66271
+---
+ src/corelib/io/qstandardpaths_unix.cpp | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- qtbase/src/corelib/io/qstandardpaths_unix.cpp
++++ qtbase/src/corelib/io/qstandardpaths_unix.cpp
+@@ -143,7 +143,8 @@
+         const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
+                                                | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
+         if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) {
+-            qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir));
++            qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
++                     qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
+             return QString();
+         }
+         return xdgRuntimeDir;
Index: files/Reset-QNAM-s-NetworkConfiguration-when-state-changes.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Reset-QNAM-s-NetworkConfiguration-when-state-changes.patch b/trunk/dports/aqua/qt5-mac/files/Reset-QNAM-s-NetworkConfiguration-when-state-changes.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Reset-QNAM-s-NetworkConfiguration-when-state-changes.patch	(working copy)
@@ -0,0 +1,44 @@
+From 0d9f3517935cf1fe194926a99208f3426d2104af Mon Sep 17 00:00:00 2001
+From: Lorn Potter <lorn.potter@gmail.com>
+Date: Mon, 27 Oct 2014 19:26:47 +1000
+Subject: [PATCH] Reset QNAM's NetworkConfiguration when state changes.
+
+Since QNAM is initialized with defaultConfiguration, we need to
+reset the internal configuration used to the current
+defaultConfiguration when the state changes and a new configuration
+becomes the default.
+
+Task-number: QTBUG-40234
+Change-Id: I50f23c62804f29370915eecac2c92301c5f3ead2
+---
+ src/network/access/qnetworkaccessmanager.cpp | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+--- qtbase/src/network/access/qnetworkaccessmanager.cpp
++++ qtbase/src/network/access/qnetworkaccessmanager.cpp
+@@ -1143,7 +1143,12 @@
+     if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) {
+         QNetworkConfigurationManager manager;
+         if (!d->networkConfiguration.identifier().isEmpty()) {
+-            d->createSession(d->networkConfiguration);
++            if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined)
++                    && d->networkConfiguration != manager.defaultConfiguration())
++                d->createSession(manager.defaultConfiguration());
++            else
++                d->createSession(d->networkConfiguration);
++
+         } else {
+             if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
+                 d->createSession(manager.defaultConfiguration());
+@@ -1598,6 +1603,11 @@
+     if (customNetworkConfiguration) {
+         online = (networkConfiguration.state() & QNetworkConfiguration::Active);
+     } else {
++        if (isOnline && online != isOnline) {
++            networkSessionStrongRef.clear();
++            networkSessionWeakRef.clear();
++        }
++
+         online = isOnline;
+     }
+ }
Index: files/Use-a-property-cache-to-cut-down-on-blocking-calls.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/Use-a-property-cache-to-cut-down-on-blocking-calls.patch b/trunk/dports/aqua/qt5-mac/files/Use-a-property-cache-to-cut-down-on-blocking-calls.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/Use-a-property-cache-to-cut-down-on-blocking-calls.patch	(working copy)
@@ -0,0 +1,4445 @@
+From 1df2cd6af5c40db588fc3ec40c7adfafc1b5eea3 Mon Sep 17 00:00:00 2001
+From: Lorn Potter <lorn.potter@gmail.com>
+Date: Wed, 29 Oct 2014 19:40:43 +1000
+Subject: [PATCH] Use a property cache to cut down on blocking calls
+
+Refactor old code
+Stop memory leaks
+Properly support mobile data (ofono)
+
+Change-Id: I7f23882ee0ee345a049a4a93ddd452b6d2e53710
+---
+ src/plugins/bearer/connman/connman.pro             |   4 +-
+ src/plugins/bearer/connman/qconnmanengine.h        |   2 +-
+ src/plugins/bearer/connman/qofonoservice_linux.cpp | 303 ---------
+ src/plugins/bearer/connman/qofonoservice_linux_p.h | 172 -----
+ .../bearer/linux_common/qofonoservice_linux.cpp    | 370 +++++++++++
+ .../bearer/linux_common/qofonoservice_linux_p.h    | 195 ++++++
+ .../bearer/networkmanager/networkmanager.pro       |   6 +-
+ .../networkmanager/qnetworkmanagerengine.cpp       | 364 +++++------
+ .../bearer/networkmanager/qnetworkmanagerengine.h  |  22 +-
+ .../networkmanager/qnetworkmanagerservice.cpp      | 693 +++++++++++++++------
+ .../bearer/networkmanager/qnetworkmanagerservice.h | 105 +++-
+ .../bearer/networkmanager/qnmdbushelper.cpp        | 140 -----
+ src/plugins/bearer/networkmanager/qnmdbushelper.h  |  73 ---
+ 13 files changed, 1318 insertions(+), 1131 deletions(-)
+ delete mode 100644 src/plugins/bearer/connman/qofonoservice_linux.cpp
+ delete mode 100644 src/plugins/bearer/connman/qofonoservice_linux_p.h
+ create mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+ create mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux_p.h
+ delete mode 100644 src/plugins/bearer/networkmanager/qnmdbushelper.cpp
+ delete mode 100644 src/plugins/bearer/networkmanager/qnmdbushelper.h
+
+--- qtbase/src/plugins/bearer/connman/connman.pro
++++ qtbase/src/plugins/bearer/connman/connman.pro
+@@ -8,14 +8,14 @@
+ CONFIG += link_pkgconfig
+ 
+ HEADERS += qconnmanservice_linux_p.h \
+-           qofonoservice_linux_p.h \
++           ../linux_common/qofonoservice_linux_p.h \
+            qconnmanengine.h \
+            ../qnetworksession_impl.h \
+            ../qbearerengine_impl.h
+ 
+ SOURCES += main.cpp \
+            qconnmanservice_linux.cpp \
+-           qofonoservice_linux.cpp \
++           ../linux_common/qofonoservice_linux.cpp \
+            qconnmanengine.cpp \
+            ../qnetworksession_impl.cpp
+ 
+--- qtbase/src/plugins/bearer/connman/qconnmanengine.h
++++ qtbase/src/plugins/bearer/connman/qconnmanengine.h
+@@ -56,7 +56,7 @@
+ #include "../qbearerengine_impl.h"
+ 
+ #include "qconnmanservice_linux_p.h"
+-#include "qofonoservice_linux_p.h"
++#include "../linux_common/qofonoservice_linux_p.h"
+ 
+ #include <QMap>
+ #include <QVariant>
+--- /dev/null
++++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux.cpp
+@@ -0,0 +1,370 @@
++/****************************************************************************
++**
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
++** Contact: http://www.qt-project.org/legal
++**
++** This file is part of the plugins of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL21$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
++** use the contact form at http://qt.digia.com/contact-us.
++**
++** 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 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Digia gives you certain additional
++** rights. These rights are described in the Digia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include <QObject>
++#include <QList>
++#include <QtDBus/QtDBus>
++#include <QtDBus/QDBusConnection>
++#include <QtDBus/QDBusError>
++#include <QtDBus/QDBusInterface>
++#include <QtDBus/QDBusMessage>
++#include <QtDBus/QDBusReply>
++#include <QtDBus/QDBusPendingCallWatcher>
++#include <QtDBus/QDBusObjectPath>
++#include <QtDBus/QDBusPendingCall>
++
++#include "qofonoservice_linux_p.h"
++
++#ifndef QT_NO_BEARERMANAGEMENT
++#ifndef QT_NO_DBUS
++
++QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item)
++{
++    argument.beginStructure();
++    argument << item.path << item.properties;
++    argument.endStructure();
++    return argument;
++}
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item)
++{
++    argument.beginStructure();
++    argument >> item.path >> item.properties;
++    argument.endStructure();
++    return argument;
++}
++
++QT_BEGIN_NAMESPACE
++
++QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
++        : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
++                                 QStringLiteral(OFONO_MANAGER_PATH),
++                                 OFONO_MANAGER_INTERFACE,
++                                 QDBusConnection::systemBus(), parent)
++{
++    qDBusRegisterMetaType<ObjectPathProperties>();
++    qDBusRegisterMetaType<PathPropertiesList>();
++
++    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
++                           QStringLiteral(OFONO_MANAGER_PATH),
++                           QStringLiteral(OFONO_MANAGER_INTERFACE),
++                           QStringLiteral("ModemAdded"),
++                           this,SLOT(modemAdded(QDBusObjectPath, QVariantMap)));
++    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
++                           QStringLiteral(OFONO_MANAGER_PATH),
++                           QStringLiteral(OFONO_MANAGER_INTERFACE),
++                           QStringLiteral("ModemRemoved"),
++                           this,SLOT(modemRemoved(QDBusObjectPath)));
++}
++
++QOfonoManagerInterface::~QOfonoManagerInterface()
++{
++}
++
++QStringList QOfonoManagerInterface::getModems()
++{
++    if (modemList.isEmpty()) {
++        QList<QVariant> argumentList;
++        QDBusPendingReply<PathPropertiesList> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetModems"), argumentList);
++        reply.waitForFinished();
++        if (!reply.isError()) {
++            foreach (ObjectPathProperties modem, reply.value()) {
++                modemList << modem.path.path();
++            }
++        }
++    }
++
++    return modemList;
++}
++
++QString QOfonoManagerInterface::currentModem()
++{
++    QStringList modems = getModems();
++    foreach (const QString &modem, modems) {
++        QOfonoModemInterface device(modem);
++        if (device.isPowered() && device.isOnline())
++        return modem;
++    }
++    return QString();
++}
++
++void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/)
++{
++    if (!modemList.contains(path.path())) {
++        modemList << path.path();
++        Q_EMIT modemChanged();
++    }
++}
++
++void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path)
++{
++    if (modemList.contains(path.path())) {
++        modemList.removeOne(path.path());
++        Q_EMIT modemChanged();
++    }
++}
++
++
++QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
++    : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
++                             dbusPathName,
++                             OFONO_MODEM_INTERFACE,
++                             QDBusConnection::systemBus(), parent)
++{
++    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
++                                         path(),
++                                         OFONO_MODEM_INTERFACE,
++                                         QStringLiteral("PropertyChanged"),
++                                         this,SLOT(propertyChanged(QString,QDBusVariant)));
++}
++
++QOfonoModemInterface::~QOfonoModemInterface()
++{
++}
++
++void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value)
++{
++    propertiesMap[name] = value.variant();
++}
++
++bool QOfonoModemInterface::isPowered()
++{
++    QVariant var = getProperty(QStringLiteral("Powered"));
++    return qdbus_cast<bool>(var);
++}
++
++bool QOfonoModemInterface::isOnline()
++{
++    QVariant var = getProperty(QStringLiteral("Online"));
++    return qdbus_cast<bool>(var);
++}
++
++QVariantMap QOfonoModemInterface::getProperties()
++{
++    if (propertiesMap.isEmpty()) {
++        QList<QVariant> argumentList;
++        QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
++        if (!reply.isError()) {
++            propertiesMap = reply.value();
++        }
++    }
++    return propertiesMap;
++}
++
++QVariant QOfonoModemInterface::getProperty(const QString &property)
++{
++    QVariant var;
++    QVariantMap map = getProperties();
++    if (map.contains(property))
++        var = map.value(property);
++    return var;
++}
++
++
++QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
++    : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
++                             dbusPathName,
++                             OFONO_NETWORK_REGISTRATION_INTERFACE,
++                             QDBusConnection::systemBus(), parent)
++{
++}
++
++QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
++{
++}
++
++QString QOfonoNetworkRegistrationInterface::getTechnology()
++{
++    QVariant var = getProperty(QStringLiteral("Technology"));
++    return qdbus_cast<QString>(var);
++}
++
++QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
++{
++    QVariant var;
++    QVariantMap map = getProperties();
++    if (map.contains(property))
++        var = map.value(property);
++    return var;
++}
++
++QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
++{
++    if (propertiesMap.isEmpty()) {
++        QList<QVariant> argumentList;
++        QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
++        reply.waitForFinished();
++        if (!reply.isError()) {
++            propertiesMap = reply.value();
++        }
++    }
++    return propertiesMap;
++}
++
++QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
++    : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
++                             dbusPathName,
++                             OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
++                             QDBusConnection::systemBus(), parent)
++{
++    QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE),
++                                         path(),
++                                         QLatin1String(OFONO_MODEM_INTERFACE),
++                                         QLatin1String("PropertyChanged"),
++                                         this,SLOT(propertyChanged(QString,QDBusVariant)));
++}
++
++QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
++{
++}
++
++QStringList QOfonoDataConnectionManagerInterface::contexts()
++{
++    if (contextList.isEmpty()) {
++        QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts"));
++        reply.waitForFinished();
++        if (!reply.isError()) {
++            foreach (ObjectPathProperties context, reply.value()) {
++                contextList << context.path.path();
++            }
++        }
++    }
++    return contextList;
++}
++
++bool QOfonoDataConnectionManagerInterface::roamingAllowed()
++{
++    QVariant var = getProperty(QStringLiteral("RoamingAllowed"));
++    return qdbus_cast<bool>(var);
++}
++
++QString QOfonoDataConnectionManagerInterface::bearer()
++{
++    QVariant var = getProperty(QStringLiteral("Bearer"));
++    return qdbus_cast<QString>(var);
++}
++
++QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
++{
++    QVariant var;
++    QVariantMap map = getProperties();
++    if (map.contains(property))
++        var = map.value(property);
++    return var;
++}
++
++QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
++{
++    if (propertiesMap.isEmpty()) {
++        QList<QVariant> argumentList;
++        QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
++        if (!reply.isError()) {
++            propertiesMap = reply.value();
++        }
++    }
++    return propertiesMap;
++}
++
++void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value)
++{
++    propertiesMap[name] = value.variant();
++    if (name == QLatin1String("RoamingAllowed"))
++        Q_EMIT roamingAllowedChanged(value.variant().toBool());
++}
++
++
++QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent)
++    : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
++                             dbusPathName,
++                             OFONO_CONNECTION_CONTEXT_INTERFACE,
++                             QDBusConnection::systemBus(), parent)
++{
++    QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE),
++                                         path(),
++                                         QLatin1String(OFONO_MODEM_INTERFACE),
++                                         QLatin1String("PropertyChanged"),
++                                         this,SLOT(propertyChanged(QString,QDBusVariant)));
++}
++
++QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface()
++{
++}
++
++QVariantMap QOfonoConnectionContextInterface::getProperties()
++{
++    if (propertiesMap.isEmpty()) {
++        QList<QVariant> argumentList;
++        QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList);
++        if (!reply.isError()) {
++            propertiesMap = reply.value();
++        }
++    }
++    return propertiesMap;
++}
++
++void QOfonoConnectionContextInterface::propertyChanged(const QString &name, const QDBusVariant &value)
++{
++    propertiesMap[name] = value.variant();
++}
++
++QVariant QOfonoConnectionContextInterface::getProperty(const QString &property)
++{
++    QVariant var;
++    QVariantMap map = getProperties();
++    if (map.contains(property))
++        var = map.value(property);
++    return var;
++}
++
++bool QOfonoConnectionContextInterface::active()
++{
++    QVariant var = getProperty(QStringLiteral("Active"));
++    return qdbus_cast<bool>(var);
++}
++
++QString QOfonoConnectionContextInterface::accessPointName()
++{
++    QVariant var = getProperty(QStringLiteral("AccessPointName"));
++    return qdbus_cast<QString>(var);
++}
++
++QString QOfonoConnectionContextInterface::name()
++{
++    QVariant var = getProperty(QStringLiteral("Name"));
++    return qdbus_cast<QString>(var);
++}
++
++QT_END_NAMESPACE
++
++#endif // QT_NO_DBUS
++#endif // QT_NO_BEARERMANAGEMENT
+--- /dev/null
++++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux_p.h
+@@ -0,0 +1,195 @@
++/****************************************************************************
++**
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
++** Contact: http://www.qt-project.org/legal
++**
++** This file is part of the plugins of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL21$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
++** use the contact form at http://qt.digia.com/contact-us.
++**
++** 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 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Digia gives you certain additional
++** rights. These rights are described in the Digia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#ifndef QOFONOSERVICE_H
++#define QOFONOSERVICE_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 <QtDBus/QtDBus>
++#include <QtDBus/QDBusConnection>
++#include <QtDBus/QDBusError>
++#include <QtDBus/QDBusInterface>
++#include <QtDBus/QDBusMessage>
++#include <QtDBus/QDBusReply>
++
++#include <QtDBus/QDBusPendingCallWatcher>
++#include <QtDBus/QDBusObjectPath>
++#include <QtDBus/QDBusContext>
++#include <QMap>
++
++#ifndef QT_NO_BEARERMANAGEMENT
++#ifndef QT_NO_DBUS
++
++#define OFONO_SERVICE                            "org.ofono"
++#define OFONO_MANAGER_INTERFACE                  "org.ofono.Manager"
++#define OFONO_MANAGER_PATH                       "/"
++
++#define OFONO_MODEM_INTERFACE                    "org.ofono.Modem"
++#define OFONO_NETWORK_REGISTRATION_INTERFACE     "org.ofono.NetworkRegistration"
++#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE  "org.ofono.ConnectionManager"
++#define OFONO_CONNECTION_CONTEXT_INTERFACE       "org.ofono.ConnectionContext"
++
++QT_BEGIN_NAMESPACE
++
++QT_END_NAMESPACE
++
++struct ObjectPathProperties
++{
++    QDBusObjectPath path;
++    QVariantMap properties;
++};
++typedef QList<ObjectPathProperties> PathPropertiesList;
++Q_DECLARE_METATYPE(ObjectPathProperties)
++Q_DECLARE_METATYPE (PathPropertiesList)
++
++QT_BEGIN_NAMESPACE
++
++class QOfonoManagerInterface : public  QDBusAbstractInterface
++{
++    Q_OBJECT
++
++public:
++
++    QOfonoManagerInterface( QObject *parent = 0);
++    ~QOfonoManagerInterface();
++
++    QStringList getModems();
++    QString currentModem();
++signals:
++    void modemChanged();
++private:
++    QStringList modemList;
++private slots:
++    void modemAdded(const QDBusObjectPath &path, const QVariantMap &var);
++    void modemRemoved(const QDBusObjectPath &path);
++};
++
++class QOfonoModemInterface : public QDBusAbstractInterface
++{
++    Q_OBJECT
++
++public:
++
++    explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0);
++    ~QOfonoModemInterface();
++
++    bool isPowered();
++    bool isOnline();
++private:
++    QVariantMap getProperties();
++    QVariantMap propertiesMap;
++    QVariant getProperty(const QString &);
++    void propertyChanged(const QString &, const QDBusVariant &value);
++};
++
++
++class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface
++{
++    Q_OBJECT
++
++public:
++
++    explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0);
++    ~QOfonoNetworkRegistrationInterface();
++
++    QString getTechnology();
++
++private:
++    QVariantMap getProperties();
++    QVariant getProperty(const QString &);
++    QVariantMap propertiesMap;
++Q_SIGNALS:
++    void propertyChanged(const QString &, const QDBusVariant &value);
++};
++
++class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface
++{
++    Q_OBJECT
++
++public:
++
++    explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0);
++    ~QOfonoDataConnectionManagerInterface();
++
++    QStringList contexts();
++    bool roamingAllowed();
++    QVariant getProperty(const QString &);
++    QString bearer();
++Q_SIGNALS:
++    void roamingAllowedChanged(bool);
++private:
++    QVariantMap getProperties();
++    QVariantMap propertiesMap;
++    QStringList contextList;
++private slots:
++    void propertyChanged(const QString &, const QDBusVariant &value);
++};
++
++class QOfonoConnectionContextInterface : public QDBusAbstractInterface
++{
++    Q_OBJECT
++
++public:
++
++    explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = 0);
++    ~QOfonoConnectionContextInterface();
++
++    QVariant getProperty(const QString &);
++    bool active();
++    QString accessPointName();
++    QString name();
++
++Q_SIGNALS:
++private:
++    QVariantMap getProperties();
++    QVariantMap propertiesMap;
++private slots:
++    void propertyChanged(const QString &, const QDBusVariant &value);
++};
++
++QT_END_NAMESPACE
++
++#endif // QT_NO_DBUS
++#endif // QT_NO_BEARERMANAGEMENT
++
++#endif //QOFONOSERVICE_H
+--- qtbase/src/plugins/bearer/connman/qofonoservice_linux.cpp
++++ /dev/null
+@@ -1,311 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+-** Contact: http://www.qt-project.org/legal
+-**
+-** This file is part of the plugins of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:LGPL$
+-** Commercial License Usage
+-** Licensees holding valid commercial Qt licenses may use this file in
+-** accordance with the commercial license agreement provided with the
+-** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
+-** use the contact form at http://qt.digia.com/contact-us.
+-**
+-** 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, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
+-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-**
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-
+-#include <QObject>
+-#include <QList>
+-#include <QtDBus/QtDBus>
+-#include <QtDBus/QDBusConnection>
+-#include <QtDBus/QDBusError>
+-#include <QtDBus/QDBusInterface>
+-#include <QtDBus/QDBusMessage>
+-#include <QtDBus/QDBusReply>
+-#include <QtDBus/QDBusPendingCallWatcher>
+-#include <QtDBus/QDBusObjectPath>
+-#include <QtDBus/QDBusPendingCall>
+-
+-#include "qofonoservice_linux_p.h"
+-
+-#ifndef QT_NO_BEARERMANAGEMENT
+-#ifndef QT_NO_DBUS
+-
+-QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item)
+-{
+-    argument.beginStructure();
+-    argument << item.path << item.properties;
+-    argument.endStructure();
+-    return argument;
+-}
+-
+-const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item)
+-{
+-    argument.beginStructure();
+-    argument >> item.path >> item.properties;
+-    argument.endStructure();
+-    return argument;
+-}
+-
+-QT_BEGIN_NAMESPACE
+-
+-QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
+-        : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
+-                                 QStringLiteral(OFONO_MANAGER_PATH),
+-                                 OFONO_MANAGER_INTERFACE,
+-                                 QDBusConnection::systemBus(), parent)
+-{
+-    qDBusRegisterMetaType<ObjectPathProperties>();
+-    qDBusRegisterMetaType<PathPropertiesList>();
+-
+-    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
+-                           QStringLiteral(OFONO_MANAGER_PATH),
+-                           QStringLiteral(OFONO_MANAGER_INTERFACE),
+-                           QStringLiteral("ModemAdded"),
+-                           this,SLOT(modemAdded(QDBusObjectPath, QVariantMap)));
+-    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
+-                           QStringLiteral(OFONO_MANAGER_PATH),
+-                           QStringLiteral(OFONO_MANAGER_INTERFACE),
+-                           QStringLiteral("ModemRemoved"),
+-                           this,SLOT(modemRemoved(QDBusObjectPath)));
+-}
+-
+-QOfonoManagerInterface::~QOfonoManagerInterface()
+-{
+-}
+-
+-QStringList QOfonoManagerInterface::getModems()
+-{
+-    if (modemList.isEmpty()) {
+-        QList<QVariant> argumentList;
+-        QDBusPendingReply<PathPropertiesList> reply = asyncCallWithArgumentList(QLatin1String("GetModems"), argumentList);
+-        reply.waitForFinished();
+-        if (!reply.isError()) {
+-            foreach (ObjectPathProperties modem, reply.value()) {
+-                modemList << modem.path.path();
+-            }
+-        } else {
+-            qDebug() << reply.error().message();
+-        }
+-    }
+-
+-    return modemList;
+-}
+-
+-QString QOfonoManagerInterface::currentModem()
+-{
+-    QStringList modems = getModems();
+-    foreach (const QString &modem, modems) {
+-        QOfonoModemInterface device(modem);
+-        if (device.isPowered() && device.isOnline())
+-        return modem;
+-    }
+-    return QString();
+-}
+-
+-void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/)
+-{
+-    if (!modemList.contains(path.path())) {
+-        modemList << path.path();
+-        Q_EMIT modemChanged();
+-    }
+-}
+-
+-void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path)
+-{
+-    if (modemList.contains(path.path())) {
+-        modemList.removeOne(path.path());
+-        Q_EMIT modemChanged();
+-    }
+-}
+-
+-
+-QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
+-    : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
+-                             dbusPathName,
+-                             OFONO_MODEM_INTERFACE,
+-                             QDBusConnection::systemBus(), parent)
+-{
+-    QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE),
+-                                         path(),
+-                                         OFONO_MODEM_INTERFACE,
+-                                         QStringLiteral("PropertyChanged"),
+-                                         this,SLOT(propertyChanged(QString,QDBusVariant)));
+-}
+-
+-QOfonoModemInterface::~QOfonoModemInterface()
+-{
+-}
+-
+-void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value)
+-{
+-    propertiesMap[name] = value.variant();
+-}
+-
+-bool QOfonoModemInterface::isPowered()
+-{
+-    QVariant var = getProperty(QStringLiteral("Powered"));
+-    return qdbus_cast<bool>(var);
+-}
+-
+-bool QOfonoModemInterface::isOnline()
+-{
+-    QVariant var = getProperty(QStringLiteral("Online"));
+-    return qdbus_cast<bool>(var);
+-}
+-
+-QVariantMap QOfonoModemInterface::getProperties()
+-{
+-    if (propertiesMap.isEmpty()) {
+-        QList<QVariant> argumentList;
+-        QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+-        if (!reply.isError()) {
+-            propertiesMap = reply.value();
+-        }
+-    }
+-    return propertiesMap;
+-}
+-
+-QVariant QOfonoModemInterface::getProperty(const QString &property)
+-{
+-    QVariant var;
+-    QVariantMap map = getProperties();
+-    var = map.value(property);
+-    return var;
+-}
+-
+-
+-QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
+-    : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE),
+-                             dbusPathName,
+-                             OFONO_NETWORK_REGISTRATION_INTERFACE,
+-                             QDBusConnection::systemBus(), parent)
+-{
+-}
+-
+-QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
+-{
+-}
+-
+-QString QOfonoNetworkRegistrationInterface::getTechnology()
+-{
+-    QVariant var = getProperty(QStringLiteral("Technology"));
+-    return qdbus_cast<QString>(var);
+-}
+-
+-QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
+-{
+-    QVariant var;
+-    QVariantMap map = getProperties();
+-    var = map.value(property);
+-    return var;
+-}
+-
+-QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
+-{
+-    if (propertiesMap.isEmpty()) {
+-        QList<QVariant> argumentList;
+-        QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+-        reply.waitForFinished();
+-        if (!reply.isError()) {
+-            propertiesMap = reply.value();
+-        } else {
+-            qDebug() << reply.error().message();
+-        }
+-    }
+-    return propertiesMap;
+-}
+-
+-QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
+-    : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+-                             dbusPathName,
+-                             OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
+-                             QDBusConnection::systemBus(), parent)
+-{
+-    QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE),
+-                                         path(),
+-                                         QLatin1String(OFONO_MODEM_INTERFACE),
+-                                         QLatin1String("PropertyChanged"),
+-                                         this,SLOT(propertyChanged(QString,QDBusVariant)));
+-}
+-
+-QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
+-{
+-}
+-
+-QStringList QOfonoDataConnectionManagerInterface::contexts()
+-{
+-    if (contextList.isEmpty()) {
+-        QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts"));
+-        reply.waitForFinished();
+-        if (!reply.isError()) {
+-            foreach (ObjectPathProperties context, reply.value()) {
+-                contextList << context.path.path();
+-            }
+-        }
+-    }
+-    return contextList;
+-}
+-
+-bool QOfonoDataConnectionManagerInterface::roamingAllowed()
+-{
+-    QVariant var = getProperty(QStringLiteral("RoamingAllowed"));
+-    return qdbus_cast<bool>(var);
+-}
+-
+-QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
+-{
+-    QVariant var;
+-    QVariantMap map = getProperties();
+-    var = map.value(property);
+-    return var;
+-}
+-
+-QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
+-{
+-    if (propertiesMap.isEmpty()) {
+-        QList<QVariant> argumentList;
+-        QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+-        if (!reply.isError()) {
+-            propertiesMap = reply.value();
+-        }
+-    }
+-    return propertiesMap;
+-}
+-
+-void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value)
+-{
+-    propertiesMap[name] = value.variant();
+-    if (name == QStringLiteral("RoamingAllowed"))
+-        Q_EMIT roamingAllowedChanged(value.variant().toBool());
+-}
+-
+-QT_END_NAMESPACE
+-
+-#endif // QT_NO_DBUS
+-#endif // QT_NO_BEARERMANAGEMENT
+--- qtbase/src/plugins/bearer/connman/qofonoservice_linux_p.h
++++ /dev/null
+@@ -1,180 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+-** Contact: http://www.qt-project.org/legal
+-**
+-** This file is part of the plugins of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:LGPL$
+-** Commercial License Usage
+-** Licensees holding valid commercial Qt licenses may use this file in
+-** accordance with the commercial license agreement provided with the
+-** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
+-** use the contact form at http://qt.digia.com/contact-us.
+-**
+-** 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, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
+-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-**
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-
+-#ifndef QOFONOSERVICE_H
+-#define QOFONOSERVICE_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 <QtDBus/QtDBus>
+-#include <QtDBus/QDBusConnection>
+-#include <QtDBus/QDBusError>
+-#include <QtDBus/QDBusInterface>
+-#include <QtDBus/QDBusMessage>
+-#include <QtDBus/QDBusReply>
+-
+-#include <QtDBus/QDBusPendingCallWatcher>
+-#include <QtDBus/QDBusObjectPath>
+-#include <QtDBus/QDBusContext>
+-#include <QMap>
+-
+-#ifndef QT_NO_BEARERMANAGEMENT
+-#ifndef QT_NO_DBUS
+-
+-#define OFONO_SERVICE                            "org.ofono"
+-#define OFONO_MANAGER_INTERFACE                  "org.ofono.Manager"
+-#define OFONO_MANAGER_PATH                       "/"
+-
+-#define OFONO_MODEM_INTERFACE                    "org.ofono.Modem"
+-#define OFONO_NETWORK_REGISTRATION_INTERFACE     "org.ofono.NetworkRegistration"
+-#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE  "org.ofono.ConnectionManager"
+-
+-QT_BEGIN_NAMESPACE
+-
+-QT_END_NAMESPACE
+-
+-struct ObjectPathProperties
+-{
+-    QDBusObjectPath path;
+-    QVariantMap properties;
+-};
+-typedef QList<ObjectPathProperties> PathPropertiesList;
+-Q_DECLARE_METATYPE(ObjectPathProperties)
+-Q_DECLARE_METATYPE (PathPropertiesList)
+-
+-QT_BEGIN_NAMESPACE
+-
+-class QOfonoManagerInterface : public  QDBusAbstractInterface
+-{
+-    Q_OBJECT
+-
+-public:
+-
+-    QOfonoManagerInterface( QObject *parent = 0);
+-    ~QOfonoManagerInterface();
+-
+-    QStringList getModems();
+-    QString currentModem();
+-signals:
+-    void modemChanged();
+-private:
+-    QStringList modemList;
+-private slots:
+-    void modemAdded(const QDBusObjectPath &path, const QVariantMap &var);
+-    void modemRemoved(const QDBusObjectPath &path);
+-};
+-
+-class QOfonoModemInterface : public QDBusAbstractInterface
+-{
+-    Q_OBJECT
+-
+-public:
+-
+-    explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0);
+-    ~QOfonoModemInterface();
+-
+-    bool isPowered();
+-    bool isOnline();
+-private:
+-    QVariantMap getProperties();
+-    QVariantMap propertiesMap;
+-    QVariant getProperty(const QString &);
+-    void propertyChanged(const QString &, const QDBusVariant &value);
+-};
+-
+-
+-class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface
+-{
+-    Q_OBJECT
+-
+-public:
+-
+-    explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0);
+-    ~QOfonoNetworkRegistrationInterface();
+-
+-    QString getTechnology();
+-
+-private:
+-    QVariantMap getProperties();
+-    QVariant getProperty(const QString &);
+-    QVariantMap propertiesMap;
+-Q_SIGNALS:
+-    void propertyChanged(const QString &, const QDBusVariant &value);
+-};
+-
+-class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface
+-{
+-    Q_OBJECT
+-
+-public:
+-
+-    explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0);
+-    ~QOfonoDataConnectionManagerInterface();
+-
+-    QStringList contexts();
+-    bool roamingAllowed();
+-Q_SIGNALS:
+-    void roamingAllowedChanged(bool);
+-private:
+-    QVariantMap getProperties();
+-    QVariantMap propertiesMap;
+-    QVariant getProperty(const QString &);
+-    QStringList contextList;
+-private slots:
+-    void propertyChanged(const QString &, const QDBusVariant &value);
+-};
+-
+-
+-QT_END_NAMESPACE
+-
+-#endif // QT_NO_DBUS
+-#endif // QT_NO_BEARERMANAGEMENT
+-
+-#endif //QOFONOSERVICE_H
+--- qtbase/src/plugins/bearer/networkmanager/main.cpp
++++ qtbase/src/plugins/bearer/networkmanager/main.cpp
+@@ -1,40 +1,32 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the plugins of the Qt Toolkit.
+ **
+-** $QT_BEGIN_LICENSE:LGPL$
++** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
+ ** use the contact form at http://qt.digia.com/contact-us.
+ **
+ ** 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.
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
++** rights. These rights are described in the Digia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+--- qtbase/src/plugins/bearer/networkmanager/networkmanager.pro
++++ qtbase/src/plugins/bearer/networkmanager/networkmanager.pro
+@@ -6,16 +6,16 @@
+ 
+ QT = core network-private dbus
+ 
+-HEADERS += qnmdbushelper.h \
+-           qnetworkmanagerservice.h \
++HEADERS += qnetworkmanagerservice.h \
+            qnetworkmanagerengine.h \
++           ../linux_common/qofonoservice_linux_p.h \
+            ../qnetworksession_impl.h \
+            ../qbearerengine_impl.h
+ 
+ SOURCES += main.cpp \
+-           qnmdbushelper.cpp \
+            qnetworkmanagerservice.cpp \
+            qnetworkmanagerengine.cpp \
++           ../linux_common/qofonoservice_linux.cpp \
+            ../qnetworksession_impl.cpp
+ 
+ OTHER_FILES += networkmanager.json
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+@@ -1,40 +1,32 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the plugins of the Qt Toolkit.
+ **
+-** $QT_BEGIN_LICENSE:LGPL$
++** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
+ ** use the contact form at http://qt.digia.com/contact-us.
+ **
+ ** 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.
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
++** rights. These rights are described in the Digia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+@@ -55,6 +47,7 @@
+ #include <QDBusInterface>
+ #include <QDBusMessage>
+ #include <QDBusReply>
++#include "../linux_common/qofonoservice_linux_p.h"
+ 
+ #ifndef QT_NO_BEARERMANAGEMENT
+ #ifndef QT_NO_DBUS
+@@ -63,130 +56,113 @@
+ 
+ QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
+ :   QBearerEngineImpl(parent),
+-    interface(new QNetworkManagerInterface(this)),
+-    systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)),
+-    userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this))
++    managerInterface(new QNetworkManagerInterface(this)),
++    systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this)),
++    ofonoManager(new QOfonoManagerInterface(this))
+ {
+-    if (!interface->isValid())
++
++    if (!managerInterface->isValid())
+         return;
+ 
+-    interface->setConnections();
+-    connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)),
++    qDBusRegisterMetaType<QNmSettingsMap>();
++
++    connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)),
+             this, SLOT(deviceAdded(QDBusObjectPath)));
+-    connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)),
++    connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)),
+             this, SLOT(deviceRemoved(QDBusObjectPath)));
+-#if 0
+-    connect(interface, SIGNAL(stateChanged(QString,quint32)),
+-            this, SIGNAL(configurationsChanged()));
+-#endif
+-    connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
++    connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
+             this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
+-    connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+-            this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>)));
+-
+-    qDBusRegisterMetaType<QNmSettingsMap>();
++    connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
++            this, SLOT(interfacePropertiesChanged(QMap<QString,QVariant>)));
++    managerInterface->setConnections();
+ 
+-    systemSettings->setConnections();
+     connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
+             this, SLOT(newConnection(QDBusObjectPath)));
+-
+-    userSettings->setConnections();
+-    connect(userSettings, SIGNAL(newConnection(QDBusObjectPath)),
+-            this, SLOT(newConnection(QDBusObjectPath)));
++    systemSettings->setConnections();
+ }
+ 
+ QNetworkManagerEngine::~QNetworkManagerEngine()
+ {
+     qDeleteAll(connections);
++    connections.clear();
+     qDeleteAll(accessPoints);
++    accessPoints.clear();
+     qDeleteAll(wirelessDevices);
+-    qDeleteAll(activeConnections);
++    wirelessDevices.clear();
++    qDeleteAll(activeConnectionsList);
++    activeConnectionsList.clear();
++    qDeleteAll(interfaceDevices);
++    interfaceDevices.clear();
++
++    connectionInterfaces.clear();
++
++    qDeleteAll(ofonoContextManagers);
++    ofonoContextManagers.clear();
++
++    qDeleteAll(wiredDevices);
++    wiredDevices.clear();
+ }
+ 
+ void QNetworkManagerEngine::initialize()
+ {
+     QMutexLocker locker(&mutex);
+ 
+-    // Get current list of access points.
+-    foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
++    if (ofonoManager->isValid()) {
++        Q_FOREACH (const QString &modem, ofonoManager->getModems()) {
++            QOfonoDataConnectionManagerInterface *ofonoContextManager
++                    = new QOfonoDataConnectionManagerInterface(modem,this);
++            ofonoContextManagers.insert(modem, ofonoContextManager);
++        }
++    }
++    // Get active connections.
++    foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
++
++        QNetworkManagerConnectionActive *activeConnection =
++                new QNetworkManagerConnectionActive(acPath.path(),this);
++        activeConnectionsList.insert(acPath.path(), activeConnection);
++        connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
++                this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
++        activeConnection->setConnections();
++
++        QStringList devices = activeConnection->devices();
++        if (!devices.isEmpty()) {
++            QNetworkManagerInterfaceDevice device(devices.at(0),this);
++            connectionInterfaces.insert(activeConnection->connection().path(),device.networkInterface());
++        }
++    }
++
++        // Get current list of access points.
++    foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
+         locker.unlock();
+-        deviceAdded(devicePath);
++        deviceAdded(devicePath); //add all accesspoints
+         locker.relock();
+     }
+ 
+     // Get connections.
+     foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
+         locker.unlock();
+-        newConnection(settingsPath, systemSettings);
+-        locker.relock();
+-    }
+-    foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) {
+-        locker.unlock();
+-        newConnection(settingsPath, userSettings);
++        if (!hasIdentifier(settingsPath.path()))
++            newConnection(settingsPath, systemSettings); //add system connection configs
+         locker.relock();
+     }
+ 
+-    // 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>)));
+-    }
++    Q_EMIT updateCompleted();
+ }
+ 
+ bool QNetworkManagerEngine::networkManagerAvailable() const
+ {
+-    QMutexLocker locker(&mutex);
+-
+-    return interface->isValid();
++    return managerInterface->isValid();
+ }
+ 
+-QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
++QString QNetworkManagerEngine::getInterfaceFromId(const QString &settingsPath)
+ {
+-    QMutexLocker locker(&mutex);
+-
+-    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;
+-
+-            QNetworkManagerInterfaceDevice device(devices.at(0).path());
+-            return device.networkInterface();
+-        }
+-    }
+-
+-    return QString();
++    return connectionInterfaces.value(settingsPath);
+ }
+ 
+ bool QNetworkManagerEngine::hasIdentifier(const QString &id)
+ {
+     QMutexLocker locker(&mutex);
+-
+-    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;
++    return accessPointConfigurations.contains(id);
+ }
+ 
+ void QNetworkManagerEngine::connectToId(const QString &id)
+@@ -198,47 +174,54 @@
+     if (!connection)
+         return;
+ 
+-    QNmSettingsMap map = connection->getSettings();
+-    const QString connectionType = map.value("connection").value("type").toString();
++    NMDeviceType connectionType = connection->getType();
+ 
+     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();
++    const QString settingsPath = connection->connectionInterface()->path();
++    QString specificPath = configuredAccessPoints.key(settingsPath);
++
++    QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices);
++    while (i.hasNext()) {
++        i.next();
++        if (i.value()->deviceType() == DEVICE_TYPE_ETHERNET &&
++            connectionType == DEVICE_TYPE_ETHERNET) {
++            dbusDevicePath = i.key();
+             break;
+-        } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
+-                   connectionType == QLatin1String("802-11-wireless")) {
+-            dbusDevicePath = devicePath.path();
++        } else if (i.value()->deviceType() == DEVICE_TYPE_WIFI &&
++                   connectionType == DEVICE_TYPE_WIFI) {
++            dbusDevicePath = i.key();
+             break;
+-        }
+-        else if (device.deviceType() == DEVICE_TYPE_GSM &&
+-                connectionType == QLatin1String("gsm")) {
+-            dbusDevicePath = devicePath.path();
++        } else if (i.value()->deviceType() == DEVICE_TYPE_MODEM &&
++                connectionType == DEVICE_TYPE_MODEM) {
++            dbusDevicePath = i.key();
+             break;
+         }
+     }
+ 
+-    const QString service = connection->connectionInterface()->service();
+-    const QString settingsPath = connection->connectionInterface()->path();
++    if (specificPath.isEmpty())
++        specificPath = "/";
+ 
+-    interface->activateConnection(service, QDBusObjectPath(settingsPath),
+-                                  QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/"));
++    managerInterface->activateConnection(QDBusObjectPath(settingsPath),
++                                  QDBusObjectPath(dbusDevicePath), QDBusObjectPath(specificPath));
+ }
+ 
+ void QNetworkManagerEngine::disconnectFromId(const QString &id)
+ {
+     QMutexLocker locker(&mutex);
+ 
+-    foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+-        QNetworkManagerConnectionActive activeConnection(acPath.path());
+-
+-        const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
+-                                                         activeConnection.connection().path()));
++    QNetworkManagerSettingsConnection *connection = connectionFromId(id);
++    QNmSettingsMap map = connection->getSettings();
++    bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !!
++    if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm
++        emit connectionError(id, QBearerEngineImpl::OperationNotSupported);
++        return;
++    }
+ 
+-        if (id == identifier && accessPointConfigurations.contains(id)) {
+-            interface->deactivateConnection(acPath);
++    QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
++    while (i.hasNext()) {
++        i.next();
++        if (id == i.value()->connection().path() && accessPointConfigurations.contains(id)) {
++            managerInterface->deactivateConnection(QDBusObjectPath(i.key()));
+             break;
+         }
+     }
+@@ -246,16 +229,24 @@
+ 
+ void QNetworkManagerEngine::requestUpdate()
+ {
++    if (managerInterface->wirelessEnabled()) {
++        QHashIterator<QString, QNetworkManagerInterfaceDeviceWireless *> i(wirelessDevices);
++        while (i.hasNext()) {
++            i.next();
++            i.value()->requestScan();
++        }
++    }
+     QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
+ }
+ 
+-void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
+-                                                       const QMap<QString, QVariant> &properties)
++void QNetworkManagerEngine::scanFinished()
+ {
+-    QMutexLocker locker(&mutex);
+-
+-    Q_UNUSED(path)
++    QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
++}
+ 
++void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVariant> &properties)
++{
++    QMutexLocker locker(&mutex);
+     QMapIterator<QString, QVariant> i(properties);
+     while (i.hasNext()) {
+         i.next();
+@@ -267,35 +258,37 @@
+                 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();
++            QStringList priorActiveConnections = activeConnectionsList.keys();
+ 
+             foreach (const QDBusObjectPath &acPath, activeConnections) {
+                 priorActiveConnections.removeOne(acPath.path());
+                 QNetworkManagerConnectionActive *activeConnection =
+-                    this->activeConnections.value(acPath.path());
++                    activeConnectionsList.value(acPath.path());
++
+                 if (!activeConnection) {
+-                    activeConnection = new QNetworkManagerConnectionActive(acPath.path());
+-                    this->activeConnections.insert(acPath.path(), activeConnection);
++                    activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this);
++                    activeConnectionsList.insert(acPath.path(), activeConnection);
+ 
++                    connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
++                            this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
+                     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()));
++                const QString id = activeConnection->connection().path();
+ 
+                 identifiers.removeOne(id);
+ 
+                 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+                 if (ptr) {
+                     ptr->mutex.lock();
+-                    if (activeConnection->state() == 2 &&
++                    if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
+                         ptr->state != QNetworkConfiguration::Active) {
+                         ptr->state = QNetworkConfiguration::Active;
++
++                        if (activeConnectionsList.value(id) && activeConnectionsList.value(id)->defaultRoute()
++                                && managerInterface->state() < QNetworkManagerInterface::NM_STATE_CONNECTED_GLOBAL) {
++                            ptr->purpose = QNetworkConfiguration::PrivatePurpose;
++                        }
+                         ptr->mutex.unlock();
+ 
+                         locker.unlock();
+@@ -308,16 +301,16 @@
+             }
+ 
+             while (!priorActiveConnections.isEmpty())
+-                delete this->activeConnections.take(priorActiveConnections.takeFirst());
++                delete activeConnectionsList.take(priorActiveConnections.takeFirst());
+ 
+             while (!identifiers.isEmpty()) {
+-                // These configurations are not active
+                 QNetworkConfigurationPrivatePointer ptr =
+                     accessPointConfigurations.value(identifiers.takeFirst());
+ 
+                 ptr->mutex.lock();
+                 if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+-                    ptr->state = QNetworkConfiguration::Discovered;
++                    QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
++                    ptr->state = (flag | QNetworkConfiguration::Discovered);
+                     ptr->mutex.unlock();
+ 
+                     locker.unlock();
+@@ -331,66 +324,96 @@
+     }
+ }
+ 
+-void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &path,
+-                                                              const QMap<QString, QVariant> &properties)
++void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties)
+ {
+     QMutexLocker locker(&mutex);
+ 
+     Q_UNUSED(properties)
+ 
+-    QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path);
++    QNetworkManagerConnectionActive *activeConnection = qobject_cast<QNetworkManagerConnectionActive *>(sender());
+ 
+     if (!activeConnection)
+         return;
+ 
+-    const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
+-                                             activeConnection->connection().path()));
++    const QString id = activeConnection->connection().path();
+ 
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+     if (ptr) {
+         ptr->mutex.lock();
+-        if (activeConnection->state() == 2 &&
+-            ptr->state != QNetworkConfiguration::Active) {
+-            ptr->state = QNetworkConfiguration::Active;
++        if (properties.value("State").toUInt() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
++            QStringList devices = activeConnection->devices();
++            if (!devices.isEmpty()) {
++                QNetworkManagerInterfaceDevice device(devices.at(0),this);
++                connectionInterfaces.insert(id,device.networkInterface());
++            }
++
++            ptr->state |= QNetworkConfiguration::Active;
+             ptr->mutex.unlock();
+ 
+             locker.unlock();
+             emit configurationChanged(ptr);
+             locker.relock();
+         } else {
++            connectionInterfaces.remove(id);
+             ptr->mutex.unlock();
+         }
+     }
+ }
+ 
+-void QNetworkManagerEngine::devicePropertiesChanged(const QString &path,
+-                                                    const QMap<QString, QVariant> &properties)
++void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connectionsList)
+ {
+-    Q_UNUSED(path);
+-    Q_UNUSED(properties);
++    QMutexLocker locker(&mutex);
++    for (int i = 0; i < connections.count(); ++i) {
++        if (connectionsList.contains(connections.at(i)->connectionInterface()->path()))
++            continue;
++
++        const QString settingsPath = connections.at(i)->connectionInterface()->path();
++
++        QNetworkConfigurationPrivatePointer ptr =
++            accessPointConfigurations.value(settingsPath);
++        ptr->mutex.lock();
++        QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
++        ptr->state = (flag | QNetworkConfiguration::Discovered);
++        ptr->mutex.unlock();
++
++        locker.unlock();
++        emit configurationChanged(ptr);
++        locker.relock();
++        Q_EMIT updateCompleted();
++    }
+ }
+ 
+ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
+ {
+-    QNetworkManagerInterfaceDevice device(path.path());
+-    if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
++    QNetworkManagerInterfaceDevice *iDevice;
++    iDevice = new QNetworkManagerInterfaceDevice(path.path(),this);
++    connect(iDevice,SIGNAL(connectionsChanged(QStringList)),
++            this,SLOT(deviceConnectionsChanged(QStringList)));
++
++    iDevice->setConnections();
++    interfaceDevices.insert(path.path(),iDevice);
++    if (iDevice->deviceType() == DEVICE_TYPE_WIFI) {
+         QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
+-            new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path());
++            new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this);
+ 
++        connect(wirelessDevice, SIGNAL(accessPointAdded(QString)),
++                this, SLOT(newAccessPoint(QString)));
++        connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)),
++                this, SLOT(removeAccessPoint(QString)));
++        connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished()));
+         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);
++            newAccessPoint(apPath.path());
+ 
+-        mutex.lock();
+         wirelessDevices.insert(path.path(), wirelessDevice);
+-        mutex.unlock();
++    }
++
++    if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) {
++        QNetworkManagerInterfaceDeviceWired *wiredDevice =
++                new QNetworkManagerInterfaceDeviceWired(iDevice->connectionInterface()->path(),this);
++        connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool)));
++        wiredDevices.insert(iDevice->connectionInterface()->path(), wiredDevice);
+     }
+ }
+ 
+@@ -398,50 +421,126 @@
+ {
+     QMutexLocker locker(&mutex);
+ 
+-    delete wirelessDevices.take(path.path());
++    if (interfaceDevices.contains(path.path())) {
++        locker.unlock();
++        delete interfaceDevices.take(path.path());
++        locker.relock();
++    }
++    if (wirelessDevices.contains(path.path())) {
++        locker.unlock();
++        delete wirelessDevices.take(path.path());
++        locker.relock();
++    }
++    if (wiredDevices.contains(path.path())) {
++        locker.unlock();
++        delete wiredDevices.take(path.path());
++        locker.relock();
++    }
++}
++
++void QNetworkManagerEngine::wiredCarrierChanged(bool carrier)
++{
++    QNetworkManagerInterfaceDeviceWired *deviceWired = qobject_cast<QNetworkManagerInterfaceDeviceWired *>(sender());
++    if (!deviceWired)
++        return;
++    QMutexLocker locker(&mutex);
++    foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
++        for (int i = 0; i < connections.count(); ++i) {
++            QNetworkManagerSettingsConnection *connection = connections.at(i);
++            if (connection->getType() == DEVICE_TYPE_ETHERNET
++                    && settingsPath.path() == connection->connectionInterface()->path()) {
++                QNetworkConfigurationPrivatePointer ptr =
++                        accessPointConfigurations.value(settingsPath.path());
++
++                if (ptr) {
++                    ptr->mutex.lock();
++                    if (carrier)
++                        ptr->state |= QNetworkConfiguration::Discovered;
++                    else
++                        ptr->state = QNetworkConfiguration::Defined;
++                    ptr->mutex.unlock();
++                    locker.unlock();
++                    emit configurationChanged(ptr);
++                    return;
++                }
++            }
++        }
++    }
+ }
+ 
+ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
+                                           QNetworkManagerSettings *settings)
+ {
+     QMutexLocker locker(&mutex);
+-
+     if (!settings)
+         settings = qobject_cast<QNetworkManagerSettings *>(sender());
+ 
+-    if (!settings)
++    if (!settings) {
+         return;
++    }
+ 
+     QNetworkManagerSettingsConnection *connection =
+         new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
+-                                              path.path());
++                                              path.path(),this);
++    const QString settingsPath = connection->connectionInterface()->path();
++    if (accessPointConfigurations.contains(settingsPath)) {
++        return;
++    }
++
+     connections.append(connection);
+ 
+-    connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
+-    connect(connection, SIGNAL(updated(QNmSettingsMap)),
+-            this, SLOT(updateConnection(QNmSettingsMap)));
++    connect(connection,SIGNAL(removed(QString)),this,SLOT(removeConnection(QString)));
++    connect(connection,SIGNAL(updated()),this,SLOT(updateConnection()));
++    connection->setConnections();
+ 
+-    const QString service = connection->connectionInterface()->service();
+-    const QString settingsPath = connection->connectionInterface()->path();
++    NMDeviceType deviceType = connection->getType();
++
++    if (deviceType == DEVICE_TYPE_WIFI) {
++        QString apPath;
++        for (int i = 0; i < accessPoints.count(); ++i) {
++            if (connection->getSsid() == accessPoints.at(i)->ssid()) {
++                // remove the corresponding accesspoint from configurations
++                apPath = accessPoints.at(i)->connectionInterface()->path();
++                QNetworkConfigurationPrivatePointer ptr
++                        = accessPointConfigurations.take(apPath);
++                if (ptr) {
++                    locker.unlock();
++                    emit configurationRemoved(ptr);
++                    locker.relock();
++                }
++            }
++        }
++        if (!configuredAccessPoints.contains(settingsPath))
++            configuredAccessPoints.insert(apPath,settingsPath);
++    }
+ 
+     QNetworkConfigurationPrivate *cpPriv =
+-        parseConnection(service, settingsPath, connection->getSettings());
++        parseConnection(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) {
++    QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
++    while (i.hasNext()) {
++        i.next();
++        if (i.value()->connection().path() == settingsPath) {
+             cpPriv->state |= QNetworkConfiguration::Active;
+             break;
+         }
+     }
+-
++    if (deviceType == DEVICE_TYPE_ETHERNET) {
++        QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices);
++        while (i.hasNext()) {
++             i.next();
++             if (i.value()->deviceType() == deviceType) {
++                QNetworkManagerInterfaceDeviceWired *wiredDevice
++                        = wiredDevices.value(i.value()->connectionInterface()->path());
++                 if (wiredDevice->carrier()) {
++                     cpPriv->state |= QNetworkConfiguration::Discovered;
++                 }
++             }
++         }
++     }
+     QNetworkConfigurationPrivatePointer ptr(cpPriv);
+     accessPointConfigurations.insert(ptr->id, ptr);
+-
+     locker.unlock();
+     emit configurationAdded(ptr);
+ }
+@@ -450,27 +549,36 @@
+ {
+     QMutexLocker locker(&mutex);
+ 
+-    Q_UNUSED(path)
+-
+     QNetworkManagerSettingsConnection *connection =
+         qobject_cast<QNetworkManagerSettingsConnection *>(sender());
++
+     if (!connection)
+         return;
+ 
++    connection->deleteLater();
+     connections.removeAll(connection);
+ 
+-    const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' +
+-                                             connection->connectionInterface()->path()));
++    const QString id = path;
+ 
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
+ 
+-    connection->deleteLater();
+-
+-    locker.unlock();
+-    emit configurationRemoved(ptr);
++    if (ptr) {
++        locker.unlock();
++        emit configurationRemoved(ptr);
++        locker.relock();
++    }
++    // add base AP back into configurations
++    QMapIterator<QString, QString> i(configuredAccessPoints);
++    while (i.hasNext()) {
++        i.next();
++        if (i.value() == path) {
++            configuredAccessPoints.remove(i.key());
++            newAccessPoint(i.key());
++        }
++    }
+ }
+ 
+-void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
++void QNetworkManagerEngine::updateConnection()
+ {
+     QMutexLocker locker(&mutex);
+ 
+@@ -478,18 +586,15 @@
+         qobject_cast<QNetworkManagerSettingsConnection *>(sender());
+     if (!connection)
+         return;
+-
+-    const QString service = connection->connectionInterface()->service();
+     const QString settingsPath = connection->connectionInterface()->path();
+ 
+-    QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
++    QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings());
+ 
+     // Check if connection is active.
+-    foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
++    foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
+         QNetworkManagerConnectionActive activeConnection(acPath.path());
+ 
+-        if (activeConnection.serviceName() == service &&
+-            activeConnection.connection().path() == settingsPath &&
++        if (activeConnection.connection().path() == settingsPath &&
+             activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+             cpPriv->state |= QNetworkConfiguration::Active;
+             break;
+@@ -509,28 +614,29 @@
+ 
+     locker.unlock();
+     emit configurationChanged(ptr);
++    locker.relock();
+     delete cpPriv;
+ }
+ 
+ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
+ {
+     QMutexLocker locker(&mutex);
+-
+     QDBusPendingReply<QDBusObjectPath> reply(*watcher);
++    watcher->deleteLater();
++
+     if (!reply.isError()) {
+         QDBusObjectPath result = reply.value();
+ 
+         QNetworkManagerConnectionActive activeConnection(result.path());
+ 
+-        const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' +
+-                                                 activeConnection.connection().path()));
++        const QString id = activeConnection.connection().path();
+ 
+         QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+         if (ptr) {
+             ptr->mutex.lock();
+-            if (activeConnection.state() == 2 &&
++            if (activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
+                 ptr->state != QNetworkConfiguration::Active) {
+-                ptr->state = QNetworkConfiguration::Active;
++                ptr->state |= QNetworkConfiguration::Active;
+                 ptr->mutex.unlock();
+ 
+                 locker.unlock();
+@@ -543,42 +649,40 @@
+     }
+ }
+ 
+-void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
++void QNetworkManagerEngine::newAccessPoint(const QString &path)
+ {
+     QMutexLocker locker(&mutex);
+ 
+-    Q_UNUSED(path)
+-
+     QNetworkManagerInterfaceAccessPoint *accessPoint =
+-        new QNetworkManagerInterfaceAccessPoint(objectPath.path());
+-    accessPoints.append(accessPoint);
++        new QNetworkManagerInterfaceAccessPoint(path,this);
+ 
+-    accessPoint->setConnections();
+-    connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
+-            this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
+-
+-    // Check if configuration for this SSID already exists.
++    bool okToAdd = true;
+     for (int i = 0; i < accessPoints.count(); ++i) {
+-        if (accessPoint != accessPoints.at(i) &&
+-            accessPoint->ssid() == accessPoints.at(i)->ssid()) {
+-            return;
++        if (accessPoints.at(i)->connectionInterface()->path() == path) {
++            okToAdd = false;
+         }
+     }
+-
++    if (okToAdd) {
++        accessPoints.append(accessPoint);
++        accessPoint->setConnections();
++    }
+     // Check if configuration exists for connection.
+     if (!accessPoint->ssid().isEmpty()) {
++
+         for (int i = 0; i < connections.count(); ++i) {
+             QNetworkManagerSettingsConnection *connection = connections.at(i);
++            const QString settingsPath = connection->connectionInterface()->path();
+ 
+             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));
++                if (!configuredAccessPoints.contains(path)) {
++                    configuredAccessPoints.insert(path,settingsPath);
++                }
+ 
+                 QNetworkConfigurationPrivatePointer ptr =
+-                    accessPointConfigurations.value(connectionId);
++                    accessPointConfigurations.value(settingsPath);
+                 ptr->mutex.lock();
+-                ptr->state = QNetworkConfiguration::Discovered;
++                QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
++                ptr->state = (flag | QNetworkConfiguration::Discovered);
+                 ptr->mutex.unlock();
+ 
+                 locker.unlock();
+@@ -593,13 +697,9 @@
+ 
+     ptr->name = accessPoint->ssid();
+     ptr->isValid = true;
+-    ptr->id = QString::number(qHash(objectPath.path()));
++    ptr->id = path;
+     ptr->type = QNetworkConfiguration::InternetAccessPoint;
+-    if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
+-        ptr->purpose = QNetworkConfiguration::PrivatePurpose;
+-    } else {
+-        ptr->purpose = QNetworkConfiguration::PublicPurpose;
+-    }
++    ptr->purpose = QNetworkConfiguration::PublicPurpose;
+     ptr->state = QNetworkConfiguration::Undefined;
+     ptr->bearerType = QNetworkConfiguration::BearerWLAN;
+ 
+@@ -609,30 +709,24 @@
+     emit configurationAdded(ptr);
+ }
+ 
+-void QNetworkManagerEngine::removeAccessPoint(const QString &path,
+-                                              const QDBusObjectPath &objectPath)
++void QNetworkManagerEngine::removeAccessPoint(const QString &path)
+ {
+     QMutexLocker locker(&mutex);
+-
+-    Q_UNUSED(path)
+-
+     for (int i = 0; i < accessPoints.count(); ++i) {
+         QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
+-
+-        if (accessPoint->connectionInterface()->path() == objectPath.path()) {
++        if (accessPoint->connectionInterface()->path() == path) {
+             accessPoints.removeOne(accessPoint);
+ 
+-            if (configuredAccessPoints.contains(accessPoint)) {
++            if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) {
+                 // find connection and change state to Defined
+-                configuredAccessPoints.removeOne(accessPoint);
++                configuredAccessPoints.remove(accessPoint->connectionInterface()->path());
++
+                 for (int i = 0; i < connections.count(); ++i) {
+                     QNetworkManagerSettingsConnection *connection = connections.at(i);
+ 
+-                    if (accessPoint->ssid() == connection->getSsid()) {
+-                        const QString service = connection->connectionInterface()->service();
++                    if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet
+                         const QString settingsPath = connection->connectionInterface()->path();
+-                        const QString connectionId =
+-                            QString::number(qHash(service + ' ' + settingsPath));
++                        const QString connectionId = settingsPath;
+ 
+                         QNetworkConfigurationPrivatePointer ptr =
+                             accessPointConfigurations.value(connectionId);
+@@ -648,7 +742,7 @@
+                 }
+             } else {
+                 QNetworkConfigurationPrivatePointer ptr =
+-                    accessPointConfigurations.take(QString::number(qHash(objectPath.path())));
++                    accessPointConfigurations.take(path);
+ 
+                 if (ptr) {
+                     locker.unlock();
+@@ -656,111 +750,74 @@
+                     locker.relock();
+                 }
+             }
+-
+             delete accessPoint;
+-
+             break;
+         }
+     }
+ }
+ 
+-void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map)
+-{
+-    QMutexLocker locker(&mutex);
+-
+-    Q_UNUSED(map)
+-
+-    QNetworkManagerInterfaceAccessPoint *accessPoint =
+-        qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender());
+-    if (!accessPoint)
+-        return;
+-
+-    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->mutex.lock();
+-            ptr->state = QNetworkConfiguration::Discovered;
+-            ptr->mutex.unlock();
+-
+-            locker.unlock();
+-            emit configurationChanged(ptr);
+-            return;
+-        }
+-    }
+-}
+-
+-QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service,
+-                                                                     const QString &settingsPath,
++QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath,
+                                                                      const QNmSettingsMap &map)
+ {
++    QMutexLocker locker(&mutex);
+     QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
+     cpPriv->name = map.value("connection").value("id").toString();
++
+     cpPriv->isValid = true;
+-    cpPriv->id = QString::number(qHash(service + ' ' + settingsPath));
++    cpPriv->id = 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->bearerType = QNetworkConfiguration::BearerEthernet;
+-        cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+ 
+-        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()) {
++        foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
++            QNetworkManagerInterfaceDevice device(devicePath.path(),this);
++            if (device.deviceType() == DEVICE_TYPE_ETHERNET) {
++                QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.connectionInterface()->path());
++                if (wiredDevice->carrier()) {
+                     cpPriv->state |= QNetworkConfiguration::Discovered;
+                     break;
+                 }
+-
+             }
+         }
+     } else if (connectionType == QLatin1String("802-11-wireless")) {
+         cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
+ 
+         const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
+-        const QString connectionSecurity = map.value("802-11-wireless").value("security").toString();
+-        if(!connectionSecurity.isEmpty()) {
+-            cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
+-        } else {
+-            cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+-        }
+         for (int i = 0; i < accessPoints.count(); ++i) {
+-            if (connectionSsid == accessPoints.at(i)->ssid()) {
++            if (connectionSsid == accessPoints.at(i)->ssid()
++                    && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) {
+                 cpPriv->state |= QNetworkConfiguration::Discovered;
+-                if (!configuredAccessPoints.contains(accessPoints.at(i))) {
+-                    configuredAccessPoints.append(accessPoints.at(i));
++                if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) {
++                    configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath);
+ 
+-                    const QString accessPointId =
+-                        QString::number(qHash(accessPoints.at(i)->connectionInterface()->path()));
++                    const QString accessPointId = accessPoints.at(i)->connectionInterface()->path();
+                     QNetworkConfigurationPrivatePointer ptr =
+                         accessPointConfigurations.take(accessPointId);
+ 
+                     if (ptr) {
+-                        mutex.unlock();
++                        locker.unlock();
+                         emit configurationRemoved(ptr);
+-                        mutex.lock();
++                        locker.relock();
+                     }
+                 }
+                 break;
+             }
+         }
+-    } else if (connectionType == "gsm") {
+-        cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
+-    } else if (connectionType == "cdma") {
+-        cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
++    } else if (connectionType == QLatin1String("gsm")) {
++
++        const QString contextPath = map.value("connection").value("id").toString();
++        cpPriv->name = contextName(contextPath);
++        cpPriv->bearerType = currentBearerType(contextPath);
++
++        if (map.value("connection").contains("timestamp")) {
++            cpPriv->state |= QNetworkConfiguration::Discovered;
++        }
+     }
+ 
+     return cpPriv;
+@@ -770,12 +827,7 @@
+ {
+     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)
++        if (id == connection->connectionInterface()->path())
+             return connection;
+     }
+ 
+@@ -785,7 +837,6 @@
+ QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id)
+ {
+     QMutexLocker locker(&mutex);
+-
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ 
+     if (!ptr)
+@@ -794,11 +845,10 @@
+     if (!ptr->isValid)
+         return QNetworkSession::Invalid;
+ 
+-    foreach (const QString &acPath, activeConnections.keys()) {
+-        QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath);
++    foreach (const QString &acPath, activeConnectionsList.keys()) {
++        QNetworkManagerConnectionActive *activeConnection = activeConnectionsList.value(acPath);
+ 
+-        const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' +
+-                                                         activeConnection->connection().path()));
++        const QString identifier = activeConnection->connection().path();
+ 
+         if (id == identifier) {
+             switch (activeConnection->state()) {
+@@ -828,7 +878,7 @@
+ 
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+     if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+-        const QString networkInterface = getInterfaceFromId(id);
++        const QString networkInterface = connectionInterfaces.value(id);
+         if (!networkInterface.isEmpty()) {
+             const QString devFile = QLatin1String("/sys/class/net/") +
+                                     networkInterface +
+@@ -856,7 +906,7 @@
+ 
+     QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+     if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+-        const QString networkInterface = getInterfaceFromId(id);
++        const QString networkInterface = connectionInterfaces.value(id);
+         if (!networkInterface.isEmpty()) {
+             const QString devFile = QLatin1String("/sys/class/net/") +
+                                     networkInterface +
+@@ -892,7 +942,8 @@
+ QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
+ {
+     return QNetworkConfigurationManager::ForcedRoaming |
+-           QNetworkConfigurationManager::CanStartAndStopInterfaces;
++            QNetworkConfigurationManager::DataStatistics |
++            QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ }
+ 
+ QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
+@@ -902,9 +953,67 @@
+ 
+ QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
+ {
++    QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
++    while (i.hasNext()) {
++        i.next();
++        QNetworkManagerConnectionActive *activeConnection = i.value();
++        if ((activeConnection->defaultRoute() || activeConnection->default6Route())) {
++            return accessPointConfigurations.value(activeConnection->connection().path());
++        }
++    }
++
+     return QNetworkConfigurationPrivatePointer();
+ }
+ 
++QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id)
++{
++    if (ofonoManager->isValid()) {
++        QString contextPart = id.section('/', -1);
++
++        QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++        while (i.hasNext()) {
++            i.next();
++            QString contextPath = i.key() +"/"+contextPart;
++            if (i.value()->contexts().contains(contextPath)) {
++
++                QString bearer = i.value()->bearer();
++                if (bearer == QStringLiteral("gsm")) {
++                    return QNetworkConfiguration::Bearer2G;
++                } else if (bearer == QStringLiteral("edge")) {
++                    return QNetworkConfiguration::Bearer2G;
++                } else if (bearer == QStringLiteral("umts")) {
++                    return QNetworkConfiguration::BearerWCDMA;
++                } else if (bearer == QStringLiteral("hspa")
++                           || bearer == QStringLiteral("hsdpa")
++                           || bearer == QStringLiteral("hsupa")) {
++                    return QNetworkConfiguration::BearerHSPA;
++                } else if (bearer == QStringLiteral("lte")) {
++                    return QNetworkConfiguration::BearerLTE;
++                }
++            }
++        }
++    }
++    return QNetworkConfiguration::BearerUnknown;
++}
++
++QString QNetworkManagerEngine::contextName(const QString &path)
++{
++    if (ofonoManager->isValid()) {
++        QString contextPart = path.section('/', -1);
++        QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
++        while (i.hasNext()) {
++            i.next();
++            Q_FOREACH (const QString &oContext, i.value()->contexts()) {
++                if (oContext.contains(contextPart)) {
++                    QOfonoConnectionContextInterface contextInterface(oContext,this);
++                    return contextInterface.name();
++                }
++            }
++        }
++    }
++    return path;
++}
++
+ QT_END_NAMESPACE
+ 
+ #endif // QT_NO_DBUS
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+@@ -1,40 +1,32 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the plugins of the Qt Toolkit.
+ **
+-** $QT_BEGIN_LICENSE:LGPL$
++** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
+ ** use the contact form at http://qt.digia.com/contact-us.
+ **
+ ** 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.
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
++** rights. These rights are described in the Digia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+@@ -57,6 +49,8 @@
+ 
+ #include "qnetworkmanagerservice.h"
+ 
++#include "../linux_common/qofonoservice_linux_p.h"
++
+ #include <QMap>
+ #include <QVariant>
+ 
+@@ -97,40 +91,47 @@
+     QNetworkConfigurationPrivatePointer defaultConfiguration();
+ 
+ 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 interfacePropertiesChanged(const QMap<QString, QVariant> &properties);
++    void activeConnectionPropertiesChanged(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 updateConnection();
+     void activationFinished(QDBusPendingCallWatcher *watcher);
++    void deviceConnectionsChanged(const QStringList &activeConnectionsList);
+ 
+-    void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
+-    void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
+-    void updateAccessPoint(const QMap<QString, QVariant> &map);
++    void newAccessPoint(const QString &path);
++    void removeAccessPoint(const QString &path);
++    void scanFinished();
++
++    void wiredCarrierChanged(bool);
+ 
+ private:
+-    QNetworkConfigurationPrivate *parseConnection(const QString &service,
+-                                                  const QString &settingsPath,
++    QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath,
+                                                   const QNmSettingsMap &map);
+     QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
+ 
+-private:
+-    QNetworkManagerInterface *interface;
++    QNetworkManagerInterface *managerInterface;
+     QNetworkManagerSettings *systemSettings;
+-    QNetworkManagerSettings *userSettings;
++    QHash<QString, QNetworkManagerInterfaceDeviceWired *> wiredDevices;
+     QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
+-    QHash<QString, QNetworkManagerConnectionActive *> activeConnections;
++
++    QHash<QString, QNetworkManagerConnectionActive *> activeConnectionsList;
+     QList<QNetworkManagerSettingsConnection *> connections;
+     QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
+-    QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints;
++    QHash<QString, QNetworkManagerInterfaceDevice *> interfaceDevices;
++
++    QMap<QString,QString> configuredAccessPoints; //ap, settings path
++    QHash<QString,QString> connectionInterfaces; // ac, interface
++
++    QOfonoManagerInterface *ofonoManager;
++    QHash <QString, QOfonoDataConnectionManagerInterface *> ofonoContextManagers;
++    QNetworkConfiguration::BearerType currentBearerType(const QString &id);
++    QString contextName(const QString &path);
++
+ };
+ 
+ QT_END_NAMESPACE
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+@@ -1,40 +1,32 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the plugins of the Qt Toolkit.
+ **
+-** $QT_BEGIN_LICENSE:LGPL$
++** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
+ ** use the contact form at http://qt.digia.com/contact-us.
+ **
+ ** 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.
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
++** rights. These rights are described in the Digia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+@@ -52,7 +44,6 @@
+ #include <QtDBus/QDBusPendingCall>
+ 
+ #include "qnetworkmanagerservice.h"
+-#include "qnmdbushelper.h"
+ 
+ #ifndef QT_NO_DBUS
+ 
+@@ -72,18 +63,38 @@
+     d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+                                                 QLatin1String(NM_DBUS_PATH),
+                                                 QLatin1String(NM_DBUS_INTERFACE),
+-                                                QDBusConnection::systemBus());
++                                                QDBusConnection::systemBus(),parent);
+     if (!d->connectionInterface->isValid()) {
+         d->valid = false;
+         return;
+     }
+     d->valid = true;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+-                    this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
+-    connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
+-            this, SIGNAL(stateChanged(QString,quint32)));
+ 
++    QDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  QLatin1String(NM_DBUS_PATH),
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus());
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE);
++    QDBusPendingReply<QVariantMap> propsReply
++            = managerPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusPendingReply<QList <QDBusObjectPath> > nmReply
++            = d->connectionInterface->call(QLatin1String("GetDevices"));
++    nmReply.waitForFinished();
++    if (!nmReply.isError()) {
++        devicesPathList = nmReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  QLatin1String(NM_DBUS_PATH),
++                                  QLatin1String(NM_DBUS_INTERFACE),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+ }
+ 
+ QNetworkManagerInterface::~QNetworkManagerInterface()
+@@ -99,27 +110,24 @@
+ 
+ bool QNetworkManagerInterface::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+-    QDBusConnection dbusConnection = QDBusConnection::systemBus();
+-
+-    bool allOk = false;
+-    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+                                   QLatin1String(NM_DBUS_PATH),
+                                   QLatin1String(NM_DBUS_INTERFACE),
+                                   QLatin1String("PropertiesChanged"),
+-                                nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
+-        allOk = true;
+-    }
+-    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
++
++    bool allOk = false;
++    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+                                   QLatin1String(NM_DBUS_PATH),
+                                   QLatin1String(NM_DBUS_INTERFACE),
+                                   QLatin1String("DeviceAdded"),
+                                 this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
+         allOk = true;
+     }
+-    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+                                   QLatin1String(NM_DBUS_PATH),
+                                   QLatin1String(NM_DBUS_INTERFACE),
+                                   QLatin1String("DeviceRemoved"),
+@@ -135,52 +143,106 @@
+     return d->connectionInterface;
+ }
+ 
+-QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const
++QList <QDBusObjectPath> QNetworkManagerInterface::getDevices()
+ {
+-    QDBusReply<QList<QDBusObjectPath> > reply =  d->connectionInterface->call(QLatin1String("GetDevices"));
+-    return reply.value();
++    if (devicesPathList.isEmpty()) {
++        qWarning() << "using blocking call!";
++        QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices"));
++        devicesPathList = reply.value();
++    }
++    return devicesPathList;
+ }
+ 
+-void QNetworkManagerInterface::activateConnection( const QString &serviceName,
+-                                                  QDBusObjectPath connectionPath,
++void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath,
+                                                   QDBusObjectPath devicePath,
+                                                   QDBusObjectPath specificObject)
+ {
+     QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"),
+-                                                                    QVariant(serviceName),
+                                                                     QVariant::fromValue(connectionPath),
+                                                                     QVariant::fromValue(devicePath),
+                                                                     QVariant::fromValue(specificObject));
+ 
+-   QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall, this);
++   QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall);
+    connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+                     this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
+ }
+ 
+ void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath)  const
+ {
+-    d->connectionInterface->call(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
++    d->connectionInterface->asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
+ }
+ 
+ bool QNetworkManagerInterface::wirelessEnabled()  const
+ {
+-    return d->connectionInterface->property("WirelessEnabled").toBool();
++    if (propertyMap.contains("WirelessEnabled"))
++        return propertyMap.value("WirelessEnabled").toBool();
++    return false;
+ }
+ 
+ bool QNetworkManagerInterface::wirelessHardwareEnabled()  const
+ {
+-    return d->connectionInterface->property("WirelessHardwareEnabled").toBool();
++    if (propertyMap.contains("WirelessHardwareEnabled"))
++        return propertyMap.value("WirelessHardwareEnabled").toBool();
++    return false;
+ }
+ 
+ QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const
+ {
+-    QVariant prop = d->connectionInterface->property("ActiveConnections");
+-    return prop.value<QList<QDBusObjectPath> >();
++    if (propertyMap.contains("ActiveConnections")) {
++
++        const QDBusArgument &dbusArgs = propertyMap.value("ActiveConnections").value<QDBusArgument>();
++        QDBusObjectPath path;
++        QList <QDBusObjectPath> list;
++
++        dbusArgs.beginArray();
++        while (!dbusArgs.atEnd()) {
++            dbusArgs >> path;
++            list.append(path);
++        }
++        dbusArgs.endArray();
++
++        return list;
++    }
++
++    QList <QDBusObjectPath> list;
++    list << QDBusObjectPath();
++    return list;
+ }
+ 
+-quint32 QNetworkManagerInterface::state()
++QNetworkManagerInterface::NMState QNetworkManagerInterface::state()
+ {
+-    return d->connectionInterface->property("State").toUInt();
++    if (propertyMap.contains("State"))
++        return static_cast<QNetworkManagerInterface::NMState>(propertyMap.value("State").toUInt());
++    return QNetworkManagerInterface::NM_STATE_UNKNOWN;
++}
++
++QString QNetworkManagerInterface::version() const
++{
++    if (propertyMap.contains("Version"))
++        return propertyMap.value("Version").toString();
++    return QString();
++}
++
++void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++
++        if (i.key() == QStringLiteral("State")) {
++            quint32 state = i.value().toUInt();
++            if (state == NM_DEVICE_STATE_ACTIVATED
++                || state == NM_DEVICE_STATE_DISCONNECTED
++                || state == NM_DEVICE_STATE_UNAVAILABLE
++                || state == NM_DEVICE_STATE_FAILED) {
++                Q_EMIT propertiesChanged(map);
++                Q_EMIT stateChanged(state);
++            }
++        } else if (i.key() == QStringLiteral("ActiveConnections")) {
++            Q_EMIT propertiesChanged(map);
++        }
++    }
+ }
+ 
+ class QNetworkManagerInterfaceAccessPointPrivate
+@@ -192,18 +254,38 @@
+ };
+ 
+ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
+-        : QObject(parent), nmDBusHelper(0)
++        : QObject(parent)
+ {
+     d = new QNetworkManagerInterfaceAccessPointPrivate();
+     d->path = dbusPathName;
+     d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+                                                 d->path,
+                                                 QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+-                                                QDBusConnection::systemBus());
++                                                QDBusConnection::systemBus(),parent);
+     if (!d->connectionInterface->isValid()) {
+         d->valid = false;
+         return;
+     }
++    QDBusInterface accessPointPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus());
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT);
++    QDBusPendingReply<QVariantMap> propsReply
++            = accessPointPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
++
+     d->valid = true;
+ 
+ }
+@@ -221,24 +303,10 @@
+ 
+ bool QNetworkManagerInterfaceAccessPoint::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+-    bool allOk = false;
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+-            this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
+-
+-    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
+-                              QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+-                              QLatin1String("PropertiesChanged"),
+-                              nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
+-        allOk = true;
+-
+-    }
+-    return allOk;
++    return true;
+ }
+ 
+ QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const
+@@ -248,47 +316,74 @@
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::flags() const
+ {
+-    return d->connectionInterface->property("Flags").toUInt();
++    if (propertyMap.contains("Flags"))
++        return propertyMap.value("Flags").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::wpaFlags() const
+ {
+-    return d->connectionInterface->property("WpaFlags").toUInt();
++    if (propertyMap.contains("WpaFlags"))
++        return propertyMap.value("WpaFlags").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::rsnFlags() const
+ {
+-    return d->connectionInterface->property("RsnFlags").toUInt();
++    if (propertyMap.contains("RsnFlags"))
++        return propertyMap.value("RsnFlags").toUInt();
++    return 0;
+ }
+ 
+ QString QNetworkManagerInterfaceAccessPoint::ssid() const
+ {
+-    return d->connectionInterface->property("Ssid").toString();
++    if (propertyMap.contains("Ssid"))
++        return propertyMap.value("Ssid").toString();
++    return QString();
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::frequency() const
+ {
+-    return d->connectionInterface->property("Frequency").toUInt();
++    if (propertyMap.contains("Frequency"))
++        return propertyMap.value("Frequency").toUInt();
++    return 0;
+ }
+ 
+ QString QNetworkManagerInterfaceAccessPoint::hwAddress() const
+ {
+-    return d->connectionInterface->property("HwAddress").toString();
++    if (propertyMap.contains("HwAddress"))
++        return propertyMap.value("HwAddress").toString();
++    return QString();
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::mode() const
+ {
+-    return d->connectionInterface->property("Mode").toUInt();
++    if (propertyMap.contains("Mode"))
++        return propertyMap.value("Mode").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::maxBitrate() const
+ {
+-    return d->connectionInterface->property("MaxBitrate").toUInt();
++    if (propertyMap.contains("MaxBitrate"))
++        return propertyMap.value("MaxBitrate").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceAccessPoint::strength() const
+ {
+-    return d->connectionInterface->property("Strength").toUInt();
++    if (propertyMap.contains("Strength"))
++        return propertyMap.value("Strength").toUInt();
++    return 0;
++}
++
++void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++    }
+ }
+ 
+ class QNetworkManagerInterfaceDevicePrivate
+@@ -300,18 +395,39 @@
+ };
+ 
+ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
+-        : QObject(parent), nmDBusHelper(0)
++        : QObject(parent)
+ {
++
+     d = new QNetworkManagerInterfaceDevicePrivate();
+     d->path = deviceObjectPath;
+     d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+                                                 d->path,
+                                                 QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+-                                                QDBusConnection::systemBus());
++                                                QDBusConnection::systemBus(),parent);
+     if (!d->connectionInterface->isValid()) {
+         d->valid = false;
+         return;
+     }
++    QDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus(),parent);
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE);
++    QDBusPendingReply<QVariantMap> propsReply
++            = devicePropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+     d->valid = true;
+ }
+ 
+@@ -328,22 +444,10 @@
+ 
+ bool QNetworkManagerInterfaceDevice::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+-    bool allOk = false;
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
+-            this, SIGNAL(stateChanged(QString,quint32)));
+-    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
+-                              QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+-                              QLatin1String("StateChanged"),
+-                              nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
+-        allOk = true;
+-    }
+-    return allOk;
++    return true;
+ }
+ 
+ QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const
+@@ -353,33 +457,66 @@
+ 
+ QString QNetworkManagerInterfaceDevice::udi() const
+ {
+-    return d->connectionInterface->property("Udi").toString();
++    if (propertyMap.contains("Udi"))
++        return propertyMap.value("Udi").toString();
++    return QString();
+ }
+ 
+ QString QNetworkManagerInterfaceDevice::networkInterface() const
+ {
+-    return d->connectionInterface->property("Interface").toString();
++    if (propertyMap.contains("Interface"))
++        return propertyMap.value("Interface").toString();
++    return QString();
+ }
+ 
+ quint32 QNetworkManagerInterfaceDevice::ip4Address() const
+ {
+-    return d->connectionInterface->property("Ip4Address").toUInt();
++    if (propertyMap.contains("Ip4Address"))
++        return propertyMap.value("Ip4Address").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceDevice::state() const
+ {
+-    return d->connectionInterface->property("State").toUInt();
++    if (propertyMap.contains("State"))
++        return propertyMap.value("State").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceDevice::deviceType() const
+ {
+-    return d->connectionInterface->property("DeviceType").toUInt();
++    if (propertyMap.contains("DeviceType"))
++        return propertyMap.value("DeviceType").toUInt();
++    return 0;
+ }
+ 
+ QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
+ {
+-    QVariant prop = d->connectionInterface->property("Ip4Config");
+-    return prop.value<QDBusObjectPath>();
++    if (propertyMap.contains("Ip4Config"))
++        return propertyMap.value("Ip4Config").value<QDBusObjectPath>();
++    return QDBusObjectPath();
++}
++
++void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        if (i.key() == QStringLiteral("AvailableConnections")) { //Device
++            const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
++            QDBusObjectPath path;
++            QStringList paths;
++            dbusArgs.beginArray();
++            while (!dbusArgs.atEnd()) {
++                dbusArgs >> path;
++                paths << path.path();
++            }
++            dbusArgs.endArray();
++            Q_EMIT connectionsChanged(paths);
++        }
++        propertyMap.insert(i.key(),i.value());
++    }
++    Q_EMIT propertiesChanged(map);
+ }
+ 
+ class QNetworkManagerInterfaceDeviceWiredPrivate
+@@ -391,7 +528,7 @@
+ };
+ 
+ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
+-    : QObject(parent), nmDBusHelper(0)
++    : QObject(parent)
+ {
+     d = new QNetworkManagerInterfaceDeviceWiredPrivate();
+     d->path = ifaceDevicePath;
+@@ -403,6 +540,27 @@
+         d->valid = false;
+         return;
+     }
++    QDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus(),parent);
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED);
++    QDBusPendingReply<QVariantMap> propsReply
++            = deviceWiredPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
++
+     d->valid = true;
+ }
+ 
+@@ -420,23 +578,9 @@
+ 
+ bool QNetworkManagerInterfaceDeviceWired::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+-
+-    bool allOk = false;
+-
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+-            this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
+-    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
+-                              QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+-                              QLatin1String("PropertiesChanged"),
+-                              nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) )  {
+-        allOk = true;
+-    }
+-    return allOk;
++    return true;
+ }
+ 
+ QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const
+@@ -446,17 +590,53 @@
+ 
+ QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
+ {
+-    return d->connectionInterface->property("HwAddress").toString();
++    if (propertyMap.contains("HwAddress"))
++        return propertyMap.value("HwAddress").toString();
++    return QString();
+ }
+ 
+ quint32 QNetworkManagerInterfaceDeviceWired::speed() const
+ {
+-    return d->connectionInterface->property("Speed").toUInt();
++    if (propertyMap.contains("Speed"))
++        return propertyMap.value("Speed").toUInt();
++    return 0;
+ }
+ 
+ bool QNetworkManagerInterfaceDeviceWired::carrier() const
+ {
+-    return d->connectionInterface->property("Carrier").toBool();
++    if (propertyMap.contains("Carrier"))
++        return propertyMap.value("Carrier").toBool();
++    return false;
++}
++
++QStringList QNetworkManagerInterfaceDeviceWired::availableConnections()
++{
++    QStringList list;
++    if (propertyMap.contains("AvailableConnections")) {
++        const QDBusArgument &dbusArgs = propertyMap.value("Carrier").value<QDBusArgument>();
++        QDBusObjectPath path;
++        dbusArgs.beginArray();
++        while (!dbusArgs.atEnd()) {
++            dbusArgs >> path;
++            list << path.path();
++        }
++        dbusArgs.endArray();
++    }
++
++    return list;
++}
++
++void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++        if (i.key() == QStringLiteral("Carrier")) {
++            Q_EMIT carrierChanged(i.value().toBool());
++        }
++    }
++    Q_EMIT propertiesChanged(map);
+ }
+ 
+ class QNetworkManagerInterfaceDeviceWirelessPrivate
+@@ -468,7 +648,7 @@
+ };
+ 
+ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
+-    : QObject(parent), nmDBusHelper(0)
++    : QObject(parent)
+ {
+     d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
+     d->path = ifaceDevicePath;
+@@ -480,6 +660,34 @@
+         d->valid = false;
+         return;
+     }
++
++
++    QDBusPendingReply<QList <QDBusObjectPath> > nmReply
++            = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
++
++    if (!nmReply.isError()) {
++        accessPointsList = nmReply.value();
++    }
++
++    QDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus(),parent);
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS);
++    QDBusPendingReply<QVariantMap> propsReply
++            = deviceWirelessPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+     d->valid = true;
+ }
+ 
+@@ -494,50 +702,50 @@
+     return d->valid;
+ }
+ 
++void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path)
++{
++    if (path.path().length() > 2)
++        Q_EMIT accessPointAdded(path.path());
++}
++
++void QNetworkManagerInterfaceDeviceWireless::slotAccessPointRemoved(QDBusObjectPath path)
++{
++    if (path.path().length() > 2)
++        Q_EMIT accessPointRemoved(path.path());
++}
++
+ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+     QDBusConnection dbusConnection = QDBusConnection::systemBus();
+-    bool allOk = false;
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+-            this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
++    bool allOk = true;
+ 
+-    connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)),
+-            this,SIGNAL(accessPointAdded(QString,QDBusObjectPath)));
+-
+-    connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)),
+-            this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath)));
+-
+-    if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
++    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++                                d->path,
+                               QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+                               QLatin1String("AccessPointAdded"),
+-                              nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
+-        allOk = true;
++                              this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
++        allOk = false;
+     }
+ 
+ 
+-    if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+                               d->path,
+                               QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+                               QLatin1String("AccessPointRemoved"),
+-                              nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
+-        allOk = true;
++                              this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
++        allOk = false;
+     }
+ 
+-
+-    if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
+-                              QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+-                              QLatin1String("PropertiesChanged"),
+-                              nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
+-        allOk = true;
++    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
++                               d->path,
++                               QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
++                               QLatin1String("ScanDone"),
++                               this, SLOT(scanIsDone()))) {
++        allOk = false;
+     }
+-
+     return allOk;
+ }
+ 
+@@ -548,33 +756,162 @@
+ 
+ QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
+ {
+-    QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
+-    return reply.value();
++    if (accessPointsList.isEmpty()) {
++        qWarning() << "Using blocking call!";
++        QDBusReply<QList<QDBusObjectPath> > reply
++                = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
++        accessPointsList = reply.value();
++    }
++    return accessPointsList;
+ }
+ 
+ QString QNetworkManagerInterfaceDeviceWireless::hwAddress() const
+ {
+-    return d->connectionInterface->property("HwAddress").toString();
++    if (propertyMap.contains("HwAddress"))
++        return propertyMap.value("HwAddress").toString();
++    return QString();
+ }
+ 
+ quint32 QNetworkManagerInterfaceDeviceWireless::mode() const
+ {
+-    return d->connectionInterface->property("Mode").toUInt();
++    if (propertyMap.contains("Mode"))
++        return propertyMap.value("Mode").toUInt();
++    return 0;
+ }
+ 
+ quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const
+ {
+-    return d->connectionInterface->property("Bitrate").toUInt();
++    if (propertyMap.contains("Bitrate"))
++        return propertyMap.value("Bitrate").toUInt();
++    return 0;
+ }
+ 
+ QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const
+ {
+-    return d->connectionInterface->property("ActiveAccessPoint").value<QDBusObjectPath>();
++    if (propertyMap.contains("ActiveAccessPoint"))
++        return propertyMap.value("ActiveAccessPoint").value<QDBusObjectPath>();
++    return QDBusObjectPath();
+ }
+ 
+ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
+ {
+-    return d->connectionInterface->property("WirelelessCapabilities").toUInt();
++    if (propertyMap.contains("WirelelessCapabilities"))
++        return propertyMap.value("WirelelessCapabilities").toUInt();
++    return 0;
++}
++
++void QNetworkManagerInterfaceDeviceWireless::scanIsDone()
++{
++    Q_EMIT scanDone();
++}
++
++void QNetworkManagerInterfaceDeviceWireless::requestScan()
++{
++    d->connectionInterface->asyncCall(QLatin1String("RequestScan"));
++}
++
++void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++        if (i.key() == QStringLiteral("ActiveAccessPoint")) { //DeviceWireless
++            Q_EMIT propertiesChanged(map);
++        }
++    }
++}
++
++class QNetworkManagerInterfaceDeviceModemPrivate
++{
++public:
++    QDBusInterface *connectionInterface;
++    QString path;
++    bool valid;
++};
++
++QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, QObject *parent)
++    : QObject(parent)
++{
++    d = new QNetworkManagerInterfaceDeviceModemPrivate();
++    d->path = ifaceDevicePath;
++    d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                d->path,
++                                                QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
++                                                QDBusConnection::systemBus(), parent);
++    if (!d->connectionInterface->isValid()) {
++        d->valid = false;
++        return;
++    }
++    QDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus(),parent);
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM);
++    QDBusPendingReply<QVariantMap> propsReply
++            = deviceModemPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
++    d->valid = true;
++}
++
++QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem()
++{
++    delete d->connectionInterface;
++    delete d;
++}
++
++bool QNetworkManagerInterfaceDeviceModem::isValid()
++{
++
++    return d->valid;
++}
++
++bool QNetworkManagerInterfaceDeviceModem::setConnections()
++{
++    if (!isValid() )
++        return false;
++
++    return true;
++}
++
++QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const
++{
++    return d->connectionInterface;
++}
++
++QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const
++{
++    if (propertyMap.contains("ModemCapabilities"))
++        return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("ModemCapabilities").toUInt());
++    return QNetworkManagerInterfaceDeviceModem::None;
++}
++
++QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::currentCapabilities() const
++{
++    if (propertyMap.contains("CurrentCapabilities"))
++        return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("CurrentCapabilities").toUInt());
++    return QNetworkManagerInterfaceDeviceModem::None;
++}
++
++void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++    }
++    Q_EMIT propertiesChanged(map);
+ }
+ 
+ class QNetworkManagerSettingsPrivate
+@@ -598,6 +935,14 @@
+         d->valid = false;
+         return;
+     }
++
++    QDBusPendingReply<QList <QDBusObjectPath> > nmReply
++            = d->connectionInterface->call(QLatin1String("ListConnections"));
++
++    if (!nmReply.isError()) {
++        connectionsList = nmReply.value();
++    }
++
+     d->valid = true;
+ }
+ 
+@@ -614,12 +959,14 @@
+ 
+ bool QNetworkManagerSettings::setConnections()
+ {
+-    bool allOk = false;
++    bool allOk = true;
+ 
+-    if (!QDBusConnection::systemBus().connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
+-                           QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
+-                           this, SIGNAL(newConnection(QDBusObjectPath)))) {
+-        allOk = true;
++    if (!QDBusConnection::systemBus().connect(d->path,
++                                             QLatin1String(NM_DBUS_PATH_SETTINGS),
++                                             QLatin1String(NM_DBUS_IFACE_SETTINGS),
++                                             QLatin1String("NewConnection"),
++                                             this, SIGNAL(newConnection(QDBusObjectPath)))) {
++        allOk = false;
+     }
+ 
+     return allOk;
+@@ -627,8 +974,22 @@
+ 
+ QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
+ {
+-    QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("ListConnections"));
+-    return  reply.value();
++    if (connectionsList.isEmpty()) {
++        qWarning() << "Using blocking call!";
++        QDBusReply<QList<QDBusObjectPath> > reply
++                = d->connectionInterface->call(QLatin1String("ListConnections"));
++        connectionsList = reply.value();
++    }
++    return connectionsList;
++}
++
++
++QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid)
++{
++    QList<QVariant> argumentList;
++    argumentList << QVariant::fromValue(uuid);
++    QDBusReply<QDBusObjectPath > reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList);
++    return reply.value().path();
+ }
+ 
+ QDBusInterface *QNetworkManagerSettings::connectionInterface() const
+@@ -648,7 +1009,7 @@
+ };
+ 
+ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
+-    : QObject(parent), nmDBusHelper(0)
++    : QObject(parent)
+ {
+     qDBusRegisterMetaType<QNmSettingsMap>();
+     d = new QNetworkManagerSettingsConnectionPrivate();
+@@ -663,8 +1024,12 @@
+         return;
+     }
+     d->valid = true;
+-    QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
+-    d->settingsMap = rep.value();
++
++    QDBusPendingReply<QNmSettingsMap> nmReply
++            = d->connectionInterface->call(QLatin1String("GetSettings"));
++    if (!nmReply.isError()) {
++        d->settingsMap = nmReply.value();
++    }
+ }
+ 
+ QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
+@@ -680,33 +1045,34 @@
+ 
+ bool QNetworkManagerSettingsConnection::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+     QDBusConnection dbusConnection = QDBusConnection::systemBus();
+-    bool allOk = false;
+-    if(!dbusConnection.connect(d->service, d->path,
+-                           QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
+-                           this, SIGNAL(updated(QNmSettingsMap)))) {
+-        allOk = true;
+-    } else {
+-        QDBusError error = dbusConnection.lastError();
++    bool allOk = true;
++    if (!dbusConnection.connect(d->service,
++                               d->path,
++                               QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
++                               QLatin1String("Updated"),
++                               this, SIGNAL(updated()))) {
++        allOk = false;
+     }
+ 
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)),
+-            this,SIGNAL(removed(QString)));
+-
+-    if (!dbusConnection.connect(d->service, d->path,
+-                           QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
+-                           nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
+-        allOk = true;
++    if (!dbusConnection.connect(d->service,
++                               d->path,
++                               QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
++                               QLatin1String("Removed"),
++                               this, SIGNAL(slotSettingsRemoved()))) {
++        allOk = false;
+     }
+-
+     return allOk;
+ }
+ 
++void QNetworkManagerSettingsConnection::slotSettingsRemoved()
++{
++    Q_EMIT removed(d->path);
++}
++
+ QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
+ {
+     return d->connectionInterface;
+@@ -714,8 +1080,11 @@
+ 
+ QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
+ {
+-    QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
+-    d->settingsMap = rep.value();
++    if (d->settingsMap.isEmpty()) {
++        qWarning() << "Using blocking call!";
++        QDBusReply<QNmSettingsMap> reply = d->connectionInterface->call(QLatin1String("GetSettings"));
++        d->settingsMap = reply.value();
++    }
+     return d->settingsMap;
+ }
+ 
+@@ -725,9 +1094,11 @@
+         d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
+ 
+     if (devType == QLatin1String("802-3-ethernet"))
+-        return DEVICE_TYPE_802_3_ETHERNET;
++        return DEVICE_TYPE_ETHERNET;
+     else if (devType == QLatin1String("802-11-wireless"))
+-        return DEVICE_TYPE_802_11_WIRELESS;
++        return DEVICE_TYPE_WIFI;
++    else if (devType == QLatin1String("gsm"))
++        return DEVICE_TYPE_MODEM;
+     else
+         return DEVICE_TYPE_UNKNOWN;
+ }
+@@ -774,10 +1145,10 @@
+ {
+     NMDeviceType type = getType();
+ 
+-    if (type == DEVICE_TYPE_802_3_ETHERNET) {
++    if (type == DEVICE_TYPE_ETHERNET) {
+         return d->settingsMap.value(QLatin1String("802-3-ethernet"))
+                              .value(QLatin1String("mac-address")).toString();
+-    } else if (type == DEVICE_TYPE_802_11_WIRELESS) {
++    } else if (type == DEVICE_TYPE_WIFI) {
+         return d->settingsMap.value(QLatin1String("802-11-wireless"))
+                              .value(QLatin1String("mac-address")).toString();
+     } else {
+@@ -787,7 +1158,7 @@
+ 
+ QStringList QNetworkManagerSettingsConnection::getSeenBssids()
+ {
+-    if (getType() == DEVICE_TYPE_802_11_WIRELESS) {
++    if (getType() == DEVICE_TYPE_WIFI) {
+         return d->settingsMap.value(QLatin1String("802-11-wireless"))
+                              .value(QLatin1String("seen-bssids")).toStringList();
+     } else {
+@@ -803,8 +1174,8 @@
+     bool valid;
+ };
+ 
+-QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent)
+-    : QObject(parent), nmDBusHelper(0)
++QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent)
++    : QObject(parent)
+ {
+     d = new QNetworkManagerConnectionActivePrivate();
+     d->path = activeConnectionObjectPath;
+@@ -816,6 +1187,29 @@
+         d->valid = false;
+         return;
+     }
++    QDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
++                                                  d->path,
++                                                  QLatin1String("org.freedesktop.DBus.Properties"),
++                                                  QDBusConnection::systemBus());
++
++
++    QList<QVariant> argumentList;
++    argumentList << QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION);
++    QDBusPendingReply<QVariantMap> propsReply
++            = connectionActivePropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
++                                                                       argumentList);
++
++    if (!propsReply.isError()) {
++        propertyMap = propsReply.value();
++    } else {
++        qWarning() << propsReply.error().message();
++    }
++
++    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
++                                  d->path,
++                                  QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
++                                  QLatin1String("PropertiesChanged"),
++                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
+     d->valid = true;
+ }
+ 
+@@ -832,23 +1226,10 @@
+ 
+ bool QNetworkManagerConnectionActive::setConnections()
+ {
+-    if(!isValid() )
++    if (!isValid())
+         return false;
+ 
+-    bool allOk = false;
+-    delete nmDBusHelper;
+-    nmDBusHelper = new QNmDBusHelper(this);
+-    connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+-            this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
+-    if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+-                              d->path,
+-                              QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+-                              QLatin1String("PropertiesChanged"),
+-                              nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) )  {
+-        allOk = true;
+-    }
+-
+-    return allOk;
++    return true;
+ }
+ 
+ QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const
+@@ -856,37 +1237,72 @@
+     return d->connectionInterface;
+ }
+ 
+-QString QNetworkManagerConnectionActive::serviceName() const
+-{
+-    return d->connectionInterface->property("ServiceName").toString();
+-}
+-
+ QDBusObjectPath QNetworkManagerConnectionActive::connection() const
+ {
+-    QVariant prop = d->connectionInterface->property("Connection");
+-    return prop.value<QDBusObjectPath>();
++    if (propertyMap.contains("Connection"))
++        return propertyMap.value("Connection").value<QDBusObjectPath>();
++    return QDBusObjectPath();
+ }
+ 
+ QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const
+ {
+-    QVariant prop = d->connectionInterface->property("SpecificObject");
+-    return prop.value<QDBusObjectPath>();
+-}
+-
+-QList<QDBusObjectPath> QNetworkManagerConnectionActive::devices() const
+-{
+-    QVariant prop = d->connectionInterface->property("Devices");
+-    return prop.value<QList<QDBusObjectPath> >();
++    if (propertyMap.contains("SpecificObject"))
++        return propertyMap.value("SpecificObject").value<QDBusObjectPath>();
++    return QDBusObjectPath();
++}
++
++QStringList QNetworkManagerConnectionActive::devices() const
++{
++    QStringList list;
++    if (propertyMap.contains("Devices")) {
++        const QDBusArgument &dbusArgs = propertyMap.value("Devices").value<QDBusArgument>();
++        QDBusObjectPath path;
++
++        dbusArgs.beginArray();
++        while (!dbusArgs.atEnd()) {
++            dbusArgs >> path;
++            list.append(path.path());
++        }
++        dbusArgs.endArray();
++    }
++    return list;
+ }
+ 
+ quint32 QNetworkManagerConnectionActive::state() const
+ {
+-    return d->connectionInterface->property("State").toUInt();
++    if (propertyMap.contains("State"))
++        return propertyMap.value("State").toUInt();
++    return 0;
+ }
+ 
+ bool QNetworkManagerConnectionActive::defaultRoute() const
+ {
+-    return d->connectionInterface->property("Default").toBool();
++    if (propertyMap.contains("Default"))
++        return propertyMap.value("Default").toBool();
++    return false;
++}
++
++bool QNetworkManagerConnectionActive::default6Route() const
++{
++    if (propertyMap.contains("Default6"))
++        return propertyMap.value("Default6").toBool();
++    return false;
++}
++
++void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
++{
++    QMapIterator<QString, QVariant> i(map);
++    while (i.hasNext()) {
++        i.next();
++        propertyMap.insert(i.key(),i.value());
++        if (i.key() == QStringLiteral("State")) {
++            quint32 state = i.value().toUInt();
++            if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
++                || state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
++                Q_EMIT propertiesChanged(map);
++            }
++        }
++    }
+ }
+ 
+ class QNetworkManagerIp4ConfigPrivate
+--- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
++++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+@@ -1,40 +1,32 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the plugins of the Qt Toolkit.
+ **
+-** $QT_BEGIN_LICENSE:LGPL$
++** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
+ ** use the contact form at http://qt.digia.com/contact-us.
+ **
+ ** 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.
++** General Public License version 2.1 or version 3 as published by the Free
++** Software Foundation and appearing in the file LICENSE.LGPLv21 and
++** LICENSE.LGPLv3 included in the packaging of this file. Please review the
++** following information to ensure the GNU Lesser General Public License
++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** In addition, as a special exception, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
++** rights. These rights are described in the Digia Qt LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+@@ -64,7 +56,6 @@
+ #include <QtDBus/QDBusObjectPath>
+ #include <QtDBus/QDBusContext>
+ #include <QMap>
+-#include "qnmdbushelper.h"
+ 
+ #ifndef QT_NO_DBUS
+ 
+@@ -72,31 +63,32 @@
+ typedef enum NMDeviceType
+ {
+     DEVICE_TYPE_UNKNOWN = 0,
+-    DEVICE_TYPE_802_3_ETHERNET,
+-    DEVICE_TYPE_802_11_WIRELESS,
+-    DEVICE_TYPE_GSM,
+-    DEVICE_TYPE_CDMA
++    DEVICE_TYPE_ETHERNET,
++    DEVICE_TYPE_WIFI,
++    DEVICE_TYPE_MODEM = 8
+ } NMDeviceType;
+ 
+ typedef enum
+ {
+     NM_DEVICE_STATE_UNKNOWN = 0,
+-    NM_DEVICE_STATE_UNMANAGED,
+-    NM_DEVICE_STATE_UNAVAILABLE,
+-    NM_DEVICE_STATE_DISCONNECTED,
+-    NM_DEVICE_STATE_PREPARE,
+-    NM_DEVICE_STATE_CONFIG,
+-    NM_DEVICE_STATE_NEED_AUTH,
+-    NM_DEVICE_STATE_IP_CONFIG,
+-    NM_DEVICE_STATE_ACTIVATED,
+-    NM_DEVICE_STATE_FAILED
++    NM_DEVICE_STATE_UNMANAGED = 10,
++    NM_DEVICE_STATE_UNAVAILABLE = 20,
++    NM_DEVICE_STATE_DISCONNECTED = 30,
++    NM_DEVICE_STATE_PREPARE = 40,
++    NM_DEVICE_STATE_CONFIG = 50,
++    NM_DEVICE_STATE_NEED_AUTH = 60,
++    NM_DEVICE_STATE_IP_CONFIG = 70,
++    NM_DEVICE_STATE_ACTIVATED = 100,
++    NM_DEVICE_STATE_DEACTIVATING = 110,
++    NM_DEVICE_STATE_FAILED = 120
+ } NMDeviceState;
+ 
+ typedef enum
+ {
+     NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
+     NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
+-    NM_ACTIVE_CONNECTION_STATE_ACTIVATED
++    NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
++    NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4
+ } NMActiveConnectionState;
+ 
+ #define NM_DBUS_SERVICE                     "org.freedesktop.NetworkManager"
+@@ -106,13 +98,14 @@
+ #define NM_DBUS_INTERFACE_DEVICE            NM_DBUS_INTERFACE ".Device"
+ #define NM_DBUS_INTERFACE_DEVICE_WIRED      NM_DBUS_INTERFACE_DEVICE ".Wired"
+ #define NM_DBUS_INTERFACE_DEVICE_WIRELESS   NM_DBUS_INTERFACE_DEVICE ".Wireless"
++#define NM_DBUS_INTERFACE_DEVICE_MODEM      NM_DBUS_INTERFACE_DEVICE ".Modem"
+ #define NM_DBUS_PATH_ACCESS_POINT           NM_DBUS_PATH "/AccessPoint"
+ #define NM_DBUS_INTERFACE_ACCESS_POINT      NM_DBUS_INTERFACE ".AccessPoint"
+ 
+-#define NM_DBUS_PATH_SETTINGS               "/org/freedesktop/NetworkManagerSettings"
++#define NM_DBUS_PATH_SETTINGS               "/org/freedesktop/NetworkManager/Settings"
+ 
+-#define NM_DBUS_IFACE_SETTINGS_CONNECTION   "org.freedesktop.NetworkManagerSettings.Connection"
+-#define NM_DBUS_IFACE_SETTINGS              "org.freedesktop.NetworkManagerSettings"
++#define NM_DBUS_IFACE_SETTINGS_CONNECTION   "org.freedesktop.NetworkManager.Settings.Connection"
++#define NM_DBUS_IFACE_SETTINGS              "org.freedesktop.NetworkManager.Settings"
+ #define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
+ #define NM_DBUS_INTERFACE_IP4_CONFIG        NM_DBUS_INTERFACE ".IP4Config"
+ 
+@@ -141,12 +134,23 @@
+     Q_OBJECT
+ 
+ public:
++    typedef enum
++    {
++        NM_STATE_UNKNOWN = 0,
++        NM_STATE_ASLEEP = 10,
++        NM_STATE_DISCONNECTED = 20,
++        NM_STATE_DISCONNECTING = 30,
++        NM_STATE_CONNECTING = 40,
++        NM_STATE_CONNECTED_LOCAL = 50,
++        NM_STATE_CONNECTED_SITE = 60,
++        NM_STATE_CONNECTED_GLOBAL = 70
++    } NMState;
+ 
+     QNetworkManagerInterface(QObject *parent = 0);
+     ~QNetworkManagerInterface();
+ 
+-    QList <QDBusObjectPath> getDevices() const;
+-    void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject);
++    QList <QDBusObjectPath> getDevices();
++    void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject);
+     void deactivateConnection(QDBusObjectPath connectionPath) const;
+ 
+     QDBusObjectPath path() const;
+@@ -155,21 +159,28 @@
+     bool wirelessEnabled() const;
+     bool wirelessHardwareEnabled() const;
+     QList <QDBusObjectPath> activeConnections() const;
+-    quint32 state();
++    NMState state();
++    QString version() const;
+     bool setConnections();
+     bool isValid();
+ 
+ Q_SIGNALS:
+     void deviceAdded(QDBusObjectPath);
+     void deviceRemoved(QDBusObjectPath);
+-    void propertiesChanged( const QString &, QMap<QString,QVariant>);
+-    void stateChanged(const QString&, quint32);
++    void propertiesChanged(QMap<QString,QVariant>);
++    void stateChanged(quint32);
+     void activationFinished(QDBusPendingCallWatcher*);
++    void propertiesReady();
++    void devicesListReady();
+ 
+ private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
++
+ private:
+     QNetworkManagerInterfacePrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
++    QVariantMap propertyMap;
++    QList<QDBusObjectPath> devicesPathList;
++
+ };
+ 
+ class QNetworkManagerInterfaceAccessPointPrivate;
+@@ -234,11 +245,14 @@
+ 
+ Q_SIGNALS:
+     void propertiesChanged(QMap <QString,QVariant>);
+-    void propertiesChanged( const QString &, QMap<QString,QVariant>);
++    void propertiesReady();
++
++private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
++
+ private:
+     QNetworkManagerInterfaceAccessPointPrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
+-
++    QVariantMap propertyMap;
+ };
+ 
+ class QNetworkManagerInterfaceDevicePrivate;
+@@ -264,10 +278,14 @@
+ 
+ Q_SIGNALS:
+     void stateChanged(const QString &, quint32);
+-
++    void propertiesChanged(QMap<QString,QVariant>);
++    void connectionsChanged(QStringList);
++    void propertiesReady();
++private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
+ private:
+     QNetworkManagerInterfaceDevicePrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
++    QVariantMap propertyMap;
+ };
+ 
+ class QNetworkManagerInterfaceDeviceWiredPrivate;
+@@ -287,12 +305,19 @@
+     bool carrier() const;
+     bool setConnections();
+     bool isValid();
++    QStringList availableConnections();
+ 
+ Q_SIGNALS:
+-    void propertiesChanged( const QString &, QMap<QString,QVariant>);
++    void propertiesChanged(QMap<QString,QVariant>);
++    void propertiesReady();
++    void carrierChanged(bool);
++
++private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
++
+ private:
+     QNetworkManagerInterfaceDeviceWiredPrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
++    QVariantMap propertyMap;
+ };
+ 
+ class QNetworkManagerInterfaceDeviceWirelessPrivate;
+@@ -328,15 +353,71 @@
+     bool setConnections();
+     bool isValid();
+ 
++    void requestScan();
+ Q_SIGNALS:
+-    void propertiesChanged( const QString &, QMap<QString,QVariant>);
+-    void accessPointAdded(const QString &,QDBusObjectPath);
+-    void accessPointRemoved(const QString &,QDBusObjectPath);
++    void propertiesChanged(QMap<QString,QVariant>);
++    void accessPointAdded(const QString &);
++    void accessPointRemoved(const QString &);
++    void scanDone();
++    void propertiesReady();
++    void accessPointsReady();
++
++private Q_SLOTS:
++    void scanIsDone();
++    void propertiesSwap(QMap<QString,QVariant>);
++
++    void slotAccessPointAdded(QDBusObjectPath);
++    void slotAccessPointRemoved(QDBusObjectPath);
++
+ private:
+     QNetworkManagerInterfaceDeviceWirelessPrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
++    QVariantMap propertyMap;
++    QList <QDBusObjectPath> accessPointsList;
++};
++
++class QNetworkManagerInterfaceDeviceModemPrivate;
++class QNetworkManagerInterfaceDeviceModem : public QObject
++{
++    Q_OBJECT
++
++public:
++
++    enum ModemCapability {
++        None = 0x0,
++        Pots = 0x1,
++        Cmda_Edvo = 0x2,
++        Gsm_Umts = 0x4,
++        Lte = 0x08
++       };
++    Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability)
++
++    explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath,
++                                                    QObject *parent = 0);
++    ~QNetworkManagerInterfaceDeviceModem();
++
++    QDBusObjectPath path() const;
++    QDBusInterface *connectionInterface() const;
++
++    bool setConnections();
++    bool isValid();
++
++    ModemCapabilities modemCapabilities() const;
++    ModemCapabilities currentCapabilities() const;
++
++Q_SIGNALS:
++    void propertiesChanged(QMap<QString,QVariant>);
++    void propertiesReady();
++
++private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
++
++private:
++    QNetworkManagerInterfaceDeviceModemPrivate *d;
++    QVariantMap propertyMap;
+ };
+ 
++Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities)
++
+ class QNetworkManagerSettingsPrivate;
+ class QNetworkManagerSettings : public QObject
+ {
+@@ -349,13 +430,16 @@
+ 
+     QDBusInterface  *connectionInterface() const;
+     QList <QDBusObjectPath> listConnections();
++    QString getConnectionByUuid(const QString &uuid);
+     bool setConnections();
+     bool isValid();
+ 
+ Q_SIGNALS:
+     void newConnection(QDBusObjectPath);
++    void connectionsListReady();
+ private:
+     QNetworkManagerSettingsPrivate *d;
++    QList <QDBusObjectPath> connectionsList;
+ };
+ 
+ class QNetworkManagerSettingsConnectionPrivate;
+@@ -382,12 +466,14 @@
+     bool isValid();
+ 
+ Q_SIGNALS:
+-
+-    void updated(const QNmSettingsMap &settings);
++    void updated();
+     void removed(const QString &path);
++    void settingsReady();
++
++private Q_SLOTS:
++    void slotSettingsRemoved();
+ 
+ private:
+-    QNmDBusHelper *nmDBusHelper;
+     QNetworkManagerSettingsConnectionPrivate *d;
+ };
+ 
+@@ -408,22 +494,26 @@
+     ~ QNetworkManagerConnectionActive();
+ 
+     QDBusInterface  *connectionInterface() const;
+-    QString serviceName() const;
+     QDBusObjectPath connection() const;
+     QDBusObjectPath specificObject() const;
+-    QList<QDBusObjectPath> devices() const;
++    QStringList devices() const;
+     quint32 state() const;
+     bool defaultRoute() const;
++    bool default6Route() const;
+     bool setConnections();
+     bool isValid();
+ 
+ 
+ Q_SIGNALS:
+-    void propertiesChanged(QList<QDBusObjectPath>);
+-    void propertiesChanged( const QString &, QMap<QString,QVariant>);
++    void propertiesChanged(QMap<QString,QVariant>);
++    void propertiesReady();
++
++private Q_SLOTS:
++    void propertiesSwap(QMap<QString,QVariant>);
++
+ private:
+     QNetworkManagerConnectionActivePrivate *d;
+-    QNmDBusHelper *nmDBusHelper;
++    QVariantMap propertyMap;
+ };
+ 
+ class QNetworkManagerIp4ConfigPrivate;
+--- qtbase/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
++++ /dev/null
+@@ -1,130 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+-** Contact: http://www.qt-project.org/legal
+-**
+-** This file is part of the plugins of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:LGPL$
+-** Commercial License Usage
+-** Licensees holding valid commercial Qt licenses may use this file in
+-** accordance with the commercial license agreement provided with the
+-** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
+-** use the contact form at http://qt.digia.com/contact-us.
+-**
+-** 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, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
+-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-**
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-
+-// this class is for helping qdbus get stuff
+-
+-#include "qnmdbushelper.h"
+-
+-#include "qnetworkmanagerservice.h"
+-
+-#include <QDBusError>
+-#include <QDBusInterface>
+-#include <QDBusMessage>
+-#include <QDBusReply>
+-
+-#include <QDebug>
+-
+-#ifndef QT_NO_DBUS
+-
+-QT_BEGIN_NAMESPACE
+-
+-QNmDBusHelper::QNmDBusHelper(QObject * parent)
+-        : QObject(parent)
+-{
+-}
+-
+-QNmDBusHelper::~QNmDBusHelper()
+-{
+-}
+-
+-void QNmDBusHelper::deviceStateChanged(quint32 state)
+- {
+-    QDBusMessage msg = this->message();
+-    if(state == NM_DEVICE_STATE_ACTIVATED
+-       || state == NM_DEVICE_STATE_DISCONNECTED
+-       || state == NM_DEVICE_STATE_UNAVAILABLE
+-       || state == NM_DEVICE_STATE_FAILED) {
+-        emit pathForStateChanged(msg.path(), state);
+-    }
+- }
+-
+-void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
+-{
+-    if(path.path().length() > 2) {
+-        QDBusMessage msg = this->message();
+-        emit pathForAccessPointAdded(msg.path(), path);
+-    }
+-}
+-
+-void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
+-{
+-    if(path.path().length() > 2) {
+-        QDBusMessage msg = this->message();
+-        emit pathForAccessPointRemoved(msg.path(), path);
+-    }
+-}
+-
+-void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
+-{
+-    QDBusMessage msg = this->message();
+-    QMapIterator<QString, QVariant> i(map);
+-    while (i.hasNext()) {
+-        i.next();
+-        if( i.key() == "State") { //state only applies to device interfaces
+-            quint32 state = i.value().toUInt();
+-            if( state == NM_DEVICE_STATE_ACTIVATED
+-                || state == NM_DEVICE_STATE_DISCONNECTED
+-                || state == NM_DEVICE_STATE_UNAVAILABLE
+-                || state == NM_DEVICE_STATE_FAILED) {
+-                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);
+-        }
+-    }
+-}
+-
+-void QNmDBusHelper::slotSettingsRemoved()
+-{
+-    QDBusMessage msg = this->message();
+-    emit pathForSettingsRemoved(msg.path());
+-}
+-
+-QT_END_NAMESPACE
+-
+-#endif // QT_NO_DBUS
+--- qtbase/src/plugins/bearer/networkmanager/qnmdbushelper.h
++++ /dev/null
+@@ -1,79 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+-** Contact: http://www.qt-project.org/legal
+-**
+-** This file is part of the plugins of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:LGPL$
+-** Commercial License Usage
+-** Licensees holding valid commercial Qt licenses may use this file in
+-** accordance with the commercial license agreement provided with the
+-** Software or, alternatively, in accordance with the terms contained in
+-** a written agreement between you and Digia.  For licensing terms and
+-** conditions see http://qt.digia.com/licensing.  For further information
+-** use the contact form at http://qt.digia.com/contact-us.
+-**
+-** 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, Digia gives you certain additional
+-** rights.  These rights are described in the Digia Qt LGPL Exception
+-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-**
+-** GNU General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3.0 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.GPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU General Public License version 3.0 requirements will be
+-** met: http://www.gnu.org/copyleft/gpl.html.
+-**
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-
+-#ifndef QNMDBUSHELPERPRIVATE_H
+-#define QNMDBUSHELPERPRIVATE_H
+-
+-#include <QDBusObjectPath>
+-#include <QDBusContext>
+-#include <QMap>
+-
+-#ifndef QT_NO_DBUS
+-
+-QT_BEGIN_NAMESPACE
+-
+-class QNmDBusHelper: public QObject, protected QDBusContext
+- {
+-     Q_OBJECT
+- public:
+-    QNmDBusHelper(QObject *parent = 0);
+-    ~QNmDBusHelper();
+-
+- public slots:
+-    void deviceStateChanged(quint32);
+-    void slotAccessPointAdded( QDBusObjectPath );
+-    void slotAccessPointRemoved( QDBusObjectPath );
+-    void slotPropertiesChanged( QMap<QString,QVariant>);
+-    void slotSettingsRemoved();
+-
+-Q_SIGNALS:
+-    void pathForStateChanged(const QString &, quint32);
+-    void pathForAccessPointAdded(const QString &,  QDBusObjectPath );
+-    void pathForAccessPointRemoved(const QString &,  QDBusObjectPath );
+-    void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
+-    void pathForSettingsRemoved(const QString &);
+-};
+-
+-QT_END_NAMESPACE
+-
+-#endif // QT_NO_DBUS
+-
+-#endif// QNMDBUSHELPERPRIVATE_H
Index: files/correct-systraymenu-iconhandling.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/correct-systraymenu-iconhandling.patch b/trunk/dports/aqua/qt5-mac/files/correct-systraymenu-iconhandling.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/correct-systraymenu-iconhandling.patch	(working copy)
@@ -0,0 +1,26 @@
+diff --git qtbase/src/widgets/widgets/qmenu.cpp qtbase/src/widgets/widgets/qmenu.cpp
+index 7e48bad..00357c5 100644
+--- qtbase/src/widgets/widgets/qmenu.cpp
++++ qtbase/src/widgets/widgets/qmenu.cpp
+@@ -2978,8 +2978,19 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i
+ {
+     item->setText(action->text());
+     item->setIsSeparator(action->isSeparator());
+-    if (action->isIconVisibleInMenu())
++    if (action->isIconVisibleInMenu()) {
+         item->setIcon(action->icon());
++//        if (QWidget *w = action->parentWidget()) {
++//            QStyleOption opt;
++//            opt.init(w);
++//            item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
++//        } else {
++//            QStyleOption opt;
++//            item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));
++//        }
++    } else {
++        item->setIcon(QIcon());
++    }
+     item->setVisible(action->isVisible());
+     item->setShortcut(action->shortcut());
+     item->setCheckable(action->isCheckable());
+
Index: files/dbus_correct_signal_name_disconnect.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/dbus_correct_signal_name_disconnect.patch b/trunk/dports/aqua/qt5-mac/files/dbus_correct_signal_name_disconnect.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/dbus_correct_signal_name_disconnect.patch	(working copy)
@@ -0,0 +1,25 @@
+From 2160e7e0b7842d4ef49fdd435b4a7f127d479b90 Mon Sep 17 00:00:00 2001
+From: Jakub Adam <jakub.adam@jollamobile.com>
+Date: Wed, 4 Jun 2014 14:48:02 +0200
+Subject: [PATCH] Use correct signal name when disconnecting "NameOwnerChanged"
+
+A disconnectSignal() call with a wrong signal name caused that hook
+wasn't found and thus kept in QDBusConnectionPrivate::signalHooks
+forever.
+
+Change-Id: Id7cda225be7580529fc835b377636226abb229f9
+---
+ src/dbus/qdbusintegrator.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- qtbase/src/dbus/qdbusintegrator.cpp
++++ qtbase/src/dbus/qdbusintegrator.cpp
+@@ -2266,7 +2266,7 @@
+                     watchedServices.erase(sit);
+                     disconnectSignal(dbusServiceString(), QString(), dbusInterfaceString(),
+                                   QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
+-                                  this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
++                                  this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString)));
+                 }
+             }
+         }
Index: files/deactivate-menurole-heuristics.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/deactivate-menurole-heuristics.patch b/trunk/dports/aqua/qt5-mac/files/deactivate-menurole-heuristics.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/deactivate-menurole-heuristics.patch	(working copy)
@@ -0,0 +1,31 @@
+diff --git qtbase/src/plugins/platforms/cocoa/messages.cpp qtbase/src/plugins/platforms/cocoa/messages.cpp
+index 4f7b038..ea63338 100644
+--- qtbase/src/plugins/platforms/cocoa/messages.cpp
++++ qtbase/src/plugins/platforms/cocoa/messages.cpp
+@@ -78,16 +78,16 @@ QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
+ {
+     QString captionNoAmpersand(caption);
+     captionNoAmpersand.remove(QChar('&'));
+-    const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
+-    if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive))
+-        return QPlatformMenuItem::AboutRole;
+-    if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
+-        || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
+-        || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
+-        || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
+-        || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
+-        return QPlatformMenuItem::PreferencesRole;
+-    }
++//     const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
++//     if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive))
++//         return QPlatformMenuItem::AboutRole;
++//     if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
++//         || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
++//         || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
++//         || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
++//         || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
++//         return QPlatformMenuItem::PreferencesRole;
++//     }
+     if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive)
+         || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) {
+         return QPlatformMenuItem::QuitRole;
Index: files/debug-negative-qtimerint.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/debug-negative-qtimerint.patch b/trunk/dports/aqua/qt5-mac/files/debug-negative-qtimerint.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/debug-negative-qtimerint.patch	(working copy)
@@ -0,0 +1,13 @@
+diff --git qtbase/src/corelib/kernel/qobject.cpp qtbase/src/corelib/kernel/qobject.cpp
+index e588808..f0e2d7c 100644
+--- qtbase/src/corelib/kernel/qobject.cpp
++++ qtbase/src/corelib/kernel/qobject.cpp
+@@ -1605,7 +1605,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
+     Q_D(QObject);
+ 
+     if (interval < 0) {
+-        qWarning("QObject::startTimer: Timers cannot have negative intervals");
++        qWarning() << "QObject::startTimer: Timer" << this << "cannot have a negative interval";
+         return 0;
+     }
+ 
Index: files/disable-generic-plugin-when-others-available.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/disable-generic-plugin-when-others-available.patch b/trunk/dports/aqua/qt5-mac/files/disable-generic-plugin-when-others-available.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/disable-generic-plugin-when-others-available.patch	(working copy)
@@ -0,0 +1,11 @@
+--- qtbase/src/network/bearer/qnetworkconfigmanager_p.cpp
++++ qtbase/src/network/bearer/qnetworkconfigmanager_p.cpp
+@@ -413,7 +413,7 @@
+             }
+         }
+ 
+-        if (generic)
++        if (generic && sessionEngines.count() == 0)
+             sessionEngines.append(generic);
+ #endif // QT_NO_LIBRARY
+     }
Index: files/fix-qstandardpaths.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/fix-qstandardpaths.patch b/trunk/dports/aqua/qt5-mac/files/fix-qstandardpaths.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/fix-qstandardpaths.patch	(working copy)
@@ -0,0 +1,105 @@
+--- qtbase/src/corelib/io/orig.qstandardpaths_mac.cpp	2014-09-11 12:48:06.000000000 +0200
++++ qtbase/src/corelib/io/qstandardpaths_mac.cpp	2015-01-10 22:11:59.000000000 +0100
+@@ -45,6 +45,7 @@
+ 
+ #ifndef QT_BOOTSTRAPPED
+ #include <qcoreapplication.h>
++#include <qlibraryinfo.h>
+ #endif
+ 
+ #include <CoreFoundation/CoreFoundation.h>
+@@ -126,7 +127,7 @@
+     if (err)
+        return QString();
+ 
+-   QString path = getFullPath(ref);
++    QString path = getFullPath(ref);
+ 
+     if (type == QStandardPaths::DataLocation || type == QStandardPaths::CacheLocation)
+         appendOrganizationAndApp(path);
+@@ -175,17 +176,85 @@
+     }
+ }
+ 
++static void normaliseDirs(QStringList &dirs)
++{
++    // Normalise paths, skip relative paths
++    QMutableListIterator<QString> it(dirs);
++    while (it.hasNext()) {
++        const QString dir = it.next();
++        if (!dir.startsWith(QLatin1Char('/')))
++            it.remove();
++        else
++            it.setValue(QDir::cleanPath(dir));
++    }
++
++    // Remove duplicates from the list, there's no use for duplicated
++    // paths in XDG_CONFIG_DIRS - if it's not found in the given
++    // directory the first time, it won't be there the second time.
++    // Plus duplicate paths causes problems for example for mimetypes,
++    // where duplicate paths here lead to duplicated mime types returned
++    // for a file, eg "text/plain,text/plain" instead of "text/plain"
++    dirs.removeDuplicates();
++}
++
++static QStringList xdgConfigDirs()
++{
++    QStringList dirs;
++    // http://standards.freedesktop.org/basedir-spec/latest/
++    QString xdgConfigDirsEnv = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS"));
++    if (xdgConfigDirsEnv.isEmpty()) {
++#ifndef QT_BOOTSTRAPPED
++        dirs.append(QLibraryInfo::location(QLibraryInfo::PrefixPath) + QString::fromLatin1("/config"));
++#endif
++    } else {
++        dirs = xdgConfigDirsEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
++
++        normaliseDirs(dirs);
++    }
++    return dirs;
++}
++
++static QStringList xdgDataDirs()
++{
++    QStringList dirs;
++    // http://standards.freedesktop.org/basedir-spec/latest/
++    QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));
++    if (xdgDataDirsEnv.isEmpty()) {
++#ifndef QT_BOOTSTRAPPED
++        dirs.append(QLibraryInfo::location(QLibraryInfo::PrefixPath) + QString::fromLatin1("/share"));
++#endif
++    } else {
++        dirs = xdgDataDirsEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
++
++        normaliseDirs(dirs);
++    }
++    return dirs;
++}
++
+ QStringList QStandardPaths::standardLocations(StandardLocation type)
+ {
+     QStringList dirs;
+ 
++    if (type == GenericDataLocation) {
++        dirs.append(xdgDataDirs());
++    }
++
+     if (type == GenericDataLocation || type == DataLocation || type == GenericCacheLocation || type == CacheLocation) {
+         const QString path = macLocation(type, kOnAppropriateDisk);
+         if (!path.isEmpty())
+             dirs.append(path);
+     }
+ 
++    if (type == GenericConfigLocation || type == ConfigLocation)
++        dirs.append(xdgConfigDirs());
++
+     if (type == DataLocation) {
++        QStringList xdgDirs = xdgDataDirs();
++        for (int i = 0; i < xdgDirs.count(); ++i) {
++            appendOrganizationAndApp(xdgDirs[i]);
++        }
++        dirs.append(xdgDirs);
++
+         CFBundleRef mainBundle = CFBundleGetMainBundle();
+         if (mainBundle) {
+             CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle);
Index: files/fix_bug_in_internal_comparison_operator.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/fix_bug_in_internal_comparison_operator.patch b/trunk/dports/aqua/qt5-mac/files/fix_bug_in_internal_comparison_operator.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/fix_bug_in_internal_comparison_operator.patch	(working copy)
@@ -0,0 +1,73 @@
+Author: Lars Knoll <lars.knoll@digia.com>
+Date: Fri, 5 Sep 2014 12:58:19 +0200
+Description: [PATCH] Fix bugs in internal comparison operators
+ Lisandro removed the tests part as it didn't apply and we are not
+ running them anyway.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+
+The comparison operators between QJsonPrivate::String
+and QJsonPrivate::Latin1String weren't all correct, leading
+to wrong sorting of keys in QJsonObjects when the keys were
+outside of the latin1 range and resulting lookup errors.
+
+Task-number: QTBUG-41100
+Change-Id: Idceff615f85d7ab874ad2a8e4a6c1ce8c2aa0f65
+Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
+---
+ src/corelib/json/qjson_p.h |   23 ++++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+--- qtbase/src/corelib/json/qjson_p.h
++++ qtbase/src/corelib/json/qjson_p.h
+@@ -352,7 +352,7 @@
+         return !memcmp(d->utf16, str.d->utf16, d->length*sizeof(ushort));
+     }
+     inline bool operator<(const String &other) const;
+-    inline bool operator >=(const String &other) const { return other < *this; }
++    inline bool operator >=(const String &other) const { return !(*this < other); }
+ 
+     inline QString toString() const {
+ #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+@@ -412,12 +412,29 @@
+             val = d->length - str.d->length;
+         return val >= 0;
+     }
++    inline bool operator<(const String &str) const
++    {
++        const qle_ushort *uc = (qle_ushort *) str.d->utf16;
++        if (!uc || *uc == 0)
++            return false;
++
++        const uchar *c = (uchar *)d->latin1;
++        const uchar *e = c + qMin((int)d->length, (int)str.d->length);
+ 
++        while (c < e) {
++            if (*c != *uc)
++                break;
++            ++c;
++            ++uc;
++        }
++        return (c == e ? (int)d->length < (int)str.d->length : *c < *uc);
++
++    }
+     inline bool operator ==(const String &str) const {
+         return (str == *this);
+     }
+     inline bool operator >=(const String &str) const {
+-        return (str < *this);
++        return !(*this < str);
+     }
+ 
+     inline QString toString() const {
+@@ -454,7 +471,7 @@
+         a++,b++;
+     if (l==-1)
+         return (alen < blen);
+-    return (ushort)*a - (ushort)*b;
++    return (ushort)*a < (ushort)*b;
+ }
+ 
+ inline bool String::operator<(const Latin1String &str) const
Index: files/fix_sparc_atomics.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/fix_sparc_atomics.patch b/trunk/dports/aqua/qt5-mac/files/fix_sparc_atomics.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/fix_sparc_atomics.patch	(working copy)
@@ -0,0 +1,21 @@
+Description: Do not use specific headers for Sparc atomics
+ By removing the unexistant sparc headers the C++11 ones will be used.
+Author: Adam Majer <adamm@debian.org>
+Forwarded: no
+Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
+
+---
+ src/corelib/thread/qbasicatomic.h |    2 --
+ 1 file changed, 2 deletions(-)
+
+--- qtbase/src/corelib/thread/qbasicatomic.h
++++ qtbase/src/corelib/thread/qbasicatomic.h
+@@ -62,8 +62,6 @@
+ #  include "QtCore/qatomic_ia64.h"
+ #elif defined(Q_PROCESSOR_MIPS)
+ #  include "QtCore/qatomic_mips.h"
+-#elif defined(Q_PROCESSOR_SPARC)
+-#  include "QtCore/qatomic_sparc.h"
+ #elif defined(Q_PROCESSOR_X86)
+ #  include <QtCore/qatomic_x86.h>
+ 
Index: files/gnukfreebsd.diff
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/gnukfreebsd.diff b/trunk/dports/aqua/qt5-mac/files/gnukfreebsd.diff
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/gnukfreebsd.diff	(working copy)
@@ -0,0 +1,174 @@
+Author: Pino Toscano <toscano.pino@tiscali.it>
+Description: Initial GNU/kFreeBSD support
+ - add a gnukfreebsd-g++ qmake mkspec, mostly copied from the hurd-g++ one
+ - properly use LD_LIBRARY_PATH on GNU/* systems
+Last-Update: 2013-12-21
+Forwarded: no
+
+---
+ mkspecs/features/qt_functions.prf       |    2 
+ mkspecs/gnukfreebsd-g++/qmake.conf      |   52 ++++++++++++++++++
+ mkspecs/gnukfreebsd-g++/qplatformdefs.h |   92 ++++++++++++++++++++++++++++++++
+ 3 files changed, 146 insertions(+)
+
+--- /dev/null
++++ qtbase/mkspecs/gnukfreebsd-g++/qmake.conf
+@@ -0,0 +1,52 @@
++#
++# qmake configuration for gnukfreebsd-g++
++#
++
++MAKEFILE_GENERATOR      = UNIX
++QMAKE_PLATFORM          = gnukfreebsd
++CONFIG                 += incremental gdb_dwarf_index
++QMAKE_INCREMENTAL_STYLE = sublib
++
++QMAKE_CFLAGS_THREAD    += -D_REENTRANT
++QMAKE_CXXFLAGS_THREAD  += $$QMAKE_CFLAGS_THREAD
++
++QMAKE_INCDIR            =
++QMAKE_LIBDIR            =
++QMAKE_INCDIR_X11        =
++QMAKE_LIBDIR_X11        =
++QMAKE_INCDIR_OPENGL     =
++QMAKE_LIBDIR_OPENGL     =
++QMAKE_INCDIR_OPENGL_ES1 = $$QMAKE_INCDIR_OPENGL
++QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL
++QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
++QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
++QMAKE_INCDIR_EGL        =
++QMAKE_LIBDIR_EGL        =
++QMAKE_INCDIR_OPENVG     =
++QMAKE_LIBDIR_OPENVG     =
++
++QMAKE_LIBS              =
++QMAKE_LIBS_DYNLOAD      = -ldl
++QMAKE_LIBS_X11          = -lXext -lX11 -lm
++QMAKE_LIBS_NIS          = -lnsl
++QMAKE_LIBS_EGL          = -lEGL
++QMAKE_LIBS_OPENGL       = -lGL
++QMAKE_LIBS_OPENGL_ES1   = -lGLES_CM
++QMAKE_LIBS_OPENGL_ES2   = -lGLESv2
++QMAKE_LIBS_OPENVG       = -lOpenVG
++QMAKE_LIBS_THREAD       = -lpthread
++
++QMAKE_AR                = ar cqs
++QMAKE_OBJCOPY           = objcopy
++QMAKE_NM                = nm -P
++QMAKE_RANLIB            =
++
++QMAKE_STRIP             = strip
++QMAKE_STRIPFLAGS_LIB   += --strip-unneeded
++QMAKE_INSTALL_FILE      = install -m 644 -p
++QMAKE_INSTALL_PROGRAM   = install -m 755 -p
++
++include(../common/unix.conf)
++include(../common/gcc-base-unix.conf)
++include(../common/g++-unix.conf)
++load(qt_config)
+--- /dev/null
++++ qtbase/mkspecs/gnukfreebsd-g++/qplatformdefs.h
+@@ -0,0 +1,92 @@
++/****************************************************************************
++**
++** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Contact: http://www.qt-project.org/legal
++**
++** This file is part of the qmake spec of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and Digia.  For licensing terms and
++** conditions see http://qt.digia.com/licensing.  For further information
++** use the contact form at http://qt.digia.com/contact-us.
++**
++** 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, Digia gives you certain additional
++** rights.  These rights are described in the Digia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 3.0 as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU General Public License version 3.0 requirements will be
++** met: http://www.gnu.org/copyleft/gpl.html.
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#ifndef QPLATFORMDEFS_H
++#define QPLATFORMDEFS_H
++
++// Get Qt defines/settings
++
++#include "qglobal.h"
++
++// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
++
++// 1) need to reset default environment if _BSD_SOURCE is defined
++// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
++// 3) it seems older glibc need this to include the X/Open stuff
++#ifndef _GNU_SOURCE
++#  define _GNU_SOURCE
++#endif
++
++#include <unistd.h>
++
++
++// We are hot - unistd.h should have turned on the specific APIs we requested
++
++
++#include <pthread.h>
++#include <dirent.h>
++#include <fcntl.h>
++#include <grp.h>
++#include <pwd.h>
++#include <signal.h>
++#include <dlfcn.h>
++
++#include <sys/types.h>
++#include <sys/ioctl.h>
++#include <sys/ipc.h>
++#include <sys/time.h>
++#include <sys/shm.h>
++#include <sys/socket.h>
++#include <sys/stat.h>
++#include <sys/wait.h>
++#include <netinet/in.h>
++#ifndef QT_NO_IPV6IFNAME
++#include <net/if.h>
++#endif
++
++#include "../common/posix/qplatformdefs.h"
++
++#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
++#define QT_SNPRINTF		::snprintf
++#define QT_VSNPRINTF		::vsnprintf
++#endif
++
++#endif // QPLATFORMDEFS_H
+--- qtbase/mkspecs/features/qt_functions.prf
++++ qtbase/mkspecs/features/qt_functions.prf
+@@ -265,6 +265,8 @@
+             deppath.name = PATH
+         } else:contains(QMAKE_HOST.os, Linux|FreeBSD|OpenBSD|NetBSD|DragonFly|SunOS|HP-UX|QNX|GNU) {
+             deppath.name = LD_LIBRARY_PATH
++        } else:contains(QMAKE_HOST.os, ^GNU/.*) {
++            deppath.name = LD_LIBRARY_PATH
+         } else:equals(QMAKE_HOST.os, Darwin) {
+             contains(QT_CONFIG, qt_framework): \
+                 deppath.name = DYLD_FRAMEWORK_PATH
Index: files/load_testability_from_env_var.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/load_testability_from_env_var.patch b/trunk/dports/aqua/qt5-mac/files/load_testability_from_env_var.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/load_testability_from_env_var.patch	(working copy)
@@ -0,0 +1,16 @@
+Description: load testability from environment variable
+Author: Thomi Richards <thomi.richards@canonical.com>
+Forwarded: https://bugreports.qt-project.org/browse/QTBUG-32974
+
+--- qtbase/src/gui/kernel/qguiapplication.cpp
++++ qtbase/src/gui/kernel/qguiapplication.cpp
+@@ -1256,6 +1256,9 @@
+         argc = j;
+     }
+ 
++    if (qgetenv("QT_LOAD_TESTABILITY").toInt() > 0)
++        loadTestability = true;
++
+ #if defined(QT_DEBUG) && defined(Q_OS_LINUX)
+     if (!doGrabUnderDebugger && !QGuiApplicationPrivate::noGrab && runningUnderDebugger()) {
+         QGuiApplicationPrivate::noGrab = true;
Index: files/qprocess-nozombies.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/qprocess-nozombies.patch b/trunk/dports/aqua/qt5-mac/files/qprocess-nozombies.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/qprocess-nozombies.patch	(working copy)
@@ -0,0 +1,23 @@
+--- qtbase/src/corelib/io/orig.qprocess_unix.cpp	2014-04-10 20:37:11.000000000 +0200
++++ qtbase/src/corelib/io/qprocess_unix.cpp	2014-12-11 17:03:26.000000000 +0100
+@@ -1320,17 +1320,18 @@
+     processManager()->remove(q);
+ }
+ 
++//https://codereview.qt-project.org/#/c/61294/
+ bool QProcessPrivate::waitForDeadChild()
+ {
+     Q_Q(QProcess);
+ 
+     // read a byte from the death pipe
+     char c;
+-    qt_safe_read(deathPipe[0], &c, 1);
++    qint64 readcount = qt_safe_read(deathPipe[0], &c, 1);
+ 
+     // check if our process is dead
+     int exitStatus;
+-    if (qt_safe_waitpid(pid_t(pid), &exitStatus, WNOHANG) > 0) {
++    if (qt_safe_waitpid(pid_t(pid), &exitStatus, readcount > 0 ? WNOHANG : 0) > 0) {
+         processManager()->remove(q);
+         crashed = !WIFEXITED(exitStatus);
+         exitCode = WEXITSTATUS(exitStatus);
Index: files/remove_google_adsense.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/remove_google_adsense.patch b/trunk/dports/aqua/qt5-mac/files/remove_google_adsense.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/remove_google_adsense.patch	(working copy)
@@ -0,0 +1,69 @@
+Description: remove tracking javascript from examples
+Author: Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
+Last-Update: 2014-02-17
+
+---
+ examples/xml/htmlinfo/trolltech_com.html |   45 -------------------------------
+ 1 file changed, 45 deletions(-)
+
+--- qtbase/examples/xml/htmlinfo/trolltech_com.html
++++ qtbase/examples/xml/htmlinfo/trolltech_com.html
+@@ -23,14 +23,6 @@
+               content="Trolltech creates application development platforms for desktop and mobile device innovation." />
+         <meta name="keywords" content="" />
+     
+-<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"><!-- &nbsp;--></script>
+-<script type="text/javascript">
+-    <!-- Urchin script
+-                _uacct = "UA-4457116-1";
+-                urchinTracker();
+-    -->
+-	</script>
+-      
+         <base href="http://trolltech.com/homepage" />
+       
+     
+@@ -910,43 +902,6 @@
+     </div>
+       
+     </div>
+-<!-- ProspectXtractor tracker script -->
+-<script type="text/javascript"><!--
+-function _pxPar()
+-{
+-var p="";
+-p+="&ref="+escape(top.document.referrer);
+-p+="&dt="+escape(document.title);
+-p+="&sr="+screen.width+"x"+screen.height;
+-p+="&sd="+screen.colorDepth;
+-p+="&fv="+_pxFV();
+-return p;
+-}
+-function _pxFV()
+-{
+-var f=0,n=navigator;
+-if (n.plugins && n.mimeTypes.length) {
+-var x=n.plugins["Shockwave Flash"];
+-if(x && x.description) {
+-var y=x.description;
+-f=y.charAt(y.indexOf('.')-1);
+-}
+-} else {
+-r=false;
+-for(var i=15;i>=3&&r!=true;i-=1){
+-execScript('on error resume next: r=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
+-f=i;
+-}
+-}
+-return f;
+-}
+-document.write('<img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999'+_pxPar()+'" width="1" heigth="1" />');
+-//-->
+-</script>
+-<noscript>
+-<div><img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999" width="1" height="1" alt="" /></div>
+-</noscript>
+-<!-- END ProspectXtractor tracker script -->
+ </body>
+ </html>
+ 
Index: files/remove_icon_from_example.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/remove_icon_from_example.patch b/trunk/dports/aqua/qt5-mac/files/remove_icon_from_example.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/remove_icon_from_example.patch	(working copy)
@@ -0,0 +1,24 @@
+Description: remove icon link from example html file
+ This patch removes a suposedly privacy breach detected by lintian.
+ As the Trolltech site is down and the example is simply not working I am
+ just removing the link to it.
+Author: Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
+Forwarded: not-needed
+Last-Update: 2014-06-25
+
+---
+ examples/xml/htmlinfo/trolltech_com.html |    3 ---
+ 1 file changed, 3 deletions(-)
+
+--- qtbase/examples/xml/htmlinfo/trolltech_com.html
++++ qtbase/examples/xml/htmlinfo/trolltech_com.html
+@@ -110,9 +110,6 @@
+         <style type="text/css" media="all">@import url(http://trolltech.com/IEFixes.css);</style>
+     <![endif]-->
+ 
+-    <link rel="shortcut icon" type="image/x-icon"
+-          href="http://trolltech.com/favicon.ico" />
+-
+     <link rel="home" href="http://trolltech.com"
+           title="Front page" />
+     <link rel="search"
Index: files/update-QtBearer-NetworkManager-backend-API.patch
===================================================================
diff --git a/trunk/dports/aqua/qt5-mac/files/update-QtBearer-NetworkManager-backend-API.patch b/trunk/dports/aqua/qt5-mac/files/update-QtBearer-NetworkManager-backend-API.patch
new file mode 10644
--- /dev/null	(revision 0)
+++ b/trunk/dports/aqua/qt5-mac/files/update-QtBearer-NetworkManager-backend-API.patch	(working copy)
@@ -0,0 +1,57 @@
+From 151061ad4af9d1b844f0b029b4e84a3577487048 Mon Sep 17 00:00:00 2001
+From: Lorn Potter <lorn.potter@jollamobile.com>
+Date: Fri, 3 Oct 2014 19:30:04 +1000
+Subject: [PATCH] update QtBearer NetworkManager backend API
+
+Task-number: QTBUG-41747
+
+Change-Id: Idb4afea0215b94957a11895c7db97a72ae680804
+Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
+---
+ src/network/doc/src/bearermanagement.qdoc          |   2 +-
+ .../networkmanager/qnetworkmanagerengine.cpp       | 124 ++++++++++-----------
+ .../bearer/networkmanager/qnetworkmanagerengine.h  |   3 +-
+ .../networkmanager/qnetworkmanagerservice.cpp      |  30 ++---
+ .../bearer/networkmanager/qnetworkmanagerservice.h |   6 +-
+ .../qnetworksession/test/tst_qnetworksession.cpp   |  12 +-
+ 6 files changed, 90 insertions(+), 87 deletions(-)
+
+--- qtbase/src/network/doc/src/bearermanagement.qdoc
++++ qtbase/src/network/doc/src/bearermanagement.qdoc
+@@ -248,7 +248,7 @@
+         \li Linux uses the \l {http://projects.gnome.org/NetworkManager}{NetworkManager}
+            and \l {http://connman.net/}{ConnMan} / \l {http://ofono.org/}{oFono} APIs
+            which support interface notifications and starting and stopping of network
+-           interfaces.
++           interfaces. Network Manager version 0.9 and above is supported.
+     \row
+         \li Windows\unicode{0xAE} XP
+         \li This platform supports interface notifications without active polling.
+--- qtbase/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
++++ qtbase/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
+@@ -279,7 +279,11 @@
+                                                  << QLatin1String("WCDMA")
+                                                  << QLatin1String("HSPA")
+                                                  << QLatin1String("Bluetooth")
+-                                                 << QLatin1String("WiMAX");
++                                                 << QLatin1String("WiMAX")
++                                                 << QLatin1String("BearerEVDO")
++                                                 << QLatin1String("BearerLTE")
++                                                 << QLatin1String("Bearer3G")
++                                                 << QLatin1String("Bearer4G");
+ 
+     if (!configuration.isValid()) {
+         QVERIFY(configuration.bearerTypeName().isEmpty());
+@@ -1035,7 +1039,11 @@
+             if (config.bearerTypeName() != "2G" &&
+                 config.bearerTypeName() != "CDMA2000" &&
+                 config.bearerTypeName() != "WCDMA" &&
+-                config.bearerTypeName() != "HSPA") {
++                config.bearerTypeName() != "HSPA" &&
++                config.bearerTypeName() != "EVDO" &&
++                config.bearerTypeName() != "LTE" &&
++                config.bearerTypeName() != "3G" &&
++                config.bearerTypeName() != "4G") {
+                 // qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name();
+                 discoveredConfigs.removeOne(config);
+             }
