about summary refs log tree commit diff stats
path: root/src/ui/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/core.c')
-rw-r--r--src/ui/core.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 5f55b423..6cac05b9 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -2714,6 +2714,72 @@ _ui_show_lines(ProfWin *window, const gchar** lines)
 }
 
 static void
+_ui_muc_roster(const char * const room)
+{
+    ProfWin *window = wins_get_by_recipient(room);
+    if (room) {
+        GList *roster = muc_roster(room);
+        if (roster) {
+            werase(window->subwin);
+
+            wattron(window->subwin, COLOUR_ROOMINFO);
+            wprintw(window->subwin, " -Moderators\n");
+            wattroff(window->subwin, COLOUR_ROOMINFO);
+            GList *roster_curr = roster;
+            while (roster_curr) {
+                Occupant *occupant = roster_curr->data;
+                if (occupant->role == MUC_ROLE_MODERATOR) {
+                    wprintw(window->subwin, "   ");
+                    const char *presence_str = string_from_resource_presence(occupant->presence);
+                    int presence_colour = win_presence_colour(presence_str);
+                    wattron(window->subwin, presence_colour);
+                    wprintw(window->subwin, occupant->nick);
+                    wattroff(window->subwin, presence_colour);
+                    wprintw(window->subwin, "\n");
+                }
+                roster_curr = g_list_next(roster_curr);
+            }
+
+            wattron(window->subwin, COLOUR_ROOMINFO);
+            wprintw(window->subwin, " -Participants\n");
+            wattroff(window->subwin, COLOUR_ROOMINFO);
+            roster_curr = roster;
+            while (roster_curr) {
+                Occupant *occupant = roster_curr->data;
+                if (occupant->role == MUC_ROLE_PARTICIPANT) {
+                    wprintw(window->subwin, "   ");
+                    const char *presence_str = string_from_resource_presence(occupant->presence);
+                    int presence_colour = win_presence_colour(presence_str);
+                    wattron(window->subwin, presence_colour);
+                    wprintw(window->subwin, occupant->nick);
+                    wattroff(window->subwin, presence_colour);
+                    wprintw(window->subwin, "\n");
+                }
+                roster_curr = g_list_next(roster_curr);
+            }
+
+            wattron(window->subwin, COLOUR_ROOMINFO);
+            wprintw(window->subwin, " -Visitors\n");
+            wattroff(window->subwin, COLOUR_ROOMINFO);
+            roster_curr = roster;
+            while (roster_curr) {
+                Occupant *occupant = roster_curr->data;
+                if (occupant->role == MUC_ROLE_VISITOR) {
+                    wprintw(window->subwin, "   ");
+                    const char *presence_str = string_from_resource_presence(occupant->presence);
+                    int presence_colour = win_presence_colour(presence_str);
+                    wattron(window->subwin, presence_colour);
+                    wprintw(window->subwin, occupant->nick);
+                    wattroff(window->subwin, presence_colour);
+                    wprintw(window->subwin, "\n");
+                }
+                roster_curr = g_list_next(roster_curr);
+            }
+        }
+    }
+}
+
+static void
 _win_handle_switch(const wint_t * const ch)
 {
     if (*ch == KEY_F(1)) {
@@ -2980,5 +3046,6 @@ ui_init_module(void)
     ui_handle_room_role_set = _ui_handle_room_role_set;
     ui_handle_room_role_list_error = _ui_handle_room_role_list_error;
     ui_handle_room_role_list = _ui_handle_room_role_list;
+    ui_muc_roster = _ui_muc_roster;
 }