summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-02-21 11:02:42 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-02-21 15:08:13 +0000
commit349fa2e017d7c7caa5a9a4987979fdae64f10d87 (patch)
tree9db845d7e7ee83945742713c327c544872705e36
parent18e48707de894057f30936ca86cddd304da4e48f (diff)
downloadtelepathy-mission-control-5.10.tar.gz
Account: don't crash on Get('Parameters') if _dup_parameters failstelepathy-mission-control-5.10
If the connection manager is not installed, or is installed but doesn't have the protocol for the account, then _mcd_account_dup_parameters() returns %NULL. (As the comment I've added says, I think this is ridiculous—it's fall-out from MC not storing the types of parameters.) As a result, Get('Parameters') or GetAll() would crash, because dbus-glib would try to serialize a NULL GHashTable and blow up. (See <https://bugs.freedesktop.org/show_bug.cgi?id=44939>.) So with this patch, we handle NULL as "no parameters" for the sake of D-Bus properties. (Because this situation should only arise if the account is invalid, we also warn if _dup_parameters() returns NULL for valid accounts.) Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--src/mcd-account.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c
index a0ddf898..eab3c959 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -1397,6 +1397,15 @@ get_parameters (TpSvcDBusProperties *self, const gchar *name,
McdAccount *account = MCD_ACCOUNT (self);
GHashTable *params = _mcd_account_dup_parameters (account);
+ if (params == NULL)
+ {
+ if (mcd_account_is_valid (account))
+ g_warning ("%s is supposedly valid, but _dup_parameters() failed!",
+ mcd_account_get_unique_name (account));
+
+ params = tp_asv_new (NULL, NULL);
+ }
+
g_value_init (value, TP_HASH_TYPE_STRING_VARIANT_MAP);
g_value_take_boxed (value, params);
}
@@ -3228,6 +3237,14 @@ _mcd_account_dup_parameters (McdAccount *account)
priv = account->priv;
DEBUG ("called");
+
+ /* FIXME: this is ridiculous. MC stores the parameters for the account, so
+ * it should be able to expose them on D-Bus even if the CM is uninstalled.
+ * It shouldn't need to iterate across the parameters supported by the CM.
+ * But it does, because MC doesn't store the types of parameters. So it
+ * 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);