telepathy-mission-control: McdAccount: have a reference to the connectivity monitor

Simon McVittie smcv at kemper.freedesktop.org
Wed Sep 4 05:38:35 PDT 2013


Module: telepathy-mission-control
Branch: master
Commit: e076d7f16e23cd7246a20a45164a71d9e53058af
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=e076d7f16e23cd7246a20a45164a71d9e53058af

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Sep  3 18:40:06 2013 +0100

McdAccount: have a reference to the connectivity monitor

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68712
Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>

---

 src/mcd-account-manager.c |    6 +++---
 src/mcd-account.c         |   32 +++++++++++++++++++++++++++++++-
 src/mcd-account.h         |    7 ++++++-
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 0dc5363..31329f3 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -342,7 +342,7 @@ created_cb (GObject *storage_plugin_obj,
     /* actually fetch the data into our cache from the plugin: */
     if (mcd_storage_add_account_from_plugin (storage, plugin, name))
     {
-        account = mcd_account_new (am, name);
+        account = mcd_account_new (am, name, priv->minotaur);
         lad->account = account;
     }
     else
@@ -925,7 +925,7 @@ _mcd_account_manager_create_account (McdAccountManager *account_manager,
         mcd_storage_set_string (storage, unique_name,
                                 MC_ACCOUNTS_KEY_DISPLAY_NAME, display_name);
 
-    account = mcd_account_new (account_manager, unique_name);
+    account = mcd_account_new (account_manager, unique_name, priv->minotaur);
     g_free (unique_name);
 
     if (G_LIKELY (account))
@@ -1444,7 +1444,7 @@ _mcd_account_manager_setup (McdAccountManager *account_manager)
             continue;
         }
 
-        account = mcd_account_new (account_manager, *name);
+        account = mcd_account_new (account_manager, *name, priv->minotaur);
 
         if (G_UNLIKELY (!account))
         {
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 012367f..0e31750 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -127,6 +127,7 @@ struct _McdAccountPrivate
 
     McdStorage *storage;
     TpDBusDaemon *dbus_daemon;
+    McdConnectivityMonitor *connectivity;
 
     McdAccountConnectionContext *connection_context;
     GKeyFile *keyfile;		/* configuration file */
@@ -190,6 +191,7 @@ enum
 {
     PROP_0,
     PROP_DBUS_DAEMON,
+    PROP_CONNECTIVITY_MONITOR,
     PROP_STORAGE,
     PROP_NAME,
     PROP_ALWAYS_ON,
@@ -3441,6 +3443,11 @@ set_property (GObject *obj, guint prop_id,
         priv->dbus_daemon = g_value_dup_object (val);
         break;
 
+      case PROP_CONNECTIVITY_MONITOR:
+        g_assert (priv->connectivity == NULL);
+        priv->connectivity = g_value_dup_object (val);
+        break;
+
     case PROP_NAME:
 	g_assert (priv->unique_name == NULL);
 	priv->unique_name = g_value_dup_string (val);
@@ -3479,6 +3486,11 @@ get_property (GObject *obj, guint prop_id,
     case PROP_DBUS_DAEMON:
         g_value_set_object (val, priv->dbus_daemon);
 	break;
+
+    case PROP_CONNECTIVITY_MONITOR:
+        g_value_set_object (val, priv->connectivity);
+        break;
+
     case PROP_NAME:
 	g_value_set_string (val, priv->unique_name);
 	break;
@@ -3559,6 +3571,7 @@ _mcd_account_dispose (GObject *object)
     tp_clear_object (&priv->storage);
     tp_clear_object (&priv->dbus_daemon);
     tp_clear_object (&priv->self_contact);
+    tp_clear_object (&priv->connectivity);
 
     _mcd_account_set_connection_context (self, NULL);
     _mcd_account_set_connection (self, NULL);
@@ -3635,6 +3648,14 @@ mcd_account_class_init (McdAccountClass * klass)
                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
     g_object_class_install_property
+        (object_class, PROP_CONNECTIVITY_MONITOR,
+         g_param_spec_object ("connectivity monitor",
+                              "Connectivity monitor",
+                              "Connectivity monitor",
+                              MCD_TYPE_CONNECTIVITY_MONITOR,
+                              G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+    g_object_class_install_property
         (object_class, PROP_STORAGE,
          g_param_spec_object ("storage", "storage",
                                "storage", MCD_TYPE_STORAGE,
@@ -3729,7 +3750,9 @@ mcd_account_init (McdAccount *account)
 }
 
 McdAccount *
-mcd_account_new (McdAccountManager *account_manager, const gchar *name)
+mcd_account_new (McdAccountManager *account_manager,
+    const gchar *name,
+    McdConnectivityMonitor *connectivity)
 {
     gpointer *obj;
     McdStorage *storage = mcd_account_manager_get_storage (account_manager);
@@ -3738,6 +3761,7 @@ mcd_account_new (McdAccountManager *account_manager, const gchar *name)
     obj = g_object_new (MCD_TYPE_ACCOUNT,
                         "storage", storage,
                         "dbus-daemon", dbus,
+                        "connectivity-monitor", connectivity,
 			"name", name,
 			NULL);
     return MCD_ACCOUNT (obj);
@@ -5132,3 +5156,9 @@ mcd_account_dup_nickname (McdAccount *self)
 
     return mcd_storage_dup_string (self->priv->storage, name, "Nickname");
 }
+
+McdConnectivityMonitor *
+mcd_account_get_connectivity_monitor (McdAccount *self)
+{
+    return self->priv->connectivity;
+}
diff --git a/src/mcd-account.h b/src/mcd-account.h
index a213b91..e88e801 100644
--- a/src/mcd-account.h
+++ b/src/mcd-account.h
@@ -79,8 +79,10 @@ struct _McdAccountClass
 };
 
 GType mcd_account_get_type (void);
+
 McdAccount *mcd_account_new (McdAccountManager *account_manager,
-			     const gchar *name);
+    const gchar *name,
+    McdConnectivityMonitor *minotaur);
 
 void mcd_account_delete (McdAccount *account, McdAccountDeleteCb callback,
                          gpointer user_data);
@@ -145,6 +147,9 @@ gchar * mcd_account_dup_icon (McdAccount *self);
 
 gchar * mcd_account_dup_nickname (McdAccount *self);
 
+McdConnectivityMonitor *mcd_account_get_connectivity_monitor (
+    McdAccount *self);
+
 G_END_DECLS
 
 #endif



More information about the telepathy-commits mailing list