Merge lp:~phablet-team/network-manager/ofono-rm-unused-code into lp:~network-manager/network-manager/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 958
Merged at revision: 956
Proposed branch: lp:~phablet-team/network-manager/ofono-rm-unused-code
Merge into: lp:~network-manager/network-manager/ubuntu
Prerequisite: lp:~phablet-team/network-manager/lp1418077
Diff against target: 333 lines (+2/-253)
1 file modified
debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch (+2/-253)
To merge this branch: bzr merge lp:~phablet-team/network-manager/ofono-rm-unused-code
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Abstain
Ricardo Salveti (community) Approve
Review via email: mp+255305@code.launchpad.net

Description of the change

This merge proposal is a general cleanup of the NM ofono code ( src/devices/wwan/nm-modem-ofono.c ), getting rid of unused and/or code that was commented out.

To post a comment you must log in.
958. By Tony Espy

Remove unused nm-modem-ofono.c function: do_context_prepare()

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

Looks good, makes it easier to fix bugs and maintain the code as we go (and also for possible vivid specific issues), so good to land soon if possible.

review: Approve
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Changeset is fine, but given that the unused/commented code is obvious and straightforward, I'd rather avoid making cosmetic changes two weeks away from Vivid release, even when bundled with bugfixes. I don't see why it couldn't wait two more weeks and land in the next release cycle.

Call me extra careful, but it's *very* late in the release so I'd defer the decision of landing this despite it being cosmetic changes to the release team. Could you please bring it up to them?

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

The thing about not waiting for two more extra weeks (for next release) is because we're still going to maintain this code base (vivid based) for RTM for a few months.

Revision history for this message
Tony Espy (awe) wrote :

Also this code has *nothing* to do with any code run on the desktop.

The only way any of the deleted static functions could possibly be used is if they were referenced in a function table, which none of them are.

The rest of the changes are super straight-forward, private variables that aren't ever used after being initialized, and code that's commented out, or ifdef'd out.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch'
2--- debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-04-06 22:03:27 +0000
3+++ debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-04-06 22:03:27 +0000
4@@ -304,7 +304,7 @@
5 ===================================================================
6 --- /dev/null
7 +++ network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.c
8-@@ -0,0 +1,1395 @@
9+@@ -0,0 +1,1144 @@
10 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
11 +/* NetworkManager -- Network link manager
12 + *
13@@ -343,47 +343,6 @@
14 +#include "nm-dbus-manager.h"
15 +#include "NetworkManagerUtils.h"
16 +
17-+typedef enum {
18-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY = 0,
19-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_GPRS,
20-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_EDGE,
21-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_UMTS,
22-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSDPA,
23-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED,
24-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED,
25-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY,
26-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY,
27-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSUPA,
28-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA,
29-+
30-+ MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_LAST = MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA
31-+} MMModemDeprecatedMode;
32-+
33-+typedef enum {
34-+ MM_MODEM_GSM_ALLOWED_MODE_ANY = 0,
35-+ MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED = 1,
36-+ MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED = 2,
37-+ MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY = 3,
38-+ MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY = 4,
39-+ MM_MODEM_GSM_ALLOWED_MODE_4G_PREFERRED = 5,
40-+ MM_MODEM_GSM_ALLOWED_MODE_4G_ONLY = 6,
41-+
42-+ MM_MODEM_GSM_ALLOWED_MODE_LAST = MM_MODEM_GSM_ALLOWED_MODE_4G_ONLY
43-+} MMModemGsmAllowedMode;
44-+
45-+typedef enum {
46-+ MM_MODEM_GSM_ALLOWED_AUTH_UNKNOWN = 0x0000,
47-+ /* bits 0..4 order match Ericsson device bitmap */
48-+ MM_MODEM_GSM_ALLOWED_AUTH_NONE = 0x0001,
49-+ MM_MODEM_GSM_ALLOWED_AUTH_PAP = 0x0002,
50-+ MM_MODEM_GSM_ALLOWED_AUTH_CHAP = 0x0004,
51-+ MM_MODEM_GSM_ALLOWED_AUTH_MSCHAP = 0x0008,
52-+ MM_MODEM_GSM_ALLOWED_AUTH_MSCHAPV2 = 0x0010,
53-+ MM_MODEM_GSM_ALLOWED_AUTH_EAP = 0x0020,
54-+
55-+ MM_MODEM_GSM_ALLOWED_AUTH_LAST = MM_MODEM_GSM_ALLOWED_AUTH_EAP
56-+} MMModemGsmAllowedAuth;
57-+
58 +G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM)
59 +
60 +#define NM_MODEM_OFONO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MODEM_OFONO, NMModemOfonoPrivate))
61@@ -398,13 +357,8 @@
62 + DBusGProxy *context_proxy;
63 + DBusGProxy *simmanager_proxy;
64 +
65-+ DBusGProxyCall *call;
66-+
67 + GError *property_error;
68 +
69-+ guint connman_iface_source;
70-+ guint connman_iface_retries;
71-+
72 + char **interfaces;
73 + char *context_path;
74 +
75@@ -551,11 +505,7 @@
76 + } else {
77 + new_state = NM_MODEM_STATE_SEARCHING;
78 + reason = NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER;
79-+ //nm_modem_device_state_changed (NM_MODEM (self),
80-+ // NM_DEVICE_STATE_UNAVAILABLE,
81-+ // NM_DEVICE_STATE_UNKNOWN,
82-+ // reason);
83-+ }
84++ }
85 +
86 + nm_modem_set_state (NM_MODEM (self),
87 + new_state,
88@@ -864,8 +814,6 @@
89 +
90 + nm_log_dbg (LOGD_MB, "in %s", __func__);
91 +
92-+ priv->call = NULL;
93-+
94 + if (priv->connect_properties) {
95 + g_hash_table_destroy (priv->connect_properties);
96 + priv->connect_properties = NULL;
97@@ -1129,153 +1077,6 @@
98 + }
99 +}
100 +
101-+static void
102-+do_context_prepare (NMModemOfono *self, char *context_path)
103-+{
104-+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
105-+
106-+ g_return_val_if_fail (self != NULL, FALSE);
107-+ g_return_val_if_fail (NM_IS_MODEM_OFONO (self), FALSE);
108-+
109-+ nm_log_dbg (LOGD_MB, "in %s", __func__);
110-+
111-+ if (priv->context_proxy)
112-+ g_object_unref (priv->context_proxy);
113-+
114-+ priv->context_proxy = get_ofono_proxy (self,
115-+ context_path,
116-+ OFONO_DBUS_INTERFACE_CONNECTION_CONTEXT);
117-+
118-+ if (priv->context_proxy) {
119-+ priv->property_error = NULL;
120-+ g_hash_table_foreach (priv->connect_properties,
121-+ context_set_property,
122-+ (gpointer) self);
123-+ do_context_activate (self, context_path);
124-+ }
125-+}
126-+
127-+static void
128-+create_new_context_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
129-+{
130-+ NMModemOfono *self = NM_MODEM_OFONO (user_data);
131-+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
132-+ GError *error = NULL;
133-+ char *context_path = NULL;
134-+ gboolean ret = FALSE;
135-+
136-+ nm_log_dbg (LOGD_MB, "in %s", __func__);
137-+
138-+ ret = dbus_g_proxy_end_call (proxy,
139-+ call_id,
140-+ &error,
141-+ DBUS_TYPE_G_OBJECT_PATH, &context_path,
142-+ G_TYPE_INVALID);
143-+
144-+ nm_log_dbg (LOGD_MB, "%s: context path: %s", __func__, context_path);
145-+
146-+ if (ret)
147-+ do_context_prepare (self, context_path);
148-+ else {
149-+ nm_log_warn (LOGD_MB, "Ofono modem context creation failed: (%d) %s",
150-+ error ? error->code : -1,
151-+ error && error->message ? error->message : "(unknown)");
152-+
153-+ g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
154-+
155-+ g_error_free (error);
156-+ }
157-+}
158-+
159-+static void
160-+do_create_new_context (NMModemOfono *self)
161-+{
162-+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
163-+ DBusGProxy *proxy;
164-+
165-+ g_return_val_if_fail (self != NULL, FALSE);
166-+ g_return_val_if_fail (NM_IS_MODEM_OFONO (self), FALSE);
167-+
168-+ nm_log_dbg (LOGD_MB, "in %s", __func__);
169-+
170-+ if (priv->connman_proxy) {
171-+ dbus_g_proxy_begin_call_with_timeout (priv->connman_proxy,
172-+ "AddContext", create_new_context_done,
173-+ self, NULL, 20000,
174-+ G_TYPE_STRING, "internet",
175-+ G_TYPE_INVALID);
176-+ }
177-+ else {
178-+ nm_log_err (LOGD_MB, "could not bring up connection manager proxy "
179-+ "to add a new context");
180-+ }
181-+}
182-+
183-+static gboolean
184-+try_create_new_context (NMModemOfono *self)
185-+{
186-+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
187-+ GHashTable *properties;
188-+ char **interfaces;
189-+ GError *error = NULL;
190-+ gboolean found = FALSE;
191-+ int i;
192-+
193-+ nm_log_dbg (LOGD_MB, "in %s", __func__);
194-+
195-+ /* Only retry up to 20 times */
196-+ if (priv->connman_iface_retries < 20) {
197-+ dbus_g_proxy_call_with_timeout (priv->modem_proxy,
198-+ "GetProperties",
199-+ 250, &error,
200-+ G_TYPE_INVALID,
201-+ DBUS_TYPE_G_MAP_OF_VARIANT, &properties,
202-+ G_TYPE_INVALID);
203-+
204-+ if (!error) {
205-+ interfaces = (char **) g_value_get_boxed (g_hash_table_lookup (properties, "Interfaces"));
206-+
207-+ for (i = 0; interfaces[i]; i++) {
208-+ nm_log_dbg (LOGD_MB, "%s ?? %s",
209-+ interfaces[i],
210-+ OFONO_DBUS_INTERFACE_CONNECTION_MANAGER);
211-+ if (!g_strcmp0 (interfaces[i],
212-+ OFONO_DBUS_INTERFACE_CONNECTION_MANAGER)) {
213-+ found = TRUE;
214-+ break;
215-+ }
216-+ }
217-+ }
218-+ else {
219-+ nm_log_dbg (LOGD_MB, "failed test for properties: %s",
220-+ error && error->message ? error->message : "(unknown)");
221-+ }
222-+ priv->connman_iface_retries++;
223-+ }
224-+ else {
225-+ if (priv->connman_iface_source != 0)
226-+ g_source_remove (priv->connman_iface_source);
227-+
228-+ priv->connman_iface_source = 0;
229-+ priv->connman_iface_retries = 0;
230-+
231-+ g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, 0);
232-+
233-+ return FALSE;
234-+ }
235-+
236-+ if (found) {
237-+ if (priv->connman_iface_source != 0)
238-+ g_source_remove (priv->connman_iface_source);
239-+
240-+ priv->connman_iface_source = 0;
241-+ priv->connman_iface_retries = 0;
242-+ do_create_new_context (self);
243-+ }
244-+
245-+ return !found;
246-+}
247-+
248 +static void stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data);
249 +
250 +static void
251@@ -1288,12 +1089,6 @@
252 + nm_log_dbg (LOGD_MB, "in %s", __func__);
253 +
254 + if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
255-+#if 0
256-+ /* Try once every 5 seconds to see if we've got the right interfaces */
257-+ priv->connman_iface_retries = 0;
258-+ priv->connman_iface_source
259-+ = g_timeout_add (500, (GSourceFunc) try_create_new_context, self);
260-+#endif
261 + if (priv->context_path)
262 + do_context_activate (self, priv->context_path);
263 + else
264@@ -1514,44 +1309,6 @@
265 + G_TYPE_INVALID);
266 +}
267 +
268-+#if 0
269-+static void
270-+set_ofono_enabled (NMModem *self, gboolean enabled)
271-+{
272-+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
273-+ GValue value = G_VALUE_INIT;
274-+ gboolean ret;
275-+ GError *error = NULL;
276-+
277-+ g_return_if_fail (self != NULL);
278-+ g_return_if_fail (NM_IS_MODEM_OFONO (self));
279-+ g_return_if_fail (priv != NULL);
280-+ g_return_if_fail (priv->connman_proxy != NULL);
281-+
282-+ nm_log_dbg (LOGD_MB, "in %s", __func__);
283-+
284-+ g_value_init (&value, G_TYPE_BOOLEAN);
285-+ g_value_set_boolean (&value, enabled);
286-+
287-+ ret = dbus_g_proxy_call_with_timeout (priv->connman_proxy,
288-+ "SetProperty",
289-+ 20000,
290-+ &error,
291-+ G_TYPE_STRING, "Powered",
292-+ G_TYPE_VALUE, &value,
293-+ G_TYPE_INVALID,
294-+ G_TYPE_INVALID);
295-+
296-+ if (!ret) {
297-+ nm_log_warn (LOGD_MB, "OFONO modem set enabled failed: (%d) %s",
298-+ error ? error->code : -1,
299-+ error && error->message ? error->message : "(unknown)");
300-+ }
301-+ else {
302-+ get_ofono_conn_manager_properties (self);
303-+ }
304-+}
305-+#endif
306 +static void
307 +set_ofono_enabled (NMModem *self, gboolean enabled)
308 +{
309@@ -1600,9 +1357,6 @@
310 + priv->context_proxy = NULL;
311 + priv->simmanager_proxy = NULL;
312 +
313-+ priv->connman_iface_source = 0;
314-+ priv->connman_iface_retries = 0;
315-+
316 + priv->modem_online = FALSE;
317 + priv->gprs_powered = FALSE;
318 + priv->gprs_attached = FALSE;
319@@ -1690,14 +1444,9 @@
320 + modem_class->set_mm_enabled = set_ofono_enabled;
321 + modem_class->disconnect = disconnect;
322 + modem_class->deactivate = deactivate;
323-+ //modem_class->get_user_pass = get_user_pass;
324-+ //modem_class->get_setting_name = get_setting_name;
325-+ //modem_class->complete_connection = complete_connection;
326 + modem_class->check_connection_compatible = check_connection_compatible;
327 + modem_class->act_stage1_prepare = act_stage1_prepare;
328 + modem_class->static_stage3_ip4_config_start = static_stage3_ip4_config_start;
329-+
330-+ //dbus_g_error_domain_register (NM_OFONO_ERROR, NULL, NM_TYPE_OFONO_ERROR);
331 +}
332 +
333 Index: network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.h

Subscribers

People subscribed via source and target branches