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
=== modified file 'plugins/battery/CMakeLists.txt'
--- plugins/battery/CMakeLists.txt 2013-10-22 14:44:44 +0000
+++ plugins/battery/CMakeLists.txt 2014-11-12 19:07:19 +0000
@@ -7,11 +7,11 @@
7 SleepValues.qml7 SleepValues.qml
8)8)
99
10include_directories(${GLIB_INCLUDE_DIRS} ${UPOWER_GLIB_INCLUDE_DIRS} ${LIBNM_GLIB_INCLUDE_DIRS})10include_directories(${GLIB_INCLUDE_DIRS} ${UPOWER_GLIB_INCLUDE_DIRS})
11add_library(UbuntuBatteryPanel MODULE plugin.h battery.h plugin.cpp battery.cpp11add_library(UbuntuBatteryPanel MODULE plugin.h battery.h plugin.cpp battery.cpp
12${QML_SOURCES})12${QML_SOURCES})
13qt5_use_modules(UbuntuBatteryPanel Quick Qml DBus)13qt5_use_modules(UbuntuBatteryPanel Quick Qml DBus)
14target_link_libraries(UbuntuBatteryPanel ${GLIB_LDFLAGS} ${UPOWER_GLIB_LDFLAGS} ${LIBNM_GLIB_LDFLAGS})14target_link_libraries(UbuntuBatteryPanel ${GLIB_LDFLAGS} ${UPOWER_GLIB_LDFLAGS})
1515
16set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Battery)16set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Battery)
17install(TARGETS UbuntuBatteryPanel DESTINATION ${PLUG_DIR})17install(TARGETS UbuntuBatteryPanel DESTINATION ${PLUG_DIR})
1818
=== modified file 'plugins/battery/PageComponent.qml'
--- plugins/battery/PageComponent.qml 2014-11-12 19:07:19 +0000
+++ plugins/battery/PageComponent.qml 2014-11-12 19:07:19 +0000
@@ -329,15 +329,30 @@
329 Qt.resolvedUrl("SleepValues.qml"),329 Qt.resolvedUrl("SleepValues.qml"),
330 { title: text, lockOnSuspend: lockOnSuspend })330 { title: text, lockOnSuspend: lockOnSuspend })
331 }331 }
332
333 QDBusActionGroup {
334 id: networkActionGroup
335 busType: 1
336 busName: "com.canonical.indicator.network"
337 objectPath: "/com/canonical/indicator/network"
338 property variant enabled: action("wifi.enable")
339 Component.onCompleted: start()
340 }
341
332 ListItem.Standard {342 ListItem.Standard {
333 text: i18n.tr("Wi-Fi")343 text: i18n.tr("Wi-Fi")
334 control: Switch {344 control: Loader {
335 id: wifiSwitch345 active: networkActionGroup.enabled.state != null
336 property bool serverChecked: batteryBackend.wifiEnabled346 sourceComponent: Switch {
337 onServerCheckedChanged: checked = serverChecked347 id: wifiSwitch
338 Component.onCompleted: checked = serverChecked348 property bool serverChecked: networkActionGroup.enabled.state
339 onTriggered: batteryBackend.wifiEnabled = checked349 onServerCheckedChanged: checked = serverChecked
350 Component.onCompleted: checked = serverChecked
351 onTriggered: networkActionGroup.enabled.activate()
352 }
340 }353 }
354 visible: networkActionGroup.enabled.state !== undefined
355 Component.onCompleted: clicked.connect(wifiSwitch.clicked)
341 }356 }
342357
343 QDBusActionGroup {358 QDBusActionGroup {
344359
=== modified file 'plugins/battery/battery.cpp'
--- plugins/battery/battery.cpp 2014-08-28 07:22:28 +0000
+++ plugins/battery/battery.cpp 2014-11-12 19:07:19 +0000
@@ -21,18 +21,8 @@
21#include "battery.h"21#include "battery.h"
22#include <glib.h>22#include <glib.h>
23#include <libupower-glib/upower.h>23#include <libupower-glib/upower.h>
24#include <nm-client.h>
25#include <QtCore/QDebug>24#include <QtCore/QDebug>
2625
27static void wireless_enabled_changed (NMDevice *device G_GNUC_UNUSED,
28 GParamSpec *pspec G_GNUC_UNUSED,
29 gpointer user_data)
30{
31 auto object = static_cast<Battery *>(user_data);
32
33 Q_EMIT (object->wifiEnabledChanged());
34}
35
36Battery::Battery(QObject *parent) :26Battery::Battery(QObject *parent) :
37 QObject(parent),27 QObject(parent),
38 m_systemBusConnection (QDBusConnection::systemBus()),28 m_systemBusConnection (QDBusConnection::systemBus()),
@@ -43,12 +33,6 @@
43 m_deviceString("")33 m_deviceString("")
44{34{
45 m_device = up_device_new();35 m_device = up_device_new();
46 m_nm_client = nm_client_new();
47
48 g_signal_connect (m_nm_client,
49 "notify::wireless-enabled",
50 G_CALLBACK (wireless_enabled_changed),
51 this /* user_data */);
5236
53 buildDeviceString();37 buildDeviceString();
54 getLastFullCharge();38 getLastFullCharge();
@@ -93,17 +77,6 @@
93 return m_deviceString;77 return m_deviceString;
94}78}
9579
96bool Battery::getWifiEnabled()
97{
98 return nm_client_wireless_get_enabled (m_nm_client);
99}
100
101void Battery::setWifiEnabled(bool enabled)
102{
103 nm_client_wireless_set_enabled (m_nm_client, enabled);
104}
105
106
107int Battery::lastFullCharge() const80int Battery::lastFullCharge() const
108{81{
109 return m_lastFullCharge;82 return m_lastFullCharge;
@@ -214,5 +187,4 @@
214187
215Battery::~Battery() {188Battery::~Battery() {
216 g_object_unref(m_device);189 g_object_unref(m_device);
217 g_object_unref(m_nm_client);
218}190}
219191
=== modified file 'plugins/battery/battery.h'
--- plugins/battery/battery.h 2013-09-30 11:18:17 +0000
+++ plugins/battery/battery.h 2014-11-12 19:07:19 +0000
@@ -25,7 +25,6 @@
25#include <QObject>25#include <QObject>
2626
27#include <libupower-glib/upower.h>27#include <libupower-glib/upower.h>
28#include <nm-client.h>
2928
30class Battery : public QObject29class Battery : public QObject
31{30{
@@ -42,11 +41,6 @@
42 READ lastFullCharge41 READ lastFullCharge
43 NOTIFY lastFullChargeChanged)42 NOTIFY lastFullChargeChanged)
4443
45 Q_PROPERTY( bool wifiEnabled
46 READ getWifiEnabled
47 WRITE setWifiEnabled
48 NOTIFY wifiEnabledChanged)
49
50public:44public:
51 explicit Battery(QObject *parent = 0);45 explicit Battery(QObject *parent = 0);
52 ~Battery();46 ~Battery();
@@ -54,12 +48,9 @@
54 QString deviceString() const;48 QString deviceString() const;
55 int lastFullCharge() const;49 int lastFullCharge() const;
56 Q_INVOKABLE QVariantList getHistory(const QString &deviceString, const int timespan, const int resolution);50 Q_INVOKABLE QVariantList getHistory(const QString &deviceString, const int timespan, const int resolution);
57 bool getWifiEnabled();
58 void setWifiEnabled(bool enabled);
5951
60Q_SIGNALS:52Q_SIGNALS:
61 void lastFullChargeChanged();53 void lastFullChargeChanged();
62 void wifiEnabledChanged();
6354
64private:55private:
65 QDBusConnection m_systemBusConnection;56 QDBusConnection m_systemBusConnection;
@@ -69,7 +60,6 @@
69 UpDevice *m_device;60 UpDevice *m_device;
70 QString m_deviceString;61 QString m_deviceString;
71 int m_lastFullCharge;62 int m_lastFullCharge;
72 NMClient *m_nm_client;
73 void buildDeviceString();63 void buildDeviceString();
74 void getLastFullCharge();64 void getLastFullCharge();
75 bool updateLastFullCharge(UpHistoryItem *item, int offset);65 bool updateLastFullCharge(UpHistoryItem *item, int offset);

Subscribers

People subscribed via source and target branches