[polari/wip/fmuellner/log-highlighting: 1/6] room: Set self-nick in the offline case



commit ff00520981675111076bef68e11cc1ea94e08a65
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 9 02:49:17 2016 +0200

    room: Set self-nick in the offline case
    
    We keep track of the connection's self-contact property to set
    the nick we use to decide whether a particular message should be
    highlighted. Obviously this can only work while we are connected,
    so if we want to also start highlighting messages that are loaded
    while disconnected, we need to use a different property to match
    messages against - the account's nickname is probably the best we
    have in this case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768613

 src/lib/polari-room.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/lib/polari-room.c b/src/lib/polari-room.c
index 17045a8..0f977dc 100644
--- a/src/lib/polari-room.c
+++ b/src/lib/polari-room.c
@@ -248,20 +248,27 @@ strip_color_codes (const char *string) {
 static void
 update_self_nick (PolariRoom *room)
 {
-  TpConnection *conn;
-  TpContact *self;
-
   PolariRoomPrivate *priv = room->priv;
+  const char *nick;
 
   g_clear_pointer (&priv->self_nick, g_free);
 
-  if (!room->priv->channel)
-    return;
+  if (priv->channel)
+    {
+      TpConnection *conn;
+      TpContact *self;
 
-  conn = tp_channel_get_connection (room->priv->channel);
-  self = tp_connection_get_self_contact (conn);
+      conn = tp_channel_get_connection (priv->channel);
+      self = tp_connection_get_self_contact (conn);
 
-  priv->self_nick = polari_util_get_basenick (tp_contact_get_alias (self));
+      nick = polari_util_get_basenick (tp_contact_get_alias (self));
+    }
+  else
+    {
+      nick = tp_account_get_nickname (priv->account);
+    }
+
+  priv->self_nick = polari_util_get_basenick (nick);
 }
 
 static void
@@ -476,6 +483,8 @@ polari_room_set_account (PolariRoom *room,
 
   if (g_set_object (&priv->account, account))
     g_object_notify_by_pspec (G_OBJECT (room), props[PROP_ACCOUNT]);
+
+  update_self_nick (room);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]