qtmobility/src/bearer/qnetworksession_p.cpp
changeset 4 90517678cc4f
parent 0 cfcbf08528c4
child 11 06b8e2af4411
--- a/qtmobility/src/bearer/qnetworksession_p.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/src/bearer/qnetworksession_p.cpp	Mon May 03 13:18:40 2010 +0300
@@ -495,38 +495,33 @@
         startTime = QDateTime();
         return;
     }
-    QString connectionIdent = q->configuration().identifier();
     QString interface = currentInterface().hardwareAddress().toLower();
-    QString devicePath = "/org/freedesktop/Hal/devices/net_" + interface.replace(":","_");
+    const QString devicePath = QLatin1String("/org/freedesktop/Hal/devices/net_") +
+                               interface.replace(QLatin1Char(':'), QLatin1Char('_'));
 
     QString path;
     QString serviceName;
-    QNetworkManagerInterface * ifaceD;
-    ifaceD = new QNetworkManagerInterface();
+    QScopedPointer<QNetworkManagerInterface> ifaceD(new QNetworkManagerInterface());
 
-    QList<QDBusObjectPath> connections = ifaceD->activeConnections();
-    foreach(QDBusObjectPath conpath, connections) {
-        QNetworkManagerConnectionActive *conDetails;
-        conDetails = new QNetworkManagerConnectionActive(conpath.path());
-        QDBusObjectPath connection = conDetails->connection();
+    foreach (const QDBusObjectPath &conpath, ifaceD->activeConnections()) {
+        QScopedPointer<QNetworkManagerConnectionActive> conDetails(new QNetworkManagerConnectionActive(conpath.path()));
+        const QDBusObjectPath connection = conDetails->connection();
         serviceName = conDetails->serviceName();
-        QList<QDBusObjectPath> so = conDetails->devices();
-        foreach(QDBusObjectPath device, so) {
-
+        foreach (const QDBusObjectPath &device, conDetails->devices()) {
             if(device.path() == devicePath) {
                 path = connection.path();
             }
             break;
         }
     }
-if(serviceName.isEmpty())
-    return;
-    QNetworkManagerSettings *settingsiface;
-    settingsiface = new QNetworkManagerSettings(serviceName);
-    QList<QDBusObjectPath> list = settingsiface->listConnections();
-    foreach(QDBusObjectPath path, list) {
-        QNetworkManagerSettingsConnection *sysIface;
-        sysIface = new QNetworkManagerSettingsConnection(serviceName, path.path());
+
+    if(serviceName.isEmpty())
+        return;
+
+    QScopedPointer<QNetworkManagerSettings> settingsiface(new QNetworkManagerSettings(serviceName));
+    foreach (const QDBusObjectPath &path, settingsiface->listConnections()) {
+        QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
+        sysIface.reset(new QNetworkManagerSettingsConnection(serviceName, path.path()));
         startTime = QDateTime::fromTime_t(sysIface->getTimestamp());
         //                    isOpen = (publicConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
     }