diff options
author | James Booth <boothj5@gmail.com> | 2014-11-10 23:23:02 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-11-10 23:23:02 +0000 |
commit | 497b07c1c3563efdfc147b22bd8afd094caf619a (patch) | |
tree | 9dd060a249b450e24cbd2602301cecd4f75cb27e | |
parent | 5d59d17642848ddd8b969cb59b120a65b9d98241 (diff) | |
download | profani-tty-497b07c1c3563efdfc147b22bd8afd094caf619a.tar.gz |
Added /roster show|hide command, only show roster on connect success
-rw-r--r-- | src/command/command.c | 10 | ||||
-rw-r--r-- | src/command/commands.c | 12 | ||||
-rw-r--r-- | src/config/preferences.c | 14 | ||||
-rw-r--r-- | src/config/preferences.h | 4 | ||||
-rw-r--r-- | src/server_events.c | 4 | ||||
-rw-r--r-- | src/ui/console.c | 11 | ||||
-rw-r--r-- | src/ui/core.c | 21 | ||||
-rw-r--r-- | src/ui/ui.h | 3 | ||||
-rw-r--r-- | src/ui/window.c | 2 |
9 files changed, 77 insertions, 4 deletions
diff --git a/src/command/command.c b/src/command/command.c index 3300097f..a8b409d7 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -169,11 +169,13 @@ static struct cmd_t command_defs[] = { "/roster", cmd_roster, parse_args_with_freetext, 0, 3, NULL, - { "/roster [add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.", - { "/roster [add|remove|nick|clearnick] [jid] [nickname]", - "----------------------------------------------------", + { "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.", + { "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]", + "--------------------------------------------------------------", "View, add to, and remove from your roster.", "Passing no arguments lists all contacts in your roster.", + "The 'show' command will show the roster panel in the console window.", + "The 'hide' command will hide the roster panel.", "The 'add' command will add a new item, jid is required, nickname is optional.", "The 'remove' command removes a contact, jid is required.", "The 'nick' command changes a contacts nickname, both jid and nickname are required,", @@ -1230,6 +1232,8 @@ cmd_init(void) autocomplete_add(roster_ac, "nick"); autocomplete_add(roster_ac, "clearnick"); autocomplete_add(roster_ac, "remove"); + autocomplete_add(roster_ac, "show"); + autocomplete_add(roster_ac, "hide"); group_ac = autocomplete_new(); autocomplete_add(group_ac, "show"); diff --git a/src/command/commands.c b/src/command/commands.c index 98ebe90c..877b6857 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1330,6 +1330,18 @@ cmd_roster(gchar **args, struct cmd_help_t help) cons_show_roster(list); return TRUE; + // show/hide roster + } else if (g_strcmp0(args[0], "show") == 0) { + cons_show("Roster enabled."); + prefs_set_boolean(PREF_ROSTER, TRUE); + ui_show_roster(); + return TRUE; + } else if (g_strcmp0(args[0], "hide") == 0) { + cons_show("Roster disabled."); + prefs_set_boolean(PREF_ROSTER, FALSE); + ui_hide_roster(); + return TRUE; + // add contact } else if (strcmp(args[0], "add") == 0) { char *jid = args[1]; diff --git a/src/config/preferences.c b/src/config/preferences.c index 5b00efac..c5ec842e 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -453,6 +453,10 @@ _get_group(preference_t pref) case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: case PREF_WRAP: + case PREF_ROSTER: + case PREF_ROSTER_OFFLINE: + case PREF_ROSTER_RESOURCE: + case PREF_ROSTER_BY: return PREF_GROUP_UI; case PREF_STATES: case PREF_OUTTYPE: @@ -573,6 +577,14 @@ _get_key(preference_t pref) return "presence"; case PREF_WRAP: return "wrap"; + case PREF_ROSTER: + return "roster"; + case PREF_ROSTER_OFFLINE: + return "roster.offline"; + case PREF_ROSTER_RESOURCE: + return "roster.resource"; + case PREF_ROSTER_BY: + return "roster.by"; default: return NULL; } @@ -618,6 +630,8 @@ _get_default_string(preference_t pref) case PREF_STATUSES_CHAT: case PREF_STATUSES_MUC: return "all"; + case PREF_ROSTER_BY: + return "none"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 11d93feb..ec697845 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -58,6 +58,10 @@ typedef enum { PREF_HISTORY, PREF_MOUSE, PREF_OCCUPANTS, + PREF_ROSTER, + PREF_ROSTER_OFFLINE, + PREF_ROSTER_RESOURCE, + PREF_ROSTER_BY, PREF_MUC_PRIVILEGES, PREF_PRESENCE, PREF_WRAP, diff --git a/src/server_events.c b/src/server_events.c index 5e40ec42..0de5e713 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -122,6 +122,10 @@ handle_login_account_success(char *account_name) log_info("%s logged in successfully", account->jid); account_free(account); + + if (prefs_get_boolean(PREF_ROSTER)) { + ui_show_roster(); + } } void diff --git a/src/ui/console.c b/src/ui/console.c index 6a995a1a..831b1b7d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -942,6 +942,15 @@ _cons_titlebar_setting(void) } static void +_cons_roster_setting(void) +{ + if (prefs_get_boolean(PREF_ROSTER)) + cons_show("Roster (/roster) : show"); + else + cons_show("Roster (/roster) : hide"); +} + +static void _cons_show_ui_prefs(void) { cons_show("UI preferences:"); @@ -955,6 +964,7 @@ _cons_show_ui_prefs(void) cons_mouse_setting(); cons_statuses_setting(); cons_occupants_setting(); + cons_roster_setting(); cons_privileges_setting(); cons_titlebar_setting(); cons_presence_setting(); @@ -1573,6 +1583,7 @@ console_init_module(void) cons_splash_setting = _cons_splash_setting; cons_autoconnect_setting = _cons_autoconnect_setting; cons_occupants_setting = _cons_occupants_setting; + cons_roster_setting = _cons_roster_setting; cons_vercheck_setting = _cons_vercheck_setting; cons_mouse_setting = _cons_mouse_setting; cons_statuses_setting = _cons_statuses_setting; diff --git a/src/ui/core.c b/src/ui/core.c index 7bf1b20d..66b5fa2b 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2986,6 +2986,25 @@ _ui_room_hide_occupants(const char * const room) } static void +_ui_show_roster(void) +{ + ProfWin *window = wins_get_console(); + if (window && !window->subwin) { + wins_show_subwin(window); + ui_roster(); + } +} + +static void +_ui_hide_roster(void) +{ + ProfWin *window = wins_get_console(); + if (window && window->subwin) { + wins_hide_subwin(window); + } +} + +static void _win_handle_switch(const wint_t * const ch) { if (*ch == KEY_F(1)) { @@ -3291,6 +3310,8 @@ ui_init_module(void) ui_roster = _ui_roster; ui_room_show_occupants = _ui_room_show_occupants; ui_room_hide_occupants = _ui_room_hide_occupants; + ui_show_roster = _ui_show_roster; + ui_hide_roster = _ui_hide_roster; ui_room_role_change = _ui_room_role_change; ui_room_affiliation_change = _ui_room_affiliation_change; ui_switch_to_room = _ui_switch_to_room; diff --git a/src/ui/ui.h b/src/ui/ui.h index 74171235..e1f48fbd 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -175,6 +175,8 @@ void (*ui_room_member_presence)(const char * const room, const char * const nick, const char * const show, const char * const status); void (*ui_room_show_occupants)(const char * const room); void (*ui_room_hide_occupants)(const char * const room); +void (*ui_show_roster)(void); +void (*ui_hide_roster)(void); void (*ui_roster_add)(const char * const barejid, const char * const name); void (*ui_roster_remove)(const char * const barejid); void (*ui_contact_already_in_group)(const char * const contact, const char * const group); @@ -298,6 +300,7 @@ void (*cons_flash_setting)(void); void (*cons_splash_setting)(void); void (*cons_vercheck_setting)(void); void (*cons_occupants_setting)(void); +void (*cons_roster_setting)(void); void (*cons_presence_setting)(void); void (*cons_wrap_setting)(void); void (*cons_mouse_setting)(void); diff --git a/src/ui/window.c b/src/ui/window.c index f5b1679d..fa02ff95 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -71,7 +71,7 @@ win_create(const char * const title, win_type_t type) new_win->from = strdup(title); int cols = getmaxx(stdscr); - if ((type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) || (type == WIN_CONSOLE)) { + if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) { int main_cols = win_main_width(); new_win->win = newpad(PAD_SIZE, main_cols); wbkgd(new_win->win, COLOUR_TEXT); |