From 52c01a8ee8619fcfbceb339085b15a520e597667 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 31 May 2016 22:46:03 +0100 Subject: Add /presence titlebar subcommand --- src/command/cmd_ac.c | 31 ++++++++++++++++++++++++-- src/command/cmd_defs.c | 58 ++++++++++++++++++++++++------------------------- src/command/cmd_funcs.c | 7 +++++- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index e43bcdb1..41b0bf99 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -97,7 +97,8 @@ static char* _close_autocomplete(ProfWin *window, const char *const input); static char* _plugins_autocomplete(ProfWin *window, const char *const input); static char* _sendfile_autocomplete(ProfWin *window, const char *const input); static char* _blocked_autocomplete(ProfWin *window, const char *const input); -static char *_tray_autocomplete(ProfWin *window, const char *const input); +static char* _tray_autocomplete(ProfWin *window, const char *const input); +static char* _presence_autocomplete(ProfWin *window, const char *const input); static char* _script_autocomplete_func(const char *const prefix); @@ -190,6 +191,7 @@ static Autocomplete plugins_load_ac; static Autocomplete sendfile_ac; static Autocomplete blocked_ac; static Autocomplete tray_ac; +static Autocomplete presence_ac; void cmd_ac_init(void) @@ -724,6 +726,9 @@ cmd_ac_init(void) autocomplete_add(tray_ac, "off"); autocomplete_add(tray_ac, "read"); autocomplete_add(tray_ac, "timer"); + + presence_ac = autocomplete_new(); + autocomplete_add(presence_ac, "titlebar"); } void @@ -971,6 +976,8 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(plugins_ac); autocomplete_reset(blocked_ac); autocomplete_reset(tray_ac); + autocomplete_reset(presence_ac); + autocomplete_reset(script_ac); if (script_show_ac) { autocomplete_free(script_show_ac); @@ -1090,6 +1097,7 @@ cmd_ac_uninit(void) autocomplete_free(sendfile_ac); autocomplete_free(blocked_ac); autocomplete_free(tray_ac); + autocomplete_free(presence_ac); } static char* @@ -1102,7 +1110,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", - "/history", "/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn", + "/history", "/vercheck", "/privileges", "/wrap", "/winstidy", "/carbons", "/encwarn", "/lastactivity" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { @@ -1221,6 +1229,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); + g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); int len = strlen(input); char parsed[len+1]; @@ -2921,3 +2930,21 @@ _account_autocomplete(ProfWin *window, const char *const input) found = autocomplete_param_with_ac(input, "/account", account_ac, TRUE); return found; } + +static char* +_presence_autocomplete(ProfWin *window, const char *const input) +{ + char *found = NULL; + + found = autocomplete_param_with_func(input, "/presence titlebar", prefs_autocomplete_boolean_choice); + if (found) { + return found; + } + + found = autocomplete_param_with_ac(input, "/presence", presence_ac, TRUE); + if (found) { + return found; + } + + return NULL; +} diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index a979dbd6..47d6087d 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1197,21 +1197,47 @@ static struct cmd_t command_defs[] = }, { "/presence", - parse_args, 1, 1, &cons_presence_setting, + parse_args, 2, 2, &cons_presence_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_presence) CMD_TAGS( CMD_TAG_UI, CMD_TAG_CHAT) CMD_SYN( - "/presence on|off") + "/presence titlebar on|off") CMD_DESC( "Show the contacts presence in the titlebar.") CMD_ARGS( - { "on|off", "Switch display of the contacts presence in the titlebar on or off." }) + { "titlebar on|off", "Switch display of the contacts presence in the titlebar on or off." }) CMD_NOEXAMPLES }, + { "/statuses", + parse_args, 2, 2, &cons_statuses_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_statuses) + CMD_TAGS( + CMD_TAG_UI, + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/statuses console|chat|muc all|online|none") + CMD_DESC( + "Configure which presence changes are displayed in various windows. " + "The default is 'all' for all windows.") + CMD_ARGS( + { "console", "Configure what is displayed in the console window." }, + { "chat", "Configure what is displayed in chat windows." }, + { "muc", "Configure what is displayed in chat room windows." }, + { "all", "Show all presence changes." }, + { "online", "Show only online/offline changes." }, + { "none", "Don't show any presence changes." }) + CMD_EXAMPLES( + "/statuses console none", + "/statuses chat online", + "/statuses muc all") + }, + { "/wrap", parse_args, 1, 1, &cons_wrap_setting, CMD_NOSUBFUNCS @@ -2015,32 +2041,6 @@ static struct cmd_t command_defs[] = "/theme load forest") }, - { "/statuses", - parse_args, 2, 2, &cons_statuses_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_statuses) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT, - CMD_TAG_GROUPCHAT) - CMD_SYN( - "/statuses console|chat|muc all|online|none") - CMD_DESC( - "Configure which presence changes are displayed in various windows. " - "The default is 'all' for all windows.") - CMD_ARGS( - { "console", "Configure what is displayed in the console window." }, - { "chat", "Configure what is displayed in chat windows." }, - { "muc", "Configure what is displayed in chat room windows." }, - { "all", "Show all presence changes." }, - { "online", "Show only online/offline changes." }, - { "none", "Don't show any presence changes." }) - CMD_EXAMPLES( - "/statuses console none", - "/statuses chat online", - "/statuses muc all") - }, - { "/xmlconsole", parse_args, 0, 0, NULL, CMD_NOSUBFUNCS diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 544a356a..7d1e83fb 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4792,7 +4792,12 @@ cmd_console(ProfWin *window, const char *const command, gchar **args) gboolean cmd_presence(ProfWin *window, const char *const command, gchar **args) { - _cmd_set_boolean_preference(args[0], command, "Contact presence", PREF_PRESENCE); + if (g_strcmp0(args[0], "titlebar") != 0) { + cons_bad_cmd_usage(command); + return TRUE; + } + + _cmd_set_boolean_preference(args[1], command, "Contact presence", PREF_PRESENCE); return TRUE; } -- cgit 1.4.1-2-gfad0 From 383e601f2594d32ac0f0aca8bae5cf9053ceab91 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 31 May 2016 23:21:19 +0100 Subject: Move /statuses options to /presence command --- Makefile.am | 2 +- src/command/cmd_ac.c | 72 ++++++-------- src/command/cmd_defs.c | 79 ++++++++++------ src/command/cmd_funcs.c | 104 ++++++++++----------- src/command/cmd_funcs.h | 1 - src/ui/console.c | 33 +++---- src/ui/ui.h | 1 - tests/unittests/test_cmd_presence.c | 182 ++++++++++++++++++++++++++++++++++++ tests/unittests/test_cmd_presence.h | 13 +++ tests/unittests/test_cmd_statuses.c | 182 ------------------------------------ tests/unittests/test_cmd_statuses.h | 13 --- tests/unittests/unittests.c | 28 +++--- 12 files changed, 347 insertions(+), 363 deletions(-) create mode 100644 tests/unittests/test_cmd_presence.c create mode 100644 tests/unittests/test_cmd_presence.h delete mode 100644 tests/unittests/test_cmd_statuses.c delete mode 100644 tests/unittests/test_cmd_statuses.h diff --git a/Makefile.am b/Makefile.am index a2c023c5..61b5783d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -111,7 +111,7 @@ unittest_sources = \ tests/unittests/test_preferences.c tests/unittests/test_preferences.h \ tests/unittests/test_server_events.c tests/unittests/test_server_events.h \ tests/unittests/test_muc.c tests/unittests/test_muc.h \ - tests/unittests/test_cmd_statuses.c tests/unittests/test_cmd_statuses.h \ + tests/unittests/test_cmd_presence.c tests/unittests/test_cmd_presence.h \ tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \ tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \ tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \ diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 41b0bf99..7e2b3164 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -70,7 +70,6 @@ static char* _bookmark_autocomplete(ProfWin *window, const char *const input); static char* _otr_autocomplete(ProfWin *window, const char *const input); static char* _pgp_autocomplete(ProfWin *window, const char *const input); static char* _connect_autocomplete(ProfWin *window, const char *const input); -static char* _statuses_autocomplete(ProfWin *window, const char *const input); static char* _alias_autocomplete(ProfWin *window, const char *const input); static char* _join_autocomplete(ProfWin *window, const char *const input); static char* _log_autocomplete(ProfWin *window, const char *const input); @@ -157,8 +156,6 @@ static Autocomplete otr_log_ac; static Autocomplete otr_policy_ac; static Autocomplete connect_property_ac; static Autocomplete tls_property_ac; -static Autocomplete statuses_ac; -static Autocomplete statuses_setting_ac; static Autocomplete alias_ac; static Autocomplete aliases_ac; static Autocomplete join_property_ac; @@ -192,6 +189,7 @@ static Autocomplete sendfile_ac; static Autocomplete blocked_ac; static Autocomplete tray_ac; static Autocomplete presence_ac; +static Autocomplete presence_setting_ac; void cmd_ac_init(void) @@ -566,16 +564,6 @@ cmd_ac_init(void) autocomplete_add(join_property_ac, "nick"); autocomplete_add(join_property_ac, "password"); - statuses_ac = autocomplete_new(); - autocomplete_add(statuses_ac, "console"); - autocomplete_add(statuses_ac, "chat"); - autocomplete_add(statuses_ac, "muc"); - - statuses_setting_ac = autocomplete_new(); - autocomplete_add(statuses_setting_ac, "all"); - autocomplete_add(statuses_setting_ac, "online"); - autocomplete_add(statuses_setting_ac, "none"); - alias_ac = autocomplete_new(); autocomplete_add(alias_ac, "add"); autocomplete_add(alias_ac, "remove"); @@ -729,6 +717,14 @@ cmd_ac_init(void) presence_ac = autocomplete_new(); autocomplete_add(presence_ac, "titlebar"); + autocomplete_add(presence_ac, "console"); + autocomplete_add(presence_ac, "chat"); + autocomplete_add(presence_ac, "room"); + + presence_setting_ac = autocomplete_new(); + autocomplete_add(presence_setting_ac, "all"); + autocomplete_add(presence_setting_ac, "online"); + autocomplete_add(presence_setting_ac, "none"); } void @@ -946,8 +942,6 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(otr_policy_ac); autocomplete_reset(connect_property_ac); autocomplete_reset(tls_property_ac); - autocomplete_reset(statuses_ac); - autocomplete_reset(statuses_setting_ac); autocomplete_reset(alias_ac); autocomplete_reset(aliases_ac); autocomplete_reset(join_property_ac); @@ -977,6 +971,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(blocked_ac); autocomplete_reset(tray_ac); autocomplete_reset(presence_ac); + autocomplete_reset(presence_setting_ac); autocomplete_reset(script_ac); if (script_show_ac) { @@ -1063,8 +1058,6 @@ cmd_ac_uninit(void) autocomplete_free(otr_policy_ac); autocomplete_free(connect_property_ac); autocomplete_free(tls_property_ac); - autocomplete_free(statuses_ac); - autocomplete_free(statuses_setting_ac); autocomplete_free(alias_ac); autocomplete_free(aliases_ac); autocomplete_free(join_property_ac); @@ -1098,6 +1091,7 @@ cmd_ac_uninit(void) autocomplete_free(blocked_ac); autocomplete_free(tray_ac); autocomplete_free(presence_ac); + autocomplete_free(presence_setting_ac); } static char* @@ -1204,7 +1198,6 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete); g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete); g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete); - g_hash_table_insert(ac_funcs, "/statuses", _statuses_autocomplete); g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); @@ -2362,34 +2355,6 @@ _role_autocomplete(ProfWin *window, const char *const input) return result; } -static char* -_statuses_autocomplete(ProfWin *window, const char *const input) -{ - char *result = NULL; - - result = autocomplete_param_with_ac(input, "/statuses console", statuses_setting_ac, TRUE); - if (result) { - return result; - } - - result = autocomplete_param_with_ac(input, "/statuses chat", statuses_setting_ac, TRUE); - if (result) { - return result; - } - - result = autocomplete_param_with_ac(input, "/statuses muc", statuses_setting_ac, TRUE); - if (result) { - return result; - } - - result = autocomplete_param_with_ac(input, "/statuses", statuses_ac, TRUE); - if (result) { - return result; - } - - return NULL; -} - static char* _wins_autocomplete(ProfWin *window, const char *const input) { @@ -2941,6 +2906,21 @@ _presence_autocomplete(ProfWin *window, const char *const input) return found; } + found = autocomplete_param_with_ac(input, "/presence console", presence_setting_ac, TRUE); + if (found) { + return found; + } + + found = autocomplete_param_with_ac(input, "/presence chat", presence_setting_ac, TRUE); + if (found) { + return found; + } + + found = autocomplete_param_with_ac(input, "/presence room", presence_setting_ac, TRUE); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/presence", presence_ac, TRUE); if (found) { return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 47d6087d..036e6c23 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1200,43 +1200,60 @@ static struct cmd_t command_defs[] = parse_args, 2, 2, &cons_presence_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_presence) - CMD_TAGS( - CMD_TAG_UI, - CMD_TAG_CHAT) - CMD_SYN( - "/presence titlebar on|off") - CMD_DESC( - "Show the contacts presence in the titlebar.") - CMD_ARGS( - { "titlebar on|off", "Switch display of the contacts presence in the titlebar on or off." }) - CMD_NOEXAMPLES - }, - - { "/statuses", - parse_args, 2, 2, &cons_statuses_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_statuses) CMD_TAGS( CMD_TAG_UI, CMD_TAG_CHAT, CMD_TAG_GROUPCHAT) CMD_SYN( - "/statuses console|chat|muc all|online|none") - CMD_DESC( - "Configure which presence changes are displayed in various windows. " - "The default is 'all' for all windows.") - CMD_ARGS( - { "console", "Configure what is displayed in the console window." }, - { "chat", "Configure what is displayed in chat windows." }, - { "muc", "Configure what is displayed in chat room windows." }, - { "all", "Show all presence changes." }, - { "online", "Show only online/offline changes." }, - { "none", "Don't show any presence changes." }) + "/presence titlebar on|off", + "/presence console all|online|none", + "/presence chat all|online|none", + "/presence room all|online|none") + CMD_DESC( + "Show the contacts presence in the titlebar and configure presence messages in different window types.") + CMD_ARGS( + { "titlebar on|off", "Switch display of the contacts presence in the titlebar on or off." }, + { "console all", "Show all presence changes in the console window." }, + { "console online", "Show only online/offline presence changes in the console window." }, + { "console none", "Don't show any presence changes in the console window." }, + { "chat all", "Show all presence changes in the chat windows." }, + { "chat online", "Show only online/offline presence changes in chat windows." }, + { "chat none", "Don't show any presence changes in chat windows." }, + { "room all", "Show all presence changes in chat room windows." }, + { "room online", "Show only online/offline presence changes in chat room windows." }, + { "room none", "Don't show any presence changes in chat room windows." }) CMD_EXAMPLES( - "/statuses console none", - "/statuses chat online", - "/statuses muc all") - }, + "/presence titlebar off", + "/presence console none", + "/presence chat online", + "/presence room all") + }, + +// { "/statuses", +// parse_args, 2, 2, &cons_statuses_setting, +// CMD_NOSUBFUNCS +// CMD_MAINFUNC(cmd_statuses) +// CMD_TAGS( +// CMD_TAG_UI, +// CMD_TAG_CHAT, +// CMD_TAG_GROUPCHAT) +// CMD_SYN( +// "/statuses console|chat|muc all|online|none") +// CMD_DESC( +// "Configure which presence changes are displayed in various windows. " +// "The default is 'all' for all windows.") +// CMD_ARGS( +// { "console", "Configure what is displayed in the console window." }, +// { "chat", "Configure what is displayed in chat windows." }, +// { "muc", "Configure what is displayed in chat room windows." }, +// { "all", "Show all presence changes." }, +// { "online", "Show only online/offline changes." }, +// { "none", "Don't show any presence changes." }) +// CMD_EXAMPLES( +// "/statuses console none", +// "/statuses chat online", +// "/statuses muc all") +// }, { "/wrap", parse_args, 1, 1, &cons_wrap_setting, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 7d1e83fb..7f3419e3 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4792,12 +4792,59 @@ cmd_console(ProfWin *window, const char *const command, gchar **args) gboolean cmd_presence(ProfWin *window, const char *const command, gchar **args) { - if (g_strcmp0(args[0], "titlebar") != 0) { + if (strcmp(args[0], "console") != 0 && + strcmp(args[0], "chat") != 0 && + strcmp(args[0], "room") != 0 && + strcmp(args[0], "titlebar") != 0) { + cons_bad_cmd_usage(command); + return TRUE; + } + + if (strcmp(args[0], "titlebar") == 0) { + _cmd_set_boolean_preference(args[1], command, "Contact presence", PREF_PRESENCE); + return TRUE; + } + + if (strcmp(args[1], "all") != 0 && + strcmp(args[1], "online") != 0 && + strcmp(args[1], "none") != 0) { cons_bad_cmd_usage(command); return TRUE; } - _cmd_set_boolean_preference(args[1], command, "Contact presence", PREF_PRESENCE); + if (strcmp(args[0], "console") == 0) { + prefs_set_string(PREF_STATUSES_CONSOLE, args[1]); + if (strcmp(args[1], "all") == 0) { + cons_show("All presence updates will appear in the console."); + } else if (strcmp(args[1], "online") == 0) { + cons_show("Only online/offline presence updates will appear in the console."); + } else { + cons_show("Presence updates will not appear in the console."); + } + } + + if (strcmp(args[0], "chat") == 0) { + prefs_set_string(PREF_STATUSES_CHAT, args[1]); + if (strcmp(args[1], "all") == 0) { + cons_show("All presence updates will appear in chat windows."); + } else if (strcmp(args[1], "online") == 0) { + cons_show("Only online/offline presence updates will appear in chat windows."); + } else { + cons_show("Presence updates will not appear in chat windows."); + } + } + + if (strcmp(args[0], "room") == 0) { + prefs_set_string(PREF_STATUSES_MUC, args[1]); + if (strcmp(args[1], "all") == 0) { + cons_show("All presence updates will appear in chat room windows."); + } else if (strcmp(args[1], "online") == 0) { + cons_show("Only join/leave presence updates will appear in chat room windows."); + } else { + cons_show("Presence updates will not appear in chat room windows."); + } + } + return TRUE; } @@ -5740,59 +5787,6 @@ cmd_priority(ProfWin *window, const char *const command, gchar **args) return TRUE; } -gboolean -cmd_statuses(ProfWin *window, const char *const command, gchar **args) -{ - if (strcmp(args[0], "console") != 0 && - strcmp(args[0], "chat") != 0 && - strcmp(args[0], "muc") != 0) { - cons_bad_cmd_usage(command); - return TRUE; - } - - if (strcmp(args[1], "all") != 0 && - strcmp(args[1], "online") != 0 && - strcmp(args[1], "none") != 0) { - cons_bad_cmd_usage(command); - return TRUE; - } - - if (strcmp(args[0], "console") == 0) { - prefs_set_string(PREF_STATUSES_CONSOLE, args[1]); - if (strcmp(args[1], "all") == 0) { - cons_show("All presence updates will appear in the console."); - } else if (strcmp(args[1], "online") == 0) { - cons_show("Only online/offline presence updates will appear in the console."); - } else { - cons_show("Presence updates will not appear in the console."); - } - } - - if (strcmp(args[0], "chat") == 0) { - prefs_set_string(PREF_STATUSES_CHAT, args[1]); - if (strcmp(args[1], "all") == 0) { - cons_show("All presence updates will appear in chat windows."); - } else if (strcmp(args[1], "online") == 0) { - cons_show("Only online/offline presence updates will appear in chat windows."); - } else { - cons_show("Presence updates will not appear in chat windows."); - } - } - - if (strcmp(args[0], "muc") == 0) { - prefs_set_string(PREF_STATUSES_MUC, args[1]); - if (strcmp(args[1], "all") == 0) { - cons_show("All presence updates will appear in chat room windows."); - } else if (strcmp(args[1], "online") == 0) { - cons_show("Only join/leave presence updates will appear in chat room windows."); - } else { - cons_show("Presence updates will not appear in chat room windows."); - } - } - - return TRUE; -} - gboolean cmd_vercheck(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 0856f5be..52b9946e 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -125,7 +125,6 @@ gboolean cmd_software(ProfWin *window, const char *const command, gchar **args); gboolean cmd_splash(ProfWin *window, const char *const command, gchar **args); gboolean cmd_states(ProfWin *window, const char *const command, gchar **args); gboolean cmd_status(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_statuses(ProfWin *window, const char *const command, gchar **args); gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args); gboolean cmd_theme(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tiny(ProfWin *window, const char *const command, gchar **args); diff --git a/src/ui/console.c b/src/ui/console.c index 207db949..281a68d5 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1176,9 +1176,21 @@ void cons_presence_setting(void) { if (prefs_get_boolean(PREF_PRESENCE)) - cons_show("Contact presence (/presence) : ON"); + cons_show("Titlebar presence (/presence) : ON"); else - cons_show("Contact presence (/presence) : OFF"); + cons_show("Titlebar presence (/presence) : OFF"); + + char *console = prefs_get_string(PREF_STATUSES_CONSOLE); + char *chat = prefs_get_string(PREF_STATUSES_CHAT); + char *room = prefs_get_string(PREF_STATUSES_MUC); + + cons_show("Console presence (/presence) : %s", console); + cons_show("Chat presence (/presence) : %s", chat); + cons_show("Room presence (/presence) : %s", room); + + prefs_free_string(console); + prefs_free_string(chat); + prefs_free_string(room); } void @@ -1315,22 +1327,6 @@ cons_vercheck_setting(void) cons_show("Version checking (/vercheck) : OFF"); } -void -cons_statuses_setting(void) -{ - char *console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *chat = prefs_get_string(PREF_STATUSES_CHAT); - char *muc = prefs_get_string(PREF_STATUSES_MUC); - - cons_show("Console statuses (/statuses) : %s", console); - cons_show("Chat statuses (/statuses) : %s", chat); - cons_show("MUC statuses (/statuses) : %s", muc); - - prefs_free_string(console); - prefs_free_string(chat); - prefs_free_string(muc); -} - void cons_titlebar_setting(void) { @@ -1532,7 +1528,6 @@ cons_show_ui_prefs(void) cons_time_setting(); cons_resource_setting(); cons_vercheck_setting(); - cons_statuses_setting(); cons_console_setting(); cons_occupants_setting(); cons_roster_setting(); diff --git a/src/ui/ui.h b/src/ui/ui.h index 2213ccc1..c15af910 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -297,7 +297,6 @@ void cons_presence_setting(void); void cons_wrap_setting(void); void cons_winstidy_setting(void); void cons_time_setting(void); -void cons_statuses_setting(void); void cons_titlebar_setting(void); void cons_notify_setting(void); void cons_show_desktop_prefs(void); diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/test_cmd_presence.c new file mode 100644 index 00000000..74d4a132 --- /dev/null +++ b/tests/unittests/test_cmd_presence.c @@ -0,0 +1,182 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "config/preferences.h" + +#include "ui/ui.h" +#include "ui/stub_ui.h" + +#include "command/cmd_funcs.h" + +#define CMD_PRESENCE "/presence" + +void cmd_presence_shows_usage_when_bad_subcmd(void **state) +{ + gchar *args[] = { "badcmd", NULL }; + + expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + assert_true(result); +} + +void cmd_presence_shows_usage_when_bad_console_setting(void **state) +{ + gchar *args[] = { "console", "badsetting", NULL }; + + expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + assert_true(result); +} + +void cmd_presence_shows_usage_when_bad_chat_setting(void **state) +{ + gchar *args[] = { "chat", "badsetting", NULL }; + + expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + assert_true(result); +} + +void cmd_presence_shows_usage_when_bad_muc_setting(void **state) +{ + gchar *args[] = { "muc", "badsetting", NULL }; + + expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + assert_true(result); +} + +void cmd_presence_console_sets_all(void **state) +{ + gchar *args[] = { "console", "all", NULL }; + + expect_cons_show("All presence updates will appear in the console."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + assert_non_null(setting); + assert_string_equal("all", setting); + assert_true(result); +} + +void cmd_presence_console_sets_online(void **state) +{ + gchar *args[] = { "console", "online", NULL }; + + expect_cons_show("Only online/offline presence updates will appear in the console."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + assert_non_null(setting); + assert_string_equal("online", setting); + assert_true(result); +} + +void cmd_presence_console_sets_none(void **state) +{ + gchar *args[] = { "console", "none", NULL }; + + expect_cons_show("Presence updates will not appear in the console."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + assert_non_null(setting); + assert_string_equal("none", setting); + assert_true(result); +} + +void cmd_presence_chat_sets_all(void **state) +{ + gchar *args[] = { "chat", "all", NULL }; + + expect_cons_show("All presence updates will appear in chat windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CHAT); + assert_non_null(setting); + assert_string_equal("all", setting); + assert_true(result); +} + +void cmd_presence_chat_sets_online(void **state) +{ + gchar *args[] = { "chat", "online", NULL }; + + expect_cons_show("Only online/offline presence updates will appear in chat windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CHAT); + assert_non_null(setting); + assert_string_equal("online", setting); + assert_true(result); +} + +void cmd_presence_chat_sets_none(void **state) +{ + gchar *args[] = { "chat", "none", NULL }; + + expect_cons_show("Presence updates will not appear in chat windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_CHAT); + assert_non_null(setting); + assert_string_equal("none", setting); + assert_true(result); +} + +void cmd_presence_room_sets_all(void **state) +{ + gchar *args[] = { "room", "all", NULL }; + + expect_cons_show("All presence updates will appear in chat room windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_MUC); + assert_non_null(setting); + assert_string_equal("all", setting); + assert_true(result); +} + +void cmd_presence_room_sets_online(void **state) +{ + gchar *args[] = { "room", "online", NULL }; + + expect_cons_show("Only join/leave presence updates will appear in chat room windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_MUC); + assert_non_null(setting); + assert_string_equal("online", setting); + assert_true(result); +} + +void cmd_presence_room_sets_none(void **state) +{ + gchar *args[] = { "room", "none", NULL }; + + expect_cons_show("Presence updates will not appear in chat room windows."); + + gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); + + char *setting = prefs_get_string(PREF_STATUSES_MUC); + assert_non_null(setting); + assert_string_equal("none", setting); + assert_true(result); +} diff --git a/tests/unittests/test_cmd_presence.h b/tests/unittests/test_cmd_presence.h new file mode 100644 index 00000000..620921ae --- /dev/null +++ b/tests/unittests/test_cmd_presence.h @@ -0,0 +1,13 @@ +void cmd_presence_shows_usage_when_bad_subcmd(void **state); +void cmd_presence_shows_usage_when_bad_console_setting(void **state); +void cmd_presence_shows_usage_when_bad_chat_setting(void **state); +void cmd_presence_shows_usage_when_bad_muc_setting(void **state); +void cmd_presence_console_sets_all(void **state); +void cmd_presence_console_sets_online(void **state); +void cmd_presence_console_sets_none(void **state); +void cmd_presence_chat_sets_all(void **state); +void cmd_presence_chat_sets_online(void **state); +void cmd_presence_chat_sets_none(void **state); +void cmd_presence_room_sets_all(void **state); +void cmd_presence_room_sets_online(void **state); +void cmd_presence_room_sets_none(void **state); diff --git a/tests/unittests/test_cmd_statuses.c b/tests/unittests/test_cmd_statuses.c deleted file mode 100644 index f4d8c067..00000000 --- a/tests/unittests/test_cmd_statuses.c +++ /dev/null @@ -1,182 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "config/preferences.h" - -#include "ui/ui.h" -#include "ui/stub_ui.h" - -#include "command/cmd_funcs.h" - -#define CMD_STATUSES "/statuses" - -void cmd_statuses_shows_usage_when_bad_subcmd(void **state) -{ - gchar *args[] = { "badcmd", NULL }; - - expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - assert_true(result); -} - -void cmd_statuses_shows_usage_when_bad_console_setting(void **state) -{ - gchar *args[] = { "console", "badsetting", NULL }; - - expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - assert_true(result); -} - -void cmd_statuses_shows_usage_when_bad_chat_setting(void **state) -{ - gchar *args[] = { "chat", "badsetting", NULL }; - - expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - assert_true(result); -} - -void cmd_statuses_shows_usage_when_bad_muc_setting(void **state) -{ - gchar *args[] = { "muc", "badsetting", NULL }; - - expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - assert_true(result); -} - -void cmd_statuses_console_sets_all(void **state) -{ - gchar *args[] = { "console", "all", NULL }; - - expect_cons_show("All presence updates will appear in the console."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); - assert_non_null(setting); - assert_string_equal("all", setting); - assert_true(result); -} - -void cmd_statuses_console_sets_online(void **state) -{ - gchar *args[] = { "console", "online", NULL }; - - expect_cons_show("Only online/offline presence updates will appear in the console."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); - assert_non_null(setting); - assert_string_equal("online", setting); - assert_true(result); -} - -void cmd_statuses_console_sets_none(void **state) -{ - gchar *args[] = { "console", "none", NULL }; - - expect_cons_show("Presence updates will not appear in the console."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); - assert_non_null(setting); - assert_string_equal("none", setting); - assert_true(result); -} - -void cmd_statuses_chat_sets_all(void **state) -{ - gchar *args[] = { "chat", "all", NULL }; - - expect_cons_show("All presence updates will appear in chat windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CHAT); - assert_non_null(setting); - assert_string_equal("all", setting); - assert_true(result); -} - -void cmd_statuses_chat_sets_online(void **state) -{ - gchar *args[] = { "chat", "online", NULL }; - - expect_cons_show("Only online/offline presence updates will appear in chat windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CHAT); - assert_non_null(setting); - assert_string_equal("online", setting); - assert_true(result); -} - -void cmd_statuses_chat_sets_none(void **state) -{ - gchar *args[] = { "chat", "none", NULL }; - - expect_cons_show("Presence updates will not appear in chat windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_CHAT); - assert_non_null(setting); - assert_string_equal("none", setting); - assert_true(result); -} - -void cmd_statuses_muc_sets_all(void **state) -{ - gchar *args[] = { "muc", "all", NULL }; - - expect_cons_show("All presence updates will appear in chat room windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_MUC); - assert_non_null(setting); - assert_string_equal("all", setting); - assert_true(result); -} - -void cmd_statuses_muc_sets_online(void **state) -{ - gchar *args[] = { "muc", "online", NULL }; - - expect_cons_show("Only join/leave presence updates will appear in chat room windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_MUC); - assert_non_null(setting); - assert_string_equal("online", setting); - assert_true(result); -} - -void cmd_statuses_muc_sets_none(void **state) -{ - gchar *args[] = { "muc", "none", NULL }; - - expect_cons_show("Presence updates will not appear in chat room windows."); - - gboolean result = cmd_statuses(NULL, CMD_STATUSES, args); - - char *setting = prefs_get_string(PREF_STATUSES_MUC); - assert_non_null(setting); - assert_string_equal("none", setting); - assert_true(result); -} diff --git a/tests/unittests/test_cmd_statuses.h b/tests/unittests/test_cmd_statuses.h deleted file mode 100644 index 306a6fc7..00000000 --- a/tests/unittests/test_cmd_statuses.h +++ /dev/null @@ -1,13 +0,0 @@ -void cmd_statuses_shows_usage_when_bad_subcmd(void **state); -void cmd_statuses_shows_usage_when_bad_console_setting(void **state); -void cmd_statuses_shows_usage_when_bad_chat_setting(void **state); -void cmd_statuses_shows_usage_when_bad_muc_setting(void **state); -void cmd_statuses_console_sets_all(void **state); -void cmd_statuses_console_sets_online(void **state); -void cmd_statuses_console_sets_none(void **state); -void cmd_statuses_chat_sets_all(void **state); -void cmd_statuses_chat_sets_online(void **state); -void cmd_statuses_chat_sets_none(void **state); -void cmd_statuses_muc_sets_all(void **state); -void cmd_statuses_muc_sets_online(void **state); -void cmd_statuses_muc_sets_none(void **state); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 2c3d6ce5..5577104e 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -18,7 +18,7 @@ #include "test_cmd_account.h" #include "test_cmd_rooms.h" #include "test_cmd_sub.h" -#include "test_cmd_statuses.h" +#include "test_cmd_presence.h" #include "test_cmd_otr.h" #include "test_cmd_pgp.h" #include "test_jid.h" @@ -395,35 +395,35 @@ int main(int argc, char* argv[]) { unit_test(contact_available_when_highest_priority_online), unit_test(contact_available_when_highest_priority_chat), - unit_test(cmd_statuses_shows_usage_when_bad_subcmd), - unit_test(cmd_statuses_shows_usage_when_bad_console_setting), - unit_test(cmd_statuses_shows_usage_when_bad_chat_setting), - unit_test(cmd_statuses_shows_usage_when_bad_muc_setting), - unit_test_setup_teardown(cmd_statuses_console_sets_all, + unit_test(cmd_presence_shows_usage_when_bad_subcmd), + unit_test(cmd_presence_shows_usage_when_bad_console_setting), + unit_test(cmd_presence_shows_usage_when_bad_chat_setting), + unit_test(cmd_presence_shows_usage_when_bad_muc_setting), + unit_test_setup_teardown(cmd_presence_console_sets_all, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_console_sets_online, + unit_test_setup_teardown(cmd_presence_console_sets_online, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_console_sets_none, + unit_test_setup_teardown(cmd_presence_console_sets_none, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_chat_sets_all, + unit_test_setup_teardown(cmd_presence_chat_sets_all, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_chat_sets_online, + unit_test_setup_teardown(cmd_presence_chat_sets_online, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_chat_sets_none, + unit_test_setup_teardown(cmd_presence_chat_sets_none, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_muc_sets_all, + unit_test_setup_teardown(cmd_presence_room_sets_all, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_muc_sets_online, + unit_test_setup_teardown(cmd_presence_room_sets_online, load_preferences, close_preferences), - unit_test_setup_teardown(cmd_statuses_muc_sets_none, + unit_test_setup_teardown(cmd_presence_room_sets_none, load_preferences, close_preferences), -- cgit 1.4.1-2-gfad0 From 705e3dc7d8e2024d994b5390d26a78b8b21119d8 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 31 May 2016 23:22:07 +0100 Subject: Remove commented code --- src/command/cmd_defs.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 036e6c23..eafc6e5b 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1229,32 +1229,6 @@ static struct cmd_t command_defs[] = "/presence room all") }, -// { "/statuses", -// parse_args, 2, 2, &cons_statuses_setting, -// CMD_NOSUBFUNCS -// CMD_MAINFUNC(cmd_statuses) -// CMD_TAGS( -// CMD_TAG_UI, -// CMD_TAG_CHAT, -// CMD_TAG_GROUPCHAT) -// CMD_SYN( -// "/statuses console|chat|muc all|online|none") -// CMD_DESC( -// "Configure which presence changes are displayed in various windows. " -// "The default is 'all' for all windows.") -// CMD_ARGS( -// { "console", "Configure what is displayed in the console window." }, -// { "chat", "Configure what is displayed in chat windows." }, -// { "muc", "Configure what is displayed in chat room windows." }, -// { "all", "Show all presence changes." }, -// { "online", "Show only online/offline changes." }, -// { "none", "Don't show any presence changes." }) -// CMD_EXAMPLES( -// "/statuses console none", -// "/statuses chat online", -// "/statuses muc all") -// }, - { "/wrap", parse_args, 1, 1, &cons_wrap_setting, CMD_NOSUBFUNCS -- cgit 1.4.1-2-gfad0 From e758f74e48d447c622457e614f1f2f36b7ef7944 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 31 May 2016 23:26:30 +0100 Subject: Update /notify help --- src/command/cmd_defs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index eafc6e5b..dacf1c91 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1335,7 +1335,8 @@ static struct cmd_t command_defs[] = "/notify invite on|off", "/notify sub on|off") CMD_DESC( - "Settings for various kinds of desktop notifications.") + "Configure desktop notifications. " + "To configure presence update messages in the console, chat and chat room windows, see '/help presence'.") CMD_ARGS( { "chat on|off", "Notifications for regular chat messages." }, { "chat current on|off", "Whether to show regular chat message notifications when the window is focussed." }, -- cgit 1.4.1-2-gfad0