src/systeminfo/qnmdbushelper.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     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 // this class is for helping qdbus get stuff
       
    43 
       
    44 #include "qnmdbushelper_p.h"
       
    45 
       
    46 #if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC)
       
    47 #include "qnetworkmanagerservice_linux_p.h" 
       
    48 
       
    49 #include <QDBusError>
       
    50 #include <QDBusInterface>
       
    51 #include <QDBusMessage>
       
    52 #include <QDBusReply>
       
    53 #endif
       
    54 
       
    55 #include <QDebug>
       
    56 
       
    57 QTM_BEGIN_NAMESPACE
       
    58 QNmDBusHelper::QNmDBusHelper(QObject * parent)
       
    59         : QObject(parent)
       
    60 {
       
    61 }
       
    62 
       
    63 QNmDBusHelper::~QNmDBusHelper()
       
    64 {
       
    65 }
       
    66 
       
    67 void QNmDBusHelper::deviceStateChanged(quint32 state)
       
    68  {
       
    69     QDBusMessage msg = this->message();
       
    70     if(state == NM_DEVICE_STATE_ACTIVATED
       
    71        || state == NM_DEVICE_STATE_DISCONNECTED
       
    72        || state == NM_DEVICE_STATE_UNAVAILABLE
       
    73        || state == NM_DEVICE_STATE_FAILED) {
       
    74         emit pathForStateChanged(msg.path(), state);
       
    75     }
       
    76  }
       
    77 
       
    78 void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
       
    79 {
       
    80     if(path.path().length() > 2) {
       
    81         QDBusMessage msg = this->message();
       
    82         emit pathForAccessPointAdded(msg.path(), path);
       
    83     }
       
    84 }
       
    85 
       
    86 void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
       
    87 {
       
    88     if(path.path().length() > 2) {
       
    89         QDBusMessage msg = this->message();
       
    90         emit pathForAccessPointRemoved(msg.path(), path);
       
    91     }
       
    92 }
       
    93 
       
    94 void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
       
    95 {
       
    96     QDBusMessage msg = this->message();
       
    97     QMapIterator<QString, QVariant> i(map);
       
    98     while (i.hasNext()) {
       
    99         i.next();
       
   100         if( i.key() == "State") { //state only applies to device interfaces
       
   101             quint32 state = i.value().toUInt();
       
   102             if( state == NM_DEVICE_STATE_ACTIVATED
       
   103                 || state == NM_DEVICE_STATE_DISCONNECTED
       
   104                 || state == NM_DEVICE_STATE_UNAVAILABLE
       
   105                 || state == NM_DEVICE_STATE_FAILED) {
       
   106                 emit  pathForPropertiesChanged( msg.path(), map);
       
   107             }
       
   108         } else if( i.key() == "ActiveAccessPoint") {
       
   109             //            qWarning()  << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path();
       
   110             //      } else if( i.key() == "Strength")
       
   111             //            qWarning()  << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt();
       
   112             //   else
       
   113             //            qWarning()  << __PRETTY_FUNCTION__ << i.key() << ": " << i.value();
       
   114         }
       
   115     }
       
   116 }
       
   117 
       
   118 void QNmDBusHelper::slotSettingsRemoved()
       
   119 {
       
   120     QDBusMessage msg = this->message();
       
   121     emit pathForSettingsRemoved(msg.path());
       
   122 }
       
   123 
       
   124 #include "moc_qnmdbushelper_p.cpp"
       
   125 QTM_END_NAMESPACE