aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-contact.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy/empathy-contact.c')
-rw-r--r--libempathy/empathy-contact.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index c766857ee..ed7af6c38 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -56,6 +56,7 @@ typedef struct {
FolksPersona *persona;
gchar *id;
gchar *alias;
+ gchar *logged_alias;
EmpathyAvatar *avatar;
TpConnectionPresenceType presence;
guint handle;
@@ -109,6 +110,7 @@ enum
PROP_PERSONA,
PROP_ID,
PROP_ALIAS,
+ PROP_LOGGED_ALIAS,
PROP_AVATAR,
PROP_PRESENCE,
PROP_PRESENCE_MESSAGE,
@@ -318,6 +320,15 @@ empathy_contact_class_init (EmpathyContactClass *class)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
+ PROP_LOGGED_ALIAS,
+ g_param_spec_string ("logged-alias",
+ "Logged alias",
+ "The alias the user had when a message was logged, "
+ "only set when using empathy_contact_from_tpl_contact()",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
PROP_AVATAR,
g_param_spec_boxed ("avatar",
"Avatar image",
@@ -557,6 +568,9 @@ contact_get_property (GObject *object,
case PROP_ALIAS:
g_value_set_string (value, empathy_contact_get_alias (contact));
break;
+ case PROP_LOGGED_ALIAS:
+ g_value_set_string (value, empathy_contact_get_logged_alias (contact));
+ break;
case PROP_AVATAR:
g_value_set_boxed (value, empathy_contact_get_avatar (contact));
break;
@@ -608,6 +622,10 @@ contact_set_property (GObject *object,
case PROP_ALIAS:
empathy_contact_set_alias (contact, g_value_get_string (value));
break;
+ case PROP_LOGGED_ALIAS:
+ g_assert (priv->logged_alias == NULL);
+ priv->logged_alias = g_value_dup_string (value);
+ break;
case PROP_PRESENCE:
empathy_contact_set_presence (contact, g_value_get_uint (value));
break;
@@ -696,20 +714,10 @@ empathy_contact_from_tpl_contact (TpAccount *account,
if (existing_contact != NULL)
{
- EmpathyContactPriv *priv;
-
retval = g_object_new (EMPATHY_TYPE_CONTACT,
"tp-contact", empathy_contact_get_tp_contact (existing_contact),
+ "logged-alias", tpl_entity_get_alias (tpl_entity),
NULL);
-
- priv = GET_PRIV (retval);
-
- /* contact_set_property() calls empathy_contact_set_alias(), which
- * tries to set the alias on the FolksPersona, but we don't want to
- * do that when creating an EmpathyContact from a TplEntity. So just
- * set priv->alias instead of passing it to g_object_new() instead. */
- g_free (priv->alias);
- priv->alias = g_strdup (tpl_entity_get_alias (tpl_entity));
}
else
{
@@ -778,6 +786,21 @@ empathy_contact_get_alias (EmpathyContact *contact)
return empathy_contact_get_id (contact);
}
+const gchar *
+empathy_contact_get_logged_alias (EmpathyContact *contact)
+{
+ EmpathyContactPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ priv = GET_PRIV (contact);
+
+ if (priv->logged_alias != NULL)
+ return priv->logged_alias;
+ else
+ return empathy_contact_get_alias (contact);
+}
+
void
empathy_contact_set_alias (EmpathyContact *contact,
const gchar *alias)