From d0c0da1d87363a6e823ec8749272d1746c0e2f16 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 30 Jan 2014 15:13:15 +0000 Subject: mcd_account_dup_protocol: factor out Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093 Reviewed-by: Guillaume Desmottes --- 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 8e6cf5e4..6af1741d 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, -- cgit v1.2.3