summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-09-06 12:16:36 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-09-07 17:50:09 +0100
commit5ca771a0a76ef6fc41aba893bf3d100cda03a618 (patch)
tree430d016e3bd2b8a523f64d45ed9fd6827211b54f
parentbf70a86c39902ccf4fdad8aec1be1bbcc661d148 (diff)
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@collabora.co.uk>
-rw-r--r--src/mcd-account-manager.c6
-rw-r--r--src/mcd-storage.c19
-rw-r--r--src/mcd-storage.h4
3 files changed, 23 insertions, 6 deletions
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 0cc0b6d5..0f995089 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 ef023757..6ae93c80 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 b2f9566e..619e7b69 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 */