diff --git a/tests/python-test.py b/tests/python-test.py index 58f57e5..d65f9a7 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -231,6 +231,26 @@ def _string(op, group, key, value): prof.settings_set_string(group, key, value) prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + value) +def _int(op, group, key, value): + if op != "get" and op != "set": + prof.cons_bad_cmd_usage("/python-test") + return + + if group == None or key == None: + prof.cons_bad_cmd_usage("/python-test") + return + + if op == "get": + _create_win() + prof.win_focus(plugin_win) + res = prof.settings_get_int(group, key, 0) + prof.win_show(plugin_win, "Integer setting: " + str(res)) + elif op == "set": + _create_win() + prof.win_focus(plugin_win) + prof.settings_set_int(group, key, int(value)) + prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) + def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None): if subcmd == "consalert": _consalert() elif subcmd == "consshow": _consshow(arg1) @@ -246,6 +266,7 @@ def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None): elif subcmd == "ping": _ping(arg1) elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4) elif subcmd == "string": _string(arg1, arg2, arg3, arg4) + elif subcmd == "int": _int(arg1, arg2, arg3, arg4) else: prof.cons_bad_cmd_usage("/python-test") def timed_callback(): @@ -275,7 +296,9 @@ def prof_init(version, status): "/python-test boolean get ", "/python-test boolean set ", "/python-test string get ", - "/python-test string set " + "/python-test string set ", + "/python-test int get ", + "/python-test int set " ] description = "Python test plugins. All commands focus the plugin window." args = [ @@ -295,7 +318,9 @@ def prof_init(version, status): [ "boolean get ", "Get a boolean setting" ], [ "boolean set ", "Set a boolean setting" ], [ "string get ", "Get a string setting" ], - [ "string set ", "Set a string setting" ] + [ "string set ", "Set a string setting" ], + [ "int get ", "Get a integer setting" ], + [ "int set ", "Set a integer setting" ] ] examples = [ "/python-test sendline /about", @@ -308,7 +333,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", "boolean", "string" ] + [ "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping", "boolean", "string", "int" ] ) prof.register_ac("/python-test get", [ "recipient", "room" ] @@ -322,6 +347,9 @@ def prof_init(version, status): prof.register_ac("/python-test string", [ "get", "set" ] ) + prof.register_ac("/python-test int", + [ "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 c48671f..0e7036b 100644 --- a/tests/test-c-plugin/test-c-plugin.c +++ b/tests/test-c-plugin/test-c-plugin.c @@ -363,6 +363,37 @@ stringsetting(char *op, char *group, char *key, char *value) } } +void +intsetting(char *op, char *group, char *key, char *value) +{ + if (op == NULL || group == NULL || key == NULL) { + prof_cons_bad_cmd_usage("/c-test"); + return; + } + + if ((strcmp(op, "get") != 0) && (strcmp(op, "set") != 0)) { + prof_cons_bad_cmd_usage("/c-test"); + return; + } + + if (strcmp(op, "get") == 0) { + create_win(); + prof_win_focus(plugin_win); + int res = prof_settings_get_int(group, key, 0); + char buf[256]; + sprintf(buf, "Integer setting: %d", res); + prof_win_show(plugin_win, buf); + } else if (strcmp(op, "set") == 0) { + create_win(); + prof_win_focus(plugin_win); + int int_value = atoi(value); + prof_settings_set_int(group, key, int_value); + char buf[256]; + sprintf(buf, "Set [%s] %s to %d", group, key, int_value); + prof_win_show(plugin_win, buf); + } +} + void cmd_ctest(char **args) { @@ -380,6 +411,7 @@ cmd_ctest(char **args) else if (strcmp(args[0], "ping") == 0) doping(args[1]); else if (strcmp(args[0], "boolean") == 0) booleansetting(args[1], args[2], args[3], args[4]); else if (strcmp(args[0], "string") == 0) stringsetting(args[1], args[2], args[3], args[4]); + else if (strcmp(args[0], "int") == 0) intsetting(args[1], args[2], args[3], args[4]); else prof_cons_bad_cmd_usage("/c-test"); } @@ -414,6 +446,8 @@ prof_init(const char * const version, const char * const status) "/c-test boolean set ", "/c-test string get ", "/c-test string set ", + "/c-test int get ", + "/c-test int set ", NULL }; const char *description = "C test plugin. All commands focus the plugin window."; @@ -435,6 +469,8 @@ prof_init(const char * const version, const char * const status) { "boolean set ", "Set a boolean setting" }, { "string get ", "Get a string setting" }, { "string set ", "Set a string setting" }, + { "int get ", "Get a integer setting" }, + { "int set ", "Set a integer setting" }, { NULL, NULL } }; @@ -449,7 +485,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", "boolean", "string", NULL }; + char *cmd_ac[] = { "consalert", "consshow", "consshow_t", "constest", "winshow", "winshow_t", "notify", "sendline", "get", "log", "count", "ping", "boolean", "string", "int", NULL }; prof_register_ac("/c-test", cmd_ac); char *get_ac[] = { "recipient", "room", NULL }; @@ -464,6 +500,9 @@ prof_init(const char * const version, const char * const status) char *string_ac[] = { "get", "set", NULL }; prof_register_ac("/c-test string", string_ac); + char *int_ac[] = { "get", "set", NULL }; + prof_register_ac("/c-test int", int_ac); + prof_register_timed(timed_callback, 30); }