diff options
author | James Booth <boothj5@gmail.com> | 2014-11-10 00:31:11 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-11-10 00:31:11 +0000 |
commit | 36331e490829518974b58ead719588d9fefc9fee (patch) | |
tree | e22b355d081ee3b2dad4ea81c71d7b90f9fc745b | |
parent | eed8f6c76d1b7992c10ea7db380e1de5ff7e06ec (diff) | |
download | profani-tty-36331e490829518974b58ead719588d9fefc9fee.tar.gz |
Added simple roster
-rw-r--r-- | src/server_events.c | 4 | ||||
-rw-r--r-- | src/ui/core.c | 29 | ||||
-rw-r--r-- | src/ui/ui.h | 1 |
3 files changed, 34 insertions, 0 deletions
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 @@ -2805,6 +2805,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) { ProfWin *window = wins_get_by_recipient(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, ...); |