telepathy-mission-control: Unify loading of new accounts

Simon McVittie smcv at kemper.freedesktop.org
Thu Oct 4 08:19:47 PDT 2012


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

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu Sep  6 12:16:36 2012 +0100

Unify loading of new accounts

Rather than having both the AM and McdStorage know how to load a new
account, it's better to give the McdStorage a method to do it. This way,
when it gets more complicated, we only need to change one place.

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>

---

 src/mcd-account-manager.c |    6 ++----
 src/mcd-storage.c         |   19 +++++++++++++++++--
 src/mcd-storage.h         |    4 ++++
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 0cc0b6d..0f99508 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -338,16 +338,14 @@ created_cb (GObject *storage_plugin_obj,
     lad->account_lock = 1; /* will be released at the end of this function */
 
     /* actually fetch the data into our cache from the plugin: */
-    if (mcp_account_storage_get (plugin, MCP_ACCOUNT_MANAGER (storage),
-                                 name, NULL))
+    if (mcd_storage_add_account_from_plugin (storage, plugin, name))
     {
         account = mcd_account_new (am, name);
         lad->account = account;
     }
     else
     {
-        g_warning ("plugin %s disowned its own new account %s",
-                   mcp_account_storage_name (plugin), name);
+        /* that function already warned about it */
         goto finish;
     }
 
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index ef02375..6ae93c8 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -390,8 +390,7 @@ mcd_storage_load (McdStorage *self)
           gchar *name = account->data;
 
           DEBUG ("fetching %s from plugin %s [prio: %d]", name, pname, prio);
-          mcp_account_storage_get (plugin, ma, name, NULL);
-
+          mcd_storage_add_account_from_plugin (self, plugin, name);
           g_free (name);
         }
 
@@ -1300,3 +1299,19 @@ plugin_iface_init (McpAccountManagerIface *iface,
   iface->unique_name = unique_name;
   iface->list_keys = list_keys;
 }
+
+gboolean
+mcd_storage_add_account_from_plugin (McdStorage *self,
+    McpAccountStorage *plugin,
+    const gchar *account)
+{
+  if (!mcp_account_storage_get (plugin, MCP_ACCOUNT_MANAGER (self),
+      account, NULL))
+    {
+      g_warning ("plugin %s disowned account %s",
+                 mcp_account_storage_name (plugin), account);
+      return FALSE;
+    }
+
+  return TRUE;
+}
diff --git a/src/mcd-storage.h b/src/mcd-storage.h
index b2f9566..619e7b6 100644
--- a/src/mcd-storage.h
+++ b/src/mcd-storage.h
@@ -122,6 +122,10 @@ McpAccountStorage * mcd_storage_get_plugin (McdStorage *storage,
 
 G_GNUC_INTERNAL void _mcd_storage_store_connections (McdStorage *storage);
 
+gboolean mcd_storage_add_account_from_plugin (McdStorage *storage,
+    McpAccountStorage *plugin,
+    const gchar *account);
+
 G_END_DECLS
 
 #endif /* MCD_STORAGE_H */



More information about the telepathy-commits mailing list