about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-01 23:41:45 +0000
committerJames Booth <boothj5@gmail.com>2015-11-01 23:41:45 +0000
commit8b4bb1c7f100590f015fddb55b31fe3d0ea10417 (patch)
treeae8a829719c1d49cb854cf97f34d2ad3909797a4 /src/ui
parentd21faa46097f9a4bfcef92c9355427c103beb549 (diff)
downloadprofani-tty-8b4bb1c7f100590f015fddb55b31fe3d0ea10417.tar.gz
mucwin_roster takes ProfMucWin
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/mucwin.c52
-rw-r--r--src/ui/ui.h2
2 files changed, 26 insertions, 28 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 279566ba..5edc6a8d 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -194,42 +194,40 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features)
 }
 
 void
-mucwin_roster(const char *const roomjid, GList *roster, const char *const presence)
+mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    if (window == NULL) {
-        log_error("Received room roster but no window open for %s.", roomjid);
+    assert(mucwin != NULL);
+
+    ProfWin *window = (ProfWin*)mucwin;
+    if ((roster == NULL) || (g_list_length(roster) == 0)) {
+        if (presence == NULL) {
+            win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
+        } else {
+            win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
+        }
     } else {
-        if ((roster == NULL) || (g_list_length(roster) == 0)) {
-            if (presence == NULL) {
-                win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
-            } else {
-                win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
-            }
+        int length = g_list_length(roster);
+        if (presence == NULL) {
+            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
         } else {
-            int length = g_list_length(roster);
-            if (presence == NULL) {
-                win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
-            } else {
-                win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
-            }
-
-            while (roster) {
-                Occupant *occupant = roster->data;
-                const char *presence_str = string_from_resource_presence(occupant->presence);
+            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
+        }
 
-                theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
-                win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
+        while (roster) {
+            Occupant *occupant = roster->data;
+            const char *presence_str = string_from_resource_presence(occupant->presence);
 
-                if (roster->next) {
-                    win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", ");
-                }
+            theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
+            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);
 
-                roster = g_list_next(roster);
+            if (roster->next) {
+                win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", ");
             }
-            win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", "");
 
+            roster = g_list_next(roster);
         }
+        win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", "");
+
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index c7f6ec2e..61cf8745 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -172,7 +172,7 @@ void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const ni
     const char *const affiliation, const char *const actor, const char *const reason);
 void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick,
     const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
-void mucwin_roster(const char *const roomjid, GList *occupants, const char *const presence);
+void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
 void mucwin_history(const char *const roomjid, const char *const nick, GDateTime *timestamp,
     const char *const message);
 void mucwin_message(const char *const roomjid, const char *const nick, const char *const message);