Remove window checks from test plugins

This commit is contained in:
James Booth
2016-07-12 01:59:24 +01:00
parent ff23b5b2ce
commit 9c7f05305b
2 changed files with 110 additions and 123 deletions

View File

@@ -23,13 +23,8 @@ def _handle_win_input(win, line):
prof.win_show(win, "Input received: " + line)
def _create_win():
if prof.win_exists(plugin_win) == False:
prof.win_create(plugin_win, _handle_win_input)
def _consalert():
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.cons_alert()
prof.win_show(plugin_win, "called -> prof.cons_alert")
@@ -40,7 +35,7 @@ def _consshow(msg):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.cons_show(msg)
prof.win_show(plugin_win, "called -> prof.cons_show: " + msg)
@@ -51,7 +46,7 @@ def _consshow_t(group, key, dflt, msg):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
groupval = None if group == "none" else group
keyval = None if key == "none" else key
@@ -62,7 +57,7 @@ def _consshow_t(group, key, dflt, msg):
def _constest():
res = prof.current_win_is_console()
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
if res:
prof.win_show(plugin_win, "called -> prof.current_win_is_console: true")
@@ -75,7 +70,7 @@ def _winshow(msg):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.win_show(plugin_win, msg)
prof.win_show(plugin_win, "called -> prof.win_show: " + msg)
@@ -86,7 +81,7 @@ def _winshow_t(group, key, dflt, msg):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
groupval = None if group == "none" else group
keyval = None if key == "none" else key
@@ -100,7 +95,7 @@ def _sendline(line):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.send_line(line)
prof.win_show(plugin_win, "called -> prof.send_line: " + line)
@@ -111,7 +106,7 @@ def _notify(msg):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.notify(msg, 5000, "python-test plugin")
prof.win_show(plugin_win, "called -> prof.notify: " + msg)
@@ -119,7 +114,7 @@ def _notify(msg):
def _get(subject):
if subject == "recipient":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
recipient = prof.get_current_recipient();
if recipient:
prof.win_focus(plugin_win)
@@ -128,7 +123,7 @@ def _get(subject):
prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_recipient: <none>")
elif subject == "room":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
room = prof.get_current_muc()
if room:
prof.win_focus(plugin_win)
@@ -137,7 +132,7 @@ def _get(subject):
prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
elif subject == "nick":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
nick = prof.get_current_nick()
if nick:
prof.win_focus(plugin_win)
@@ -146,7 +141,7 @@ def _get(subject):
prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_nick: <none>")
elif subject == "occupants":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
occupants = prof.get_current_occupants()
if occupants:
prof.win_focus(plugin_win)
@@ -166,22 +161,22 @@ def _log(level, msg):
return
if level == "debug":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.log_debug(msg)
prof.win_show(plugin_win, "called -> prof.log_debug: " + msg)
elif level == "info":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.log_info(msg)
prof.win_show(plugin_win, "called -> prof.log_info: " + msg)
elif level == "warning":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.log_warning(msg)
prof.win_show(plugin_win, "called -> prof.log_warning: " + msg)
elif level == "error":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.log_error(msg)
prof.win_show(plugin_win, "called -> prof.log_error: " + msg)
@@ -190,7 +185,7 @@ def _log(level, msg):
def _count():
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.win_show(plugin_win, "Count: " + str(count))
@@ -202,7 +197,7 @@ def _ping(jid):
prof.cons_bad_cmd_usage("/python-test")
return
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
res = prof.send_stanza("<iq to='" + jid + "' id='pythonplugin-" + str(ping_id) + "' type='get'><ping xmlns='urn:xmpp:ping'/></iq>")
ping_id = ping_id + 1
@@ -227,7 +222,7 @@ def _boolean(op, group, key, value_str):
if op == "get":
dflt = False
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
res = prof.settings_get_boolean(group, key, dflt)
if res:
@@ -238,7 +233,7 @@ def _boolean(op, group, key, value_str):
value = False
if value_str == "true":
value = True
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.settings_set_boolean(group, key, value)
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value))
@@ -258,7 +253,7 @@ def _string(op, group, key, value):
return
if op == "get":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
res = prof.settings_get_string(group, key, None)
if res:
@@ -266,7 +261,7 @@ def _string(op, group, key, value):
else:
prof.win_show(plugin_win, "String setting: None")
elif op == "set":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.settings_set_string(group, key, value)
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + value)
@@ -282,12 +277,12 @@ def _int(op, group, key, value):
return
if op == "get":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
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_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.settings_set_int(group, key, int(value))
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value))
@@ -307,13 +302,13 @@ def _completer(op, item):
return
if op == "add":
_create_win()
prof.win_create(plugin_win, _handle_win_input)
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_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win)
prof.completer_remove("/python-test", [item])
prof.win_show(plugin_win, "Removed \"" + item + "\" to /python-test completer")
@@ -344,7 +339,7 @@ def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None):
def timed_callback():
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "timed -> timed_callback called")
@@ -472,14 +467,14 @@ def prof_init(version, status, account_name, fulljid):
def prof_on_start():
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_start")
def prof_on_shutdown():
global thread_stop
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_shutdown")
thread_stop.set()
count_thread.join()
@@ -488,64 +483,64 @@ def prof_on_shutdown():
def prof_on_unload():
global thread_stop
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_unload")
thread_stop.set()
count_thread.join()
def prof_on_connect(account_name, fulljid):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_connect: " + account_name + ", " + fulljid)
def prof_on_disconnect(account_name, fulljid):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_disconnect: " + account_name + ", " + fulljid)
def prof_pre_chat_message_display(jid, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + jid + ", " + message)
def prof_post_chat_message_display(jid, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_display: " + jid + ", " + message)
def prof_pre_chat_message_send(jid, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_send: " + jid + ", " + message)
def prof_post_chat_message_send(jid, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + jid + ", " + message)
def prof_pre_room_message_display(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_display: " + room + ", " + nick + ", " + message)
def prof_post_room_message_display(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_room_message_display: " + room + ", " + nick + ", " + message)
def prof_pre_room_message_send(room, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + room + ", " + message)
def prof_post_room_message_send(room, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_room_message_send: " + room + ", " + message)
def prof_on_room_history_message(room, nick, message, timestamp):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
if timestamp:
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message + ", " + timestamp)
else:
@@ -553,60 +548,60 @@ def prof_on_room_history_message(room, nick, message, timestamp):
def prof_pre_priv_message_display(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + room + ", " + nick + ", " + message)
def prof_post_priv_message_display(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_display: " + room + ", " + nick + ", " + message)
def prof_pre_priv_message_send(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_send: " + room + ", " + nick + ", " + message)
def prof_post_priv_message_send(room, nick, message):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + room + ", " + nick + ", " + message)
def prof_on_message_stanza_send(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_message_stanza_send: " + stanza)
def prof_on_message_stanza_receive(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_message_stanza_receive: " + stanza)
return True
def prof_on_presence_stanza_send(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_send: " + stanza)
def prof_on_presence_stanza_receive(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_receive: " + stanza)
return True
def prof_on_iq_stanza_send(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_send: " + stanza)
def prof_on_iq_stanza_receive(stanza):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_receive: " + stanza)
return True
def prof_on_contact_offline(barejid, resource, status):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
if status:
prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource + " \"" + status + "\"")
else:
@@ -614,7 +609,7 @@ def prof_on_contact_offline(barejid, resource, status):
def prof_on_contact_presence(barejid, resource, presence, status, priority):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
if status:
prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"")
else:
@@ -622,10 +617,10 @@ def prof_on_contact_presence(barejid, resource, presence, status, priority):
def prof_on_chat_win_focus(barejid):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_chat_win_focus: " + barejid)
def prof_on_room_win_focus(roomjid):
_create_win()
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_room_win_focus: " + roomjid)