diff options
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r-- | libempathy/empathy-tp-chat.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 96eda77b8..4e26a769b 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -51,6 +51,7 @@ struct _EmpathyTpChatPrivate { gboolean supports_subject; gboolean can_set_subject; gchar *subject; + gchar *subject_actor; /* Room config (for now, we only track the title and don't support * setting it) */ @@ -69,6 +70,7 @@ static void tp_chat_iface_init (EmpathyContactListIface *iface); enum { PROP_0, PROP_ACCOUNT, + PROP_SELF_CONTACT, PROP_REMOTE_CONTACT, PROP_N_MESSAGES_SENDING, PROP_TITLE, @@ -608,12 +610,26 @@ update_subject (EmpathyTpChat *self, subject = tp_asv_get_string (properties, "Subject"); if (subject != NULL) { + const gchar *actor; + g_free (priv->subject); priv->subject = g_strdup (subject); + + /* If the actor is included with this update, use it; + * otherwise, clear it to avoid showing stale information. + * Why might it not be included? When you join an IRC channel, + * you get a pair of messages: first, the current topic; next, + * who set it, and when. Idle reports these in two separate + * signals. + */ + actor = tp_asv_get_string (properties, "Actor"); + g_free (priv->subject_actor); + priv->subject_actor = g_strdup (actor); + g_object_notify (G_OBJECT (self), "subject"); } - /* TODO: track Actor and Timestamp. */ + /* TODO: track Timestamp. */ } static void @@ -732,6 +748,14 @@ empathy_tp_chat_get_subject (EmpathyTpChat *self) return priv->subject; } +const gchar * +empathy_tp_chat_get_subject_actor (EmpathyTpChat *self) +{ + EmpathyTpChatPrivate *priv = self->priv; + + return priv->subject_actor; +} + static void tp_chat_dispose (GObject *object) { @@ -767,6 +791,7 @@ tp_chat_finalize (GObject *object) g_free (self->priv->title); g_free (self->priv->subject); + g_free (self->priv->subject_actor); G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object); } @@ -948,6 +973,7 @@ tp_chat_got_renamed_contacts_cb (TpConnection *connection, /* We change our nick */ tp_clear_object (&self->priv->user); self->priv->user = g_object_ref (new); + g_object_notify (chat, "self-contact"); } check_almost_ready (self); @@ -1068,6 +1094,7 @@ tp_chat_got_self_contact_cb (TpConnection *connection, self->priv->user = g_object_ref (contact); empathy_contact_set_is_user (self->priv->user, TRUE); + g_object_notify (chat, "self-contact"); check_almost_ready (self); } @@ -1083,6 +1110,9 @@ tp_chat_get_property (GObject *object, case PROP_ACCOUNT: g_value_set_object (value, self->priv->account); break; + case PROP_SELF_CONTACT: + g_value_set_object (value, self->priv->user); + break; case PROP_REMOTE_CONTACT: g_value_set_object (value, self->priv->remote_contact); break; @@ -1171,6 +1201,19 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + /** + * EmpathyTpChat:self-contact: + * + * Not to be confused with TpChannel:group-self-contact. + */ + g_object_class_install_property (object_class, + PROP_SELF_CONTACT, + g_param_spec_object ("self-contact", + "The local contact", + "The EmpathyContact for the local user on this channel", + EMPATHY_TYPE_CONTACT, + G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_REMOTE_CONTACT, g_param_spec_object ("remote-contact", |