diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-06-22 00:53:07 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-07-05 00:50:21 +0800 |
commit | 858a4d27abd2f040d44eaeda17f618a1a63b1631 (patch) | |
tree | 536e016b2b4aa3ffe8dbfb4e755d4f94d4831fc3 | |
parent | 247f9a497a9dee8eb62d08cb161b9a5e1d7a6562 (diff) | |
download | gsoc2013-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.
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-boxes.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-irc.c | 4 | ||||
-rw-r--r-- | libempathy/empathy-contact.c | 45 | ||||
-rw-r--r-- | libempathy/empathy-contact.h | 1 |
5 files changed, 40 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index bb2b189ca..de9716960 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -897,7 +897,7 @@ theme_adium_append_message (EmpathyChatView *view, body_escaped = theme_adium_parse_body (theme, empathy_message_get_body (msg), empathy_message_get_token (msg)); - name = empathy_contact_get_alias (sender); + name = empathy_contact_get_logged_alias (sender); contact_id = empathy_contact_get_id (sender); action = (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION); diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c index c0377b6ae..7bfc313e1 100644 --- a/libempathy-gtk/empathy-theme-boxes.c +++ b/libempathy-gtk/empathy-theme-boxes.c @@ -206,7 +206,7 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme, gboolean consecutive; contact = empathy_message_get_sender (msg); - name = empathy_contact_get_alias (contact); + name = empathy_contact_get_logged_alias (contact); last_contact = empathy_chat_text_view_get_last_contact (view); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme)); time_ = empathy_message_get_timestamp (msg); @@ -349,7 +349,7 @@ theme_boxes_append_message (EmpathyChatTextView *view, gchar *body; body = g_strdup_printf (" * %s %s", - empathy_contact_get_alias (sender), + empathy_contact_get_logged_alias (sender), empathy_message_get_body (message)); empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view), body, diff --git a/libempathy-gtk/empathy-theme-irc.c b/libempathy-gtk/empathy-theme-irc.c index afd59523e..2ee81a23e 100644 --- a/libempathy-gtk/empathy-theme-irc.c +++ b/libempathy-gtk/empathy-theme-irc.c @@ -62,11 +62,11 @@ theme_irc_append_message (EmpathyChatTextView *view, buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); contact = empathy_message_get_sender (message); - name = empathy_contact_get_alias (contact); + name = empathy_contact_get_logged_alias (contact); if (empathy_message_get_tptype (message) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) { tmp = g_strdup_printf (" * %s %s", - empathy_contact_get_alias (contact), + empathy_contact_get_logged_alias (contact), empathy_message_get_body (message)); empathy_chat_text_view_append_body (view, tmp, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION); 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); |