diff --git a/tests/python-test.py b/tests/python-test.py index 08d233e..af65319 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -168,6 +168,39 @@ def cmd_pythontest(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None): prof.win_show(plugin_win, "Ping sent successfully") else: prof.win_show(plugin_win, "Error sending ping") + elif arg1 == "boolean": + if arg2 == "get": + if arg3 == None or arg4 == None: + prof.cons_bad_cmd_usage("/python-test") + else: + group = arg3 + key = arg4 + dflt = False + create_win() + prof.win_focus(plugin_win) + res = prof.settings_get_boolean(group, key, dflt) + if res: + prof.win_show(plugin_win, "Boolean setting: TRUE") + else: + prof.win_show(plugin_win, "Boolean setting: FALSE") + elif arg2 == "set": + if arg3 == None or arg4 == None or arg5 == None: + prof.cons_bad_cmd_usage("/python-test") + else: + group = arg3 + key = arg4 + if arg5 != "true" and arg5 != "false": + prof.cons_bad_cmd_usage("/python-test") + else: + value = False + if arg5 == "true": + value = True + create_win() + prof.win_focus(plugin_win) + prof.settings_set_boolean(group, key, value) + prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) + else: + prof.cons_bad_cmd_usage("/python-test") else: prof.cons_bad_cmd_usage("/python-test") @@ -194,7 +227,9 @@ def prof_init(version, status): "/python-test get recipient|room", "/python-test log debug|info|warning|error ", "/python-test count", - "/python-test ping " + "/python-test ping ", + "/python-test boolean get ", + "/python-test boolean set " ] description = "Python test plugins. All commands focus the plugin window." args = [ @@ -210,7 +245,9 @@ def prof_init(version, status): [ "get room", "Show the current room JID, if ina a chat room"], [ "log debug|info|warning|error ", "Log a message at the specified level" ], [ "count", "Show the counter, incremented every 5 seconds by a worker thread" ], - [ "ping ", "Send an XMPP ping to the specified Jabber ID" ] + [ "ping ", "Send an XMPP ping to the specified Jabber ID" ], + [ "boolean get ", "Get a boolean setting" ], + [ "boolean set ", "Set a boolean setting" ] ] examples = [ "/python-test sendline /about", @@ -223,7 +260,7 @@ def prof_init(version, status): prof.register_command("/python-test", 1, 5, synopsis, description, args, examples, cmd_pythontest) prof.register_ac("/python-test", - [ "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping" ] + [ "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping", "boolean" ] ) prof.register_ac("/python-test get", [ "recipient", "room" ] @@ -231,6 +268,9 @@ def prof_init(version, status): prof.register_ac("/python-test log", [ "debug", "info", "warning", "error" ] ) + prof.register_ac("/python-test boolean", + [ "get", "set" ] + ) prof.register_timed(timed_callback, 30) diff --git a/tests/test-c-plugin/test-c-plugin.c b/tests/test-c-plugin/test-c-plugin.c index 8a3f6f1..c296126 100644 --- a/tests/test-c-plugin/test-c-plugin.c +++ b/tests/test-c-plugin/test-c-plugin.c @@ -249,6 +249,49 @@ cmd_ctest(char **args) prof_win_show(plugin_win, "Error sending ping"); } } + } else if (strcmp(args[0], "boolean") == 0) { + if (args[1] == NULL) { + prof_cons_bad_cmd_usage("/c-test"); + } else if (strcmp(args[1], "get") == 0) { + if (args[2] == NULL || args[3] == NULL) { + prof_cons_bad_cmd_usage("/c-test"); + } else { + char *group = args[2]; + char *key = args[3]; + int dflt = 0; + create_win(); + prof_win_focus(plugin_win); + int res = prof_settings_get_boolean(group, key, dflt); + if (res) { + prof_win_show(plugin_win, "Boolean setting: TRUE"); + } else { + prof_win_show(plugin_win, "Boolean setting: FALSE"); + } + } + } else if (strcmp(args[1], "set") == 0) { + if (args[2] == NULL || args[3] == NULL || args[4] == NULL) { + prof_cons_bad_cmd_usage("/c-test"); + } else { + char *group = args[2]; + char *key = args[3]; + if ((strcmp(args[4], "true") != 0) && (strcmp(args[4], "false") != 0)) { + prof_cons_bad_cmd_usage("/c-test"); + } else { + int value = 0; + if (strcmp(args[4], "true") == 0) { + value = 1; + } + create_win(); + prof_win_focus(plugin_win); + prof_settings_set_boolean(group, key, value); + char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(args[4])]; + sprintf(buf, "Set [%s] %s to %s", group, key, args[4]); + prof_win_show(plugin_win, buf); + } + } + } else { + prof_cons_bad_cmd_usage("/c-test"); + } } else { prof_cons_bad_cmd_usage("/c-test"); } @@ -281,6 +324,8 @@ prof_init(const char * const version, const char * const status) "/c-test log debug|info|warning|error ", "/c-test count", "/c-test ping ", + "/c-test boolean get ", + "/c-test boolean set ", NULL }; const char *description = "C test plugin. All commands focus the plugin window."; @@ -298,6 +343,8 @@ prof_init(const char * const version, const char * const status) { "log debug|info|warning|error ", "Log a message at the specified level" }, { "count", "Show the counter, incremented every 5 seconds by a worker thread" }, { "ping ", "Send an XMPP ping to the specified Jabber ID" }, + { "boolean get ", "Get a boolean setting" }, + { "boolean set ", "Set a boolean setting" }, { NULL, NULL } }; @@ -312,7 +359,7 @@ prof_init(const char * const version, const char * const status) prof_register_command("/c-test", 1, 5, synopsis, description, args, examples, cmd_ctest); - char *cmd_ac[] = { "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping", NULL }; + char *cmd_ac[] = { "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping", "boolean", NULL }; prof_register_ac("/c-test", cmd_ac); char *get_ac[] = { "recipient", "room", NULL }; @@ -321,6 +368,9 @@ prof_init(const char * const version, const char * const status) char *log_ac[] = { "debug", "info", "warning", "error", NULL }; prof_register_ac("/c-test log", log_ac); + char *boolean_ac[] = { "get", "set", NULL }; + prof_register_ac("/c-test boolean", boolean_ac); + prof_register_timed(timed_callback, 30); }