aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-06-22 00:53:07 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-07-05 00:50:21 +0800
commit858a4d27abd2f040d44eaeda17f618a1a63b1631 (patch)
tree536e016b2b4aa3ffe8dbfb4e755d4f94d4831fc3 /libempathy
parent247f9a497a9dee8eb62d08cb161b9a5e1d7a6562 (diff)
downloadgsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar.gz
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar.bz2
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar.lz
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar.xz
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.tar.zst
gsoc2013-empathy-858a4d27abd2f040d44eaeda17f618a1a63b1631.zip
empathy_contact_from_tpl_contact: don't override the alias
Add a logged-alias property instead, which can be used by those who need the old alias. And use it in chat themes for the backlog.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c45
-rw-r--r--libempathy/empathy-contact.h1
2 files changed, 35 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)
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index b32971a3f..cb8f5a660 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -77,6 +77,7 @@ EmpathyContact * empathy_contact_from_tpl_contact (TpAccount *account,
TpContact * empathy_contact_get_tp_contact (EmpathyContact *contact);
const gchar * empathy_contact_get_id (EmpathyContact *contact);
const gchar * empathy_contact_get_alias (EmpathyContact *contact);
+const gchar * empathy_contact_get_logged_alias (EmpathyContact *contact);
void empathy_contact_set_alias (EmpathyContact *contact, const gchar *alias);
void empathy_contact_change_group (EmpathyContact *contact, const gchar *group,
gboolean is_member);