Merge lp:~ken-vandine/ubuntu-system-settings/rtm-lp1391940 into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 939
Merged at revision: 942
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/rtm-lp1391940
Merge into: lp:ubuntu-system-settings/rtm-14.09
Prerequisite: lp:~ken-vandine/ubuntu-system-settings/rtm-lp1336715.check.sync
Diff against target: 163 lines (+23/-46)
4 files modified
plugins/battery/CMakeLists.txt (+2/-2)
plugins/battery/PageComponent.qml (+21/-6)
plugins/battery/battery.cpp (+0/-28)
plugins/battery/battery.h (+0/-10)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm-lp1391940
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
Ubuntu Touch System Settings Pending
Review via email: mp+241608@code.launchpad.net

Commit message

[battery] don't control wifi state with libnm, use the QDBusActionGroup from indicator-network

Description of the change

[battery] don't control wifi state with libnm, use the QDBusActionGroup from indicator-network

To post a comment you must log in.
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

code LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/battery/CMakeLists.txt'
2--- plugins/battery/CMakeLists.txt 2013-10-22 14:44:44 +0000
3+++ plugins/battery/CMakeLists.txt 2014-11-12 19:07:19 +0000
4@@ -7,11 +7,11 @@
5 SleepValues.qml
6 )
7
8-include_directories(${GLIB_INCLUDE_DIRS} ${UPOWER_GLIB_INCLUDE_DIRS} ${LIBNM_GLIB_INCLUDE_DIRS})
9+include_directories(${GLIB_INCLUDE_DIRS} ${UPOWER_GLIB_INCLUDE_DIRS})
10 add_library(UbuntuBatteryPanel MODULE plugin.h battery.h plugin.cpp battery.cpp
11 ${QML_SOURCES})
12 qt5_use_modules(UbuntuBatteryPanel Quick Qml DBus)
13-target_link_libraries(UbuntuBatteryPanel ${GLIB_LDFLAGS} ${UPOWER_GLIB_LDFLAGS} ${LIBNM_GLIB_LDFLAGS})
14+target_link_libraries(UbuntuBatteryPanel ${GLIB_LDFLAGS} ${UPOWER_GLIB_LDFLAGS})
15
16 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Battery)
17 install(TARGETS UbuntuBatteryPanel DESTINATION ${PLUG_DIR})
18
19=== modified file 'plugins/battery/PageComponent.qml'
20--- plugins/battery/PageComponent.qml 2014-11-12 19:07:19 +0000
21+++ plugins/battery/PageComponent.qml 2014-11-12 19:07:19 +0000
22@@ -329,15 +329,30 @@
23 Qt.resolvedUrl("SleepValues.qml"),
24 { title: text, lockOnSuspend: lockOnSuspend })
25 }
26+
27+ QDBusActionGroup {
28+ id: networkActionGroup
29+ busType: 1
30+ busName: "com.canonical.indicator.network"
31+ objectPath: "/com/canonical/indicator/network"
32+ property variant enabled: action("wifi.enable")
33+ Component.onCompleted: start()
34+ }
35+
36 ListItem.Standard {
37 text: i18n.tr("Wi-Fi")
38- control: Switch {
39- id: wifiSwitch
40- property bool serverChecked: batteryBackend.wifiEnabled
41- onServerCheckedChanged: checked = serverChecked
42- Component.onCompleted: checked = serverChecked
43- onTriggered: batteryBackend.wifiEnabled = checked
44+ control: Loader {
45+ active: networkActionGroup.enabled.state != null
46+ sourceComponent: Switch {
47+ id: wifiSwitch
48+ property bool serverChecked: networkActionGroup.enabled.state
49+ onServerCheckedChanged: checked = serverChecked
50+ Component.onCompleted: checked = serverChecked
51+ onTriggered: networkActionGroup.enabled.activate()
52+ }
53 }
54+ visible: networkActionGroup.enabled.state !== undefined
55+ Component.onCompleted: clicked.connect(wifiSwitch.clicked)
56 }
57
58 QDBusActionGroup {
59
60=== modified file 'plugins/battery/battery.cpp'
61--- plugins/battery/battery.cpp 2014-08-28 07:22:28 +0000
62+++ plugins/battery/battery.cpp 2014-11-12 19:07:19 +0000
63@@ -21,18 +21,8 @@
64 #include "battery.h"
65 #include <glib.h>
66 #include <libupower-glib/upower.h>
67-#include <nm-client.h>
68 #include <QtCore/QDebug>
69
70-static void wireless_enabled_changed (NMDevice *device G_GNUC_UNUSED,
71- GParamSpec *pspec G_GNUC_UNUSED,
72- gpointer user_data)
73-{
74- auto object = static_cast<Battery *>(user_data);
75-
76- Q_EMIT (object->wifiEnabledChanged());
77-}
78-
79 Battery::Battery(QObject *parent) :
80 QObject(parent),
81 m_systemBusConnection (QDBusConnection::systemBus()),
82@@ -43,12 +33,6 @@
83 m_deviceString("")
84 {
85 m_device = up_device_new();
86- m_nm_client = nm_client_new();
87-
88- g_signal_connect (m_nm_client,
89- "notify::wireless-enabled",
90- G_CALLBACK (wireless_enabled_changed),
91- this /* user_data */);
92
93 buildDeviceString();
94 getLastFullCharge();
95@@ -93,17 +77,6 @@
96 return m_deviceString;
97 }
98
99-bool Battery::getWifiEnabled()
100-{
101- return nm_client_wireless_get_enabled (m_nm_client);
102-}
103-
104-void Battery::setWifiEnabled(bool enabled)
105-{
106- nm_client_wireless_set_enabled (m_nm_client, enabled);
107-}
108-
109-
110 int Battery::lastFullCharge() const
111 {
112 return m_lastFullCharge;
113@@ -214,5 +187,4 @@
114
115 Battery::~Battery() {
116 g_object_unref(m_device);
117- g_object_unref(m_nm_client);
118 }
119
120=== modified file 'plugins/battery/battery.h'
121--- plugins/battery/battery.h 2013-09-30 11:18:17 +0000
122+++ plugins/battery/battery.h 2014-11-12 19:07:19 +0000
123@@ -25,7 +25,6 @@
124 #include <QObject>
125
126 #include <libupower-glib/upower.h>
127-#include <nm-client.h>
128
129 class Battery : public QObject
130 {
131@@ -42,11 +41,6 @@
132 READ lastFullCharge
133 NOTIFY lastFullChargeChanged)
134
135- Q_PROPERTY( bool wifiEnabled
136- READ getWifiEnabled
137- WRITE setWifiEnabled
138- NOTIFY wifiEnabledChanged)
139-
140 public:
141 explicit Battery(QObject *parent = 0);
142 ~Battery();
143@@ -54,12 +48,9 @@
144 QString deviceString() const;
145 int lastFullCharge() const;
146 Q_INVOKABLE QVariantList getHistory(const QString &deviceString, const int timespan, const int resolution);
147- bool getWifiEnabled();
148- void setWifiEnabled(bool enabled);
149
150 Q_SIGNALS:
151 void lastFullChargeChanged();
152- void wifiEnabledChanged();
153
154 private:
155 QDBusConnection m_systemBusConnection;
156@@ -69,7 +60,6 @@
157 UpDevice *m_device;
158 QString m_deviceString;
159 int m_lastFullCharge;
160- NMClient *m_nm_client;
161 void buildDeviceString();
162 void getLastFullCharge();
163 bool updateLastFullCharge(UpHistoryItem *item, int offset);

Subscribers

People subscribed via source and target branches