diff options
author | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2014-04-15 20:17:07 +0100 |
---|---|---|
committer | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2014-04-15 20:17:07 +0100 |
commit | 3d4c1e4e419ba71508692f58f3fad3e0882aeba6 (patch) | |
tree | a44d1f7dc6b00e026fe5ea0caff8972d96e9c0b1 | |
parent | f7685da235cc9a4795f81ccfeff5e8856877b320 (diff) |
modem-source: Separate cancellable for start/stop
Use a separate cancellable for operations related to starting and
stopping the source.
-rw-r--r-- | src/gclue-modem-source.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/gclue-modem-source.c b/src/gclue-modem-source.c index ad4dbf7..4a4968d 100644 --- a/src/gclue-modem-source.c +++ b/src/gclue-modem-source.c @@ -46,6 +46,7 @@ struct _GClueModemSourcePrivate { MMModemLocation *modem_location; GCancellable *cancellable; + GCancellable *active_cancellable; }; static void @@ -173,7 +174,7 @@ on_modem_enabled (GObject *source_object, mm_modem_location_setup (priv->modem_location, caps, TRUE, - priv->cancellable, + priv->active_cancellable, on_modem_location_setup, user_data); } @@ -194,8 +195,9 @@ gclue_modem_source_start (GClueLocationSource *source) if (priv->modem == NULL) return FALSE; + priv->active_cancellable = g_cancellable_new (); mm_modem_enable (priv->modem, - priv->cancellable, + priv->active_cancellable, on_modem_enabled, source); return TRUE; @@ -219,6 +221,8 @@ gclue_modem_source_stop (GClueLocationSource *source) g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modem_location), G_CALLBACK (on_location_changed), source); + g_cancellable_cancel (priv->active_cancellable); + g_clear_object (&priv->active_cancellable); mm_modem_disable (priv->modem, NULL, @@ -297,11 +301,13 @@ on_mm_object_added (GDBusObjectManager *manager, source->priv->modem = mm_object_get_modem (mm_object); source->priv->modem_location = mm_object_get_modem_location (mm_object); - if (gclue_location_source_get_active (GCLUE_LOCATION_SOURCE (source))) + if (gclue_location_source_get_active (GCLUE_LOCATION_SOURCE (source))) { + source->priv->active_cancellable = g_cancellable_new (); mm_modem_enable (source->priv->modem, - source->priv->cancellable, + source->priv->active_cancellable, on_modem_enabled, user_data); + } refresh_accuracy_level (source); } |