1 Commits
irc ... browser

Author SHA1 Message Date
James Booth
4e5cd39bdb Add download to browser command 2016-06-09 23:28:06 +01:00
14 changed files with 303 additions and 716 deletions

1
.gitignore vendored
View File

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

View File

@@ -8,8 +8,6 @@ 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
-------------------------------------- --------------------------------------
@@ -32,12 +30,12 @@ Build with:
``` ```
./bootstrap.sh ./bootstrap.sh
./configure ./configure --enable-python-plugins
make make
sudo make install sudo make install
``` ```
After building, run `profanity -v` to see which language support is available, example output: Only support for Python 2.7 is currently included, 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
@@ -59,16 +57,24 @@ Python plugins: Enabled
Installing plugins Installing plugins
------------------ ------------------
Use the `/plugins install` command, e.g. 1 - Copy the plugin
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 install ~/projects-git/profanity-plugins/say.py [plugins]
load=browser.py;platform-info.py;ascii.py;pid.so
``` ```
See the `/help plugins` command for further plugin management options. Getting help on plugins:
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
@@ -91,33 +97,11 @@ command=cyan
result=green result=green
``` ```
Plugin settings Example plugin code
--------------- -------------------
The plugins API also includes functions to read and write settings. The settings are stored in: 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):
```
~/.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

@@ -6,44 +6,84 @@ import prof
import os import os
import webbrowser import webbrowser
import re import re
import requests
from os.path import expanduser
_links = {} _links = {}
_lastlink = {} _lastlink = {}
def _cmd_browser(url): def _get_url():
link = None
jid = prof.get_current_recipient()
room = prof.get_current_muc()
# check if in chat window
if jid is not None:
# check for link from recipient
if jid in _lastlink.keys():
link = _lastlink[jid]
else:
prof.cons_show("No links found from " + jid)
# check if in muc window
elif room is not None:
if room in _lastlink.keys():
link = _lastlink[room]
else:
prof.cons_show("No links found in " + room)
# not in chat/muc window
else:
prof.cons_show("You must supply a URL to the /browser command")
return link
def _cmd_browser(arg1=None, arg2=None):
global _lastlink global _lastlink
link = None link = None
# use arg if supplied if arg1 == "setdir":
if (url is not None): if not arg2:
link = url prof.cons_bad_cmd_usage("/browser")
else:
jid = prof.get_current_recipient()
room = prof.get_current_muc()
# check if in chat window
if (jid is not None):
# check for link from recipient
if jid in _lastlink.keys():
link = _lastlink[jid]
else:
prof.cons_show("No links found from " + jid)
# check if in muc window
elif (room is not None):
if room in _lastlink.keys():
link = _lastlink[room]
else:
prof.cons_show("No links found from " + room)
# not in chat/muc window
else: else:
prof.cons_show("You must supply a URL to the /browser command") prof.settings_set_string("browser", "download.path", arg2)
prof.cons_show("browser.py set download path to" + arg2)
# open the browser if link found return
if (link is not None):
if arg1 == "get":
link = arg2 if arg2 is not None else _get_url()
if not link:
prof.log_debug("browser.py: no link found for get command")
return
folder = prof.settings_get_string("browser", "download.path", "")
if folder == "":
prof.cons_show("Download path not set, see /help browser")
return
if folder[0] == '~':
folder = expanduser("~") + folder[1:]
response = requests.get(link)
if response.status_code != 200:
prof.log_debug("browser.py: received non 200 response for get command")
return
filename = link.split("/")[-1]
full_path = folder + "/" + filename
prof.log_debug("browser.py: Saving link {link} to file {file}".format(link=link, file=full_path))
with open(full_path, 'wb') as f:
for chunk in response.iter_content(8):
f.write(chunk)
return
link = arg1 if arg1 is not None else _get_url();
if link is not None:
prof.cons_show("Opening " + link + " in browser") prof.cons_show("Opening " + link + " in browser")
_open_browser(link) _open_browser(link)
@@ -64,18 +104,28 @@ def _open_browser(url):
def prof_init(version, status, account_name, fulljid): def prof_init(version, status, account_name, fulljid):
synopsis = [ synopsis = [
"/browser", "/browser",
"/browser <url>" "/browser <url>",
"/browser get <url>",
"/browser setdir <folder>"
] ]
description = "View a URL in the systems default browser. If no argument is supplied, the last URL in the current chat or room will be used. " \ description = (
"View a URL in the systems default browser, or download and view link contents " +
"If no argument is supplied, the last URL in the current chat or room will be used. " +
"Tab autocompletion will go through all previous links in the current chat/room" "Tab autocompletion will go through all previous links in the current chat/room"
)
args = [ args = [
[ "<url>", "URL to open in the browser" ] [ "<url>", "URL to open in the browser" ],
[ "download <url>", "Download contents of specified URL" ],
[ "setdir <dir>", "Filesystem path to store downloaded content" ]
] ]
examples = [ examples = [
"/browser http://www.profanity.im" "/browser http://www.profanity.im",
"/browser setdir ~/Downloads",
"/browser get http://www.movenoticias.com/wp-content/uploads/2015/05/Bruce-Iron-Maiden-850x583.jpg"
] ]
prof.register_command("/browser", 0, 1, synopsis, description, args, examples, _cmd_browser) prof.register_command("/browser", 0, 2, synopsis, description, args, examples, _cmd_browser)
prof.completer_add("/browser", [ "get", "setdir" ])
def prof_on_chat_win_focus(jid): def prof_on_chat_win_focus(jid):
@@ -92,16 +142,20 @@ def prof_on_room_win_focus(room):
def _process_message(jid, current_jid, message): def _process_message(jid, current_jid, message):
links = re.findall(r'(https?://\S+)', message) links = re.findall(r'(https?://\S+)', message)
if (len(links) > 0): if len(links) > 0:
if jid not in _links: if jid not in _links:
_links[jid] = [] _links[jid] = []
# add to list of links for jid # add to list of links for jid
for link in links: for link in links:
if link not in _links[jid]: if link not in _links[jid]:
prof.log_debug("browser.py: Saving {link} for {jid}".format(link=link, jid=jid))
_links[jid].append(link) _links[jid].append(link)
# add to autocompleter if message for current window # add to autocompleter if message for current window
if current_jid == jid: if current_jid == jid:
prof.completer_add("/browser", _links[jid]) prof.completer_add("/browser", _links[jid])
# set last link for jid # set last link for jid
_lastlink[jid] = links[len(links)-1] _lastlink[jid] = links[len(links)-1]

View File

@@ -63,7 +63,6 @@ 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))
@@ -72,12 +71,10 @@ 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,7 +9,6 @@ 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,20 +1,16 @@
""" """
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(":-)", chr(9786)) 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(9785)) result = result.replace(":-(", u'\u2639'.encode("utf-8"))
result = result.replace(":(", chr(9785)) result = result.replace(":(", u'\u2639'.encode("utf-8"))
return result return result

View File

@@ -1,13 +1,10 @@
""" """
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 tkinter as tk import sys
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)
{ {
char *synopsis[] = { "/pid", NULL }; const char *synopsis[] = { "/pid", NULL };
char *description = "Show process ID and parent Process ID in the console window."; const char *description = "Show process ID and parent Process ID in the console window.";
char *args[][2] = { { NULL, NULL } }; const char *args[][2] = { { NULL, NULL } };
char *examples[] = { NULL }; const 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);
} }

View File

@@ -1,164 +0,0 @@
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

View File

@@ -1,44 +0,0 @@
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_string_get("say", "args", "") args = prof.settings_get_string("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_string_get("say", "enabled", "off") enabled = prof.settings_get_string("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,12 +30,10 @@ 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_string_get("say", "enabled", "off") enabled = prof.settings_get_string("say", "enabled", "off")
current_muc = prof.get_current_muc() current_muc = prof.get_current_muc()
if enabled == "on": if enabled == "on" or (enable == "active" and current_muc == jid):
say(nick + " in " + room + " says " + message) say(nick + " says " + message + " in " + room)
elif enabled == "active" and current_muc == room:
say(nick + " says " + message)
return message return message
@@ -50,22 +48,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_string_set("say", "enabled", "on") prof.settings_set_string("say", "enabled", "on")
prof.cons_show("Say plugin enabled") prof.cons_show("Say plugin enabled")
elif arg1 == "off": elif arg1 == "off":
prof.settings_string_set("say", "enabled", "off") prof.settings_set_string("say", "enabled", "off")
prof.cons_show("Say plugin disabled") prof.cons_show("Say plugin disabled")
elif arg1 == "active": elif arg1 == "active":
prof.settings_string_set("say", "enabled", "active") prof.settings_set_string("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_string_set("say", "args", arg2) prof.settings_set_string("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_string_set("say", "args", "") prof.settings_set_string("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:
@@ -73,8 +71,8 @@ def _cmd_say(arg1=None, arg2=None):
else: else:
say(arg2) say(arg2)
else: else:
enabled = prof.settings_string_get("say", "enabled", "off") enabled = prof.settings_get_string("say", "enabled", "off")
args = prof.settings_string_get("say", "args", "") args = prof.settings_get_string("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 != "":
@@ -88,7 +86,7 @@ def prof_init(version, status, account_name, fulljid):
"/say clearargs", "/say clearargs",
"/say test <message>" "/say test <message>"
] ]
description = "Read messages out loud" description = "Read all 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,46 +7,42 @@ 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
global thread_stop while True:
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():
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
@@ -54,34 +50,31 @@ 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()
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
@@ -89,32 +82,29 @@ 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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
prof.win_create(plugin_win, _handle_win_input) _create_win()
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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
recipient = prof.get_current_recipient(); recipient = prof.get_current_recipient();
if recipient: if recipient:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -123,7 +113,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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
room = prof.get_current_muc() room = prof.get_current_muc()
if room: if room:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -132,7 +122,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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
nick = prof.get_current_nick() nick = prof.get_current_nick()
if nick: if nick:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -141,7 +131,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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
occupants = prof.get_current_occupants() occupants = prof.get_current_occupants()
if occupants: if occupants:
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
@@ -154,42 +144,39 @@ 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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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():
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
@@ -197,7 +184,7 @@ def _ping(jid):
prof.cons_bad_cmd_usage("/python-test") prof.cons_bad_cmd_usage("/python-test")
return return
prof.win_create(plugin_win, _handle_win_input) _create_win()
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
@@ -206,7 +193,6 @@ 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")
@@ -222,9 +208,9 @@ def _boolean(op, group, key, value_str):
if op == "get": if op == "get":
dflt = False dflt = False
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_boolean_get(group, key, dflt) res = prof.settings_get_boolean(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:
@@ -233,12 +219,11 @@ def _boolean(op, group, key, value_str):
value = False value = False
if value_str == "true": if value_str == "true":
value = True value = True
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_boolean_set(group, key, value) prof.settings_set_boolean(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")
@@ -253,73 +238,19 @@ def _string(op, group, key, value):
return return
if op == "get": if op == "get":
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_string_get(group, key, None) res = prof.settings_get_string(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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_string_set(group, key, value) prof.settings_set_string(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")
@@ -330,17 +261,16 @@ def _int(op, group, key, value):
return return
if op == "get": if op == "get":
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
res = prof.settings_int_get(group, key, 0) res = prof.settings_get_int(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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
prof.win_focus(plugin_win) prof.win_focus(plugin_win)
prof.settings_int_set(group, key, int(value)) prof.settings_set_int(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")
@@ -348,20 +278,19 @@ 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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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":
prof.win_create(plugin_win, _handle_win_input) _create_win()
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")
@@ -371,44 +300,33 @@ 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 == "string_list": _string_list(arg1, arg2, arg3, arg4) elif subcmd == "int": _int(arg1, arg2, arg3, arg4)
elif subcmd == "int": _int(arg1, arg2, arg3, arg4) elif subcmd == "incoming": _incoming(arg1, arg2, arg3)
elif subcmd == "incoming": _incoming(arg1, arg2, arg3) elif subcmd == "completer": _completer(arg1, arg2)
elif subcmd == "completer": _completer(arg1, arg2) else: prof.cons_bad_cmd_usage("/python-test")
else: prof.cons_bad_cmd_usage("/python-test")
def timed_callback(): def timed_callback():
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
global count t = threading.Thread(target=_inc_counter)
global ping_id t.daemon = True
global thread_stop t.start()
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");
@@ -435,10 +353,6 @@ 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>",
@@ -465,10 +379,6 @@ 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." ],
@@ -501,7 +411,6 @@ def prof_init(version, status, account_name, fulljid):
"ping", "ping",
"boolean", "boolean",
"string", "string",
"string_list",
"int", "int",
"incoming", "incoming",
"completer" "completer"
@@ -519,9 +428,6 @@ 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" ]
) )
@@ -529,164 +435,124 @@ def prof_init(version, status, account_name, fulljid):
[ "add", "remove" ] [ "add", "remove" ]
) )
prof.register_timed(timed_callback, 5) prof.register_timed(timed_callback, 30)
def prof_on_start(): def prof_on_start():
prof.win_create(plugin_win, _handle_win_input) _create_win()
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():
global thread_stop _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")
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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):
prof.win_create(plugin_win, _handle_win_input) _create_win()
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,10 +31,18 @@ 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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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");
@@ -47,7 +55,7 @@ consshow(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -63,7 +71,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;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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;
@@ -79,7 +87,7 @@ void
constest(void) constest(void)
{ {
int res = prof_current_win_is_console(); int res = prof_current_win_is_console();
prof_win_create(plugin_win, handle_win_input); create_win();
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");
@@ -95,7 +103,7 @@ winshow(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -111,7 +119,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;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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;
@@ -130,7 +138,7 @@ sendline(char *line)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -146,7 +154,7 @@ donotify(char *msg)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -164,7 +172,7 @@ getsubject(char *subject)
} }
if (strcmp(subject, "recipient") == 0) { if (strcmp(subject, "recipient") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -177,7 +185,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) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -190,7 +198,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) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -203,7 +211,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) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -231,7 +239,7 @@ logmsg(char *level, char *msg)
} }
if (strcmp(level, "debug") == 0) { if (strcmp(level, "debug") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -239,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, "info") == 0) { } else if (strcmp(level, "info") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -247,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, "warning") == 0) { } else if (strcmp(level, "warning") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -255,7 +263,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) {
prof_win_create(plugin_win, handle_win_input); create_win();
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: ";
@@ -270,7 +278,7 @@ logmsg(char *level, char *msg)
void void
docount(void) docount(void)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -284,7 +292,7 @@ doping(char *jid)
prof_cons_bad_cmd_usage("/c-test"); prof_cons_bad_cmd_usage("/c-test");
return; return;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
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>";
@@ -322,9 +330,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;
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int res = prof_settings_boolean_get(group, key, dflt); int res = prof_settings_get_boolean(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 {
@@ -335,9 +343,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;
} }
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_settings_boolean_set(group, key, value); prof_settings_set_boolean(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);
@@ -363,9 +371,9 @@ stringsetting(char *op, char *group, char *key, char *value)
} }
if (strcmp(op, "get") == 0) { if (strcmp(op, "get") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
char *res = prof_settings_string_get(group, key, NULL); char *res = prof_settings_get_string(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);
@@ -374,96 +382,15 @@ 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) {
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
prof_settings_string_set(group, key, value); prof_settings_set_string(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)
{ {
@@ -478,17 +405,17 @@ intsetting(char *op, char *group, char *key, char *value)
} }
if (strcmp(op, "get") == 0) { if (strcmp(op, "get") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int res = prof_settings_int_get(group, key, 0); int res = prof_settings_get_int(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) {
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_focus(plugin_win); prof_win_focus(plugin_win);
int int_value = atoi(value); int int_value = atoi(value);
prof_settings_int_set(group, key, int_value); prof_settings_set_int(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);
@@ -510,7 +437,7 @@ completer(char *op, char *item)
} }
if (strcmp(op, "add") == 0) { if (strcmp(op, "add") == 0) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -519,7 +446,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) {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -549,7 +476,6 @@ 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]);
@@ -559,7 +485,7 @@ cmd_ctest(char **args)
void void
timed_callback(void) timed_callback(void)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
prof_win_show(plugin_win, "timed -> timed_callback called"); prof_win_show(plugin_win, "timed -> timed_callback called");
} }
@@ -580,7 +506,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);
char *synopsis[] = { const 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>",
@@ -597,18 +523,14 @@ 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
}; };
char *description = "C test plugin. All commands focus the plugin window."; const char *description = "C test plugin. All commands focus the plugin window.";
char *args[][2] = { const 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. " },
@@ -628,10 +550,6 @@ 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." },
@@ -640,7 +558,7 @@ prof_init(const char * const version, const char * const status, const char *con
{ NULL, NULL } { NULL, NULL }
}; };
char *examples[] = { const 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\"",
@@ -666,7 +584,6 @@ 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",
@@ -686,45 +603,33 @@ 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, 5); prof_register_timed(timed_callback, 30);
} }
void void
prof_on_start(void) prof_on_start(void)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -735,7 +640,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -746,7 +651,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -759,7 +664,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -770,7 +675,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -783,7 +688,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -794,7 +699,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -807,7 +712,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -818,7 +723,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -831,7 +736,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -842,7 +747,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
char *str = "fired -> prof_on_room_history_message: "; char *str = "fired -> prof_on_room_history_message: ";
if (timestamp == NULL) { if (timestamp == NULL) {
@@ -859,7 +764,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -872,7 +777,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -883,7 +788,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -896,7 +801,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -907,7 +812,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -922,7 +827,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -935,7 +840,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -948,7 +853,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -961,7 +866,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -974,7 +879,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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];
@@ -987,7 +892,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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;
@@ -1003,7 +908,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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;
@@ -1019,7 +924,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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);
@@ -1029,7 +934,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)
{ {
prof_win_create(plugin_win, handle_win_input); create_win();
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) page_ac.append(result.encode("utf-8"))
prof.win_show_themed(win, "wikipedia", "search.results", None, result) prof.win_show_themed(win, "wikipedia", "search.results", None, result.encode("utf-8"))
_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) link_ac.append(page.url.encode("utf-8"))
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) prof.win_show_themed(win, "wikipedia", "summary.title", None, page.title.encode("utf-8"))
prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url) prof.win_show_themed(win, "wikipedia", "summary.url", None, page.url.encode("utf-8"))
summary = wikipedia.summary(page_str) summary = wikipedia.summary(page_str)
prof.win_show_themed(win, "wikipedia", "summary.text", None, summary) prof.win_show_themed(win, "wikipedia", "summary.text", None, summary.encode("utf-8"))
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) prof.win_show_themed(win, "wikipedia", "page.title", None, page.title.encode("utf-8"))
prof.win_show_themed(win, "wikipedia", "page.text", None, page.content) prof.win_show_themed(win, "wikipedia", "page.text", None, page.content.encode("utf-8"))
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) prof.win_show_themed(win, "wikipedia", "images.url", None, image.encode("utf-8"))
link_ac.append(image) link_ac.append(image.encode("utf-8"))
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) prof.win_show_themed(win, "wikipedia", "links.link", None, link.encode("utf-8"))
page_ac.append(link) page_ac.append(link.encode("utf-8"))
_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) prof.win_show_themed(win, "wikipedia", "refs.url", None, ref.encode("utf-8"))
link_ac.append(ref) link_ac.append(ref.encode("utf-8"))
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)