telepathy-mission-control: mcd_account_dup_protocol: factor out
Simon McVittie
smcv at kemper.freedesktop.org
Mon Feb 3 08:38:38 PST 2014
Module: telepathy-mission-control
Branch: master
Commit: d0c0da1d87363a6e823ec8749272d1746c0e2f16
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=d0c0da1d87363a6e823ec8749272d1746c0e2f16
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Thu Jan 30 15:13:15 2014 +0000
mcd_account_dup_protocol: factor out
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
---
src/mcd-account.c | 51 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 8e6cf5e..6af1741 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -3519,6 +3519,39 @@ mcd_account_is_valid (McdAccount *account)
return priv->invalid_reason == NULL;
}
+/*
+ * mcd_account_dup_protocol:
+ * @self: the account
+ *
+ * Returns: (transfer full): the account's connection manager's protocol,
+ * possibly %NULL if "not valid"
+ */
+static TpProtocol *
+mcd_account_dup_protocol (McdAccount *self)
+{
+ TpProtocol *protocol;
+
+ if (!self->priv->manager && !load_manager (self))
+ {
+ DEBUG ("unable to load manager for account %s",
+ self->priv->unique_name);
+ return NULL;
+ }
+
+ protocol = _mcd_manager_dup_protocol (self->priv->manager,
+ self->priv->protocol_name);
+
+ if (G_UNLIKELY (protocol == NULL))
+ {
+ DEBUG ("unable to get protocol for %s account %s",
+ self->priv->protocol_name,
+ self->priv->unique_name);
+ return NULL;
+ }
+
+ return protocol;
+}
+
/**
* mcd_account_is_enabled:
* @account: the #McdAccount.
@@ -3559,7 +3592,6 @@ mcd_account_get_object_path (McdAccount *account)
GHashTable *
_mcd_account_dup_parameters (McdAccount *account)
{
- McdAccountPrivate *priv;
TpProtocol *protocol;
GList *protocol_params;
GList *iter;
@@ -3567,8 +3599,6 @@ _mcd_account_dup_parameters (McdAccount *account)
g_return_val_if_fail (MCD_IS_ACCOUNT (account), NULL);
- priv = account->priv;
-
DEBUG ("called");
/* FIXME: this is ridiculous. MC stores the parameters for the account, so
@@ -3578,21 +3608,8 @@ _mcd_account_dup_parameters (McdAccount *account)
* needs the CM (or .manager file) to be around to tell it whether "true"
* is a string or a booleanâ¦
*/
- if (!priv->manager && !load_manager (account))
- {
- DEBUG ("unable to load manager for account %s", priv->unique_name);
- return NULL;
- }
-
- protocol = _mcd_manager_dup_protocol (priv->manager,
- priv->protocol_name);
- if (G_UNLIKELY (protocol == NULL))
- {
- DEBUG ("unable to get protocol for %s account %s", priv->protocol_name,
- priv->unique_name);
- return NULL;
- }
+ protocol = mcd_account_dup_protocol (account);
params = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
More information about the telepathy-commits
mailing list