qtmobility/src/bearer/qnetworkmanagerservice_p.h
branchRCL_3
changeset 10 cd2778e5acfe
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QNETWORKMANAGERSERVICE_H
       
    43 #define QNETWORKMANAGERSERVICE_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 
       
    55 #include <qmobilityglobal.h>
       
    56 
       
    57 #include <QtDBus/QtDBus>
       
    58 #include <QtDBus/QDBusConnection>
       
    59 #include <QtDBus/QDBusError>
       
    60 #include <QtDBus/QDBusInterface>
       
    61 #include <QtDBus/QDBusMessage>
       
    62 #include <QtDBus/QDBusReply>
       
    63 #include <QNetworkInterface>
       
    64 
       
    65 
       
    66 #include <QtDBus/QDBusPendingCallWatcher>
       
    67 #include <QtDBus/QDBusObjectPath>
       
    68 #include <QtDBus/QDBusContext>
       
    69 #include <QMap>
       
    70 #include "qnmdbushelper_p.h"
       
    71 
       
    72 #ifndef NETWORK_MANAGER_H
       
    73 typedef enum NMDeviceType
       
    74 {
       
    75     DEVICE_TYPE_UNKNOWN = 0,
       
    76     DEVICE_TYPE_802_3_ETHERNET,
       
    77     DEVICE_TYPE_802_11_WIRELESS,
       
    78     DEVICE_TYPE_GSM,
       
    79     DEVICE_TYPE_CDMA
       
    80 } NMDeviceType;
       
    81 
       
    82 typedef enum
       
    83 {
       
    84     NM_DEVICE_STATE_UNKNOWN = 0,
       
    85     NM_DEVICE_STATE_UNMANAGED,
       
    86     NM_DEVICE_STATE_UNAVAILABLE,
       
    87     NM_DEVICE_STATE_DISCONNECTED,
       
    88     NM_DEVICE_STATE_PREPARE,
       
    89     NM_DEVICE_STATE_CONFIG,
       
    90     NM_DEVICE_STATE_NEED_AUTH,
       
    91     NM_DEVICE_STATE_IP_CONFIG,
       
    92     NM_DEVICE_STATE_ACTIVATED,
       
    93     NM_DEVICE_STATE_FAILED
       
    94 } NMDeviceState;
       
    95 
       
    96 #define	NM_DBUS_SERVICE			"org.freedesktop.NetworkManager"
       
    97 
       
    98 #define	NM_DBUS_PATH				        "/org/freedesktop/NetworkManager"
       
    99 #define	NM_DBUS_INTERFACE			        "org.freedesktop.NetworkManager"
       
   100 #define	NM_DBUS_INTERFACE_DEVICE	        NM_DBUS_INTERFACE ".Device"
       
   101 #define NM_DBUS_INTERFACE_DEVICE_WIRED      NM_DBUS_INTERFACE_DEVICE ".Wired"
       
   102 #define NM_DBUS_INTERFACE_DEVICE_WIRELESS   NM_DBUS_INTERFACE_DEVICE ".Wireless"
       
   103 #define NM_DBUS_PATH_ACCESS_POINT           NM_DBUS_PATH "/AccessPoint"
       
   104 #define NM_DBUS_INTERFACE_ACCESS_POINT      NM_DBUS_INTERFACE ".AccessPoint"
       
   105 
       
   106 #define NM_DBUS_PATH_SETTINGS             "/org/freedesktop/NetworkManagerSettings"
       
   107 
       
   108 #define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection"
       
   109 #define NM_DBUS_IFACE_SETTINGS            "org.freedesktop.NetworkManagerSettings"
       
   110 #define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
       
   111 #define NM_DBUS_INTERFACE_IP4_CONFIG        NM_DBUS_INTERFACE ".IP4Config"
       
   112 
       
   113 #define NM_DBUS_SERVICE_USER_SETTINGS     "org.freedesktop.NetworkManagerUserSettings"
       
   114 #define NM_DBUS_SERVICE_SYSTEM_SETTINGS   "org.freedesktop.NetworkManagerSystemSettings"
       
   115 
       
   116 #define NM_802_11_AP_FLAGS_NONE				0x00000000
       
   117 #define NM_802_11_AP_FLAGS_PRIVACY			0x00000001
       
   118 #endif
       
   119 
       
   120 QTM_BEGIN_NAMESPACE
       
   121 typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
       
   122 typedef QList<quint32> ServerThing;
       
   123 QTM_END_NAMESPACE
       
   124 
       
   125 
       
   126 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsMap))
       
   127 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(ServerThing))
       
   128 
       
   129 QTM_BEGIN_NAMESPACE
       
   130 
       
   131 class QNetworkManagerInterfacePrivate;
       
   132 class QNetworkManagerInterface : public QObject
       
   133 {
       
   134     Q_OBJECT
       
   135     
       
   136 public:
       
   137     
       
   138     QNetworkManagerInterface(QObject *parent = 0);
       
   139     ~QNetworkManagerInterface();
       
   140     
       
   141     QList <QDBusObjectPath> getDevices() const;
       
   142     void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject);
       
   143     void deactivateConnection(QDBusObjectPath connectionPath) const;
       
   144     
       
   145     QDBusObjectPath path() const;
       
   146     QDBusInterface *connectionInterface() const;
       
   147     
       
   148     bool wirelessEnabled() const;
       
   149     bool wirelessHardwareEnabled() const;
       
   150     QList <QDBusObjectPath> activeConnections() const;
       
   151     quint32 state();
       
   152     bool setConnections();
       
   153     bool isValid();
       
   154     
       
   155 Q_SIGNALS:
       
   156     void deviceAdded(QDBusObjectPath);
       
   157     void deviceRemoved(QDBusObjectPath);
       
   158     void propertiesChanged( const QString &, QMap<QString,QVariant>);
       
   159     void stateChanged(const QString&, quint32);
       
   160     void activationFinished(QDBusPendingCallWatcher*);
       
   161 
       
   162 private Q_SLOTS:
       
   163 private:
       
   164     QNetworkManagerInterfacePrivate *d;
       
   165     QNmDBusHelper *nmDBusHelper;
       
   166 };
       
   167 
       
   168 class QNetworkManagerInterfaceAccessPointPrivate;
       
   169 class QNetworkManagerInterfaceAccessPoint : public QObject
       
   170 {
       
   171     Q_OBJECT
       
   172     
       
   173 public:
       
   174     
       
   175     enum DeviceState {
       
   176         Unknown = 0,
       
   177         Unmanaged,
       
   178         Unavailable,
       
   179         Disconnected,
       
   180         Prepare,
       
   181         Config,
       
   182         NeedAuthentication,
       
   183         IpConfig,
       
   184         Activated,
       
   185         Failed
       
   186     };
       
   187     
       
   188     enum ApFlag {
       
   189         ApNone = 0x0,
       
   190         Privacy = 0x1
       
   191     };
       
   192     
       
   193     Q_DECLARE_FLAGS(ApFlags, ApFlag);
       
   194     
       
   195     enum ApSecurityFlag {
       
   196         ApSecurityNone = 0x0,
       
   197         PairWep40 = 0x1,
       
   198         PairWep104 = 0x2,
       
   199         PairTkip = 0x4,
       
   200         PairCcmp = 0x8,
       
   201         GroupWep40 = 0x10,
       
   202         GroupWep104 = 0x20,
       
   203         GroupTkip = 0x40,
       
   204         GroupCcmp = 0x80,
       
   205         KeyPsk = 0x100,
       
   206         Key8021x = 0x200
       
   207     };
       
   208     
       
   209     Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag);
       
   210     
       
   211     explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
       
   212     ~QNetworkManagerInterfaceAccessPoint();
       
   213 
       
   214     QDBusInterface *connectionInterface() const;
       
   215 
       
   216     quint32 flags() const;
       
   217     quint32 wpaFlags() const;
       
   218     quint32 rsnFlags() const;
       
   219     QString ssid() const;
       
   220     quint32 frequency() const;
       
   221     QString hwAddress() const;
       
   222     quint32 mode() const;
       
   223     quint32 maxBitrate() const;
       
   224     quint32 strength() const;
       
   225     bool setConnections();
       
   226     bool isValid();
       
   227     
       
   228 Q_SIGNALS:
       
   229     void propertiesChanged(QMap <QString,QVariant>);
       
   230     void propertiesChanged( const QString &, QMap<QString,QVariant>);
       
   231 private:
       
   232     QNetworkManagerInterfaceAccessPointPrivate *d;
       
   233     QNmDBusHelper *nmDBusHelper;
       
   234 
       
   235 };
       
   236 
       
   237 class QNetworkManagerInterfaceDevicePrivate;
       
   238 class QNetworkManagerInterfaceDevice : public QObject
       
   239 {
       
   240     Q_OBJECT
       
   241     
       
   242 public:
       
   243     
       
   244     explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
       
   245     ~QNetworkManagerInterfaceDevice();
       
   246     
       
   247     QString udi() const;
       
   248     QNetworkInterface networkInterface() const;
       
   249     QDBusInterface *connectionInterface() const;
       
   250     quint32 ip4Address() const;
       
   251     quint32 state() const;
       
   252     quint32 deviceType() const;
       
   253     
       
   254     QDBusObjectPath ip4config() const;
       
   255     bool setConnections();
       
   256     bool isValid();
       
   257     
       
   258 Q_SIGNALS:
       
   259     void stateChanged(const QString &, quint32);
       
   260 
       
   261 private:
       
   262     QNetworkManagerInterfaceDevicePrivate *d;
       
   263     QNmDBusHelper *nmDBusHelper;
       
   264 };
       
   265 
       
   266 class QNetworkManagerInterfaceDeviceWiredPrivate;
       
   267 class QNetworkManagerInterfaceDeviceWired : public QObject
       
   268 {
       
   269     Q_OBJECT
       
   270     
       
   271 public:
       
   272     
       
   273     explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
       
   274                                                  QObject *parent = 0);
       
   275     ~QNetworkManagerInterfaceDeviceWired();
       
   276     
       
   277     QDBusInterface  *connectionInterface() const;
       
   278     QString hwAddress() const;
       
   279     quint32 speed() const;
       
   280     bool carrier() const;
       
   281     bool setConnections();
       
   282     bool isValid();
       
   283     
       
   284 Q_SIGNALS:
       
   285     void propertiesChanged( const QString &, QMap<QString,QVariant>);
       
   286 private:
       
   287     QNetworkManagerInterfaceDeviceWiredPrivate *d;
       
   288     QNmDBusHelper *nmDBusHelper;
       
   289 };
       
   290 
       
   291 class QNetworkManagerInterfaceDeviceWirelessPrivate;
       
   292 class QNetworkManagerInterfaceDeviceWireless : public QObject
       
   293 {
       
   294     Q_OBJECT
       
   295     
       
   296 public:
       
   297     
       
   298     enum DeviceCapability {
       
   299         None = 0x0,
       
   300         Wep40 = 0x1,
       
   301         Wep104 = 0x2,
       
   302         Tkip = 0x4,
       
   303         Ccmp = 0x8,
       
   304         Wpa = 0x10,
       
   305         Rsn = 0x20
       
   306        };
       
   307     
       
   308     explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
       
   309                                                     QObject *parent = 0);
       
   310     ~QNetworkManagerInterfaceDeviceWireless();
       
   311     
       
   312     QDBusObjectPath path() const;
       
   313     QList <QDBusObjectPath> getAccessPoints();
       
   314     QDBusInterface *connectionInterface() const;
       
   315 
       
   316     QString hwAddress() const;
       
   317     quint32 mode() const;
       
   318     quint32 bitrate() const;
       
   319     QDBusObjectPath activeAccessPoint() const;
       
   320     quint32 wirelessCapabilities() const;
       
   321     bool setConnections();
       
   322     bool isValid();
       
   323     
       
   324 Q_SIGNALS:
       
   325     void propertiesChanged( const QString &, QMap<QString,QVariant>);
       
   326     void accessPointAdded(const QString &,QDBusObjectPath);
       
   327     void accessPointRemoved(const QString &,QDBusObjectPath);
       
   328 private:
       
   329     QNetworkManagerInterfaceDeviceWirelessPrivate *d;
       
   330     QNmDBusHelper *nmDBusHelper;
       
   331 };
       
   332 
       
   333 class QNetworkManagerSettingsPrivate;
       
   334 class QNetworkManagerSettings : public QObject
       
   335 {
       
   336     Q_OBJECT
       
   337     
       
   338 public:
       
   339     
       
   340     explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
       
   341     ~QNetworkManagerSettings();
       
   342     
       
   343     QDBusInterface  *connectionInterface() const;
       
   344     QList <QDBusObjectPath> listConnections();
       
   345     bool setConnections();
       
   346     bool isValid();
       
   347 
       
   348 Q_SIGNALS:
       
   349     void newConnection(QDBusObjectPath);
       
   350 private:
       
   351     QNetworkManagerSettingsPrivate *d;
       
   352 };
       
   353 
       
   354 class QNetworkManagerSettingsConnectionPrivate;
       
   355 class QNetworkManagerSettingsConnection : public QObject
       
   356 {
       
   357     Q_OBJECT
       
   358     
       
   359 public:
       
   360     
       
   361     QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0);
       
   362     ~QNetworkManagerSettingsConnection();
       
   363     
       
   364     QDBusInterface  *connectionInterface() const;
       
   365     QNmSettingsMap getSettings();
       
   366     bool setConnections();
       
   367     NMDeviceType getType();
       
   368     bool isAutoConnect();
       
   369     quint64 getTimestamp();
       
   370     QString getId();
       
   371     QString getUuid();
       
   372     QString getSsid();
       
   373     QString getMacAddress();
       
   374     QStringList getSeenBssids();
       
   375     bool isValid();
       
   376 
       
   377 Q_SIGNALS:
       
   378     
       
   379     void updated(QMap< QString, QMap<QString,QVariant> > s);
       
   380     void removed(const QString &);
       
   381 
       
   382 private:
       
   383     QNmDBusHelper *nmDBusHelper;
       
   384     QNetworkManagerSettingsConnectionPrivate *d;
       
   385 };
       
   386 
       
   387 class QNetworkManagerConnectionActivePrivate;
       
   388 class QNetworkManagerConnectionActive : public QObject
       
   389 {
       
   390     Q_OBJECT
       
   391     
       
   392 public:
       
   393     
       
   394     enum ActiveConnectionState {
       
   395         Unknown = 0,
       
   396         Activating = 1,
       
   397         Activated = 2
       
   398        };
       
   399     
       
   400     explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
       
   401     ~ QNetworkManagerConnectionActive();
       
   402     
       
   403     QDBusInterface  *connectionInterface() const;
       
   404     QString serviceName() const;
       
   405     QDBusObjectPath connection() const;
       
   406     QDBusObjectPath specificObject() const;
       
   407     QList<QDBusObjectPath> devices() const;
       
   408     quint32 state() const;
       
   409     bool defaultRoute() const;
       
   410     bool setConnections();
       
   411     bool isValid();
       
   412 
       
   413     
       
   414 Q_SIGNALS:
       
   415     void propertiesChanged(QList<QDBusObjectPath>);
       
   416     void propertiesChanged( const QString &, QMap<QString,QVariant>);
       
   417 private:
       
   418     QNetworkManagerConnectionActivePrivate *d;
       
   419     QNmDBusHelper *nmDBusHelper;
       
   420 };
       
   421 
       
   422 class QNetworkManagerIp4ConfigPrivate;
       
   423 class QNetworkManagerIp4Config : public QObject
       
   424 {
       
   425     Q_OBJECT
       
   426     
       
   427 public:
       
   428     explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
       
   429 	~QNetworkManagerIp4Config();
       
   430 
       
   431     QStringList domains() const;
       
   432     bool isValid();
       
   433 
       
   434  private:
       
   435 	QNetworkManagerIp4ConfigPrivate *d;    
       
   436 };
       
   437 QTM_END_NAMESPACE
       
   438 
       
   439 
       
   440 #endif //QNETWORKMANAGERSERVICE_H