From 36331e490829518974b58ead719588d9fefc9fee Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 10 Nov 2014 00:31:11 +0000 Subject: [PATCH] Added simple roster --- src/server_events.c | 4 ++++ src/ui/core.c | 29 +++++++++++++++++++++++++++++ src/ui/ui.h | 1 + 3 files changed, 34 insertions(+) diff --git a/src/server_events.c b/src/server_events.c index 01281215..5e40ec42 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -454,6 +454,8 @@ handle_contact_offline(char *barejid, char *resource, char *status) prefs_free_string(show_chat_win); jid_destroy(jid); } + + ui_roster(); } void @@ -494,6 +496,8 @@ handle_contact_online(char *barejid, Resource *resource, prefs_free_string(show_console); prefs_free_string(show_chat_win); } + + ui_roster(); } void diff --git a/src/ui/core.c b/src/ui/core.c index 4f88c294..31575e67 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2804,6 +2804,34 @@ _ui_show_lines(ProfWin *window, const gchar** lines) } } +static void +_ui_roster(void) +{ + ProfWin *window = wins_get_console(); + if (window) { + GSList *contacts = roster_get_contacts(); + if (contacts) { + werase(window->subwin); + wattron(window->subwin, COLOUR_ROOMINFO); + wprintw(window->subwin, " -Roster\n"); + wattroff(window->subwin, COLOUR_ROOMINFO); + GSList *curr = contacts; + while (curr) { + PContact contact = curr->data; + const char *name = p_contact_name_or_jid(contact); + const char *presence = p_contact_presence(contact); + int presence_colour = win_presence_colour(presence); + + wattron(window->subwin, presence_colour); + wprintw(window->subwin, " %s\n", name); + wattroff(window->subwin, presence_colour); + curr = g_slist_next(curr); + } + } + g_slist_free(contacts); + } +} + static void _ui_muc_roster(const char * const room) { @@ -3212,6 +3240,7 @@ ui_init_module(void) 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; + ui_roster = _ui_roster; ui_room_show_occupants = _ui_room_show_occupants; ui_room_hide_occupants = _ui_room_hide_occupants; ui_room_role_change = _ui_room_role_change; diff --git a/src/ui/ui.h b/src/ui/ui.h index 4c5c7013..a2e7e67b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -246,6 +246,7 @@ void (*ui_open_xmlconsole_win)(void); gboolean (*ui_win_has_unsaved_form)(int num); void (*ui_muc_roster)(const char * const room); +void (*ui_roster)(void); // console window actions void (*cons_show)(const char * const msg, ...);