Merge lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac into lp:ubuntu-system-settings
- show-ip-and-mac
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ken VanDine | ||||
Approved revision: | 954 | ||||
Merged at revision: | 991 | ||||
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac | ||||
Merge into: | lp:ubuntu-system-settings | ||||
Diff against target: |
549 lines (+393/-8) 10 files modified
plugins/about/CMakeLists.txt (+11/-2) plugins/about/PageComponent.qml (+19/-0) plugins/about/networkabout.cpp (+95/-0) plugins/about/networkabout.h (+57/-0) plugins/about/plugin.cpp (+3/-1) plugins/wifi/AccessPoint.qml (+12/-0) plugins/wifi/CMakeLists.txt (+1/-0) plugins/wifi/NetworkDetailsBrief.qml (+79/-0) plugins/wifi/wifidbushelper.cpp (+104/-4) plugins/wifi/wifidbushelper.h (+12/-1) |
||||
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Ken VanDine | Approve | ||
Review via email:
|
Commit message
[about/wifi] adding mac addresses for bt and wifi, and ip for wifi
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:949
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:951
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sebastien Bacher (seb128) wrote : | # |
Thanks, I didn't do a real review but the listitem need to have their text set as translatable (e.g using i18.tr() for the strings)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sebastien Bacher (seb128) wrote : | # |
could you also link to the corresponding bug so it gets closed on upload?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:953
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ken VanDine (ken-vandine) wrote : | # |
The title on the NetworkDetailsBrief page should be the wireless network name according to the design.
- 954. By Jonas G. Drange
-
translatable strings, naming panel network name
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ken VanDine (ken-vandine) wrote : | # |
Looks good, thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:954
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:954
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sebastien Bacher (seb128) wrote : | # |
Works fine, thanks
Preview Diff
1 | === modified file 'plugins/about/CMakeLists.txt' |
2 | --- plugins/about/CMakeLists.txt 2014-07-22 20:21:24 +0000 |
3 | +++ plugins/about/CMakeLists.txt 2014-08-29 18:12:46 +0000 |
4 | @@ -18,8 +18,17 @@ |
5 | ) |
6 | |
7 | add_library(UbuntuStorageAboutPanel MODULE |
8 | -plugin.cpp storageabout.cpp click.cpp plugin.h storageabout.h click.h |
9 | -${QML_SOURCES}) # So they show up in Qt designer. |
10 | + plugin.cpp |
11 | + storageabout.cpp |
12 | + click.cpp |
13 | + networkabout.cpp |
14 | + plugin.h |
15 | + storageabout.h |
16 | + click.h |
17 | + networkabout.h |
18 | + ${QML_SOURCES} # So they show up in Qt designer. |
19 | +) |
20 | + |
21 | qt5_use_modules(UbuntuStorageAboutPanel Qml Quick DBus) |
22 | target_link_libraries(UbuntuStorageAboutPanel |
23 | ${ANDR_PROP_LDFLAGS} ${GLIB_LDFLAGS} ${GIO_LDFLAGS}) |
24 | |
25 | === modified file 'plugins/about/PageComponent.qml' |
26 | --- plugins/about/PageComponent.qml 2014-08-06 13:54:52 +0000 |
27 | +++ plugins/about/PageComponent.qml 2014-08-29 18:12:46 +0000 |
28 | @@ -55,6 +55,10 @@ |
29 | modemPath: manager.modems[0] |
30 | } |
31 | |
32 | + NetworkAbout { |
33 | + id: network |
34 | + } |
35 | + |
36 | Flickable { |
37 | id: scrollWidget |
38 | anchors.fill: parent |
39 | @@ -118,6 +122,21 @@ |
40 | visible: imeiNumber |
41 | } |
42 | |
43 | + ListItem.SingleValue { |
44 | + text: i18n.tr("Wi-Fi address") |
45 | + value: network.networkMacAddresses[0] |
46 | + visible: network.networkMacAddresses.length > 0 |
47 | + showDivider: bthwaddr.visible |
48 | + } |
49 | + |
50 | + ListItem.SingleValue { |
51 | + id: bthwaddr |
52 | + text: i18n.tr("Bluetooth address") |
53 | + value: network.bluetoothMacAddress |
54 | + visible: network.bluetoothMacAddress |
55 | + showDivider: false |
56 | + } |
57 | + |
58 | ListItem.Divider {} |
59 | |
60 | ListItem.Standard { |
61 | |
62 | === added file 'plugins/about/networkabout.cpp' |
63 | --- plugins/about/networkabout.cpp 1970-01-01 00:00:00 +0000 |
64 | +++ plugins/about/networkabout.cpp 2014-08-29 18:12:46 +0000 |
65 | @@ -0,0 +1,95 @@ |
66 | +/* |
67 | + * This file is part of system-settings |
68 | + * |
69 | + * Copyright (C) 2014 Canonical Ltd. |
70 | + * |
71 | + * Contact: Jonas G. Drange <jonas.drange@canonical.com> |
72 | + * |
73 | + * This program is free software: you can redistribute it and/or modify it |
74 | + * under the terms of the GNU General Public License version 3, as published |
75 | + * by the Free Software Foundation. |
76 | + * |
77 | + * This program is distributed in the hope that it will be useful, but |
78 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
79 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
80 | + * PURPOSE. See the GNU General Public License for more details. |
81 | + * |
82 | + * You should have received a copy of the GNU General Public License along |
83 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
84 | + */ |
85 | + |
86 | +#include <QDebug> |
87 | +#include <QDBusReply> |
88 | + |
89 | +#include "networkabout.h" |
90 | + |
91 | +NetworkAbout::NetworkAbout(QObject *parent) |
92 | + : QObject(parent), |
93 | + m_systemBusConnection(QDBusConnection::systemBus()) |
94 | +{ |
95 | + |
96 | + setupNetworkMacAddresses(); |
97 | + setupBluetoothMacAddress(); |
98 | +} |
99 | + |
100 | +void NetworkAbout::setupNetworkMacAddresses() |
101 | +{ |
102 | + QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces(); |
103 | + int count = ifaces.count(); |
104 | + |
105 | + QString str = QString(); |
106 | + for(int i=0;i<count;i++) |
107 | + { |
108 | + QNetworkInterface iface = ifaces.at(i); |
109 | + str = iface.hardwareAddress(); |
110 | + // add interfaces that are not loopback |
111 | + if (!iface.flags().testFlag(QNetworkInterface::IsLoopBack)) { |
112 | + m_networkMacAddresses << str; |
113 | + } |
114 | + } |
115 | +} |
116 | + |
117 | +void NetworkAbout::setupBluetoothMacAddress() |
118 | +{ |
119 | + QDBusInterface bluezManagerInterface ( |
120 | + "org.bluez", |
121 | + "/", |
122 | + "org.bluez.Manager", |
123 | + m_systemBusConnection, |
124 | + this); |
125 | + |
126 | + if (!bluezManagerInterface.isValid()) { |
127 | + return; |
128 | + } |
129 | + |
130 | + QDBusReply<QDBusObjectPath> defaultDevice = bluezManagerInterface.call("DefaultAdapter"); |
131 | + |
132 | + if (!defaultDevice.isValid()) { |
133 | + return; |
134 | + } |
135 | + |
136 | + QDBusInterface adapterInterface ( |
137 | + "org.bluez", |
138 | + defaultDevice.value().path(), |
139 | + "org.bluez.Adapter", |
140 | + m_systemBusConnection, |
141 | + this); |
142 | + |
143 | + QDBusReply<QVariantMap> props = adapterInterface.call("GetProperties"); |
144 | + |
145 | + if (!props.isValid()) { |
146 | + return; |
147 | + } |
148 | + |
149 | + m_bluetoothMacAddress = props.value()["Address"].toString(); |
150 | +} |
151 | + |
152 | +QStringList NetworkAbout::networkMacAddresses() |
153 | +{ |
154 | + return m_networkMacAddresses; |
155 | +} |
156 | + |
157 | +QString NetworkAbout::bluetoothMacAddress() |
158 | +{ |
159 | + return m_bluetoothMacAddress; |
160 | +} |
161 | |
162 | === added file 'plugins/about/networkabout.h' |
163 | --- plugins/about/networkabout.h 1970-01-01 00:00:00 +0000 |
164 | +++ plugins/about/networkabout.h 2014-08-29 18:12:46 +0000 |
165 | @@ -0,0 +1,57 @@ |
166 | +/* |
167 | + * This file is part of system-settings |
168 | + * |
169 | + * Copyright (C) 2014 Canonical Ltd. |
170 | + * |
171 | + * Contact: Jonas G. Drange <jonas.drange@canonical.com> |
172 | + * |
173 | + * This program is free software: you can redistribute it and/or modify it |
174 | + * under the terms of the GNU General Public License version 3, as published |
175 | + * by the Free Software Foundation. |
176 | + * |
177 | + * This program is distributed in the hope that it will be useful, but |
178 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
179 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
180 | + * PURPOSE. See the GNU General Public License for more details. |
181 | + * |
182 | + * You should have received a copy of the GNU General Public License along |
183 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
184 | + */ |
185 | + |
186 | +#ifndef NETWORKABOUT_H |
187 | +#define NETWORKABOUT_H |
188 | + |
189 | +#include <QObject> |
190 | +#include <QStringList> |
191 | +#include <QtNetwork> |
192 | +#include <QtDBus/QDBusInterface> |
193 | + |
194 | + |
195 | +class NetworkAbout : public QObject |
196 | +{ |
197 | + Q_OBJECT |
198 | + Q_PROPERTY( QStringList networkMacAddresses |
199 | + READ networkMacAddresses |
200 | + NOTIFY networkMacAddressesChanged ) |
201 | + Q_PROPERTY( QString bluetoothMacAddress |
202 | + READ bluetoothMacAddress |
203 | + NOTIFY bluetoothMacAddressChanged ) |
204 | + |
205 | +public: |
206 | + explicit NetworkAbout (QObject *parent = 0); |
207 | + QStringList networkMacAddresses(); |
208 | + QString bluetoothMacAddress(); |
209 | + |
210 | +Q_SIGNALS: |
211 | + void networkMacAddressesChanged(QStringList addresses); |
212 | + void bluetoothMacAddressChanged(QString addresses); |
213 | + |
214 | +private: |
215 | + QStringList m_networkMacAddresses; |
216 | + QString m_bluetoothMacAddress; |
217 | + void setupNetworkMacAddresses(); |
218 | + void setupBluetoothMacAddress(); |
219 | + QDBusConnection m_systemBusConnection; |
220 | +}; |
221 | + |
222 | +#endif // NETWORKABOUT_H |
223 | |
224 | === modified file 'plugins/about/plugin.cpp' |
225 | --- plugins/about/plugin.cpp 2014-07-23 13:37:06 +0000 |
226 | +++ plugins/about/plugin.cpp 2014-08-29 18:12:46 +0000 |
227 | @@ -23,14 +23,16 @@ |
228 | #include <QtQml/QQmlContext> |
229 | #include "click.h" |
230 | #include "storageabout.h" |
231 | +#include "networkabout.h" |
232 | |
233 | |
234 | void BackendPlugin::registerTypes(const char *uri) |
235 | { |
236 | Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.StorageAbout")); |
237 | - |
238 | + |
239 | qRegisterMetaType<ClickModel::Roles>(); |
240 | qmlRegisterType<ClickModel>(uri, 1, 0, "ClickRoles"); |
241 | + qmlRegisterType<NetworkAbout>(uri, 1, 0, "NetworkAbout"); |
242 | qmlRegisterType<StorageAbout>(uri, 1, 0, "UbuntuStorageAboutPanel"); |
243 | } |
244 | |
245 | |
246 | === modified file 'plugins/wifi/AccessPoint.qml' |
247 | --- plugins/wifi/AccessPoint.qml 2013-11-28 15:09:15 +0000 |
248 | +++ plugins/wifi/AccessPoint.qml 2014-08-29 18:12:46 +0000 |
249 | @@ -34,6 +34,11 @@ |
250 | onCheckedChanged: { |
251 | // Can't rely on binding. Checked is assigned on click. |
252 | checkBoxActive.checked = checked; |
253 | + |
254 | + // if stack has NetworkDetailsBrief, pop it |
255 | + if (pageStack.depth === 3) { |
256 | + pageStack.pop(); |
257 | + } |
258 | } |
259 | |
260 | iconName: { |
261 | @@ -65,4 +70,11 @@ |
262 | accessPoint.activate(); |
263 | } |
264 | } |
265 | + progression: checked |
266 | + onClicked: { |
267 | + if (checked) { |
268 | + pageStack.push(Qt.resolvedUrl("NetworkDetailsBrief.qml"), |
269 | + {networkName : text, accessPoint: accessPoint}) |
270 | + } |
271 | + } |
272 | } |
273 | |
274 | === modified file 'plugins/wifi/CMakeLists.txt' |
275 | --- plugins/wifi/CMakeLists.txt 2014-06-18 14:16:53 +0000 |
276 | +++ plugins/wifi/CMakeLists.txt 2014-08-29 18:12:46 +0000 |
277 | @@ -7,6 +7,7 @@ |
278 | IndicatorBase.qml |
279 | MenuItemFactory.qml |
280 | NetworkDetails.qml |
281 | +NetworkDetailsBrief.qml |
282 | OtherNetwork.qml |
283 | PageComponent.qml |
284 | PreviousNetworks.qml |
285 | |
286 | === added file 'plugins/wifi/NetworkDetailsBrief.qml' |
287 | --- plugins/wifi/NetworkDetailsBrief.qml 1970-01-01 00:00:00 +0000 |
288 | +++ plugins/wifi/NetworkDetailsBrief.qml 2014-08-29 18:12:46 +0000 |
289 | @@ -0,0 +1,79 @@ |
290 | +/* |
291 | + * This file is part of system-settings |
292 | + * |
293 | + * Copyright (C) 2014 Canonical Ltd. |
294 | + * |
295 | + * Contact: Jonas G. Drange <jonas.drange@canonical.com> |
296 | + * |
297 | + * This program is free software: you can redistribute it and/or modify it |
298 | + * under the terms of the GNU General Public License version 3, as published |
299 | + * by the Free Software Foundation. |
300 | + * |
301 | + * This program is distributed in the hope that it will be useful, but |
302 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
303 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
304 | + * PURPOSE. See the GNU General Public License for more details. |
305 | + * |
306 | + * You should have received a copy of the GNU General Public License along |
307 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
308 | + */ |
309 | + |
310 | +import QtQuick 2.0 |
311 | +import QtQuick.Layouts 1.1 |
312 | +import SystemSettings 1.0 |
313 | +import Ubuntu.Components 0.1 |
314 | +import Ubuntu.Components.ListItems 0.1 as ListItem |
315 | +import Ubuntu.SystemSettings.Wifi 1.0 |
316 | + |
317 | +ItemPage { |
318 | + |
319 | + property string networkName |
320 | + property var accessPoint |
321 | + |
322 | + title: networkName |
323 | + |
324 | + Column { |
325 | + |
326 | + anchors.fill: parent |
327 | + |
328 | + ListItem.Divider {} |
329 | + |
330 | + Button { |
331 | + text : i18n.tr("Disconnect") |
332 | + anchors { |
333 | + left: parent.left |
334 | + right: parent.right |
335 | + margins: units.gu(2) |
336 | + } |
337 | + onClicked: { |
338 | + if (DbusHelper.deactivateConnection()) { |
339 | + accessPoint.checked = false; |
340 | + accessPoint.checkedChanged(false) |
341 | + } |
342 | + |
343 | + } |
344 | + } |
345 | + |
346 | + ListItem.Standard { |
347 | + text: i18n.tr("IP address") |
348 | + id: addressItem |
349 | + control: TextField { |
350 | + text: DbusHelper.wifiIp4Address |
351 | + readOnly: true |
352 | + horizontalAlignment: TextInput.AlignRight |
353 | + width: addressItem.width/2 |
354 | + persistentSelection: true |
355 | + font.pixelSize: units.dp(16) |
356 | + font.weight: Font.Light |
357 | + font.family: "Ubuntu" |
358 | + color: "#AAAAAA" |
359 | + maximumLength: 20 |
360 | + focus: true |
361 | + clip: true |
362 | + opacity: 0.9 |
363 | + cursorVisible: false |
364 | + hasClearButton: false |
365 | + } |
366 | + } |
367 | + } |
368 | +} |
369 | |
370 | === modified file 'plugins/wifi/wifidbushelper.cpp' |
371 | --- plugins/wifi/wifidbushelper.cpp 2014-07-23 13:53:48 +0000 |
372 | +++ plugins/wifi/wifidbushelper.cpp 2014-08-29 18:12:46 +0000 |
373 | @@ -23,15 +23,20 @@ |
374 | #include <QtDebug> |
375 | #include <QDBusInterface> |
376 | #include <algorithm> |
377 | +#include <arpa/inet.h> |
378 | |
379 | #include "nm_manager_proxy.h" |
380 | #include "nm_settings_proxy.h" |
381 | #include "nm_settings_connection_proxy.h" |
382 | |
383 | +#define NM_SERVICE "org.freedesktop.NetworkManager" |
384 | +#define NM_PATH "/org/freedesktop/NetworkManager" |
385 | + |
386 | typedef QMap<QString,QVariantMap> ConfigurationData; |
387 | Q_DECLARE_METATYPE(ConfigurationData) |
388 | |
389 | -WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent) |
390 | +WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent), |
391 | + m_systemBusConnection(QDBusConnection::systemBus()) |
392 | { |
393 | qDBusRegisterMetaType<ConfigurationData>(); |
394 | } |
395 | @@ -43,9 +48,9 @@ |
396 | return; |
397 | } |
398 | |
399 | - OrgFreedesktopNetworkManagerInterface mgr("org.freedesktop.NetworkManager", |
400 | - "/org/freedesktop/NetworkManager", |
401 | - QDBusConnection::systemBus()); |
402 | + OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE, |
403 | + NM_PATH, |
404 | + m_systemBusConnection); |
405 | |
406 | QMap<QString, QVariantMap> configuration; |
407 | |
408 | @@ -115,6 +120,53 @@ |
409 | tmp); |
410 | } |
411 | |
412 | +QString WifiDbusHelper::getWifiIpAddress() |
413 | +{ |
414 | + OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE, |
415 | + NM_PATH, |
416 | + m_systemBusConnection); |
417 | + |
418 | + // find the first wlan adapter for now |
419 | + auto reply1 = mgr.GetDevices(); |
420 | + reply1.waitForFinished(); |
421 | + if(!reply1.isValid()) { |
422 | + qWarning() << "Could not get network device: " << reply1.error().message() << "\n"; |
423 | + return QString(); |
424 | + } |
425 | + auto devices = reply1.value(); |
426 | + int ip4addr; |
427 | + |
428 | + QDBusObjectPath dev; |
429 | + for (const auto &d : devices) { |
430 | + QDBusInterface iface("org.freedesktop.NetworkManager", |
431 | + d.path(), |
432 | + "org.freedesktop.NetworkManager.Device", |
433 | + m_systemBusConnection); |
434 | + |
435 | + auto type_v = iface.property("DeviceType"); |
436 | + if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) { |
437 | + ip4addr = iface.property("Ip4Address").toInt(); |
438 | + dev = d; |
439 | + break; |
440 | + } |
441 | + } |
442 | + |
443 | + if (dev.path().isEmpty()) { |
444 | + // didn't find a wifi device |
445 | + return QString(); |
446 | + } |
447 | + |
448 | + if (!ip4addr) { |
449 | + // no ip address |
450 | + return QString(); |
451 | + } |
452 | + |
453 | + |
454 | + struct in_addr ip_addr; |
455 | + ip_addr.s_addr = ip4addr; |
456 | + return QString(inet_ntoa(ip_addr)); |
457 | +} |
458 | + |
459 | struct Network : public QObject |
460 | { |
461 | struct DontCare : public std::exception {}; |
462 | @@ -316,3 +368,51 @@ |
463 | qWarning() << "Error forgetting network: " << reply.error().message() << "\n"; |
464 | } |
465 | } |
466 | + |
467 | +bool WifiDbusHelper::deactivateConnection() { |
468 | + OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE, |
469 | + NM_PATH, |
470 | + m_systemBusConnection); |
471 | + // find the first wlan adapter for now |
472 | + auto reply1 = mgr.GetDevices(); |
473 | + reply1.waitForFinished(); |
474 | + if(!reply1.isValid()) { |
475 | + qWarning() << "deactivateConnection: Could not get network device: " << reply1.error().message() << "\n"; |
476 | + return false; |
477 | + } |
478 | + auto devices = reply1.value(); |
479 | + |
480 | + QDBusObjectPath activeConnection; |
481 | + QDBusObjectPath dev; |
482 | + for (const auto &d : devices) { |
483 | + QDBusInterface iface(NM_SERVICE, |
484 | + d.path(), |
485 | + "org.freedesktop.NetworkManager.Device", |
486 | + m_systemBusConnection); |
487 | + |
488 | + auto type_v = iface.property("DeviceType"); |
489 | + if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) { |
490 | + activeConnection = qvariant_cast<QDBusObjectPath>(iface.property("ActiveConnection")); |
491 | + dev = d; |
492 | + break; |
493 | + } |
494 | + } |
495 | + |
496 | + if (dev.path().isEmpty()) { |
497 | + // didn't find a wifi device |
498 | + return false; |
499 | + } |
500 | + |
501 | + if (activeConnection.path().isEmpty()) { |
502 | + // no active connection |
503 | + return false; |
504 | + } |
505 | + |
506 | + auto reply = mgr.DeactivateConnection(activeConnection); |
507 | + reply.waitForFinished(); |
508 | + if(!reply.isValid()) { |
509 | + qWarning() << "Error deactivating connection: " << reply.error().message() << "\n"; |
510 | + return false; |
511 | + } |
512 | + return true; |
513 | +} |
514 | |
515 | === modified file 'plugins/wifi/wifidbushelper.h' |
516 | --- plugins/wifi/wifidbushelper.h 2014-07-23 13:53:48 +0000 |
517 | +++ plugins/wifi/wifidbushelper.h 2014-08-29 18:12:46 +0000 |
518 | @@ -21,6 +21,7 @@ |
519 | #define WIFI_DBUS_HELPER |
520 | |
521 | #include <QObject> |
522 | +#include <QtDBus> |
523 | |
524 | /** |
525 | * For sending specific dbus messages from QML. |
526 | @@ -28,6 +29,9 @@ |
527 | |
528 | class WifiDbusHelper final : public QObject { |
529 | Q_OBJECT |
530 | + Q_PROPERTY( QString wifiIp4Address |
531 | + READ getWifiIpAddress |
532 | + NOTIFY wifiIp4AddressChanged) |
533 | |
534 | public: |
535 | explicit WifiDbusHelper(QObject *parent = nullptr); |
536 | @@ -36,7 +40,14 @@ |
537 | Q_INVOKABLE void connect(QString ssid, int security, QString password); |
538 | Q_INVOKABLE QList<QStringList> getPreviouslyConnectedWifiNetworks(); |
539 | Q_INVOKABLE void forgetConnection(const QString dbus_path); |
540 | - |
541 | + Q_INVOKABLE bool deactivateConnection(); |
542 | + |
543 | +Q_SIGNALS: |
544 | + void wifiIp4AddressChanged(QString wifiIp4Address); |
545 | + |
546 | +private: |
547 | + QDBusConnection m_systemBusConnection; |
548 | + QString getWifiIpAddress(); |
549 | }; |
550 | |
551 |
PASSED: Continuous integration, rev:947 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- ci/1322/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/4155 jenkins. qa.ubuntu. com/job/ generic- mediumtests- utopic/ 3166 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- utopic- i386-ci/ 514 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- mako/3983 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/5407 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/5407/ artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 12250 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-utopic/ 2588 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/3453 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/3453/ artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- ci/1322/ rebuild
http://