summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-05-11 16:03:43 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-05-12 09:45:29 +0100
commitd8235e54477ea27dd8a0471d1522eacd3a1732d7 (patch)
tree22e3f811ce77574a9a85902466a0686a37d4e605
parente266f28db961d3026404c72b21a6b6071a2d4e3d (diff)
text-channel: use the TpContact we've already prepared for received messagesohhai
We've already prepared the remote contact with all the features we want so let's not use the TpContact that TpSignalledMessage gives us as that might not be prepared with everything we want, like the alias. We can obviously only do this in the non-chatroom case. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-logger/text-channel.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/telepathy-logger/text-channel.c b/telepathy-logger/text-channel.c
index a2c7f5e..d777553 100644
--- a/telepathy-logger/text-channel.c
+++ b/telepathy-logger/text-channel.c
@@ -445,13 +445,38 @@ on_message_received_cb (TpTextChannel *text_chan,
TplEntity *sender;
if (priv->is_chatroom)
- receiver = priv->remote;
+ {
+ receiver = priv->remote;
+
+ sender = tpl_entity_new_from_tp_contact (
+ tp_signalled_message_get_sender (TP_MESSAGE (message)),
+ TPL_ENTITY_CONTACT);
+ }
else
- receiver = priv->self;
+ {
+ const gchar *sender_nick;
+
+ /* First try and get the sender-nickname from the message
+ * headers. If it's there then create a contact entity to get
+ * its alias. If not then just use the contact we've already
+ * prepared and got an alias for. */
+ sender_nick = tp_asv_get_string (tp_message_peek (TP_MESSAGE (message), 0),
+ "sender-nickname");
+
+ if (sender_nick == NULL)
+ {
+ /* Fall back to the contact we prepared ages ago. */
+ sender = g_object_ref (priv->remote);
+ }
+ else
+ {
+ /* Use sender-nickname. */
+ sender = tpl_entity_new (tpl_entity_get_identifier (priv->remote),
+ TPL_ENTITY_CONTACT, sender_nick, NULL);
+ }
- sender = tpl_entity_new_from_tp_contact (
- tp_signalled_message_get_sender (TP_MESSAGE (message)),
- TPL_ENTITY_CONTACT);
+ receiver = priv->self;
+ }
tpl_text_channel_store_message (self, TP_MESSAGE (message),
sender, receiver);