Merge lp:~cyphermox/network-manager/powersave+primaryconnectiontype into lp:~phablet-team/network-manager/rtm

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 864
Merged at revision: 863
Proposed branch: lp:~cyphermox/network-manager/powersave+primaryconnectiontype
Merge into: lp:~phablet-team/network-manager/rtm
Diff against target: 373 lines (+337/-0)
5 files modified
debian/changelog (+18/-0)
debian/libnm-util2.symbols (+1/-0)
debian/patches/powersave.patch (+114/-0)
debian/patches/primary_connection_type.patch (+202/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~cyphermox/network-manager/powersave+primaryconnectiontype
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+239556@code.launchpad.net

Description of the change

- Add powersave (barajas bug 1367745)
- New PrimaryConnectionType property backported from upstream git master to be used by unity8 (bug 1384776)

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

LGTM

Will create a patch and test to see if it actually works as expected (before top approval).

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

*Will create a package

Revision history for this message
Ricardo Salveti (rsalveti) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-10-15 19:24:43 +0000
+++ debian/changelog 2014-10-24 13:10:24 +0000
@@ -1,3 +1,21 @@
1network-manager (0.9.8.8-0ubuntu29) UNRELEASED; urgency=medium
2
3 [ Mathieu Trudel-Lapierre ]
4 * debian/patches/powersave.patch: enable powersave mode when wifi devices
5 are activated; disable it when we're disconnected so as not to interfere
6 with scanning and getting connected again to some network. (LP: #1384823)
7 * debian/libnm-util2.symbols: update symbols file for new method
8 nm_connection_get_connection_type introduced for the PrimaryConnectionType
9 patch.
10
11 [ Ryan Lortie ]
12 * debian/patches/primary_connection_type.patch: export the type of the
13 currently active primary connection (the one that currently owns the
14 default gateway), for use by applications to figure out when not to do
15 heavy requests, for example, while on mobile broadband. (LP: #1384776)
16
17 -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Thu, 23 Oct 2014 15:05:25 -0400
18
1network-manager (0.9.8.8-0ubuntu28) utopic; urgency=medium19network-manager (0.9.8.8-0ubuntu28) utopic; urgency=medium
220
3 * debian/patches/add_ofono_support.patch: Ignore calls to set_mm_enabled;21 * debian/patches/add_ofono_support.patch: Ignore calls to set_mm_enabled;
422
=== modified file 'debian/libnm-util2.symbols'
--- debian/libnm-util2.symbols 2013-02-26 15:00:41 +0000
+++ debian/libnm-util2.symbols 2014-10-24 13:10:24 +0000
@@ -10,6 +10,7 @@
10 nm_connection_error_get_type@Base 0.7.010 nm_connection_error_get_type@Base 0.7.0
11 nm_connection_error_quark@Base 0.7.011 nm_connection_error_quark@Base 0.7.0
12 nm_connection_for_each_setting_value@Base 0.7.012 nm_connection_for_each_setting_value@Base 0.7.0
13 nm_connection_get_connection_type@Base 0.9.8.8-0ubuntu29~
13 nm_connection_get_id@Base 0.8.99814 nm_connection_get_id@Base 0.8.998
14 nm_connection_get_path@Base 0.7.015 nm_connection_get_path@Base 0.7.0
15 nm_connection_get_setting@Base 0.7.016 nm_connection_get_setting@Base 0.7.0
1617
=== added file 'debian/patches/powersave.patch'
--- debian/patches/powersave.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/powersave.patch 2014-10-24 13:10:24 +0000
@@ -0,0 +1,114 @@
1From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2Subject: Enable the use of powersave mode on supporting wireless devices
3Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1384823
4
5---
6 src/nm-device-wifi.c | 5 +++++
7 src/wifi/wifi-utils-nl80211.c | 23 +++++++++++++++++++++++
8 src/wifi/wifi-utils-private.h | 3 +++
9 src/wifi/wifi-utils.c | 8 ++++++++
10 4 files changed, 39 insertions(+)
11
12Index: b/src/nm-device-wifi.c
13===================================================================
14--- a/src/nm-device-wifi.c
15+++ b/src/nm-device-wifi.c
16@@ -959,6 +959,8 @@ deactivate (NMDevice *dev)
17 /* Reset MAC address back to initial address */
18 _set_hw_addr (self, priv->initial_hw_addr, "reset");
19
20+ wifi_utils_set_powersave (priv->wifi_data, FALSE);
21+
22 /* Ensure we're in infrastructure mode after deactivation; some devices
23 * (usually older ones) don't scan well in adhoc mode.
24 */
25@@ -3489,12 +3491,15 @@ device_state_changed (NMDevice *device,
26 nm_supplicant_interface_disconnect (priv->supplicant.iface);
27 break;
28 case NM_DEVICE_STATE_ACTIVATED:
29+ wifi_utils_set_powersave (priv->wifi_data, TRUE);
30 activation_success_handler (device);
31 break;
32 case NM_DEVICE_STATE_FAILED:
33+ wifi_utils_set_powersave (priv->wifi_data, FALSE);
34 activation_failure_handler (device);
35 break;
36 case NM_DEVICE_STATE_DISCONNECTED:
37+ wifi_utils_set_powersave (priv->wifi_data, FALSE);
38 /* Kick off a scan to get latest results */
39 priv->scan_interval = SCAN_INTERVAL_MIN;
40 cancel_pending_scan (self);
41Index: b/src/wifi/wifi-utils-nl80211.c
42===================================================================
43--- a/src/wifi/wifi-utils-nl80211.c
44+++ b/src/wifi/wifi-utils-nl80211.c
45@@ -248,6 +248,28 @@ wifi_nl80211_set_mode (WifiData *data, c
46 return FALSE;
47 }
48
49+static gboolean
50+wifi_nl80211_set_powersave (WifiData *data, gboolean powersave)
51+{
52+ WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
53+ struct nl_msg *msg;
54+ int err;
55+
56+ msg = nl80211_alloc_msg (nl80211, NL80211_CMD_SET_POWER_SAVE, 0);
57+
58+ if (powersave)
59+ NLA_PUT_U32 (msg, NL80211_ATTR_PS_STATE, NL80211_PS_ENABLED);
60+ else
61+ NLA_PUT_U32 (msg, NL80211_ATTR_PS_STATE, NL80211_PS_DISABLED);
62+
63+ err = nl80211_send_and_recv (nl80211, msg, NULL, NULL);
64+ return err ? FALSE : TRUE;
65+
66+nla_put_failure:
67+ nlmsg_free (msg);
68+ return FALSE;
69+}
70+
71 /* @divisor: pass what value @xbm should be divided by to get dBm */
72 static guint32 nl80211_xbm_to_percent (gint32 xbm, guint32 divisor)
73 {
74@@ -739,6 +761,7 @@ wifi_nl80211_init (const char *iface, in
75 nl80211 = wifi_data_new (iface, ifindex, sizeof (*nl80211));
76 nl80211->parent.get_mode = wifi_nl80211_get_mode;
77 nl80211->parent.set_mode = wifi_nl80211_set_mode;
78+ nl80211->parent.set_powersave = wifi_nl80211_set_powersave;
79 nl80211->parent.get_freq = wifi_nl80211_get_freq;
80 nl80211->parent.find_freq = wifi_nl80211_find_freq;
81 nl80211->parent.get_ssid = wifi_nl80211_get_ssid;
82Index: b/src/wifi/wifi-utils.c
83===================================================================
84--- a/src/wifi/wifi-utils.c
85+++ b/src/wifi/wifi-utils.c
86@@ -104,6 +104,14 @@ wifi_utils_set_mode (WifiData *data, con
87 return data->set_mode ? data->set_mode (data, mode) : TRUE;
88 }
89
90+gboolean
91+wifi_utils_set_powersave (WifiData *data, gboolean powersave)
92+{
93+ g_return_val_if_fail (data != NULL, FALSE);
94+
95+ return data->set_powersave ? data->set_powersave (data, powersave) : TRUE;
96+}
97+
98 guint32
99 wifi_utils_get_freq (WifiData *data)
100 {
101Index: b/src/wifi/wifi-utils-private.h
102===================================================================
103--- a/src/wifi/wifi-utils-private.h
104+++ b/src/wifi/wifi-utils-private.h
105@@ -36,6 +36,9 @@ struct WifiData {
106
107 gboolean (*set_mode) (WifiData *data, const NM80211Mode mode);
108
109+ /* Set power saving mode on an interface (nl80211 only) */
110+ gboolean (*set_powersave) (WifiData *data, gboolean powersave);
111+
112 /* Return current frequency in MHz (really associated BSS frequency) */
113 guint32 (*get_freq) (WifiData *data);
114
0115
=== added file 'debian/patches/primary_connection_type.patch'
--- debian/patches/primary_connection_type.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/primary_connection_type.patch 2014-10-24 13:10:24 +0000
@@ -0,0 +1,202 @@
1From 01dab14dbba76dd804858cad5f3b6ec4605b0d1a Mon Sep 17 00:00:00 2001
2From: Ryan Lortie <desrt@desrt.ca>
3Date: Thu, 23 Oct 2014 13:56:52 -0400
4Subject: [PATCH] Add PrimaryConnectionType property to the manager
5
6This will provide an extremely easy way for applications to find out
7what type of connection the system is currently using. They might want
8to do this to avoid using data if a phone is on a 3G connection, for
9example.
10
11Backported from https://bugzilla.gnome.org/show_bug.cgi?id=739080
12---
13 introspection/nm-manager.xml | 8 ++++++++
14 libnm-util/libnm-util.ver | 1 +
15 libnm-util/nm-connection.c | 21 +++++++++++++++++++++
16 libnm-util/nm-connection.h | 2 ++
17 src/nm-active-connection.c | 11 +++++++++++
18 src/nm-active-connection.h | 2 ++
19 src/nm-manager.c | 15 +++++++++++++++
20 src/nm-manager.h | 1 +
21 8 files changed, 61 insertions(+)
22
23diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml
24index a0e2773..97ffc87 100644
25--- a/introspection/nm-manager.xml
26+++ b/introspection/nm-manager.xml
27@@ -326,6 +326,14 @@
28 </tp:docstring>
29 </property>
30
31+ <property name="PrimaryConnectionType" type="s" access="read">
32+ <tp:docstring>
33+ The connection type of the "primary" active connection being
34+ used to access the network. This is the same as the Type
35+ property on the object indicated by PrimaryConnection.
36+ </tp:docstring>
37+ </property>
38+
39 <property name="ActivatingConnection" type="o" access="read">
40 <tp:docstring>
41 The object path of an active connection that is currently
42diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
43index 04f2a91..dd68293 100644
44--- a/libnm-util/libnm-util.ver
45+++ b/libnm-util/libnm-util.ver
46@@ -11,6 +11,7 @@ global:
47 nm_connection_error_get_type;
48 nm_connection_error_quark;
49 nm_connection_for_each_setting_value;
50+ nm_connection_get_connection_type;
51 nm_connection_get_id;
52 nm_connection_get_path;
53 nm_connection_get_setting;
54diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
55index 15b1685..e684138 100644
56--- a/libnm-util/nm-connection.c
57+++ b/libnm-util/nm-connection.c
58@@ -1249,6 +1249,27 @@ nm_connection_get_id (NMConnection *connection)
59 return nm_setting_connection_get_id (s_con);
60 }
61
62+/**
63+ * nm_connection_get_connection_type:
64+ * @connection: the #NMConnection
65+ *
66+ * A shortcut to return the type from the connection's #NMSettingConnection.
67+ *
68+ * Returns: the type from the connection's 'connection' setting
69+ **/
70+const char *
71+nm_connection_get_connection_type (NMConnection *connection)
72+{
73+ NMSettingConnection *s_con;
74+
75+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
76+
77+ s_con = nm_connection_get_setting_connection (connection);
78+ g_return_val_if_fail (s_con != NULL, NULL);
79+
80+ return nm_setting_connection_get_connection_type (s_con);
81+}
82+
83 /*************************************************************/
84
85 /**
86diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
87index 4d060cc..d6a18f7 100644
88--- a/libnm-util/nm-connection.h
89+++ b/libnm-util/nm-connection.h
90@@ -187,6 +187,8 @@ const char * nm_connection_get_uuid (NMConnection *connection);
91
92 const char * nm_connection_get_id (NMConnection *connection);
93
94+const char * nm_connection_get_connection_type (NMConnection *connection);
95+
96 NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection);
97 NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
98 NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
99diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
100index 6e3a5da..5faded1 100644
101--- a/src/nm-active-connection.c
102+++ b/src/nm-active-connection.c
103@@ -137,6 +137,17 @@ nm_active_connection_get_connection (NMActiveConnection *self)
104 }
105
106 const char *
107+nm_active_connection_get_connection_type (NMActiveConnection *self)
108+{
109+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
110+
111+ if (priv->connection == NULL)
112+ return NULL;
113+
114+ return nm_connection_get_connection_type (priv->connection);
115+}
116+
117+const char *
118 nm_active_connection_get_path (NMActiveConnection *self)
119 {
120 return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->path;
121diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h
122index 2f17c58..0401f88 100644
123--- a/src/nm-active-connection.h
124+++ b/src/nm-active-connection.h
125@@ -70,6 +70,8 @@ void nm_active_connection_export (NMActiveConnection *self);
126 NMConnection *nm_active_connection_get_connection (NMActiveConnection *self);
127 const char * nm_active_connection_get_name (NMActiveConnection *self);
128
129+const char * nm_active_connection_get_connection_type (NMActiveConnection *self);
130+
131 const char * nm_active_connection_get_path (NMActiveConnection *self);
132
133 const char * nm_active_connection_get_specific_object (NMActiveConnection *self);
134diff --git a/src/nm-manager.c b/src/nm-manager.c
135index 9c82d14..11a50f2 100644
136--- a/src/nm-manager.c
137+++ b/src/nm-manager.c
138@@ -291,6 +291,7 @@ enum {
139 PROP_ACTIVE_CONNECTIONS,
140 PROP_CONNECTIVITY,
141 PROP_PRIMARY_CONNECTION,
142+ PROP_PRIMARY_CONNECTION_TYPE,
143 PROP_ACTIVATING_CONNECTION,
144
145 /* Not exported */
146@@ -4054,6 +4055,7 @@ policy_default_device_changed (GObject *object, GParamSpec *pspec, gpointer user
147 priv->primary_connection = ac ? g_object_ref (ac) : NULL;
148 nm_log_dbg (LOGD_CORE, "PrimaryConnection now %s", ac ? nm_active_connection_get_name (ac) : "(none)");
149 g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION);
150+ g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION_TYPE);
151 }
152 }
153
154@@ -4660,6 +4662,7 @@ get_property (GObject *object, guint prop_id,
155 GSList *iter;
156 GPtrArray *active;
157 const char *path;
158+ const char *type;
159
160 switch (prop_id) {
161 case PROP_VERSION:
162@@ -4705,6 +4708,10 @@ get_property (GObject *object, guint prop_id,
163 path = priv->primary_connection ? nm_active_connection_get_path (priv->primary_connection) : "/";
164 g_value_set_boxed (value, path);
165 break;
166+ case PROP_PRIMARY_CONNECTION_TYPE:
167+ type = priv->primary_connection ? nm_active_connection_get_connection_type (priv->primary_connection) : NULL;
168+ g_value_set_string (value, type ? type : "");
169+ break;
170 case PROP_ACTIVATING_CONNECTION:
171 path = priv->activating_connection ? nm_active_connection_get_path (priv->activating_connection) : "/";
172 g_value_set_boxed (value, path);
173@@ -4981,6 +4988,14 @@ nm_manager_class_init (NMManagerClass *manager_class)
174 G_PARAM_READABLE));
175
176 g_object_class_install_property
177+ (object_class, PROP_PRIMARY_CONNECTION_TYPE,
178+ g_param_spec_string (NM_MANAGER_PRIMARY_CONNECTION_TYPE, "", "",
179+ NULL,
180+ G_PARAM_READABLE |
181+ G_PARAM_STATIC_STRINGS));
182+
183+
184+ g_object_class_install_property
185 (object_class, PROP_ACTIVATING_CONNECTION,
186 g_param_spec_boxed (NM_MANAGER_ACTIVATING_CONNECTION,
187 "Activating connection",
188diff --git a/src/nm-manager.h b/src/nm-manager.h
189index 9884d05..a0c9065 100644
190--- a/src/nm-manager.h
191+++ b/src/nm-manager.h
192@@ -61,6 +61,7 @@ typedef enum {
193 #define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections"
194 #define NM_MANAGER_CONNECTIVITY "connectivity"
195 #define NM_MANAGER_PRIMARY_CONNECTION "primary-connection"
196+#define NM_MANAGER_PRIMARY_CONNECTION_TYPE "primary-connection-type"
197 #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection"
198
199 /* Not exported */
200--
2012.1.0
202
0203
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-10-15 19:24:43 +0000
+++ debian/patches/series 2014-10-24 13:10:24 +0000
@@ -43,3 +43,5 @@
43remove-extra-scan_done-on-scan-start.patch43remove-extra-scan_done-on-scan-start.patch
44scan_update_last_seen.patch44scan_update_last_seen.patch
45cull_aps_on_scan_done_signal.patch45cull_aps_on_scan_done_signal.patch
46powersave.patch
47primary_connection_type.patch

Subscribers

People subscribed via source and target branches