|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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_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 |
|
59 |
|
60 QNmDBusHelper::QNmDBusHelper(QObject * parent) |
|
61 : QObject(parent) |
|
62 { |
|
63 } |
|
64 |
|
65 QNmDBusHelper::~QNmDBusHelper() |
|
66 { |
|
67 } |
|
68 |
|
69 void QNmDBusHelper::deviceStateChanged(quint32 state) |
|
70 { |
|
71 QDBusMessage msg = this->message(); |
|
72 if(state == NM_DEVICE_STATE_ACTIVATED |
|
73 || state == NM_DEVICE_STATE_DISCONNECTED |
|
74 || state == NM_DEVICE_STATE_UNAVAILABLE |
|
75 || state == NM_DEVICE_STATE_FAILED) { |
|
76 emit pathForStateChanged(msg.path(), state); |
|
77 } |
|
78 } |
|
79 |
|
80 void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path) |
|
81 { |
|
82 if(path.path().length() > 2) { |
|
83 QDBusMessage msg = this->message(); |
|
84 emit pathForAccessPointAdded(msg.path(), path); |
|
85 } |
|
86 } |
|
87 |
|
88 void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path) |
|
89 { |
|
90 if(path.path().length() > 2) { |
|
91 QDBusMessage msg = this->message(); |
|
92 emit pathForAccessPointRemoved(msg.path(), path); |
|
93 } |
|
94 } |
|
95 |
|
96 void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map) |
|
97 { |
|
98 QDBusMessage msg = this->message(); |
|
99 QMapIterator<QString, QVariant> i(map); |
|
100 while (i.hasNext()) { |
|
101 i.next(); |
|
102 if( i.key() == "State") { //state only applies to device interfaces |
|
103 quint32 state = i.value().toUInt(); |
|
104 if( state == NM_DEVICE_STATE_ACTIVATED |
|
105 || state == NM_DEVICE_STATE_DISCONNECTED |
|
106 || state == NM_DEVICE_STATE_UNAVAILABLE |
|
107 || state == NM_DEVICE_STATE_FAILED) { |
|
108 emit pathForPropertiesChanged( msg.path(), map); |
|
109 } |
|
110 } else if( i.key() == "ActiveAccessPoint") { |
|
111 // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path(); |
|
112 // } else if( i.key() == "Strength") |
|
113 // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt(); |
|
114 // else |
|
115 // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value(); |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 void QNmDBusHelper::slotSettingsRemoved() |
|
121 { |
|
122 QDBusMessage msg = this->message(); |
|
123 emit pathForSettingsRemoved(msg.path()); |
|
124 } |
|
125 |
|
126 #include "moc_qnmdbushelper_p.cpp" |
|
127 QTM_END_NAMESPACE |