32 Commits
browser ... irc

Author SHA1 Message Date
James Booth
7bae9545f1 Added prof-irc.py 2016-08-08 22:55:43 +01:00
James Booth
72542b75dc Update all plugins for renamed settings functions 2016-08-07 00:17:42 +01:00
James Booth
afc2a585a3 Fix offline message in presence_notify.py 2016-08-04 00:46:14 +01:00
James Booth
b7c758161d Fixed help for presence_notify.py 2016-08-04 00:26:53 +01:00
James Booth
83ec503ea9 Add resource setting to presence_notify.py 2016-08-03 23:43:00 +01:00
James Booth
c02c159e24 Store online contacts in presence_notify.py 2016-08-03 23:26:36 +01:00
James Booth
217f4e3c99 Added ignore list to presence_notify.py 2016-08-03 23:05:02 +01:00
James Booth
d5dcd54ec8 Add status to presense_notify.py 2016-08-03 22:37:51 +01:00
James Booth
3036624725 Fix presence_notify.py offline message 2016-08-03 01:52:22 +01:00
James Booth
042e626423 Added presence_notify.py 2016-08-03 00:23:58 +01:00
James Booth
05b3d69cbb Update test plugins 2016-08-01 22:41:42 +01:00
James Booth
dc057d40a7 Remove whitespace in python test 2016-08-01 21:58:50 +01:00
James Booth
d80767f1c4 Added string list settings to pyhton test 2016-08-01 21:35:47 +01:00
James Booth
9a2234a1b4 Update README.md 2016-07-31 00:23:11 +01:00
James Booth
47acbc76ac Update README.md 2016-07-31 00:18:38 +01:00
James Booth
1250d1df42 Remove const qualifiers 2016-07-25 01:54:16 +01:00
James Booth
c39550cd1c Update README.md 2016-07-24 02:58:32 +01:00
James Booth
38c06599c1 Remove unnecessary unicode handling 2016-07-24 02:42:57 +01:00
James Booth
32ad1708a9 Make paste.py python2 and 3 compatible 2016-07-20 01:05:34 +01:00
James Booth
dfd7b09d9e Make emoticons.py python2 and 3 compatible 2016-07-20 00:56:45 +01:00
James Booth
91558b7f06 Fixed clients.py for python3 2016-07-19 23:42:48 +01:00
James Booth
6d954537b9 Update README.md 2016-07-19 01:16:52 +01:00
James Booth
b8a19f3cff Update README.md 2016-07-19 01:14:40 +01:00
James Booth
77c2eb0f56 Update gitignore 2016-07-19 00:39:13 +01:00
James Booth
eeb1c0e214 Update syscmd.py for python3 2016-07-19 00:11:12 +01:00
James Booth
2a20b83f53 Update README.md 2016-07-13 00:00:38 +01:00
James Booth
64a97f5177 Update README.md 2016-07-12 23:59:56 +01:00
James Booth
9c7f05305b Remove window checks from test plugins 2016-07-12 01:59:24 +01:00
James Booth
ff23b5b2ce Clean up thread in python test 2016-07-09 22:48:11 +01:00
James Booth
ef43aa0267 C test: cancel thread on unload 2016-07-05 23:16:34 +01:00
James Booth
8cf42e000b Add unload hook to test plugins 2016-07-05 22:04:12 +01:00
James Booth
2895411eb6 Fix /say active in rooms 2016-06-20 23:23:58 +01:00
13 changed files with 682 additions and 215 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
*.so *.so
.idea/

View File

@@ -8,6 +8,8 @@ Plugin support for Profanity is currently in development.
For a list of outstanding issues before releasing 0.5.0, see: https://github.com/boothj5/profanity/milestones/0.5.0 For a list of outstanding issues before releasing 0.5.0, see: https://github.com/boothj5/profanity/milestones/0.5.0
* [Website documentation](http://www.profanity.im/plugins.html)
Building Profanity with plugin support Building Profanity with plugin support
-------------------------------------- --------------------------------------
@@ -30,12 +32,12 @@ Build with:
``` ```
./bootstrap.sh ./bootstrap.sh
./configure --enable-python-plugins ./configure
make make
sudo make install sudo make install
``` ```
Only support for Python 2.7 is currently included, after building, run `profanity -v` to see which language support is available, example output: After building, run `profanity -v` to see which language support is available, example output:
``` ```
Profanity, version 0.5.0dev.plugins-python.63a7316 Profanity, version 0.5.0dev.plugins-python.63a7316
@@ -57,24 +59,16 @@ Python plugins: Enabled
Installing plugins Installing plugins
------------------ ------------------
1 - Copy the plugin Use the `/plugins install` command, e.g.
For Python, Ruby and Lua plugins, copy the plugin to `$XDG_DATA/profanity/plugins/`, (`~/.local/share/profanity/plugins/` on most systems).
For C plugins, build the plugin using the supplied Makefile, and then copy the `.so` file to the same location.
2 - Load the plugin
Run the `/plugins load <plugin>` command to load the plugin, e.g. `/plugins load browser.py`, the plugin can also be manually added to the config file `$XDG_CONFIG/profanity/profrc` (`~/.config/profanity/profrc` on most systems).
For example:
``` ```
[plugins] /plugins install ~/projects-git/profanity-plugins/say.py
load=browser.py;platform-info.py;ascii.py;pid.so
``` ```
Getting help on plugins: See the `/help plugins` command for further plugin management options.
More help on plugins
--------------------
* `/plugins` - Shows a list of loaded plugins. * `/plugins` - Shows a list of loaded plugins.
* `/help commands plugins` - Shows commands defined by plugins * `/help commands plugins` - Shows commands defined by plugins
@@ -97,11 +91,33 @@ command=cyan
result=green result=green
``` ```
Example plugin code Plugin settings
------------------- ---------------
Whilst the API is being developed, the following test plugins are a good reference of possible hooks and API calls available, (Ruby and Lua examples might not be up to date): The plugins API also includes functions to read and write settings. The settings are stored in:
```
~/.local/share/profanity/plugin_settings
```
For example ([say.py](https://github.com/boothj5/profanity-plugins/blob/master/say.py) plugin):
```
[say]
args=-v english -s 120
enabled=active
```
Developing plugins
------------------
API Documentation:
* [Python API](http://www.profanity.im/plugins/python/html/prof.html)
* [Python hooks](http://www.profanity.im/plugins/python/html/plugin.html)
* [C API](http://www.profanity.im/plugins/c/html/profapi_8h.html)
* [C hooks](http://www.profanity.im/plugins/c/html/profhooks_8h.html)
Example test plugins (Ruby and Lua examples might not be up to date):
* [tests/test-c-plugin.c](https://github.com/boothj5/profanity-plugins/blob/master/tests/test-c-plugin/test-c-plugin.c) * [tests/test-c-plugin.c](https://github.com/boothj5/profanity-plugins/blob/master/tests/test-c-plugin/test-c-plugin.c)
* [tests/python-test.py](https://github.com/boothj5/profanity-plugins/blob/master/tests/python-test.py) * [tests/python-test.py](https://github.com/boothj5/profanity-plugins/blob/master/tests/python-test.py)
* [tests/RubyTest.rb](https://github.com/boothj5/profanity-plugins/blob/master/tests/RubyTest.rb) * [tests/RubyTest.rb](https://github.com/boothj5/profanity-plugins/blob/master/tests/RubyTest.rb)

View File

@@ -63,6 +63,7 @@ def _sv_send(muc, occupant):
ET.SubElement(iq, "query", { ET.SubElement(iq, "query", {
"xmlns": "jabber:iq:version" "xmlns": "jabber:iq:version"
}) })
iq_id_count = iq_id_count + 1 iq_id_count = iq_id_count + 1
prof.send_stanza(ET.tostring(iq)) prof.send_stanza(ET.tostring(iq))
@@ -71,10 +72,12 @@ def _sv_send(muc, occupant):
def _cmd_clients(): def _cmd_clients():
muc = prof.get_current_muc() muc = prof.get_current_muc()
if muc == None: if muc == None:
prof.cons_show("Command only valid in chat rooms.")
return return
occupants = prof.get_current_occupants() occupants = prof.get_current_occupants()
if occupants == None or len(occupants) == 0: if occupants == None or len(occupants) == 0:
prof.cons_show("No occupants for /clients command.")
return return
nick = prof.get_current_nick() nick = prof.get_current_nick()

View File

@@ -9,6 +9,7 @@ cp say.py ~/.local/share/profanity/plugins/.
cp whoami.py ~/.local/share/profanity/plugins/. cp whoami.py ~/.local/share/profanity/plugins/.
cp wikipedia-prof.py ~/.local/share/profanity/plugins/. cp wikipedia-prof.py ~/.local/share/profanity/plugins/.
cp clients.py ~/.local/share/profanity/plugins/. cp clients.py ~/.local/share/profanity/plugins/.
cp presence_notify.py ~/.local/share/profanity/plugins/.
cp tests/python-test.py ~/.local/share/profanity/plugins/. cp tests/python-test.py ~/.local/share/profanity/plugins/.
cd pid cd pid

View File

@@ -1,16 +1,20 @@
""" """
Convert smileys ( :) :( etc) to the Unicode character representation Convert smileys ( :) :( etc) to the Unicode character representation
Dependencies:
pip install future
""" """
import prof import prof
from builtins import chr
def _emote(input_str): def _emote(input_str):
result = input_str result = input_str
result = result.replace(":-)", u'\u263a'.encode("utf-8")) result = result.replace(":-)", chr(9786))
result = result.replace(":)", u'\u263a'.encode("utf-8")) result = result.replace(":)", chr(9786))
result = result.replace(":-(", u'\u2639'.encode("utf-8")) result = result.replace(":-(", chr(9785))
result = result.replace(":(", u'\u2639'.encode("utf-8")) result = result.replace(":(", chr(9785))
return result return result

View File

@@ -1,10 +1,13 @@
""" """
Paste the contents of the clipboard when in a chat or room window. Paste the contents of the clipboard when in a chat or room window.
Dependencies:
pip install future
sudo apt-get python-tk (or python3-tk)
""" """
import prof import prof
import sys import tkinter as tk
import Tkinter as tk
def _cmd_paste(): def _cmd_paste():

View File

@@ -30,10 +30,10 @@ cmd_pid(char **args)
void void
prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid) prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid)
{ {
const char *synopsis[] = { "/pid", NULL }; char *synopsis[] = { "/pid", NULL };
const char *description = "Show process ID and parent Process ID in the console window."; char *description = "Show process ID and parent Process ID in the console window.";
const char *args[][2] = { { NULL, NULL } }; char *args[][2] = { { NULL, NULL } };
const char *examples[] = { NULL }; char *examples[] = { NULL };
prof_register_command("/pid", 0, 0, synopsis, description, args, examples, cmd_pid); prof_register_command("/pid", 0, 0, synopsis, description, args, examples, cmd_pid);
} }

164
presence_notify.py Normal file
View File

@@ -0,0 +1,164 @@
import prof
online = set()
def _show_settings():
prof.cons_show("")
prof.cons_show("Presence notify plugin settings:")
mode = prof.settings_string_get("presence_notify", "mode", "all")
prof.cons_show("Mode: {mode}".format(mode=mode))
resource = prof.settings_boolean_get("presence_notify", "resource", False)
if resource:
prof.cons_show("Resource: ON")
else:
prof.cons_show("Resource: OFF")
ignored_list = prof.settings_string_list_get("presence_notify", "ignored")
if ignored_list and len(ignored_list) > 0:
prof.cons_show("Ignored:")
for contact in ignored_list:
prof.cons_show(" {barejid}".format(barejid=contact))
def _cmd_presence_notify(arg1=None, arg2=None, arg3=None):
if arg1 == "all":
prof.settings_string_set("presence_notify", "mode", "all")
prof.cons_show("Notifying on all presence changes")
return
if arg1 == "online":
prof.settings_string_set("presence_notify", "mode", "online")
prof.cons_show("Notifying on online/offline presence changes only")
return
if arg1 == "off":
prof.settings_string_set("presence_notify", "mode", "off")
prof.cons_show("Presence notifications disabled")
return
if arg1 == "ignored":
if arg2 == "clear":
prof.settings_string_list_clear("presence_notify", "ignored")
prof.cons_show("Removed all ignored contacts for presence notifications")
return
if arg2 == "add":
if not arg3:
prof.cons_bad_cmd_usage("/presence_notify")
return
prof.settings_string_list_add("presence_notify", "ignored", arg3)
prof.cons_show("Added {contact} to ignored contacts for presence notifications".format(contact=arg3))
return
if arg2 == "remove":
if not arg3:
prof.cons_bad_cmd_usage("/presence_notify")
return
res = prof.settings_string_list_remove("presence_notify", "ignored", arg3)
if res:
prof.cons_show("Removed {contact} from ignored contacts for presence notifications".format(contact=arg3))
else:
prof.cons_show("{contact} not in ignore list for presence notiications".format(contact=arg3))
return
prof.cons_bad_cmd_usage("/presence_notify")
return
if arg1 == "resource":
if arg2 == "on":
prof.settings_boolean_set("presence_notify", "resource", True)
prof.cons_show("Showing resource in presence notifications")
return;
if arg2 == "off":
prof.settings_boolean_set("presence_notify", "resource", False)
prof.cons_show("Hiding resource in presence notifications")
return;
prof.cons_bad_cmd_usage("/presence_notify")
return
_show_settings()
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/presence_notify all|online|off",
"/presence_notify ignored add|remove|clear [<barejid>]",
"/presence_notify resource on|off"
]
description = "Send a desktop notification on presence updates."
args = [
[ "all", "Enable all presence notifications" ],
[ "online", "Enable only online/offline presence notifications" ],
[ "off", "Disable presence notifications" ],
[ "ignored add|remove <barejid>", "Add or remove a contact from the list excluded from presence notifications"],
[ "ignored clear", "Clear the list of excluded contacts"],
[ "resource on|off", "Enable/disable showing the contacts resource in the notification"]
]
examples = [
"/presence_notify all",
"/presence_notify ignored add bob@server.org"
]
prof.register_command("/presence_notify", 0, 3, synopsis, description, args, examples, _cmd_presence_notify)
prof.completer_add("/presence_notify",
[ "all", "online", "off", "ignored", "resource" ]
)
prof.completer_add("/presence_notify ignored",
[ "add", "remove", "clear" ]
)
prof.completer_add("/presence_notify resource",
[ "on", "off" ]
)
def _do_notify(barejid, presence):
ignored = prof.settings_string_list_get("presence_notify", "ignored")
if ignored and barejid in ignored:
return False
mode = prof.settings_string_get("presence_notify", "mode", "all")
if mode == "all":
return True
elif mode == "online":
if barejid in online:
if presence == "offline":
online.remove(barejid)
return True
else:
return False
else:
if presence != "offline":
online.add(barejid)
return True
else:
return False
else: # off
return False
def prof_on_contact_presence(barejid, resource, presence, status, priority):
if _do_notify(barejid, presence):
jid = barejid
if prof.settings_boolean_get("presence_notify", "resource", False):
jid = jid + "/" + resource
message = "{jid} is {presence}".format(jid=jid, presence=presence)
if status:
message = message + ", \"{status}\"".format(status=status)
prof.notify(message, 5000, "Presence")
return
def prof_on_contact_offline(barejid, resource, status):
if _do_notify(barejid, "offline"):
jid = barejid
if prof.settings_boolean_get("presence_notify", "resource", False):
jid = jid + "/" + resource
message = "{jid} is offline".format(jid=jid)
if status:
message = message + ", \"{status}\"".format(status=status)
prof.notify(message, 5000, "Presence")
return

44
prof-irc.py Normal file
View File

@@ -0,0 +1,44 @@
import prof
import irc.client
def on_join(connection, event):
main_loop(connection)
def on_connect(connection, event):
if irc.client.is_channel(target):
connection.join(target)
return
main_loop(connection)
def get_lines():
while True:
yield sys.stdin.readline().strip()
def main_loop(connection):
for line in itertools.takewhile(bool, get_lines()):
print(line)
connection.privmsg(target, line)
connection.quit("Using irc.client.py")
def on_disconnect(connection, event):
raise SystemExit()
def prof_init(version, status, account_name, fulljid):
reactor = irc.client.Reactor()
try:
c = reactor.server().connect("irc.freenode.net", 6665, "boothj5")
except irc.client.ServerConnectionError:
prof.cons_show(sys.exc_info()[1])
c.add_global_handler("welcome", on_connect)
c.add_global_handler("join", on_join)
c.add_global_handler("disconnect", on_disconnect)
reactor.process_forever()

28
say.py
View File

@@ -12,7 +12,7 @@ import os
from sys import platform from sys import platform
def say(message): def say(message):
args = prof.settings_get_string("say", "args", "") args = prof.settings_string_get("say", "args", "")
if platform == "darwin": if platform == "darwin":
os.system("say " + args + " '" + message + "' 2>/dev/null") os.system("say " + args + " '" + message + "' 2>/dev/null")
@@ -21,7 +21,7 @@ def say(message):
def prof_post_chat_message_display(jid, message): def prof_post_chat_message_display(jid, message):
enabled = prof.settings_get_string("say", "enabled", "off") enabled = prof.settings_string_get("say", "enabled", "off")
current_recipient = prof.get_current_recipient() current_recipient = prof.get_current_recipient()
if enabled == "on" or (enabled == "active" and current_recipient == jid): if enabled == "on" or (enabled == "active" and current_recipient == jid):
say(jid + " says " + message) say(jid + " says " + message)
@@ -30,10 +30,12 @@ def prof_post_chat_message_display(jid, message):
def prof_post_room_message_display(room, nick, message): def prof_post_room_message_display(room, nick, message):
enabled = prof.settings_get_string("say", "enabled", "off") enabled = prof.settings_string_get("say", "enabled", "off")
current_muc = prof.get_current_muc() current_muc = prof.get_current_muc()
if enabled == "on" or (enable == "active" and current_muc == jid): if enabled == "on":
say(nick + " says " + message + " in " + room) say(nick + " in " + room + " says " + message)
elif enabled == "active" and current_muc == room:
say(nick + " says " + message)
return message return message
@@ -48,22 +50,22 @@ def prof_post_priv_message_display(room, nick, message):
def _cmd_say(arg1=None, arg2=None): def _cmd_say(arg1=None, arg2=None):
if arg1 == "on": if arg1 == "on":
prof.settings_set_string("say", "enabled", "on") prof.settings_string_set("say", "enabled", "on")
prof.cons_show("Say plugin enabled") prof.cons_show("Say plugin enabled")
elif arg1 == "off": elif arg1 == "off":
prof.settings_set_string("say", "enabled", "off") prof.settings_string_set("say", "enabled", "off")
prof.cons_show("Say plugin disabled") prof.cons_show("Say plugin disabled")
elif arg1 == "active": elif arg1 == "active":
prof.settings_set_string("say", "enabled", "active") prof.settings_string_set("say", "enabled", "active")
prof.cons_show("Say plugin enabled for active window only") prof.cons_show("Say plugin enabled for active window only")
elif arg1 == "args": elif arg1 == "args":
if arg2 == None: if arg2 == None:
prof.cons_bad_cmd_usage("/say") prof.cons_bad_cmd_usage("/say")
else: else:
prof.settings_set_string("say", "args", arg2) prof.settings_string_set("say", "args", arg2)
prof.cons_show("Say plugin arguments set to: " + arg2) prof.cons_show("Say plugin arguments set to: " + arg2)
elif arg1 == "clearargs": elif arg1 == "clearargs":
prof.settings_set_string("say", "args", "") prof.settings_string_set("say", "args", "")
prof.cons_show("Say plugin arguments cleared") prof.cons_show("Say plugin arguments cleared")
elif arg1 == "test": elif arg1 == "test":
if arg2 == None: if arg2 == None:
@@ -71,8 +73,8 @@ def _cmd_say(arg1=None, arg2=None):
else: else:
say(arg2) say(arg2)
else: else:
enabled = prof.settings_get_string("say", "enabled", "off") enabled = prof.settings_string_get("say", "enabled", "off")
args = prof.settings_get_string("say", "args", "") args = prof.settings_string_get("say", "args", "")
prof.cons_show("Say plugin settings:") prof.cons_show("Say plugin settings:")
prof.cons_show("enabled : " + enabled) prof.cons_show("enabled : " + enabled)
if args != "": if args != "":
@@ -86,7 +88,7 @@ def prof_init(version, status, account_name, fulljid):
"/say clearargs", "/say clearargs",
"/say test <message>" "/say test <message>"
] ]
description = "Read all messages out loud" description = "Read messages out loud"
args = [ args = [
[ "on|off", "Enable/disable say for all windows" ], [ "on|off", "Enable/disable say for all windows" ],
[ "active", "Enable say for active window only" ], [ "active", "Enable say for active window only" ],

View File

@@ -7,42 +7,46 @@ plugin_win = "Python Test"
count = 0 count = 0
ping_id = 1 ping_id = 1
count_thread = None
thread_stop = None
def _inc_counter(): def _inc_counter():
global count global count
while True: global thread_stop
while not thread_stop.is_set():
time.sleep(5) time.sleep(5)
count = count + 1 count = count + 1
def _handle_win_input(win, line): def _handle_win_input(win, line):
prof.win_show(win, "Input received: " + 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(): def _consalert():
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.cons_alert() prof.cons_alert()
prof.win_show(plugin_win, "called -> prof.cons_alert") prof.win_show(plugin_win, "called -> prof.cons_alert")
def _consshow(msg): def _consshow(msg):
if not msg: if not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.cons_show(msg) prof.cons_show(msg)
prof.win_show(plugin_win, "called -> prof.cons_show: " + msg) prof.win_show(plugin_win, "called -> prof.cons_show: " + msg)
def _consshow_t(group, key, dflt, msg): def _consshow_t(group, key, dflt, msg):
if not group or not key or not dflt or not msg: if not group or not key or not dflt or not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
groupval = None if group == "none" else group groupval = None if group == "none" else group
keyval = None if key == "none" else key keyval = None if key == "none" else key
@@ -50,31 +54,34 @@ def _consshow_t(group, key, dflt, msg):
prof.cons_show_themed(groupval, keyval, dfltval, msg) prof.cons_show_themed(groupval, keyval, dfltval, msg)
prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg) prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg)
def _constest(): def _constest():
res = prof.current_win_is_console() res = prof.current_win_is_console()
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
if res: if res:
prof.win_show(plugin_win, "called -> prof.current_win_is_console: true") prof.win_show(plugin_win, "called -> prof.current_win_is_console: true")
else: else:
prof.win_show(plugin_win, "called -> prof.current_win_is_console: false") prof.win_show(plugin_win, "called -> prof.current_win_is_console: false")
def _winshow(msg): def _winshow(msg):
if not msg: if not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.win_show(plugin_win, msg) prof.win_show(plugin_win, msg)
prof.win_show(plugin_win, "called -> prof.win_show: " + msg) prof.win_show(plugin_win, "called -> prof.win_show: " + msg)
def _winshow_t(group, key, dflt, msg): def _winshow_t(group, key, dflt, msg):
if not group or not key or not dflt or not msg: if not group or not key or not dflt or not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
groupval = None if group == "none" else group groupval = None if group == "none" else group
keyval = None if key == "none" else key keyval = None if key == "none" else key
@@ -82,29 +89,32 @@ def _winshow_t(group, key, dflt, msg):
prof.win_show_themed(plugin_win, groupval, keyval, dfltval, msg) prof.win_show_themed(plugin_win, groupval, keyval, dfltval, msg)
prof.win_show(plugin_win, "called -> prof_win_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg) prof.win_show(plugin_win, "called -> prof_win_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg)
def _sendline(line): def _sendline(line):
if not line: if not line:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.send_line(line) prof.send_line(line)
prof.win_show(plugin_win, "called -> prof.send_line: " + line) prof.win_show(plugin_win, "called -> prof.send_line: " + line)
def _notify(msg): def _notify(msg):
if not msg: if not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.notify(msg, 5000, "python-test plugin") prof.notify(msg, 5000, "python-test plugin")
prof.win_show(plugin_win, "called -> prof.notify: " + msg) prof.win_show(plugin_win, "called -> prof.notify: " + msg)
def _get(subject): def _get(subject):
if subject == "recipient": if subject == "recipient":
_create_win() prof.win_create(plugin_win, _handle_win_input)
recipient = prof.get_current_recipient(); recipient = prof.get_current_recipient();
if recipient: if recipient:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -113,7 +123,7 @@ def _get(subject):
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_recipient: <none>") prof.win_show(plugin_win, "called -> prof_get_current_recipient: <none>")
elif subject == "room": elif subject == "room":
_create_win() prof.win_create(plugin_win, _handle_win_input)
room = prof.get_current_muc() room = prof.get_current_muc()
if room: if room:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -122,7 +132,7 @@ def _get(subject):
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>") prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
elif subject == "nick": elif subject == "nick":
_create_win() prof.win_create(plugin_win, _handle_win_input)
nick = prof.get_current_nick() nick = prof.get_current_nick()
if nick: if nick:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -131,7 +141,7 @@ def _get(subject):
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.win_show(plugin_win, "called -> prof_get_current_nick: <none>") prof.win_show(plugin_win, "called -> prof_get_current_nick: <none>")
elif subject == "occupants": elif subject == "occupants":
_create_win() prof.win_create(plugin_win, _handle_win_input)
occupants = prof.get_current_occupants() occupants = prof.get_current_occupants()
if occupants: if occupants:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -144,39 +154,42 @@ def _get(subject):
else: else:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
def _log(level, msg): def _log(level, msg):
if not level or not msg: if not level or not msg:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
if level == "debug": if level == "debug":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.log_debug(msg) prof.log_debug(msg)
prof.win_show(plugin_win, "called -> prof.log_debug: " + msg) prof.win_show(plugin_win, "called -> prof.log_debug: " + msg)
elif level == "info": elif level == "info":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.log_info(msg) prof.log_info(msg)
prof.win_show(plugin_win, "called -> prof.log_info: " + msg) prof.win_show(plugin_win, "called -> prof.log_info: " + msg)
elif level == "warning": elif level == "warning":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.log_warning(msg) prof.log_warning(msg)
prof.win_show(plugin_win, "called -> prof.log_warning: " + msg) prof.win_show(plugin_win, "called -> prof.log_warning: " + msg)
elif level == "error": elif level == "error":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.log_error(msg) prof.log_error(msg)
prof.win_show(plugin_win, "called -> prof.log_error: " + msg) prof.win_show(plugin_win, "called -> prof.log_error: " + msg)
else: else:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
def _count(): def _count():
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.win_show(plugin_win, "Count: " + str(count)) prof.win_show(plugin_win, "Count: " + str(count))
def _ping(jid): def _ping(jid):
global ping_id global ping_id
@@ -184,7 +197,7 @@ def _ping(jid):
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) 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>") 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 ping_id = ping_id + 1
@@ -193,6 +206,7 @@ def _ping(jid):
else: else:
prof.win_show(plugin_win, "Error sending ping") prof.win_show(plugin_win, "Error sending ping")
def _boolean(op, group, key, value_str): def _boolean(op, group, key, value_str):
if op != "get" and op != "set": if op != "get" and op != "set":
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
@@ -208,9 +222,9 @@ def _boolean(op, group, key, value_str):
if op == "get": if op == "get":
dflt = False dflt = False
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_get_boolean(group, key, dflt) res = prof.settings_boolean_get(group, key, dflt)
if res: if res:
prof.win_show(plugin_win, "Boolean setting: TRUE") prof.win_show(plugin_win, "Boolean setting: TRUE")
else: else:
@@ -219,11 +233,12 @@ def _boolean(op, group, key, value_str):
value = False value = False
if value_str == "true": if value_str == "true":
value = True value = True
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_set_boolean(group, key, value) prof.settings_boolean_set(group, key, value)
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value))
def _string(op, group, key, value): def _string(op, group, key, value):
if op != "get" and op != "set": if op != "get" and op != "set":
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
@@ -238,19 +253,73 @@ def _string(op, group, key, value):
return return
if op == "get": if op == "get":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_get_string(group, key, None) res = prof.settings_string_get(group, key, None)
if res: if res:
prof.win_show(plugin_win, "String setting: " + res) prof.win_show(plugin_win, "String setting: " + res)
else: else:
prof.win_show(plugin_win, "String setting: None") prof.win_show(plugin_win, "String setting: None")
elif op == "set": elif op == "set":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_set_string(group, key, value) prof.settings_string_set(group, key, value)
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + value) prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + value)
def _string_list(op, group, key, value):
if op != "get" and op != "add" and op !="remove" and op != "remove_all":
prof.cons_bad_cmd_usage("/python-test")
return
if op == "get":
if group == None or key == None:
prof.cons_bad_cmd_usage("/python-test")
return
res = prof.settings_string_list_get(group, key)
prof.win_focus(plugin_win)
if res is None:
prof.win_show(plugin_win, "No list found")
return
prof.win_show(plugin_win, "String list:")
for el in res:
prof.win_show(plugin_win, " " + el)
return
if op == "add":
if group == None or key == None or value == None:
prof.cons_bad_cmd_usage("/python-test")
return
prof.settings_string_list_add(group, key, value)
prof.win_focus(plugin_win)
prof.win_show(plugin_win, "Added '" + value + "' to [" + group + "]" + " " + key)
return
if op == "remove":
if group == None or key == None or value == None:
prof.cons_bad_cmd_usage("/python-test")
return
res = prof.settings_string_list_remove(group, key, value)
prof.win_focus(plugin_win)
if res:
prof.win_show(plugin_win, "Removed '" + value + "' from [" + group + "]" + " " + key)
else:
prof.win_show(plugin_win, "Error removing string item from list")
return;
if op == "remove_all":
if group == None or key == None:
prof.cons_bad_cmd_usage("/python-test")
return
res = prof.settings_string_list_clear(group, key)
prof.win_focus(plugin_win)
if res:
prof.win_show(plugin_win, "Removed all items from [" + group + "]" + " " + key)
else:
prof.win_show(plugin_win, "Error removing list")
return
def _int(op, group, key, value): def _int(op, group, key, value):
if op != "get" and op != "set": if op != "get" and op != "set":
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
@@ -261,16 +330,17 @@ def _int(op, group, key, value):
return return
if op == "get": if op == "get":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_get_int(group, key, 0) res = prof.settings_int_get(group, key, 0)
prof.win_show(plugin_win, "Integer setting: " + str(res)) prof.win_show(plugin_win, "Integer setting: " + str(res))
elif op == "set": elif op == "set":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_set_int(group, key, int(value)) prof.settings_int_set(group, key, int(value))
prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value))
def _incoming(barejid, resource, message): def _incoming(barejid, resource, message):
if not barejid or not resource or not message: if not barejid or not resource or not message:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
@@ -278,19 +348,20 @@ def _incoming(barejid, resource, message):
prof.incoming_message(barejid, resource, message) prof.incoming_message(barejid, resource, message)
def _completer(op, item): def _completer(op, item):
if not item: if not item:
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
if op == "add": if op == "add":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.completer_add("/python-test", [item]) prof.completer_add("/python-test", [item])
prof.win_show(plugin_win, "Added \"" + item + "\" to /python-test completer") prof.win_show(plugin_win, "Added \"" + item + "\" to /python-test completer")
prof.completer_add("/python-test completer remove", [item]) prof.completer_add("/python-test completer remove", [item])
elif op == "remove": elif op == "remove":
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.completer_remove("/python-test", [item]) prof.completer_remove("/python-test", [item])
prof.win_show(plugin_win, "Removed \"" + item + "\" to /python-test completer") prof.win_show(plugin_win, "Removed \"" + item + "\" to /python-test completer")
@@ -300,33 +371,44 @@ def _completer(op, item):
def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None): def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None):
if subcmd == "consalert": _consalert() if subcmd == "consalert": _consalert()
elif subcmd == "consshow": _consshow(arg1) elif subcmd == "consshow": _consshow(arg1)
elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4) elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4)
elif subcmd == "constest": _constest() elif subcmd == "constest": _constest()
elif subcmd == "winshow": _winshow(arg1) elif subcmd == "winshow": _winshow(arg1)
elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4) elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4)
elif subcmd == "sendline": _sendline(arg1) elif subcmd == "sendline": _sendline(arg1)
elif subcmd == "notify": _notify(arg1) elif subcmd == "notify": _notify(arg1)
elif subcmd == "get": _get(arg1) elif subcmd == "get": _get(arg1)
elif subcmd == "log": _log(arg1, arg2) elif subcmd == "log": _log(arg1, arg2)
elif subcmd == "count": _count() elif subcmd == "count": _count()
elif subcmd == "ping": _ping(arg1) elif subcmd == "ping": _ping(arg1)
elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4) elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4)
elif subcmd == "string": _string(arg1, arg2, arg3, arg4) elif subcmd == "string": _string(arg1, arg2, arg3, arg4)
elif subcmd == "int": _int(arg1, arg2, arg3, arg4) elif subcmd == "string_list": _string_list(arg1, arg2, arg3, arg4)
elif subcmd == "incoming": _incoming(arg1, arg2, arg3) elif subcmd == "int": _int(arg1, arg2, arg3, arg4)
elif subcmd == "completer": _completer(arg1, arg2) elif subcmd == "incoming": _incoming(arg1, arg2, arg3)
else: prof.cons_bad_cmd_usage("/python-test") elif subcmd == "completer": _completer(arg1, arg2)
else: prof.cons_bad_cmd_usage("/python-test")
def timed_callback(): def timed_callback():
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "timed -> timed_callback called") prof.win_show(plugin_win, "timed -> timed_callback called")
def prof_init(version, status, account_name, fulljid): def prof_init(version, status, account_name, fulljid):
t = threading.Thread(target=_inc_counter) global count
t.daemon = True global ping_id
t.start() global thread_stop
count = 0
ping_id = 1
thread_stop = threading.Event()
count_thread = threading.Thread(target=_inc_counter)
count_thread.daemon = True
count_thread.start()
prof.disco_add_feature("urn:xmpp:profanity:python_test_plugin"); prof.disco_add_feature("urn:xmpp:profanity:python_test_plugin");
@@ -353,6 +435,10 @@ def prof_init(version, status, account_name, fulljid):
"/python-test boolean set <group> <key> <value>", "/python-test boolean set <group> <key> <value>",
"/python-test string get <group> <key>", "/python-test string get <group> <key>",
"/python-test string set <group> <key> <value>", "/python-test string set <group> <key> <value>",
"/python-test string_list get <group> <key>",
"/python-test string_list add <group> <key> <value>",
"/python-test string_list remove <group> <key> <value>",
"/python-test string_list remove_all <group> <key>",
"/python-test int get <group> <key>", "/python-test int get <group> <key>",
"/python-test int set <group> <key> <value>", "/python-test int set <group> <key> <value>",
"/python-test incoming <barejid> <resource> <message>", "/python-test incoming <barejid> <resource> <message>",
@@ -379,6 +465,10 @@ def prof_init(version, status, account_name, fulljid):
[ "boolean set <group> <key> <value>", "Set a boolean setting" ], [ "boolean set <group> <key> <value>", "Set a boolean setting" ],
[ "string get <group> <key>", "Get a string setting" ], [ "string get <group> <key>", "Get a string setting" ],
[ "string set <group> <key> <value>", "Set a string setting" ], [ "string set <group> <key> <value>", "Set a string setting" ],
[ "string_list get <group> <key>", "Get a string list setting" ],
[ "string_list add <group> <key> <value>", "Add a string to a string list setting" ],
[ "string_list remove <group> <key> <value>", "Remove a string from a string list setting" ],
[ "string_list remove_all <group> <key>", "Remove all strings from a string list setting" ],
[ "int get <group> <key>", "Get a integer setting" ], [ "int get <group> <key>", "Get a integer setting" ],
[ "int set <group> <key> <value>", "Set 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." ],
@@ -411,6 +501,7 @@ def prof_init(version, status, account_name, fulljid):
"ping", "ping",
"boolean", "boolean",
"string", "string",
"string_list",
"int", "int",
"incoming", "incoming",
"completer" "completer"
@@ -428,6 +519,9 @@ def prof_init(version, status, account_name, fulljid):
prof.completer_add("/python-test string", prof.completer_add("/python-test string",
[ "get", "set" ] [ "get", "set" ]
) )
prof.completer_add("/python-test string_list",
[ "get", "add", "remove", "remove_all" ]
)
prof.completer_add("/python-test int", prof.completer_add("/python-test int",
[ "get", "set" ] [ "get", "set" ]
) )
@@ -435,124 +529,164 @@ def prof_init(version, status, account_name, fulljid):
[ "add", "remove" ] [ "add", "remove" ]
) )
prof.register_timed(timed_callback, 30) prof.register_timed(timed_callback, 5)
def prof_on_start(): def prof_on_start():
_create_win() prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_start") prof.win_show(plugin_win, "fired -> prof_on_start")
def prof_on_shutdown(): def prof_on_shutdown():
_create_win() global thread_stop
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_shutdown") prof.win_show(plugin_win, "fired -> prof_on_shutdown")
thread_stop.set()
count_thread.join()
def prof_on_unload():
global thread_stop
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): 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) prof.win_show(plugin_win, "fired -> prof_on_connect: " + account_name + ", " + fulljid)
def prof_on_disconnect(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) prof.win_show(plugin_win, "fired -> prof_on_disconnect: " + account_name + ", " + fulljid)
def prof_pre_chat_message_display(jid, message): 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) prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + jid + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_chat_message_display: " + jid + ", " + message)
def prof_pre_chat_message_send(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) prof.win_show(plugin_win, "fired -> prof_pre_chat_message_send: " + jid + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + jid + ", " + message)
def prof_pre_room_message_display(room, nick, 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) prof.win_show(plugin_win, "fired -> prof_pre_room_message_display: " + room + ", " + nick + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_room_message_display: " + room + ", " + nick + ", " + message)
def prof_pre_room_message_send(room, 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) prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + room + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_room_message_send: " + room + ", " + message)
def prof_on_room_history_message(room, nick, message, timestamp): def prof_on_room_history_message(room, nick, message, timestamp):
_create_win() prof.win_create(plugin_win, _handle_win_input)
if timestamp: if timestamp:
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message + ", " + timestamp) prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message + ", " + timestamp)
else: else:
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message) prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message)
def prof_pre_priv_message_display(room, nick, message): 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) prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + room + ", " + nick + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_priv_message_display: " + room + ", " + nick + ", " + message)
def prof_pre_priv_message_send(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) prof.win_show(plugin_win, "fired -> prof_pre_priv_message_send: " + room + ", " + nick + ", " + message)
def prof_post_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) prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + room + ", " + nick + ", " + message)
def prof_on_message_stanza_send(stanza): 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) prof.win_show(plugin_win, "fired -> prof_on_message_stanza_send: " + stanza)
def prof_on_message_stanza_receive(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) prof.win_show(plugin_win, "fired -> prof_on_message_stanza_receive: " + stanza)
return True return True
def prof_on_presence_stanza_send(stanza): 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) prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_send: " + stanza)
def prof_on_presence_stanza_receive(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) prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_receive: " + stanza)
return True return True
def prof_on_iq_stanza_send(stanza): 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) prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_send: " + stanza)
def prof_on_iq_stanza_receive(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) prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_receive: " + stanza)
return True return True
def prof_on_contact_offline(barejid, resource, status): def prof_on_contact_offline(barejid, resource, status):
_create_win() prof.win_create(plugin_win, _handle_win_input)
if status: if status:
prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource + " \"" + status + "\"") prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource + " \"" + status + "\"")
else: else:
prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource) prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource)
def prof_on_contact_presence(barejid, resource, presence, status, priority): def prof_on_contact_presence(barejid, resource, presence, status, priority):
_create_win() prof.win_create(plugin_win, _handle_win_input)
if status: if status:
prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"") prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"")
else: else:
prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority)) prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority))
def prof_on_chat_win_focus(barejid): 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) prof.win_show(plugin_win, "fired -> prof_on_chat_win_focus: " + barejid)
def prof_on_room_win_focus(roomjid): 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) prof.win_show(plugin_win, "fired -> prof_on_room_win_focus: " + roomjid)

View File

@@ -31,18 +31,10 @@ handle_win_input(PROF_WIN_TAG win, char *line)
prof_win_show(win, buf); prof_win_show(win, buf);
} }
void
create_win(void)
{
if (!prof_win_exists(plugin_win)) {
prof_win_create(plugin_win, handle_win_input);
}
}
void void
consalert(void) consalert(void)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_cons_alert(); prof_cons_alert();
prof_win_show(plugin_win, "called -> prof_cons_alert"); prof_win_show(plugin_win, "called -> prof_cons_alert");
@@ -55,7 +47,7 @@ consshow(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_cons_show(msg); prof_cons_show(msg);
char *str = "called -> prof_cons_show: "; char *str = "called -> prof_cons_show: ";
@@ -71,7 +63,7 @@ consshow_t(char *group, char *key, char *def, char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *groupval = strcmp(group, "none") == 0 ? NULL : group; char *groupval = strcmp(group, "none") == 0 ? NULL : group;
char *keyval = strcmp(key, "none") == 0 ? NULL : key; char *keyval = strcmp(key, "none") == 0 ? NULL : key;
@@ -87,7 +79,7 @@ void
constest(void) constest(void)
{ {
int res = prof_current_win_is_console(); int res = prof_current_win_is_console();
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
if (res) { if (res) {
prof_win_show(plugin_win, "called -> prof_current_win_is_console: true"); prof_win_show(plugin_win, "called -> prof_current_win_is_console: true");
@@ -103,7 +95,7 @@ winshow(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_win_show(plugin_win, msg); prof_win_show(plugin_win, msg);
char *str = "called -> prof_win_show: "; char *str = "called -> prof_win_show: ";
@@ -119,7 +111,7 @@ winshow_t(char *group, char *key, char *def, char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *groupval = strcmp(group, "none") == 0 ? NULL : group; char *groupval = strcmp(group, "none") == 0 ? NULL : group;
char *keyval = strcmp(key, "none") == 0 ? NULL : key; char *keyval = strcmp(key, "none") == 0 ? NULL : key;
@@ -138,7 +130,7 @@ sendline(char *line)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_send_line(line); prof_send_line(line);
char *str = "called -> prof_send_line: "; char *str = "called -> prof_send_line: ";
@@ -154,7 +146,7 @@ donotify(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_notify(msg, 5000, "c-test plugin"); prof_notify(msg, 5000, "c-test plugin");
char *str = "called -> prof_notify: "; char *str = "called -> prof_notify: ";
@@ -172,7 +164,7 @@ getsubject(char *subject)
} }
if (strcmp(subject, "recipient") == 0) { if (strcmp(subject, "recipient") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *recipient = prof_get_current_recipient(); char *recipient = prof_get_current_recipient();
if (recipient) { if (recipient) {
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
@@ -185,7 +177,7 @@ getsubject(char *subject)
prof_win_show(plugin_win, "called -> prof_get_current_recipient: <none>"); prof_win_show(plugin_win, "called -> prof_get_current_recipient: <none>");
} }
} else if (strcmp(subject, "room") == 0) { } else if (strcmp(subject, "room") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *room = prof_get_current_muc(); char *room = prof_get_current_muc();
if (room) { if (room) {
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
@@ -198,7 +190,7 @@ getsubject(char *subject)
prof_win_show(plugin_win, "called -> prof_get_current_muc: <none>"); prof_win_show(plugin_win, "called -> prof_get_current_muc: <none>");
} }
} else if (strcmp(subject, "nick") == 0) { } else if (strcmp(subject, "nick") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *nick = prof_get_current_nick(); char *nick = prof_get_current_nick();
if (nick) { if (nick) {
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
@@ -211,7 +203,7 @@ getsubject(char *subject)
prof_win_show(plugin_win, "called -> prof_get_current_nick: <none>"); prof_win_show(plugin_win, "called -> prof_get_current_nick: <none>");
} }
} else if (strcmp(subject, "occupants") == 0) { } else if (strcmp(subject, "occupants") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
char **occupants = prof_get_current_occupants(); char **occupants = prof_get_current_occupants();
if (occupants) { if (occupants) {
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
@@ -239,7 +231,7 @@ logmsg(char *level, char *msg)
} }
if (strcmp(level, "debug") == 0) { if (strcmp(level, "debug") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_log_debug(msg); prof_log_debug(msg);
char *str = "called -> prof_log_debug: "; char *str = "called -> prof_log_debug: ";
@@ -247,7 +239,7 @@ logmsg(char *level, char *msg)
sprintf(buf, "%s%s", str, msg); sprintf(buf, "%s%s", str, msg);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
} else if (strcmp(level, "info") == 0) { } else if (strcmp(level, "info") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_log_info(msg); prof_log_info(msg);
char *str = "called -> prof_log_info: "; char *str = "called -> prof_log_info: ";
@@ -255,7 +247,7 @@ logmsg(char *level, char *msg)
sprintf(buf, "%s%s", str, msg); sprintf(buf, "%s%s", str, msg);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
} else if (strcmp(level, "warning") == 0) { } else if (strcmp(level, "warning") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_log_warning(msg); prof_log_warning(msg);
char *str = "called -> prof_log_warning: "; char *str = "called -> prof_log_warning: ";
@@ -263,7 +255,7 @@ logmsg(char *level, char *msg)
sprintf(buf, "%s%s", str, msg); sprintf(buf, "%s%s", str, msg);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
} else if (strcmp(level, "error") == 0) { } else if (strcmp(level, "error") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_log_error(msg); prof_log_error(msg);
char *str = "called -> prof_log_error: "; char *str = "called -> prof_log_error: ";
@@ -278,7 +270,7 @@ logmsg(char *level, char *msg)
void void
docount(void) docount(void)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char buf[100]; char buf[100];
sprintf(buf, "Count: %d", count); sprintf(buf, "Count: %d", count);
@@ -292,7 +284,7 @@ doping(char *jid)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *strstart = "<iq to='"; char *strstart = "<iq to='";
char *strend = "' type='get'><ping xmlns='urn:xmpp:ping'/></iq>"; char *strend = "' type='get'><ping xmlns='urn:xmpp:ping'/></iq>";
@@ -330,9 +322,9 @@ booleansetting(char *op, char *group, char *key, char *value_str)
if (strcmp(op, "get") == 0) { if (strcmp(op, "get") == 0) {
int dflt = 0; int dflt = 0;
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int res = prof_settings_get_boolean(group, key, dflt); int res = prof_settings_boolean_get(group, key, dflt);
if (res) { if (res) {
prof_win_show(plugin_win, "Boolean setting: TRUE"); prof_win_show(plugin_win, "Boolean setting: TRUE");
} else { } else {
@@ -343,9 +335,9 @@ booleansetting(char *op, char *group, char *key, char *value_str)
if (strcmp(value_str, "true") == 0) { if (strcmp(value_str, "true") == 0) {
value = 1; value = 1;
} }
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_settings_set_boolean(group, key, value); prof_settings_boolean_set(group, key, value);
char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value_str)]; char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value_str)];
sprintf(buf, "Set [%s] %s to %s", group, key, value_str); sprintf(buf, "Set [%s] %s to %s", group, key, value_str);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
@@ -371,9 +363,9 @@ stringsetting(char *op, char *group, char *key, char *value)
} }
if (strcmp(op, "get") == 0) { if (strcmp(op, "get") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *res = prof_settings_get_string(group, key, NULL); char *res = prof_settings_string_get(group, key, NULL);
if (res) { if (res) {
char buf[16 + strlen(res)]; char buf[16 + strlen(res)];
sprintf(buf, "String setting: %s", res); sprintf(buf, "String setting: %s", res);
@@ -382,15 +374,96 @@ stringsetting(char *op, char *group, char *key, char *value)
prof_win_show(plugin_win, "String setting: NULL"); prof_win_show(plugin_win, "String setting: NULL");
} }
} else if (strcmp(op, "set") == 0) { } else if (strcmp(op, "set") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_settings_set_string(group, key, value); prof_settings_string_set(group, key, value);
char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value)]; char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value)];
sprintf(buf, "Set [%s] %s to %s", group, key, value); sprintf(buf, "Set [%s] %s to %s", group, key, value);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
} }
} }
void
stringlistsetting(char *op, char *group, char *key, char *value)
{
if ((strcmp(op, "get") != 0) && (strcmp(op, "add") != 0) && (strcmp(op, "remove") != 0) && (strcmp(op, "remove_all") != 0)) {
prof_cons_bad_cmd_usage("/c-test");
return;
}
if (strcmp(op, "get") == 0) {
if (group == NULL || key == NULL) {
prof_cons_bad_cmd_usage("/c-test");
return;
}
char** res = prof_settings_string_list_get(group, key);
prof_win_focus(plugin_win);
if (res == NULL) {
prof_win_show(plugin_win, "No list found");
return;
}
prof_win_show(plugin_win, "String list:");
int i = 0;
while (res[i] != NULL) {
char buf[2 + strlen(res[i]) + 1];
sprintf(buf, " %s", res[i]);
prof_win_show(plugin_win, buf);
i++;
}
return;
}
if (strcmp(op, "add") == 0) {
if (group == NULL || key == NULL || value == NULL) {
prof_cons_bad_cmd_usage("/c-test");
return;
}
prof_settings_string_list_add(group, key, value);
prof_win_focus(plugin_win);
char buf[7 + strlen(value) + 6 + strlen(group) + 2 + strlen(key) + 1];
sprintf(buf, "Added '%s' to [%s] %s", value, group, key);
prof_win_show(plugin_win, buf);
return;
}
if (strcmp(op, "remove") == 0) {
if (group == NULL || key == NULL || value == NULL) {
prof_cons_bad_cmd_usage("/c-test");
return;
}
int res = prof_settings_string_list_remove(group, key, value);
prof_win_focus(plugin_win);
if (res) {
char buf[9 + strlen(value) + 8 + strlen(group) + 2 + strlen(key) + 1];
sprintf(buf, "Removed '%s' from [%s] %s", value, group, key);
prof_win_show(plugin_win, buf);
} else {
prof_win_show(plugin_win, "Error removing string item from list");
}
return;
}
if (strcmp(op, "remove_all") == 0) {
if (group == NULL || key == NULL) {
prof_cons_bad_cmd_usage("/c-test");
return;
}
int res = prof_settings_string_list_clear(group, key);
prof_win_focus(plugin_win);
if (res) {
char buf[24 + strlen(group) + 2 + strlen(key) + 1];
sprintf(buf, "Removed all items from [%s] %s", group, key);
prof_win_show(plugin_win, buf);
} else {
prof_win_show(plugin_win, "Error removing list");
}
return;
}
return;
}
void void
intsetting(char *op, char *group, char *key, char *value) intsetting(char *op, char *group, char *key, char *value)
{ {
@@ -405,17 +478,17 @@ intsetting(char *op, char *group, char *key, char *value)
} }
if (strcmp(op, "get") == 0) { if (strcmp(op, "get") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int res = prof_settings_get_int(group, key, 0); int res = prof_settings_int_get(group, key, 0);
char buf[256]; char buf[256];
sprintf(buf, "Integer setting: %d", res); sprintf(buf, "Integer setting: %d", res);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
} else if (strcmp(op, "set") == 0) { } else if (strcmp(op, "set") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int int_value = atoi(value); int int_value = atoi(value);
prof_settings_set_int(group, key, int_value); prof_settings_int_set(group, key, int_value);
char buf[256]; char buf[256];
sprintf(buf, "Set [%s] %s to %d", group, key, int_value); sprintf(buf, "Set [%s] %s to %d", group, key, int_value);
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
@@ -437,7 +510,7 @@ completer(char *op, char *item)
} }
if (strcmp(op, "add") == 0) { if (strcmp(op, "add") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *ac[] = { item, NULL }; char *ac[] = { item, NULL };
prof_completer_add("/c-test", ac); prof_completer_add("/c-test", ac);
@@ -446,7 +519,7 @@ completer(char *op, char *item)
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
prof_completer_add("/c-test completer remove", ac); prof_completer_add("/c-test completer remove", ac);
} else if (strcmp(op, "remove") == 0) { } else if (strcmp(op, "remove") == 0) {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *ac[] = { item, NULL }; char *ac[] = { item, NULL };
prof_completer_remove("/c-test", ac); prof_completer_remove("/c-test", ac);
@@ -476,6 +549,7 @@ cmd_ctest(char **args)
else if (strcmp(args[0], "ping") == 0) doping(args[1]); 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], "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], "string") == 0) stringsetting(args[1], args[2], args[3], args[4]);
else if (strcmp(args[0], "string_list") == 0) stringlistsetting(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], "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], "incoming") == 0) incomingmsg(args[1], args[2], args[3]);
else if (strcmp(args[0], "completer") == 0) completer(args[1], args[2]); else if (strcmp(args[0], "completer") == 0) completer(args[1], args[2]);
@@ -485,7 +559,7 @@ cmd_ctest(char **args)
void void
timed_callback(void) timed_callback(void)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_show(plugin_win, "timed -> timed_callback called"); prof_win_show(plugin_win, "timed -> timed_callback called");
} }
@@ -506,7 +580,7 @@ prof_init(const char * const version, const char * const status, const char *con
} }
prof_win_show(plugin_win, buf); prof_win_show(plugin_win, buf);
const char *synopsis[] = { char *synopsis[] = {
"/c-test consalert", "/c-test consalert",
"/c-test consshow <message>", "/c-test consshow <message>",
"/c-test consshow_t <group> <key> <default> <message>", "/c-test consshow_t <group> <key> <default> <message>",
@@ -523,14 +597,18 @@ prof_init(const char * const version, const char * const status, const char *con
"/c-test boolean set <group> <key> <value>", "/c-test boolean set <group> <key> <value>",
"/c-test string get <group> <key>", "/c-test string get <group> <key>",
"/c-test string set <group> <key> <value>", "/c-test string set <group> <key> <value>",
"/c-test-test string_list get <group> <key>",
"/c-test string_list add <group> <key> <value>",
"/c-test string_list remove <group> <key> <value>",
"/c-test string_list remove_all <group> <key>",
"/c-test int get <group> <key>", "/c-test int get <group> <key>",
"/c-test int set <group> <key> <value>", "/c-test int set <group> <key> <value>",
"/c-test incoming <barejid> <resource> <message>", "/c-test incoming <barejid> <resource> <message>",
"/c-test completer add|remove <item>", "/c-test completer add|remove <item>",
NULL NULL
}; };
const char *description = "C test plugin. All commands focus the plugin window."; char *description = "C test plugin. All commands focus the plugin window.";
const char *args[][2] = { char *args[][2] = {
{ "consalert", "Highlight the console window in the status bar" }, { "consalert", "Highlight the console window in the status bar" },
{ "consshow <message>", "Show the message in the console window" }, { "consshow <message>", "Show the message in the console window" },
{ "consshow_t <group> <key> <default> <message>", "Show the themed message in the console window. " }, { "consshow_t <group> <key> <default> <message>", "Show the themed message in the console window. " },
@@ -550,6 +628,10 @@ prof_init(const char * const version, const char * const status, const char *con
{ "boolean set <group> <key> <value>", "Set a boolean setting" }, { "boolean set <group> <key> <value>", "Set a boolean setting" },
{ "string get <group> <key>", "Get a string setting" }, { "string get <group> <key>", "Get a string setting" },
{ "string set <group> <key> <value>", "Set a string setting" }, { "string set <group> <key> <value>", "Set a string setting" },
{ "string_list get <group> <key>", "Get a string list setting" },
{ "string_list add <group> <key> <value>", "Add a string to a string list setting" },
{ "string_list remove <group> <key> <value>", "Remove a string from a string list setting" },
{ "string_list remove_all <group> <key>", "Remove all strings from a string list setting" },
{ "int get <group> <key>", "Get a integer setting" }, { "int get <group> <key>", "Get a integer setting" },
{ "int set <group> <key> <value>", "Set 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." },
@@ -558,7 +640,7 @@ prof_init(const char * const version, const char * const status, const char *con
{ NULL, NULL } { NULL, NULL }
}; };
const char *examples[] = { char *examples[] = {
"/c-test sendline /about", "/c-test sendline /about",
"/c-test log debug \"Test debug message\"", "/c-test log debug \"Test debug message\"",
"/c-test consshow_t c-test cons.show none \"This is themed\"", "/c-test consshow_t c-test cons.show none \"This is themed\"",
@@ -584,6 +666,7 @@ prof_init(const char * const version, const char * const status, const char *con
"ping", "ping",
"boolean", "boolean",
"string", "string",
"string_list",
"int", "int",
"incoming", "incoming",
"completer", "completer",
@@ -603,33 +686,45 @@ prof_init(const char * const version, const char * const status, const char *con
char *string_ac[] = { "get", "set", NULL }; char *string_ac[] = { "get", "set", NULL };
prof_completer_add("/c-test string", string_ac); prof_completer_add("/c-test string", string_ac);
char *stringlist_ac[] = { "get", "add", "remove", "remove_all", NULL };
prof_completer_add("/c-test string_list", stringlist_ac);
char *int_ac[] = { "get", "set", NULL }; char *int_ac[] = { "get", "set", NULL };
prof_completer_add("/c-test int", int_ac); prof_completer_add("/c-test int", int_ac);
char *completer_ac[] = { "add", "remove", NULL }; char *completer_ac[] = { "add", "remove", NULL };
prof_completer_add("/c-test completer", completer_ac); prof_completer_add("/c-test completer", completer_ac);
prof_register_timed(timed_callback, 30); prof_register_timed(timed_callback, 5);
} }
void void
prof_on_start(void) prof_on_start(void)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_show(plugin_win, "fired -> prof_on_start"); prof_win_show(plugin_win, "fired -> prof_on_start");
} }
void void
prof_on_shutdown(void) prof_on_shutdown(void)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
prof_win_show(plugin_win, "fired -> prof_on_shutdown"); prof_win_show(plugin_win, "fired -> prof_on_shutdown");
pthread_cancel(worker_thread);
}
void
prof_on_unload(void)
{
prof_win_create(plugin_win, handle_win_input);
prof_win_show(plugin_win, "fired -> prof_on_unload");
pthread_cancel(worker_thread);
} }
void void
prof_on_connect(const char * const account_name, const char * const fulljid) prof_on_connect(const char * const account_name, const char * const fulljid)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_connect: "; char *str = "fired -> prof_on_connect: ";
char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1]; char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1];
@@ -640,7 +735,7 @@ prof_on_connect(const char * const account_name, const char * const fulljid)
void void
prof_on_disconnect(const char * const account_name, const char * const fulljid) prof_on_disconnect(const char * const account_name, const char * const fulljid)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_disconnect: "; char *str = "fired -> prof_on_disconnect: ";
char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1]; char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1];
@@ -651,7 +746,7 @@ prof_on_disconnect(const char * const account_name, const char * const fulljid)
char* char*
prof_pre_chat_message_display(const char * const jid, const char *message) prof_pre_chat_message_display(const char * const jid, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_chat_message_display: "; char *str = "fired -> prof_pre_chat_message_display: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
@@ -664,7 +759,7 @@ prof_pre_chat_message_display(const char * const jid, const char *message)
void void
prof_post_chat_message_display(const char * const jid, const char *message) prof_post_chat_message_display(const char * const jid, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_chat_message_display: "; char *str = "fired -> prof_post_chat_message_display: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
@@ -675,7 +770,7 @@ prof_post_chat_message_display(const char * const jid, const char *message)
char* char*
prof_pre_chat_message_send(const char * const jid, const char *message) prof_pre_chat_message_send(const char * const jid, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_chat_message_send: "; char *str = "fired -> prof_pre_chat_message_send: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
@@ -688,7 +783,7 @@ prof_pre_chat_message_send(const char * const jid, const char *message)
void void
prof_post_chat_message_send(const char * const jid, const char *message) prof_post_chat_message_send(const char * const jid, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_chat_message_send: "; char *str = "fired -> prof_post_chat_message_send: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
@@ -699,7 +794,7 @@ prof_post_chat_message_send(const char * const jid, const char *message)
char* char*
prof_pre_room_message_display(const char * const room, const char * const nick, const char *message) prof_pre_room_message_display(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_room_message_display: "; char *str = "fired -> prof_pre_room_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -712,7 +807,7 @@ prof_pre_room_message_display(const char * const room, const char * const nick,
void void
prof_post_room_message_display(const char * const room, const char * const nick, const char *message) prof_post_room_message_display(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_room_message_display: "; char *str = "fired -> prof_post_room_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -723,7 +818,7 @@ prof_post_room_message_display(const char * const room, const char * const nick,
char * char *
prof_pre_room_message_send(const char * const room, const char *message) prof_pre_room_message_send(const char * const room, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_room_message_send: "; char *str = "fired -> prof_pre_room_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1];
@@ -736,7 +831,7 @@ prof_pre_room_message_send(const char * const room, const char *message)
void void
prof_post_room_message_send(const char * const room, const char *message) prof_post_room_message_send(const char * const room, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_room_message_send: "; char *str = "fired -> prof_post_room_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1];
@@ -747,7 +842,7 @@ prof_post_room_message_send(const char * const room, const char *message)
void void
prof_on_room_history_message(const char * const room, const char *const nick, const char *const message, const char *const timestamp) prof_on_room_history_message(const char * const room, const char *const nick, const char *const message, const char *const timestamp)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_room_history_message: "; char *str = "fired -> prof_on_room_history_message: ";
if (timestamp == NULL) { if (timestamp == NULL) {
@@ -764,7 +859,7 @@ prof_on_room_history_message(const char * const room, const char *const nick, co
char * char *
prof_pre_priv_message_display(const char * const room, const char * const nick, const char *message) prof_pre_priv_message_display(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_priv_message_display: "; char *str = "fired -> prof_pre_priv_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -777,7 +872,7 @@ prof_pre_priv_message_display(const char * const room, const char * const nick,
void void
prof_post_priv_message_display(const char * const room, const char * const nick, const char *message) prof_post_priv_message_display(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_priv_message_display: "; char *str = "fired -> prof_post_priv_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -788,7 +883,7 @@ prof_post_priv_message_display(const char * const room, const char * const nick,
char * char *
prof_pre_priv_message_send(const char * const room, const char * const nick, const char *message) prof_pre_priv_message_send(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_priv_message_send: "; char *str = "fired -> prof_pre_priv_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -801,7 +896,7 @@ prof_pre_priv_message_send(const char * const room, const char * const nick, con
void void
prof_post_priv_message_send(const char * const room, const char * const nick, const char *message) prof_post_priv_message_send(const char * const room, const char * const nick, const char *message)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_priv_message_send: "; char *str = "fired -> prof_post_priv_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1]; char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
@@ -812,7 +907,7 @@ prof_post_priv_message_send(const char * const room, const char * const nick, co
char* char*
prof_on_message_stanza_send(const char *const stanza) prof_on_message_stanza_send(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_message_stanza_send: "; char *str = "fired -> prof_on_message_stanza_send: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -827,7 +922,7 @@ prof_on_message_stanza_send(const char *const stanza)
int int
prof_on_message_stanza_receive(const char *const stanza) prof_on_message_stanza_receive(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_message_stanza_receive: "; char *str = "fired -> prof_on_message_stanza_receive: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -840,7 +935,7 @@ prof_on_message_stanza_receive(const char *const stanza)
char* char*
prof_on_presence_stanza_send(const char *const stanza) prof_on_presence_stanza_send(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_presence_stanza_send: "; char *str = "fired -> prof_on_presence_stanza_send: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -853,7 +948,7 @@ prof_on_presence_stanza_send(const char *const stanza)
int int
prof_on_presence_stanza_receive(const char *const stanza) prof_on_presence_stanza_receive(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_presence_stanza_receive: "; char *str = "fired -> prof_on_presence_stanza_receive: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -866,7 +961,7 @@ prof_on_presence_stanza_receive(const char *const stanza)
char* char*
prof_on_iq_stanza_send(const char *const stanza) prof_on_iq_stanza_send(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_iq_stanza_send: "; char *str = "fired -> prof_on_iq_stanza_send: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -879,7 +974,7 @@ prof_on_iq_stanza_send(const char *const stanza)
int int
prof_on_iq_stanza_receive(const char *const stanza) prof_on_iq_stanza_receive(const char *const stanza)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_iq_stanza_receive: "; char *str = "fired -> prof_on_iq_stanza_receive: ";
char buf[strlen(str) + strlen(stanza) + 1]; char buf[strlen(str) + strlen(stanza) + 1];
@@ -892,7 +987,7 @@ prof_on_iq_stanza_receive(const char *const stanza)
void void
prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status) prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_contact_offline: "; char *str = "fired -> prof_on_contact_offline: ";
int status_len = status == NULL ? 0 : strlen(status) + 2; int status_len = status == NULL ? 0 : strlen(status) + 2;
@@ -908,7 +1003,7 @@ prof_on_contact_offline(const char *const barejid, const char *const resource, c
void void
prof_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority) prof_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_contact_presence: "; char *str = "fired -> prof_on_contact_presence: ";
int status_len = status == NULL ? 0 : strlen(status) + 2; int status_len = status == NULL ? 0 : strlen(status) + 2;
@@ -924,7 +1019,7 @@ prof_on_contact_presence(const char *const barejid, const char *const resource,
void void
prof_on_chat_win_focus(const char *const barejid) prof_on_chat_win_focus(const char *const barejid)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_chat_win_focus: "; char *str = "fired -> prof_on_chat_win_focus: ";
char buf[strlen(str) + strlen(barejid) + 1]; char buf[strlen(str) + strlen(barejid) + 1];
sprintf(buf, "%s%s", str, barejid); sprintf(buf, "%s%s", str, barejid);
@@ -934,7 +1029,7 @@ prof_on_chat_win_focus(const char *const barejid)
void void
prof_on_room_win_focus(const char *const roomjid) prof_on_room_win_focus(const char *const roomjid)
{ {
create_win(); prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_room_win_focus: "; char *str = "fired -> prof_on_room_win_focus: ";
char buf[strlen(str) + strlen(roomjid) + 1]; char buf[strlen(str) + strlen(roomjid) + 1];
sprintf(buf, "%s%s", str, roomjid); sprintf(buf, "%s%s", str, roomjid);

View File

@@ -78,8 +78,8 @@ def _search(search_terms):
if len(results) > 0: if len(results) > 0:
prof.win_show_themed(win, "wikipedia", "search", None, "Search results for \"" + search_terms + "\":") prof.win_show_themed(win, "wikipedia", "search", None, "Search results for \"" + search_terms + "\":")
for index, result in enumerate(results): for index, result in enumerate(results):
page_ac.append(result.encode("utf-8")) page_ac.append(result)
prof.win_show_themed(win, "wikipedia", "search.results", None, result.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "search.results", None, result)
_update_autocomplete() _update_autocomplete()
else: else:
prof.win_show_themed(win, "wikipedia", "search.noresults", None, "No search results found for \"" + search_terms + "\"") prof.win_show_themed(win, "wikipedia", "search.noresults", None, "No search results found for \"" + search_terms + "\"")
@@ -98,14 +98,14 @@ def _summary(page_str):
prof.win_focus(win) prof.win_focus(win)
return return
link_ac.append(page.url.encode("utf-8")) link_ac.append(page.url)
prof.completer_add("/wikipedia open", link_ac) prof.completer_add("/wikipedia open", link_ac)
prof.win_show_themed(win, "wikipedia", "summary.title", None, page.title.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "summary.title", None, page.title)
prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url)
summary = wikipedia.summary(page_str) summary = wikipedia.summary(page_str)
prof.win_show_themed(win, "wikipedia", "summary.text", None, summary.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "summary.text", None, summary)
prof.win_show(win, "") prof.win_show(win, "")
prof.win_focus(win) prof.win_focus(win)
@@ -119,8 +119,8 @@ def _page(page_str):
prof.win_focus(win) prof.win_focus(win)
return return
prof.win_show_themed(win, "wikipedia", "page.title", None, page.title.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "page.title", None, page.title)
prof.win_show_themed(win, "wikipedia", "page.text", None, page.content.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "page.text", None, page.content)
prof.win_show(win, "") prof.win_show(win, "")
prof.win_focus(win) prof.win_focus(win)
@@ -138,8 +138,8 @@ def _images(page_str):
prof.win_show_themed(win, "wikipedia", "images", None, "Images for " + page_str) prof.win_show_themed(win, "wikipedia", "images", None, "Images for " + page_str)
for image in page.images: for image in page.images:
prof.win_show_themed(win, "wikipedia", "images.url", None, image.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "images.url", None, image)
link_ac.append(image.encode("utf-8")) link_ac.append(image)
prof.completer_add("/wikipedia open", link_ac) prof.completer_add("/wikipedia open", link_ac)
prof.win_show(win, "") prof.win_show(win, "")
prof.win_focus(win) prof.win_focus(win)
@@ -159,8 +159,8 @@ def _links(page_str):
prof.win_show_themed(win, "wikipedia", "links", None, "Links for " + page_str) prof.win_show_themed(win, "wikipedia", "links", None, "Links for " + page_str)
for link in page.links: for link in page.links:
prof.win_show_themed(win, "wikipedia", "links.link", None, link.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "links.link", None, link)
page_ac.append(link.encode("utf-8")) page_ac.append(link)
_update_autocomplete() _update_autocomplete()
prof.win_show(win, "") prof.win_show(win, "")
prof.win_focus(win) prof.win_focus(win)
@@ -179,8 +179,8 @@ def _refs(page_str):
prof.win_show_themed(win, "wikipedia", "refs", None, "References for " + page_str) prof.win_show_themed(win, "wikipedia", "refs", None, "References for " + page_str)
for ref in page.references: for ref in page.references:
prof.win_show_themed(win, "wikipedia", "refs.url", None, ref.encode("utf-8")) prof.win_show_themed(win, "wikipedia", "refs.url", None, ref)
link_ac.append(ref.encode("utf-8")) link_ac.append(ref)
prof.completer_add("/wikipedia open", link_ac) prof.completer_add("/wikipedia open", link_ac)
prof.win_show(win, "") prof.win_show(win, "")
prof.win_focus(win) prof.win_focus(win)