Added on_chat_win_focus hooks to test plugins
This commit is contained in:
@@ -258,6 +258,27 @@ def _incoming(barejid, resource, message):
|
||||
|
||||
prof.incoming_message(barejid, resource, message)
|
||||
|
||||
def _completer(op, item):
|
||||
if not item:
|
||||
prof.cons_bad_cmd_usage("/python-test")
|
||||
return
|
||||
|
||||
if op == "add":
|
||||
_create_win()
|
||||
prof.win_focus(plugin_win)
|
||||
prof.completer_add("/python-test", [item])
|
||||
prof.win_show(plugin_win, "Added \"" + item + "\" to /python-test completer")
|
||||
prof.completer_add("/python-test completer remove", [item])
|
||||
elif op == "remove":
|
||||
_create_win()
|
||||
prof.win_focus(plugin_win)
|
||||
prof.completer_remove("/python-test", [item])
|
||||
prof.win_show(plugin_win, "Removed \"" + item + "\" to /python-test completer")
|
||||
prof.completer_remove("/python-test completer remove", [item])
|
||||
else:
|
||||
prof.cons_bad_cmd_usage("/python-test")
|
||||
|
||||
|
||||
def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||
if subcmd == "consalert": _consalert()
|
||||
elif subcmd == "consshow": _consshow(arg1)
|
||||
@@ -275,6 +296,7 @@ def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None):
|
||||
elif subcmd == "string": _string(arg1, arg2, arg3, arg4)
|
||||
elif subcmd == "int": _int(arg1, arg2, arg3, arg4)
|
||||
elif subcmd == "incoming": _incoming(arg1, arg2, arg3)
|
||||
elif subcmd == "completer": _completer(arg1, arg2)
|
||||
else: prof.cons_bad_cmd_usage("/python-test")
|
||||
|
||||
def timed_callback():
|
||||
@@ -307,7 +329,8 @@ def prof_init(version, status):
|
||||
"/python-test string set <group> <key> <value>",
|
||||
"/python-test int get <group> <key>",
|
||||
"/python-test int set <group> <key> <value>",
|
||||
"/python-test incoming <barejid> <resource> <message>"
|
||||
"/python-test incoming <barejid> <resource> <message>",
|
||||
"/python-test completer add|remove <item>"
|
||||
]
|
||||
description = "Python test plugins. All commands focus the plugin window."
|
||||
args = [
|
||||
@@ -330,7 +353,9 @@ def prof_init(version, status):
|
||||
[ "string set <group> <key> <value>", "Set a string setting" ],
|
||||
[ "int get <group> <key>", "Get a integer setting" ],
|
||||
[ "int set <group> <key> <value>", "Set a integer setting" ],
|
||||
[ "incoming <barejid> <resource> <message>", "Show an incoming message." ]
|
||||
[ "incoming <barejid> <resource> <message>", "Show an incoming message." ],
|
||||
[ "completer add <item>", "Add an autocomplete item to the /c-test command." ],
|
||||
[ "completer remove <item>", "Remove an autocomplete item from the /c-test command." ]
|
||||
]
|
||||
examples = [
|
||||
"/python-test sendline /about",
|
||||
@@ -359,7 +384,9 @@ def prof_init(version, status):
|
||||
"boolean",
|
||||
"string",
|
||||
"int",
|
||||
"incoming" ]
|
||||
"incoming",
|
||||
"completer"
|
||||
]
|
||||
)
|
||||
prof.completer_add("/python-test get",
|
||||
[ "recipient", "room" ]
|
||||
@@ -376,6 +403,9 @@ def prof_init(version, status):
|
||||
prof.completer_add("/python-test int",
|
||||
[ "get", "set" ]
|
||||
)
|
||||
prof.completer_add("/python-test completer",
|
||||
[ "add", "remove" ]
|
||||
)
|
||||
|
||||
prof.register_timed(timed_callback, 30)
|
||||
|
||||
@@ -483,3 +513,7 @@ def prof_on_contact_presence(barejid, resource, presence, status, priority):
|
||||
prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"")
|
||||
else:
|
||||
prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority))
|
||||
|
||||
def prof_on_chat_win_focus(barejid):
|
||||
_create_win()
|
||||
prof.win_show(plugin_win, "fired -> prof_on_chat_win_focus: " + barejid)
|
||||
|
||||
@@ -400,6 +400,37 @@ incomingmsg(char *barejid, char *resource, char *message)
|
||||
prof_incoming_message(barejid, resource, message);
|
||||
}
|
||||
|
||||
void
|
||||
completer(char *op, char *item)
|
||||
{
|
||||
if (item == NULL) {
|
||||
prof_cons_bad_cmd_usage("/c-test");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(op, "add") == 0) {
|
||||
create_win();
|
||||
prof_win_focus(plugin_win);
|
||||
char *ac[] = { item, NULL };
|
||||
prof_completer_add("/c-test", ac);
|
||||
char buf[256];
|
||||
sprintf(buf, "Added \"%s\" to /c-test completer", item);
|
||||
prof_win_show(plugin_win, buf);
|
||||
prof_completer_add("/c-test completer remove", ac);
|
||||
} else if (strcmp(op, "remove") == 0) {
|
||||
create_win();
|
||||
prof_win_focus(plugin_win);
|
||||
char *ac[] = { item, NULL };
|
||||
prof_completer_remove("/c-test", ac);
|
||||
char buf[256];
|
||||
sprintf(buf, "Removed \"%s\" from /c-test completer", item);
|
||||
prof_win_show(plugin_win, buf);
|
||||
prof_completer_remove("/c-test completer remove", ac);
|
||||
} else {
|
||||
prof_cons_bad_cmd_usage("/c-test");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cmd_ctest(char **args)
|
||||
{
|
||||
@@ -419,6 +450,7 @@ cmd_ctest(char **args)
|
||||
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 if (strcmp(args[0], "incoming") == 0) incomingmsg(args[1], args[2], args[3]);
|
||||
else if (strcmp(args[0], "completer") == 0) completer(args[1], args[2]);
|
||||
else prof_cons_bad_cmd_usage("/c-test");
|
||||
}
|
||||
|
||||
@@ -456,6 +488,7 @@ prof_init(const char * const version, const char * const status)
|
||||
"/c-test int get <group> <key>",
|
||||
"/c-test int set <group> <key> <value>",
|
||||
"/c-test incoming <barejid> <resource> <message>",
|
||||
"/c-test completer add|remove <item>",
|
||||
NULL
|
||||
};
|
||||
const char *description = "C test plugin. All commands focus the plugin window.";
|
||||
@@ -480,6 +513,8 @@ prof_init(const char * const version, const char * const status)
|
||||
{ "int get <group> <key>", "Get a integer setting" },
|
||||
{ "int set <group> <key> <value>", "Set a integer setting" },
|
||||
{ "incoming <barejid> <resource> <message>", "Show an incoming message." },
|
||||
{ "completer add <item>", "Add an autocomplete item to the /c-test command." },
|
||||
{ "completer remove <item>", "Remove an autocomplete item from the /c-test command." },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -511,6 +546,7 @@ prof_init(const char * const version, const char * const status)
|
||||
"string",
|
||||
"int",
|
||||
"incoming",
|
||||
"completer",
|
||||
NULL
|
||||
};
|
||||
prof_completer_add("/c-test", cmd_ac);
|
||||
@@ -530,6 +566,9 @@ prof_init(const char * const version, const char * const status)
|
||||
char *int_ac[] = { "get", "set", NULL };
|
||||
prof_completer_add("/c-test int", int_ac);
|
||||
|
||||
char *completer_ac[] = { "add", "remove", NULL };
|
||||
prof_completer_add("/c-test completer", completer_ac);
|
||||
|
||||
prof_register_timed(timed_callback, 30);
|
||||
}
|
||||
|
||||
@@ -824,3 +863,13 @@ prof_on_contact_presence(const char *const barejid, const char *const resource,
|
||||
}
|
||||
prof_win_show(plugin_win, buf);
|
||||
}
|
||||
|
||||
void
|
||||
prof_on_chat_win_focus(const char *const barejid)
|
||||
{
|
||||
create_win();
|
||||
char *str = "fired -> prof_on_chat_win_focus: ";
|
||||
char buf[strlen(str) + strlen(barejid) + 1];
|
||||
sprintf(buf, "%s%s", str, barejid);
|
||||
prof_win_show(plugin_win, buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user