|
|
8c8af5 |
From 428063526f6bf032c2ecba28cd41865d9a5661fa Mon Sep 17 00:00:00 2001
|
|
|
8c8af5 |
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
|
|
|
8c8af5 |
Date: Wed, 1 Apr 2015 20:22:20 +0100
|
|
|
8c8af5 |
Subject: [PATCH 7/7] modem-manager: Wait for modem to be enabled
|
|
|
8c8af5 |
|
|
|
8c8af5 |
Modem's location capabilities won't be known until its enabled.
|
|
|
8c8af5 |
|
|
|
8c8af5 |
https://bugs.freedesktop.org/show_bug.cgi?id=85305
|
|
|
8c8af5 |
---
|
|
|
8c8af5 |
src/gclue-modem-manager.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
8c8af5 |
1 file changed, 57 insertions(+), 1 deletion(-)
|
|
|
8c8af5 |
|
|
|
8c8af5 |
diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c
|
|
|
8c8af5 |
index 71ab96d..d48c0cb 100644
|
|
|
8c8af5 |
--- a/src/gclue-modem-manager.c
|
|
|
8c8af5 |
+++ b/src/gclue-modem-manager.c
|
|
|
8c8af5 |
@@ -484,16 +484,72 @@ modem_has_caps (GClueModemManager *manager,
|
|
|
8c8af5 |
static void
|
|
|
8c8af5 |
on_mm_object_added (GDBusObjectManager *object_manager,
|
|
|
8c8af5 |
GDBusObject *object,
|
|
|
8c8af5 |
+ gpointer user_data);
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+static void
|
|
|
8c8af5 |
+on_mm_modem_state_notify (GObject *gobject,
|
|
|
8c8af5 |
+ GParamSpec *pspec,
|
|
|
8c8af5 |
+ gpointer user_data)
|
|
|
8c8af5 |
+{
|
|
|
8c8af5 |
+ MMModem *mm_modem = MM_MODEM (gobject);
|
|
|
8c8af5 |
+ GClueModemManager *manager = GCLUE_MODEM_MANAGER (user_data);
|
|
|
8c8af5 |
+ GClueModemManagerPrivate *priv = manager->priv;
|
|
|
8c8af5 |
+ GDBusObjectManager *obj_manager = G_DBUS_OBJECT_MANAGER (priv->manager);
|
|
|
8c8af5 |
+ const char *path = mm_modem_get_path (mm_modem);
|
|
|
8c8af5 |
+ GDBusObject *object;
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ if (priv->mm_object != NULL) {
|
|
|
8c8af5 |
+ // In the meantime another modem with location caps was found.
|
|
|
8c8af5 |
+ g_signal_handlers_disconnect_by_func (mm_modem,
|
|
|
8c8af5 |
+ on_mm_modem_state_notify,
|
|
|
8c8af5 |
+ user_data);
|
|
|
8c8af5 |
+ g_object_unref (gobject);
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ return;
|
|
|
8c8af5 |
+ }
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ if (mm_modem_get_state (mm_modem) < MM_MODEM_STATE_ENABLED)
|
|
|
8c8af5 |
+ return;
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ g_debug ("Modem '%s' now enabled", path);
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ g_signal_handlers_disconnect_by_func (mm_modem,
|
|
|
8c8af5 |
+ on_mm_modem_state_notify,
|
|
|
8c8af5 |
+ user_data);
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ object = g_dbus_object_manager_get_object (obj_manager, path);
|
|
|
8c8af5 |
+ on_mm_object_added (obj_manager, object, user_data);
|
|
|
8c8af5 |
+ g_object_unref (mm_modem);
|
|
|
8c8af5 |
+}
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+static void
|
|
|
8c8af5 |
+on_mm_object_added (GDBusObjectManager *object_manager,
|
|
|
8c8af5 |
+ GDBusObject *object,
|
|
|
8c8af5 |
gpointer user_data)
|
|
|
8c8af5 |
{
|
|
|
8c8af5 |
MMObject *mm_object = MM_OBJECT (object);
|
|
|
8c8af5 |
GClueModemManager *manager = GCLUE_MODEM_MANAGER (user_data);
|
|
|
8c8af5 |
+ MMModem *mm_modem;
|
|
|
8c8af5 |
MMModemLocation *modem_location;
|
|
|
8c8af5 |
|
|
|
8c8af5 |
if (manager->priv->mm_object != NULL)
|
|
|
8c8af5 |
return;
|
|
|
8c8af5 |
|
|
|
8c8af5 |
g_debug ("New modem '%s'", mm_object_get_path (mm_object));
|
|
|
8c8af5 |
+ mm_modem = mm_object_get_modem (mm_object);
|
|
|
8c8af5 |
+ if (mm_modem_get_state (mm_modem) < MM_MODEM_STATE_ENABLED) {
|
|
|
8c8af5 |
+ g_debug ("Modem '%s' not enabled",
|
|
|
8c8af5 |
+ mm_object_get_path (mm_object));
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ g_signal_connect_object (mm_modem,
|
|
|
8c8af5 |
+ "notify::state",
|
|
|
8c8af5 |
+ G_CALLBACK (on_mm_modem_state_notify),
|
|
|
8c8af5 |
+ manager,
|
|
|
8c8af5 |
+ 0);
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
+ return;
|
|
|
8c8af5 |
+ }
|
|
|
8c8af5 |
+
|
|
|
8c8af5 |
modem_location = mm_object_peek_modem_location (mm_object);
|
|
|
8c8af5 |
if (modem_location == NULL)
|
|
|
8c8af5 |
return;
|
|
|
8c8af5 |
@@ -502,7 +558,7 @@ on_mm_object_added (GDBusObjectManager *object_manager,
|
|
|
8c8af5 |
mm_object_get_path (mm_object));
|
|
|
8c8af5 |
|
|
|
8c8af5 |
manager->priv->mm_object = g_object_ref (mm_object);
|
|
|
8c8af5 |
- manager->priv->modem = mm_object_get_modem (mm_object);
|
|
|
8c8af5 |
+ manager->priv->modem = mm_modem;
|
|
|
8c8af5 |
manager->priv->modem_location = mm_object_get_modem_location (mm_object);
|
|
|
8c8af5 |
|
|
|
8c8af5 |
g_signal_connect (G_OBJECT (manager->priv->modem_location),
|
|
|
8c8af5 |
--
|
|
|
8c8af5 |
2.1.0
|
|
|
8c8af5 |
|