Added boolean settings command to C and Python tests
This commit is contained in:
@@ -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")
|
prof.win_show(plugin_win, "Ping sent successfully")
|
||||||
else:
|
else:
|
||||||
prof.win_show(plugin_win, "Error sending ping")
|
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:
|
else:
|
||||||
prof.cons_bad_cmd_usage("/python-test")
|
prof.cons_bad_cmd_usage("/python-test")
|
||||||
|
|
||||||
@@ -194,7 +227,9 @@ def prof_init(version, status):
|
|||||||
"/python-test get recipient|room",
|
"/python-test get recipient|room",
|
||||||
"/python-test log debug|info|warning|error <message>",
|
"/python-test log debug|info|warning|error <message>",
|
||||||
"/python-test count",
|
"/python-test count",
|
||||||
"/python-test ping <jid>"
|
"/python-test ping <jid>",
|
||||||
|
"/python-test boolean get <group> <key>",
|
||||||
|
"/python-test boolean set <group> <key> <value>"
|
||||||
]
|
]
|
||||||
description = "Python test plugins. All commands focus the plugin window."
|
description = "Python test plugins. All commands focus the plugin window."
|
||||||
args = [
|
args = [
|
||||||
@@ -210,7 +245,9 @@ def prof_init(version, status):
|
|||||||
[ "get room", "Show the current room JID, if ina a chat room"],
|
[ "get room", "Show the current room JID, if ina a chat room"],
|
||||||
[ "log debug|info|warning|error <message>", "Log a message at the specified level" ],
|
[ "log debug|info|warning|error <message>", "Log a message at the specified level" ],
|
||||||
[ "count", "Show the counter, incremented every 5 seconds by a worker thread" ],
|
[ "count", "Show the counter, incremented every 5 seconds by a worker thread" ],
|
||||||
[ "ping <jid>", "Send an XMPP ping to the specified Jabber ID" ]
|
[ "ping <jid>", "Send an XMPP ping to the specified Jabber ID" ],
|
||||||
|
[ "boolean get <group> <key>", "Get a boolean setting" ],
|
||||||
|
[ "boolean set <group> <key> <value>", "Set a boolean setting" ]
|
||||||
]
|
]
|
||||||
examples = [
|
examples = [
|
||||||
"/python-test sendline /about",
|
"/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_command("/python-test", 1, 5, synopsis, description, args, examples, cmd_pythontest)
|
||||||
|
|
||||||
prof.register_ac("/python-test",
|
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",
|
prof.register_ac("/python-test get",
|
||||||
[ "recipient", "room" ]
|
[ "recipient", "room" ]
|
||||||
@@ -231,6 +268,9 @@ def prof_init(version, status):
|
|||||||
prof.register_ac("/python-test log",
|
prof.register_ac("/python-test log",
|
||||||
[ "debug", "info", "warning", "error" ]
|
[ "debug", "info", "warning", "error" ]
|
||||||
)
|
)
|
||||||
|
prof.register_ac("/python-test boolean",
|
||||||
|
[ "get", "set" ]
|
||||||
|
)
|
||||||
|
|
||||||
prof.register_timed(timed_callback, 30)
|
prof.register_timed(timed_callback, 30)
|
||||||
|
|
||||||
|
|||||||
@@ -249,6 +249,49 @@ cmd_ctest(char **args)
|
|||||||
prof_win_show(plugin_win, "Error sending ping");
|
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 {
|
} else {
|
||||||
prof_cons_bad_cmd_usage("/c-test");
|
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 <message>",
|
"/c-test log debug|info|warning|error <message>",
|
||||||
"/c-test count",
|
"/c-test count",
|
||||||
"/c-test ping <jid>",
|
"/c-test ping <jid>",
|
||||||
|
"/c-test boolean get <group> <key>",
|
||||||
|
"/c-test boolean set <group> <key> <value>",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const char *description = "C test plugin. All commands focus the plugin window.";
|
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 <message>", "Log a message at the specified level" },
|
{ "log debug|info|warning|error <message>", "Log a message at the specified level" },
|
||||||
{ "count", "Show the counter, incremented every 5 seconds by a worker thread" },
|
{ "count", "Show the counter, incremented every 5 seconds by a worker thread" },
|
||||||
{ "ping <jid>", "Send an XMPP ping to the specified Jabber ID" },
|
{ "ping <jid>", "Send an XMPP ping to the specified Jabber ID" },
|
||||||
|
{ "boolean get <group> <key>", "Get a boolean setting" },
|
||||||
|
{ "boolean set <group> <key> <value>", "Set a boolean setting" },
|
||||||
{ NULL, NULL }
|
{ 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);
|
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);
|
prof_register_ac("/c-test", cmd_ac);
|
||||||
|
|
||||||
char *get_ac[] = { "recipient", "room", NULL };
|
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 };
|
char *log_ac[] = { "debug", "info", "warning", "error", NULL };
|
||||||
prof_register_ac("/c-test log", log_ac);
|
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);
|
prof_register_timed(timed_callback, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user