mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into plugins
This commit is contained in:
commit
f7a7277e40
@ -787,21 +787,11 @@ static struct cmd_t command_defs[] =
|
||||
{ "/statuses console|chat|muc setting",
|
||||
"----------------------------------",
|
||||
"Configure how presence changes are displayed in various windows.",
|
||||
"Settings for the console:",
|
||||
" all - Show all presence changes in the console",
|
||||
" online - Show only when contacts log in/out.",
|
||||
" none - Don't show any presence changes in the console.",
|
||||
"Settings for chat windows:",
|
||||
" all - Show all presence changes in the contact's chat window if one is open.",
|
||||
" online - Show only when contacts log in/out.",
|
||||
" none - Don't show any presence changes in the chat windows.",
|
||||
"Settings for chat room windows:",
|
||||
" on - Show presence changes in chat rooms.",
|
||||
" off - Do not show presence changes in chat rooms.",
|
||||
"The defaults are:",
|
||||
" console - all",
|
||||
" chat - all",
|
||||
" muc - on",
|
||||
"Settings:",
|
||||
" all - Show all presence changes.",
|
||||
" online - Show only online/offline changes.",
|
||||
" none - Don't show any presence changes.",
|
||||
"The default is 'all' for all windows.",
|
||||
NULL } } },
|
||||
|
||||
{ "/away",
|
||||
@ -886,7 +876,7 @@ static Autocomplete otr_ac;
|
||||
static Autocomplete otr_log_ac;
|
||||
static Autocomplete connect_property_ac;
|
||||
static Autocomplete statuses_ac;
|
||||
static Autocomplete statuses_cons_chat_ac;
|
||||
static Autocomplete statuses_setting_ac;
|
||||
static Autocomplete alias_ac;
|
||||
static Autocomplete aliases_ac;
|
||||
static Autocomplete join_property_ac;
|
||||
@ -1087,10 +1077,10 @@ cmd_init(void)
|
||||
autocomplete_add(statuses_ac, "chat");
|
||||
autocomplete_add(statuses_ac, "muc");
|
||||
|
||||
statuses_cons_chat_ac = autocomplete_new();
|
||||
autocomplete_add(statuses_cons_chat_ac, "all");
|
||||
autocomplete_add(statuses_cons_chat_ac, "online");
|
||||
autocomplete_add(statuses_cons_chat_ac, "none");
|
||||
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");
|
||||
@ -1131,7 +1121,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(otr_log_ac);
|
||||
autocomplete_free(connect_property_ac);
|
||||
autocomplete_free(statuses_ac);
|
||||
autocomplete_free(statuses_cons_chat_ac);
|
||||
autocomplete_free(statuses_setting_ac);
|
||||
autocomplete_free(alias_ac);
|
||||
autocomplete_free(aliases_ac);
|
||||
autocomplete_free(join_property_ac);
|
||||
@ -1254,7 +1244,7 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(otr_log_ac);
|
||||
autocomplete_reset(connect_property_ac);
|
||||
autocomplete_reset(statuses_ac);
|
||||
autocomplete_reset(statuses_cons_chat_ac);
|
||||
autocomplete_reset(statuses_setting_ac);
|
||||
autocomplete_reset(alias_ac);
|
||||
autocomplete_reset(aliases_ac);
|
||||
autocomplete_reset(join_property_ac);
|
||||
@ -1822,17 +1812,17 @@ _statuses_autocomplete(char *input, int *size)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/statuses console", statuses_cons_chat_ac);
|
||||
result = autocomplete_param_with_ac(input, size, "/statuses console", statuses_setting_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/statuses chat", statuses_cons_chat_ac);
|
||||
result = autocomplete_param_with_ac(input, size, "/statuses chat", statuses_setting_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/statuses muc", prefs_autocomplete_boolean_choice);
|
||||
result = autocomplete_param_with_ac(input, size, "/statuses muc", statuses_setting_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2427,23 +2427,14 @@ cmd_statuses(gchar **args, struct cmd_help_t help)
|
||||
strcmp(args[0], "chat") != 0 &&
|
||||
strcmp(args[0], "muc") != 0) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "console") == 0 || strcmp(args[0], "chat") == 0) {
|
||||
if (strcmp(args[1], "all") != 0 &&
|
||||
strcmp(args[1], "online") != 0 &&
|
||||
strcmp(args[1], "none") != 0) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "muc") == 0) {
|
||||
if (strcmp(args[1], "on") != 0 && strcmp(args[1], "off") != 0) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp(args[1], "all") != 0 &&
|
||||
strcmp(args[1], "online") != 0 &&
|
||||
strcmp(args[1], "none") != 0) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "console") == 0) {
|
||||
@ -2469,9 +2460,16 @@ cmd_statuses(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "muc") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], help,
|
||||
"Chat room presence updates", PREF_STATUSES_MUC);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -490,8 +490,6 @@ _get_default_boolean(preference_t pref)
|
||||
case PREF_STATUSES:
|
||||
case PREF_AUTOAWAY_CHECK:
|
||||
case PREF_OTR_WARN:
|
||||
case PREF_STATUSES_MUC:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
@ -508,6 +506,7 @@ _get_default_string(preference_t pref)
|
||||
return "redact";
|
||||
case PREF_STATUSES_CONSOLE:
|
||||
case PREF_STATUSES_CHAT:
|
||||
case PREF_STATUSES_MUC:
|
||||
return "all";
|
||||
default:
|
||||
return NULL;
|
||||
|
@ -474,8 +474,8 @@ handle_room_member_presence(const char * const room,
|
||||
gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str);
|
||||
|
||||
if (updated) {
|
||||
gboolean show_muc = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
if (show_muc) {
|
||||
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
|
||||
if (g_strcmp0(muc_status_pref, "all") == 0) {
|
||||
ui_room_member_presence(room, nick, show, status);
|
||||
ui_current_page_off();
|
||||
}
|
||||
@ -488,8 +488,12 @@ handle_room_member_online(const char * const room, const char * const nick,
|
||||
const char * const caps_str)
|
||||
{
|
||||
muc_add_to_roster(room, nick, show, status, caps_str);
|
||||
ui_room_member_online(room, nick, show, status);
|
||||
ui_current_page_off();
|
||||
|
||||
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
|
||||
if (g_strcmp0(muc_status_pref, "none") != 0) {
|
||||
ui_room_member_online(room, nick, show, status);
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -497,8 +501,12 @@ handle_room_member_offline(const char * const room, const char * const nick,
|
||||
const char * const show, const char * const status)
|
||||
{
|
||||
muc_remove_from_roster(room, nick);
|
||||
ui_room_member_offline(room, nick);
|
||||
ui_current_page_off();
|
||||
|
||||
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
|
||||
if (g_strcmp0(muc_status_pref, "none") != 0) {
|
||||
ui_room_member_offline(room, nick);
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -992,16 +992,11 @@ _cons_statuses_setting(void)
|
||||
{
|
||||
char *console = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||
char *chat = prefs_get_string(PREF_STATUSES_CHAT);
|
||||
gboolean muc = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
char *muc = prefs_get_string(PREF_STATUSES_MUC);
|
||||
|
||||
cons_show("Console statuses (/statuses) : %s", console);
|
||||
cons_show("Chat win statuses (/statuses) : %s", chat);
|
||||
|
||||
if (muc) {
|
||||
cons_show("MUC statuses (/statuses) : ON");
|
||||
} else {
|
||||
cons_show("MUC statuses (/statuses) : OFF");
|
||||
}
|
||||
cons_show("Console statuses (/statuses) : %s", console);
|
||||
cons_show("Chat win statuses (/statuses) : %s", chat);
|
||||
cons_show("Chat room statuses (/statuses) : %s", muc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -181,36 +181,55 @@ void cmd_statuses_chat_sets_none(void **state)
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_muc_sets_on(void **state)
|
||||
void cmd_statuses_muc_sets_all(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "muc", "on", NULL };
|
||||
gchar *args[] = { "muc", "all", NULL };
|
||||
|
||||
expect_cons_show("Chat room presence updates enabled.");
|
||||
expect_cons_show("All presence updates will appear in chat room windows.");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
|
||||
gboolean setting = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||
assert_non_null(setting);
|
||||
assert_true(setting);
|
||||
assert_string_equal("all", setting);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_muc_sets_off(void **state)
|
||||
void cmd_statuses_muc_sets_online(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "muc", "off", NULL };
|
||||
gchar *args[] = { "muc", "online", NULL };
|
||||
|
||||
expect_cons_show("Chat room presence updates disabled.");
|
||||
expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
|
||||
gboolean setting = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
assert_false(setting);
|
||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||
assert_non_null(setting);
|
||||
assert_string_equal("online", setting);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_muc_sets_none(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "muc", "none", NULL };
|
||||
|
||||
expect_cons_show("Presence updates will not appear in chat room windows.");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
|
||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||
assert_non_null(setting);
|
||||
assert_string_equal("none", setting);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
|
@ -8,5 +8,6 @@ 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_on(void **state);
|
||||
void cmd_statuses_muc_sets_off(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);
|
||||
|
@ -24,9 +24,10 @@ void statuses_chat_defaults_to_all(void **state)
|
||||
assert_string_equal("all", setting);
|
||||
}
|
||||
|
||||
void statuses_muc_defaults_to_on(void **state)
|
||||
void statuses_muc_defaults_to_all(void **state)
|
||||
{
|
||||
gboolean setting = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||
|
||||
assert_true(setting);
|
||||
assert_non_null(setting);
|
||||
assert_string_equal("all", setting);
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
void statuses_console_defaults_to_all(void **state);
|
||||
void statuses_chat_defaults_to_all(void **state);
|
||||
void statuses_muc_defaults_to_on(void **state);
|
||||
void statuses_muc_defaults_to_all(void **state);
|
||||
|
@ -331,10 +331,13 @@ int main(int argc, char* argv[]) {
|
||||
unit_test_setup_teardown(cmd_statuses_chat_sets_none,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_on,
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_all,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_off,
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_online,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_none,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
|
||||
@ -344,7 +347,7 @@ int main(int argc, char* argv[]) {
|
||||
unit_test_setup_teardown(statuses_chat_defaults_to_all,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(statuses_muc_defaults_to_on,
|
||||
unit_test_setup_teardown(statuses_muc_defaults_to_all,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user