about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-12-21 20:55:58 +0000
committerJames Booth <boothj5@gmail.com>2014-12-21 20:55:58 +0000
commitd41ac71d276bbeb38192ee635cb10eda4fdfbf69 (patch)
treeb7709498df6da602c4d45dedcb12a01be7d7d5a8 /src
parent9a322a028f6c7d9a6b0b142ca9c4540e3f2082da (diff)
downloadprofani-tty-d41ac71d276bbeb38192ee635cb10eda4fdfbf69.tar.gz
Tidy titlebar.c
Diffstat (limited to 'src')
-rw-r--r--src/ui/titlebar.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index c4f4e772..36bde009 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -59,8 +59,8 @@ static gboolean typing;
 static GTimer *typing_elapsed;
 
 static void _title_bar_draw(void);
-static void _show_contact_presence(void);
 static void _show_self_presence(void);
+static void _show_contact_presence(ProfChatWin *chatwin);
 #ifdef HAVE_LIBOTR
 static void _show_privacy(ProfChatWin *chatwin);
 #endif
@@ -182,17 +182,21 @@ _title_bar_draw(void)
     mvwprintw(win, 0, 0, " %s", current_title);
 
     if (current && current->type == WIN_CHAT) {
-        ProfChatWin *chatwin = (ProfChatWin*)current;
+        ProfChatWin *chatwin = (ProfChatWin*) current;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
-        _show_contact_presence();
+        _show_contact_presence(chatwin);
+
 #ifdef HAVE_LIBOTR
         _show_privacy(chatwin);
 #endif
+
         if (typing) {
             wprintw(win, " (typing...)");
         }
     } else if (current && current->type == WIN_MUC_CONFIG) {
-        if (win_has_modified_form(current)) {
+        ProfMucConfWin *confwin = (ProfMucConfWin*) current;
+        assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
+        if (confwin->form->modified) {
             wprintw(win, " *");
         }
     }
@@ -321,13 +325,10 @@ _show_privacy(ProfChatWin *chatwin)
 #endif
 
 static void
-_show_contact_presence(void)
+_show_contact_presence(ProfChatWin *chatwin)
 {
     int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
-
-    ProfWin *current = wins_get_current();
-    ProfChatWin *chatwin = (ProfChatWin*)current;
-    if (current && win_has_chat_resource(current)) {
+    if (chatwin && chatwin->resource) {
         wprintw(win, "/");
         wprintw(win, chatwin->resource);
     }
@@ -336,24 +337,15 @@ _show_contact_presence(void)
         theme_item_t presence_colour = THEME_TITLE_OFFLINE;
         const char *presence = "offline";
 
-        if (current && win_has_chat_resource(current)) {
-            char *barejid = roster_barejid_from_name(current_recipient);
-            if (barejid) {
-                PContact contact = roster_get_contact(barejid);
-                if (contact) {
-                    Resource *resource = p_contact_get_resource(contact, chatwin->resource);
-                    if (resource) {
-                        presence = string_from_resource_presence(resource->presence);
-                    }
-                }
-            }
-        } else {
-            char *barejid = roster_barejid_from_name(current_recipient);
-            if (barejid) {
-                PContact contact = roster_get_contact(barejid);
-                if (contact) {
-                    presence = p_contact_presence(contact);
+        PContact contact = roster_get_contact(chatwin->barejid);
+        if (contact) {
+            if (chatwin && chatwin->resource) {
+                Resource *resource = p_contact_get_resource(contact, chatwin->resource);
+                if (resource) {
+                    presence = string_from_resource_presence(resource->presence);
                 }
+            } else {
+                presence = p_contact_presence(contact);
             }
         }