summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-01-07 18:19:54 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-01-08 12:12:08 +0000
commit8a6535c1c238108fc8173e2337ca0c7d000d32e4 (patch)
treeef6f96c4b996b5eecd91bdb275141135165d95aa
parente962d639f9769b23288b73b38ec2721558e072d9 (diff)
tp_contact_get_alias: prefer names from Names, falling back to legacy alias
Also adjust the change-notification accordingly. This effectively repurposes get_alias as "I don't care where it came from, just give me some way to talk about this contact", which in practice is what Aliasing always meant.
-rw-r--r--telepathy-glib/contact.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 19716287e..5531bb048 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -402,6 +402,12 @@ tp_contact_get_alias (TpContact *self)
* code */
g_return_val_if_fail (self->priv->identifier != NULL, NULL);
+ if (self->priv->local_alias != NULL)
+ return self->priv->local_alias;
+
+ if (self->priv->nickname != NULL)
+ return self->priv->nickname;
+
if (self->priv->alias != NULL)
return self->priv->alias;
@@ -1145,9 +1151,14 @@ tp_contact_class_init (TpContactClass *klass)
/**
* TpContact:alias:
*
- * The contact's alias if available, falling back to their
- * #TpContact:identifier if no alias is available or if the #TpContact has
- * not been set up to track %TP_CONTACT_FEATURE_ALIAS.
+ * A displayable name for the contact. This the #TpContact:local-alias,
+ * if not %NULL; or the #TpContact:nickname, if not %NULL; or the older
+ * Telepathy "alias", which could mean either of those; or the
+ * #TpContact:identifier if none of those is available.
+ *
+ * If the #TpContact has not been set up to track %TP_CONTACT_FEATURE_NAMES
+ * or %TP_CONTACT_FEATURE_ALIAS, none of the better sources will be
+ * available, so the #TpContact:identifier will always be used.
*
* This alias may have been supplied by the contact themselves, or by the
* local user, so it does not necessarily unambiguously identify the contact.
@@ -2424,7 +2435,12 @@ contact_maybe_set_alias (TpContact *contact,
contact->priv->identifier, contact->priv->alias, alias);
g_free (contact->priv->alias);
contact->priv->alias = g_strdup (alias);
- g_object_notify ((GObject *) contact, "alias");
+
+ /* A change to the legacy alias only changes the alias property
+ * if we have nothing better. */
+ if (contact->priv->local_alias == NULL &&
+ contact->priv->nickname == NULL)
+ g_object_notify ((GObject *) contact, "alias");
}
}
@@ -2460,6 +2476,10 @@ contact_maybe_set_nickname (TpContact *contact,
g_free (contact->priv->nickname);
contact->priv->nickname = g_strdup (nickname);
g_object_notify ((GObject *) contact, "nickname");
+
+ /* If we don't have a local-alias, nickname is the next best thing. */
+ if (contact->priv->local_alias == NULL)
+ g_object_notify ((GObject *) contact, "alias");
}
}
@@ -2495,6 +2515,7 @@ contact_maybe_set_local_alias (TpContact *contact,
g_free (contact->priv->local_alias);
contact->priv->local_alias = g_strdup (local_alias);
g_object_notify ((GObject *) contact, "local-alias");
+ g_object_notify ((GObject *) contact, "alias");
}
}