qtmobility/src/bearer/qnmwifiengine_unix.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:15:07 +0100
branchRCL_3
changeset 10 cd2778e5acfe
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/****************************************************************************
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
** All rights reserved.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
** Contact: Nokia Corporation (qt-info@nokia.com)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
** This file is part of the Qt Mobility Components.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
** $QT_BEGIN_LICENSE:LGPL$
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
** No Commercial Usage
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
** This file contains pre-release code and may not be distributed.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
** You may use this file in accordance with the terms and conditions
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
** contained in the Technology Preview License Agreement accompanying
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
** this package.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
** GNU Lesser General Public License Usage
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
** Alternatively, this file may be used under the terms of the GNU Lesser
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
** General Public License version 2.1 as published by the Free Software
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
** Foundation and appearing in the file LICENSE.LGPL included in the
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
** packaging of this file.  Please review the following information to
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
** ensure the GNU Lesser General Public License version 2.1 requirements
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
** In addition, as a special exception, Nokia gives you certain additional
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
** rights.  These rights are described in the Nokia Qt LGPL Exception
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
** If you have questions regarding the use of this file, please contact
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
** Nokia at qt-info@nokia.com.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
** $QT_END_LICENSE$
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
**
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
****************************************************************************/
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
#include "qnmwifiengine_unix_p.h"
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
#include "qnetworkconfiguration_p.h"
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
#include <qnetworkconfiguration.h>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
#include <QtCore/qstringlist.h>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
#include <QScopedPointer>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
#include <QtNetwork/qnetworkinterface.h>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
#include <qnetworkmanagerservice_p.h>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
#include <QNetworkInterface>
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
QTM_BEGIN_NAMESPACE
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
Q_GLOBAL_STATIC(QNmWifiEngine, nmWifiEngine)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
typedef  QList<QList<uint> > QNmSettingsAddressMap;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
QTM_END_NAMESPACE
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsAddressMap))
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
QTM_BEGIN_NAMESPACE
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
QNmWifiEngine::QNmWifiEngine(QObject *parent)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
:   QNetworkSessionEngine(parent)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
    iface = new QNetworkManagerInterface(this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    if(!iface->isValid()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
        return;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
    iface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
    connect(iface,SIGNAL(deviceAdded(QDBusObjectPath)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
            this,SLOT(addDevice(QDBusObjectPath)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
//     connect(iface,SIGNAL(deviceRemoved(QDBusObjectPath)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
//             this,SLOT(removeDevice(QDBusObjectPath)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
    connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
            this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
    foreach (const QDBusObjectPath &path, iface->getDevices())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
        addDevice(path);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
    QStringList connectionServices;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
    connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
    connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
    QNetworkManagerSettings *settingsiface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
    foreach (const QString &service, connectionServices) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
        settingsiface = new QNetworkManagerSettings(service, this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
        settingsiface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
        connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
                this,(SLOT(newConnection(QDBusObjectPath))));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
    updated = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
QNmWifiEngine::~QNmWifiEngine()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
QString QNmWifiEngine::getNameForConfiguration(QNetworkManagerInterfaceDevice *devIface)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
    QString newname;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
    if (devIface->state() == NM_DEVICE_STATE_ACTIVATED) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
        QString path = devIface->ip4config().path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
        QNetworkManagerIp4Config * ipIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
        ipIface = new QNetworkManagerIp4Config(path);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
        newname = ipIface->domains().join(" ");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
        delete ipIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    //fallback to interface name
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
    if(newname.isEmpty())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
        newname = devIface->networkInterface().name();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
    return newname;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
QList<QNetworkConfigurationPrivate *> QNmWifiEngine::getConfigurations(bool *ok)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
    if (ok)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
        *ok = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
    if(!updated) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
        foundConfigurations.clear();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
        if(knownSsids.isEmpty())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
            updateKnownSsids(); 
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
        scanForAccessPoints();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
        updateActiveConnectionsPaths();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
        knownConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
        accessPointConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
        updated = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
    return foundConfigurations;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
void QNmWifiEngine::knownConnections()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
    QStringList connectionServices;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
    connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
    connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
    QString connPath;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
    QScopedPointer<QNetworkManagerSettings> settingsiface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
    foreach (const QString &service, connectionServices) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
        QString ident;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
        settingsiface.reset(new QNetworkManagerSettings(service));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
        QNetworkManagerSettingsConnection *sysIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
        foreach (const QDBusObjectPath &path, settingsiface->listConnections()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
            ident = path.path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
            bool addIt = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
            QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
            sysIface = new QNetworkManagerSettingsConnection(service, path.path(), this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
            sysIface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
            connect(sysIface, SIGNAL(removed(QString)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
                    this,SLOT(settingsConnectionRemoved(QString)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
            cpPriv->name = sysIface->getId();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
            cpPriv->isValid = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
            cpPriv->id = sysIface->getUuid();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
            cpPriv->internet = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
            cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
            cpPriv->state = getStateForId(cpPriv->id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
            cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
            if(sysIface->getType() == DEVICE_TYPE_802_3_ETHERNET) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
                QString mac = sysIface->getMacAddress();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
                if(!mac.length() > 2) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
                    QString devPath;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
                    devPath = deviceConnectionPath(mac);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
                    QNetworkManagerInterfaceDevice devIface(devPath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
                    cpPriv->serviceInterface = devIface.networkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
                    QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
                    devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(devIface.connectionInterface()->path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
                    cpPriv->internet = devWiredIface->carrier();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
                    // use this mac addy
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
                } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
                    cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_3_ETHERNET, cpPriv->id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
                }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
                cpPriv->internet = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
                addIt = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
            } else if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
                QString mac = sysIface->getMacAddress();;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
                if(!mac.length() > 2) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
                    QString devPath;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
                    devPath = deviceConnectionPath(mac);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
                    QNetworkManagerInterfaceDevice devIface(devPath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
                    cpPriv->serviceInterface = devIface.networkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
                    // use this mac addy
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
                } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
                    cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_11_WIRELESS, cpPriv->id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
                }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
                addIt = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
                // get the wifi interface state first.. do we need this?
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
                //   QString activeAPPath = devWirelessIface->activeAccessPoint().path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
            if(addIt) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
                foundConfigurations.append(cpPriv);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
                configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
                cpPriv->bearer = bearerName(cpPriv->id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
        } 
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
void QNmWifiEngine::accessPointConnections()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
    QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
    foreach (const QDBusObjectPath &path, iface->getDevices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
        devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
        if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
            const QList<QString> apList = availableAccessPoints.uniqueKeys();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
            QList<QString>::const_iterator i;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
            for (i = apList.constBegin(); i != apList.constEnd(); ++i) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
                QNetworkConfigurationPrivate* cpPriv;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
                cpPriv = addAccessPoint( devIface->connectionInterface()->path(), availableAccessPoints[*i]);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
                if(cpPriv->isValid) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
                    foundConfigurations.append(cpPriv);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
                    configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
                    cpPriv->bearer = bearerName(cpPriv->id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
                }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
QString QNmWifiEngine::getInterfaceFromId(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
    return configurationInterface.value(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
bool QNmWifiEngine::hasIdentifier(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
    if (configurationInterface.contains(id))
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
        return true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
    return false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
QString QNmWifiEngine::bearerName(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
    QString interface = getInterfaceFromId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
    QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
    foreach (const QDBusObjectPath &path, iface->getDevices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
        devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
        if(interface == devIface->networkInterface().name()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
            switch(devIface->deviceType()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
                case DEVICE_TYPE_802_3_ETHERNET:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
                    return QLatin1String("Ethernet");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
                    break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
                case DEVICE_TYPE_802_11_WIRELESS:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
                    return QLatin1String("WLAN");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
                    break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
                case DEVICE_TYPE_GSM:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
                    return QLatin1String("2G");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
                    break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
                case DEVICE_TYPE_CDMA:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
                    return QLatin1String("CDMA2000");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
                    break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
                default:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
                    break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
    return QLatin1String("Unknown");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
void QNmWifiEngine::connectToId(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
    activatingConnectionPath = id;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
    QStringList connectionSettings = getConnectionPathForId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
    if(connectionSettings.isEmpty()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
        emit connectionError(id, OperationNotSupported);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
        return;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
    QDBusObjectPath connectionPath(connectionSettings.at(1));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
    QString interface = getInterfaceFromId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
    interface = QNetworkInterface::interfaceFromName(interface).hardwareAddress().toLower();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
    QString devPath;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
    devPath = deviceConnectionPath(interface);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
    QDBusObjectPath devicePath(devPath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
    iface->activateConnection(
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
            connectionSettings.at(0),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
            connectionPath,
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
            devicePath,
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
            connectionPath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
void QNmWifiEngine::disconnectFromId(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
    QString activeConnectionPath = getActiveConnectionPath(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
    if (!activeConnectionPath.isEmpty()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
        QScopedPointer<QNetworkManagerConnectionActive> activeCon;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
        activeCon.reset(new QNetworkManagerConnectionActive(activeConnectionPath));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
        QScopedPointer<QNetworkManagerSettingsConnection> settingsCon;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
        settingsCon.reset(new QNetworkManagerSettingsConnection(activeCon->serviceName(), activeCon->connection().path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
        if(settingsCon->getType() ==  DEVICE_TYPE_802_3_ETHERNET) { //use depreciated value for now
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
            emit connectionError(id, OperationNotSupported);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
        } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
            QDBusObjectPath dbpath(activeConnectionPath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
            iface->deactivateConnection(dbpath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
            activatingConnectionPath = "";
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
void QNmWifiEngine::requestUpdate()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
    updated = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
    knownSsids.clear();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
    availableAccessPoints.clear();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
    emitConfigurationsChanged();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
QNmWifiEngine *QNmWifiEngine::instance()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
    QDBusConnection dbusConnection = QDBusConnection::systemBus();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
    if (dbusConnection.isConnected()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
        QDBusConnectionInterface *dbiface = dbusConnection.interface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
        QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
        if (reply.isValid() && reply.value())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
            return nmWifiEngine();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
    return 0;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
void  QNmWifiEngine::updateKnownSsids()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
    QStringList connectionServices;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
    connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
    connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
    QScopedPointer<QNetworkManagerSettings> settingsiface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
    foreach (const QString &service, connectionServices) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
        settingsiface.reset(new QNetworkManagerSettings(service));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
        foreach (const QDBusObjectPath &path, settingsiface->listConnections()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
            QNetworkManagerSettingsConnection sysIface(service, path.path());
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
            knownSsids << sysIface.getSsid();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
void QNmWifiEngine::updateActiveConnectionsPaths()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
{ //need to know which connection paths are currently active/connected
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
    QScopedPointer<QNetworkManagerInterface> dbIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
    activeConnectionPaths.clear();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
    dbIface.reset(new QNetworkManagerInterface);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
    foreach (const QDBusObjectPath &conpath, dbIface->activeConnections())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
        activeConnectionPaths << conpath.path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPath, QDBusObjectPath path)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
    QScopedPointer<QNetworkManagerInterfaceDevice> devIface(new QNetworkManagerInterfaceDevice(iPath));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
    QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface(new QNetworkManagerInterfaceDeviceWireless(iPath));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
    QString activeAPPath = devWirelessIface->activeAccessPoint().path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
    QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface(new QNetworkManagerInterfaceAccessPoint(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
    QString ident = accessPointIface->connectionInterface()->path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
    quint32 nmState = devIface->state();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
    QString ssid = accessPointIface->ssid();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
    QString hwAddy = accessPointIface->hwAddress();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
    QString sInterface = devIface->networkInterface().name();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
    QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
    bool addIt = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
    if(addIt) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
        cpPriv->name = ssid;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
        cpPriv->isValid = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
        cpPriv->id = ident;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
        cpPriv->internet = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
        cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
        cpPriv->serviceInterface = devIface->networkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
        cpPriv->state = getAPState(nmState, knownSsids.contains(cpPriv->name));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
        if(activeAPPath == accessPointIface->connectionInterface()->path()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
            cpPriv->state = ( cpPriv->state | QNetworkConfiguration::Active);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
        if(accessPointIface->flags() == NM_802_11_AP_FLAGS_PRIVACY)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
            cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
        else
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
            cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
        return cpPriv;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
    } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
        cpPriv->isValid = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
    return cpPriv;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
 QNetworkConfiguration::StateFlags QNmWifiEngine::getAPState(qint32 nmState, bool isKnown)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
    QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
    // this is the state of the wifi device interface
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
    if(isKnown)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
        state = ( QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
    switch(nmState) { //device interface state, not AP state
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
    case  NM_DEVICE_STATE_UNKNOWN:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
    case  NM_DEVICE_STATE_UNMANAGED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
    case NM_DEVICE_STATE_UNAVAILABLE:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
        state = (QNetworkConfiguration::Undefined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
    case NM_DEVICE_STATE_DISCONNECTED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
        {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
            if(isKnown)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
                state = ( state  | QNetworkConfiguration::Discovered);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
    case NM_DEVICE_STATE_PREPARE:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
    case NM_DEVICE_STATE_CONFIG:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
    case NM_DEVICE_STATE_NEED_AUTH:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
    case NM_DEVICE_STATE_IP_CONFIG:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
        if(isKnown)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
            state = ( state | QNetworkConfiguration::Discovered);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
    case NM_DEVICE_STATE_ACTIVATED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
        {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
            if(isKnown)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
                state = ( state | QNetworkConfiguration::Discovered);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
    };
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
    return state;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
QString QNmWifiEngine::getActiveConnectionPath(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
    QStringList connectionSettings = getConnectionPathForId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
    QNetworkManagerInterface ifaceD;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
    QScopedPointer<QNetworkManagerConnectionActive> conDetailsD;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
    foreach (const QDBusObjectPath &path, ifaceD.activeConnections()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
        conDetailsD.reset(new QNetworkManagerConnectionActive( path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
        if(conDetailsD->connection().path() == connectionSettings.at(1)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
            && conDetailsD->serviceName() == connectionSettings.at(0))
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
            return path.path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
    return QString();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
 QNetworkConfiguration::StateFlags QNmWifiEngine::getStateFlag(quint32 nmstate)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
 {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
     QNetworkConfiguration::StateFlags flag;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
     switch (nmstate) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
     case  NM_DEVICE_STATE_UNKNOWN:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
     case NM_DEVICE_STATE_FAILED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
     case NM_DEVICE_STATE_UNMANAGED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
         flag = (QNetworkConfiguration::Undefined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
         break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
     case NM_DEVICE_STATE_PREPARE:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
     case NM_DEVICE_STATE_CONFIG:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
     case NM_DEVICE_STATE_NEED_AUTH:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
     case NM_DEVICE_STATE_IP_CONFIG:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
     case  NM_DEVICE_STATE_UNAVAILABLE:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
         flag = (QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
         break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
     case NM_DEVICE_STATE_DISCONNECTED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
         flag = ( flag | QNetworkConfiguration::Discovered );
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
     case NM_DEVICE_STATE_ACTIVATED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
         {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
             flag = ( flag | QNetworkConfiguration::Discovered
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
                      | QNetworkConfiguration::Active );
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
         }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
         break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
     default:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
         flag = ( QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
         break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
     };
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
     return flag;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
 }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32 nmState)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
    if(nmState == NM_DEVICE_STATE_ACTIVATED
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
       || nmState == NM_DEVICE_STATE_DISCONNECTED
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
       || nmState == NM_DEVICE_STATE_UNAVAILABLE
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
       || nmState == NM_DEVICE_STATE_FAILED) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
        QNetworkConfiguration::StateFlags state = (QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
        switch (nmState) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
                case  NM_DEVICE_STATE_UNKNOWN:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
                case NM_DEVICE_STATE_FAILED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
            state = (QNetworkConfiguration::Undefined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
            emit connectionError(activatingConnectionPath, ConnectError);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
            requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
                case  NM_DEVICE_STATE_UNAVAILABLE:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
            state = (QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
            requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
                case NM_DEVICE_STATE_DISCONNECTED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
            state = ( state | QNetworkConfiguration::Discovered );
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
            requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
                case NM_DEVICE_STATE_ACTIVATED:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
            {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
                state = ( state | QNetworkConfiguration::Discovered
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
                          | QNetworkConfiguration::Active );
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
                requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
                default:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
            state = ( QNetworkConfiguration::Defined);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
        };
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
void QNmWifiEngine::addDevice(QDBusObjectPath path)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
    QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path(), this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
    devIface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
    connect(devIface,SIGNAL(stateChanged(const QString &, quint32)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
            this, SLOT(updateDeviceInterfaceState(const QString&, quint32)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
    if(!devicePaths.contains(path.path()))
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
        devicePaths << path.path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
    switch(devIface->deviceType()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
    case DEVICE_TYPE_802_3_ETHERNET:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
        {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
            QNetworkManagerInterfaceDeviceWired * devWiredIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
            devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path(), this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
            devWiredIface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
            connect(devWiredIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
                    this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
            requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
    case DEVICE_TYPE_802_11_WIRELESS:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
        {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
            QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
            devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path(), this);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
            devWirelessIface->setConnections();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
            connect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
                    this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
            connect(devWirelessIface, SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
                    this,SLOT(accessPointAdded(const QString &,QDBusObjectPath)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
            connect(devWirelessIface, SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)),
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
                    this,SLOT(accessPointRemoved(const QString &,QDBusObjectPath)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
            requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
            default:
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
        break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
    };
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
void QNmWifiEngine::cmpPropertiesChanged(const QString &path, QMap<QString,QVariant> map)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
   QMapIterator<QString, QVariant> i(map);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
   while (i.hasNext()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
       i.next();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
       if( i.key() == "State") { //only applies to device interfaces
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
           updateDeviceInterfaceState(path, i.value().toUInt());
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
       }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
       if( i.key() == "ActiveAccessPoint") {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
       }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
       if( i.key() == "Carrier") { //someone got plugged in
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
       }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
   }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
void QNmWifiEngine::accessPointRemoved( const QString &aPath, QDBusObjectPath /*oPath*/)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
    if(aPath.contains("devices")) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
        requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
void QNmWifiEngine::accessPointAdded( const QString &/*aPath*/, QDBusObjectPath /*oPath*/)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
   requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
    bool isAvailable = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
    QStringList conPath = getConnectionPathForId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
    QString aconpath = getActiveConnectionPath(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
    if(!aconpath.isEmpty()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
        //active connection
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
        QNetworkManagerConnectionActive aConn(aconpath);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
        QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
        QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
        foreach (const QDBusObjectPath &dev, aConn.devices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
            ifaceDevice.reset(new QNetworkManagerInterfaceDevice(dev.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   620
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
            if(ifaceDevice->deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
                if(isAddressOfConnection(id, ifaceDevice->ip4Address())) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
                    // this is it!
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
                    return getStateFlag(ifaceDevice->state());
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
                } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
                    continue;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
                }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
                if(ifaceDevice->state() == NM_DEVICE_STATE_UNAVAILABLE ||
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
                   ifaceDevice->state() == NM_DEVICE_STATE_DISCONNECTED) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
                    isAvailable = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
                    devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(ifaceDevice->connectionInterface()->path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
                    if(!devWiredIface->carrier())
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
                        return QNetworkConfiguration::Defined;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
                } 
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
            } else if(ifaceDevice->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
            return getStateFlag(ifaceDevice->state());
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
    } else {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
        // not active
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
        QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
        sysIface.reset(new QNetworkManagerSettingsConnection(conPath.at(0),conPath.at(1)));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
        if(sysIface->isValid()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
            if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
                QString ssid = sysIface->getSsid();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
                bool ok = false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
                if(knownSsids.contains(ssid, Qt::CaseSensitive)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
                    foreach (const QString &onessid, knownSsids) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
                        if(onessid == ssid && availableAccessPoints.contains(ssid)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
                            ok = true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
                            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
                        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
                    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
                }   
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
                if(ok)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
                    return getStateFlag(NM_DEVICE_STATE_DISCONNECTED);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
                else
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
                    return getStateFlag(NM_DEVICE_STATE_UNAVAILABLE);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
    return QNetworkConfiguration::Defined; //not active, but we know this connection
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
bool QNmWifiEngine::isAddressOfConnection(const QString &id, quint32 ipaddress)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
    QStringList conPath = getConnectionPathForId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
    QString aConPath = getActiveConnectionPath(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
    if(aConPath.isEmpty()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
        // not active
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
        return false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
    QScopedPointer<QNetworkManagerConnectionActive> aConn;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
    aConn.reset(new QNetworkManagerConnectionActive(aConPath));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
    QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
    foreach (const QDBusObjectPath &device, aConn->devices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
        ifaceDevice.reset(new QNetworkManagerInterfaceDevice(device.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
        if(ifaceDevice->ip4Address() == ipaddress) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
            return true;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
    return false;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
QNetworkInterface QNmWifiEngine::getBestInterface( quint32 type, const QString &id)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
    // check active connections first.
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
    QStringList conIdPath = getConnectionPathForId(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
    QNetworkInterface interface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
    QScopedPointer<QNetworkManagerConnectionActive> aConn;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
    foreach (const QString &conpath, activeConnectionPaths) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
        aConn.reset(new QNetworkManagerConnectionActive(conpath));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
        if(aConn->connection().path() == conIdPath.at(1)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
            && aConn->serviceName() == conIdPath.at(0)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
            QList <QDBusObjectPath> devs = aConn->devices();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
            QNetworkManagerInterfaceDevice ifaceDevice(devs[0].path()); //just take the first one
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
            return ifaceDevice.networkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   709
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   710
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
    //try guessing
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   713
    QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   714
    foreach (const QDBusObjectPath &path, iface->getDevices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   715
        devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   716
        if(devIface->deviceType() == type ) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
            if(devIface->state() ==  NM_DEVICE_STATE_DISCONNECTED) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
                return devIface->networkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
    return QNetworkInterface();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
quint64 QNmWifiEngine::receivedDataForId(const QString &id) const
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
    if(configurationInterface.count() > 1)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
        return 0;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   729
    quint64 result = 0;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
    QString devFile;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
    devFile =  configurationInterface.value(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   733
    QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
    if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
        QTextStream in(&rx);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
        in >> result;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
        rx.close();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   739
    return result;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   742
quint64 QNmWifiEngine::sentDataForId(const QString &id) const
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
    if(configurationInterface.count() > 1)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   745
        return 0;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
    quint64 result = 0;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   747
    QString devFile;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
    devFile =  configurationInterface.value(id);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
    QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
    if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
        QTextStream in(&tx);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   753
        in >> result;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
        tx.close();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
    return result;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
void QNmWifiEngine::newConnection(QDBusObjectPath /*path*/)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   760
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   761
    requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   762
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   763
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
void QNmWifiEngine::settingsConnectionRemoved(const QString &/*path*/)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
    requestUpdate();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   767
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   768
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
void QNmWifiEngine::slotActivationFinished(QDBusPendingCallWatcher *openCall)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
    QDBusPendingReply<QDBusObjectPath> reply = *openCall;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
    if (reply.isError()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
        qWarning() <<"Error" <<  reply.error().name() << reply.error().message()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
                <<activatingConnectionPath;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
        emit connectionError(activatingConnectionPath, ConnectError);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   777
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
void QNmWifiEngine::scanForAccessPoints()
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
    availableAccessPoints.clear();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
    QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   784
    QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
    QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   786
    foreach (const QDBusObjectPath &path, iface->getDevices()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   787
        devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   788
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   789
        if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   790
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   791
            devWirelessIface.reset(new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   792
            ////////////// AccessPoints
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   793
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   794
            foreach (const QDBusObjectPath &path, devWirelessIface->getAccessPoints()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   795
                accessPointIface.reset(new QNetworkManagerInterfaceAccessPoint(path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   796
                const QString ssid = accessPointIface->ssid();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   797
                availableAccessPoints.insert(ssid, path);
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   798
            }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   800
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   801
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   802
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   803
QString QNmWifiEngine::deviceConnectionPath(const QString &mac)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   804
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   805
    QString newMac = mac.toLower();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   806
    newMac.replace(QLatin1Char(':'), QLatin1Char('_'));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   807
    //device object path might not contain just mac address
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   808
    //might contain extra numbers on the end. thanks HAL
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   809
    foreach (const QString &device, devicePaths) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   810
        if(device.contains(newMac)) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   811
            newMac = device;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   812
            break;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   813
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   814
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   815
    return newMac;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   816
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   817
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   818
QStringList QNmWifiEngine::getConnectionPathForId(const QString &uuid)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   819
{
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   820
    QStringList connectionServices;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   821
    connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   822
    connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   823
    QScopedPointer<QNetworkManagerSettings> settingsiface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   824
    foreach (const QString &service, connectionServices) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   825
        settingsiface.reset(new QNetworkManagerSettings(service));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   826
        QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   827
        foreach (const QDBusObjectPath &path, settingsiface->listConnections()) {
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   828
            sysIface.reset(new QNetworkManagerSettingsConnection(service, path.path()));
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   829
            if(sysIface->getUuid() == uuid)
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   830
                return QStringList() << service << sysIface->connectionInterface()->path();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   831
        }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   832
    }
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   833
    return QStringList();
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   834
}
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   835
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   836
#include "moc_qnmwifiengine_unix_p.cpp"
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   837
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   838
QTM_END_NAMESPACE
cd2778e5acfe Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   839