diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-30 15:13:15 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-02-03 16:29:06 +0000 |
commit | d0c0da1d87363a6e823ec8749272d1746c0e2f16 (patch) | |
tree | 8466e423429cc5b813fd46952cd63d14e5038914 | |
parent | 7ca3067a53540caf20b752f7ceb76eeb5fcffc91 (diff) |
mcd_account_dup_protocol: factor out
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r-- | src/mcd-account.c | 51 |
1 files 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, |