diff --git a/README.md b/README.md index 96b0aa1..af8dba7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,25 @@ -profanity-plugins -================= +# CProof Plugins -* [Website documentation](https://profanity-im.github.io/plugins.html) +[Website documentation](https://jabber.space/guides/plugins/) -Building Profanity with plugin support --------------------------------------- +`Master` is a development branch compatible with the latest version of CProof. + +## Installing plugins + +Use the `/plugins install` command, e.g. + +```bash +/plugins install ~/path-to/sounds.py +``` + +Alternatively, you can use URLs to raw files to install Python plugins. For example, +```bash +/plugins install https://git.jabber.space/devs/cproof-plugins/raw/branch/master/src/sounds.py +``` + +See the `/help plugins` command for further plugin management options. + +## Building CProof with plugin support Dependencies required: @@ -19,41 +34,10 @@ For Python plugins the following is also required: python-dev ``` -Installing plugins ------------------- +## Developing plugins -Use the `/plugins install` command, e.g. - -``` -/plugins install ~/projects-git/profanity-plugins/stable/say.py -``` - -See the `/help plugins` command for further plugin management options. - -Branches --------- - -* `0.5.0`: Maintenance branch compatible Profanity 0.5.0 -* `0.5.1`: Maintenance branch compatible Profanity 0.5.1 -* `master`: Development for Profanity 0.6.0 - 0.11.x - -Developing plugins ------------------- - -API Documentation: -* [Python API](https://profanity-im.github.io/plugins/0.5.1/python/html/prof.html) -* [Python hooks](https://profanity-im.github.io/plugins/0.5.1/python/html/plugin.html) -* [C API](https://profanity-im.github.io/plugins/0.5.1/c/html/profapi_8h.html) -* [C hooks](https://profanity-im.github.io/plugins/0.5.1/c/html/profhooks_8h.html) - -External plugins ------------------- - -* [moj](https://github.com/shinyblink/moj) - Replace emojis -* [profanity-copy-message-plugin](https://github.com/lonski/profanity-copy-message-plugin) - Copy messages to clipboard. -* [profanity-discord](https://github.com/colcrunch/profanity-discord) - Forward jabber pings on to discord through a webhook. -* [profanity-notifycmd](https://github.com/Neo-Oli/profanity-notifycmd) - Launch a custom shell command when you receive a message in profanity. -* [profanity-plugin-sanitise](https://github.com/nd2s/profanity-plugin-sanitise) - Clean incoming messages. -* [profanity-shortcuts-plugin](https://github.com/ReneVolution/profanity-shortcuts-plugin) - Store custom substitution shortcuts and use them in chats. -* [profanity-plugins by H3rnand3zzz](https://github.com/H3rnand3zzz/profanity-plugins) - Array of different **QoL** plugins. -* [profanity-plugins by Reimar](https://github.com/ReimarPB/profanity-plugins) - Collection of plugins +API Documentation is available on our website, [jabber.space](https://jabber.space/). +- [Python API](https://jabber.space/api-reference/python/prof/) +- [Python hooks](https://jabber.space/api-reference/python/plugin/) +- [C API](https://jabber.space/api-reference/c/profapi/) +- [C hooks](https://jabber.space/api-reference/c/profhooks/) diff --git a/development/ChatStart.rb b/development/ChatStart.rb deleted file mode 100644 index eae9402..0000000 --- a/development/ChatStart.rb +++ /dev/null @@ -1,16 +0,0 @@ -module ChatStart - - @@starts = { - "prof1@panesar" => [ "\"Prof 2\"", "prof3@panesar" ], - "prof2@panesar" => [ "prof1@panesar" ] - } - - def self.prof_on_connect(account_name, fulljid) - if @@starts[account_name] - @@starts[account_name].each { | contact | - Prof::send_line("/msg " + contact) - } - Prof::send_line("/win 1") - end - end -end diff --git a/development/chatterbot/chatterbot.py b/development/chatterbot/chatterbot.py deleted file mode 100644 index 0c6fe0c..0000000 --- a/development/chatterbot/chatterbot.py +++ /dev/null @@ -1,51 +0,0 @@ -import prof -from chatterbotapi import ChatterBotFactory, ChatterBotType - - -factory = ChatterBotFactory() -bot = factory.create(ChatterBotType.CLEVERBOT) -# bot = factory.create(ChatterBotType.JABBERWACKY) -# bot = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477') -bot_session = {} -bot_state = False - - -def prof_post_chat_message_display(barejid, resource, message): - if bot_state: - if barejid not in bot_session: - bot_session[barejid] = bot.create_session() - response = bot_session[barejid].think(message) - prof.send_line("/msg " + barejid + " " + response) - - -def _cmd_chatterbot(state): - global bot_state - - if state == "enable": - prof.cons_show("ChatterBot Activated") - bot_state = True - elif state == "disable": - prof.cons_show("ChatterBot Stopped") - bot_state = False - else: - if bot_state: - prof.cons_show("ChatterBot is running - current sessions:") - prof.cons_show(str(bot_session)) - else: - prof.cons_show("ChatterBot is stopped - /chatterbot enable to activate.") - - -def prof_init(version, status, account_name, fulljid): - synopsis = [ - "/chatterbot", - "/chatterbot enable|disable" - ] - description = "ChatterBot, running with no args will show the current chatterbot status" - args = [ - [ "enable", "Enable chatterbot" ], - [ "disable", "Disable chatterbot" ] - ] - examples = [] - - prof.register_command("/chatterbot", 0, 1, synopsis, description, args, examples, _cmd_chatterbot) - prof.completer_add("/chatterbot", [ "enable", "disable" ]) diff --git a/development/chatterbot/chatterbotapi.py b/development/chatterbot/chatterbotapi.py deleted file mode 100644 index f69ed93..0000000 --- a/development/chatterbot/chatterbotapi.py +++ /dev/null @@ -1,190 +0,0 @@ -import re -import sys -import hashlib - -if sys.version_info >= (3, 0): - from urllib.request import build_opener, HTTPCookieProcessor, urlopen - from urllib.parse import urlencode - import http.cookiejar as cookielib - -else: - from urllib import urlencode, urlopen - from urllib2 import build_opener, HTTPCookieProcessor - import cookielib - -import uuid -import xml.dom.minidom - -""" - chatterbotapi - Copyright (C) 2011 pierredavidbelanger@gmail.com - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . -""" - -################################################# -# API -################################################# - -class ChatterBotType: - - CLEVERBOT = 1 - JABBERWACKY = 2 - PANDORABOTS = 3 - -class ChatterBotFactory: - - def create(self, type, arg = None): - if type == ChatterBotType.CLEVERBOT: - return _Cleverbot('http://www.cleverbot.com', 'http://www.cleverbot.com/webservicemin', 35) - elif type == ChatterBotType.JABBERWACKY: - return _Cleverbot('http://jabberwacky.com', 'http://jabberwacky.com/webservicemin', 29) - elif type == ChatterBotType.PANDORABOTS: - if arg == None: - raise Exception('PANDORABOTS needs a botid arg') - return _Pandorabots(arg) - return None - -class ChatterBot: - - def create_session(self): - return None - -class ChatterBotSession: - - def think_thought(self, thought): - return thought - - def think(self, text): - thought = ChatterBotThought() - thought.text = text - return self.think_thought(thought).text - -class ChatterBotThought: - - pass - -################################################# -# Cleverbot impl -################################################# - -class _Cleverbot(ChatterBot): - - def __init__(self, baseUrl, serviceUrl, endIndex): - self.baseUrl = baseUrl - self.serviceUrl = serviceUrl - self.endIndex = endIndex - - def create_session(self): - return _CleverbotSession(self) - -class _CleverbotSession(ChatterBotSession): - - def __init__(self, bot): - self.bot = bot - self.vars = {} - self.vars['start'] = 'y' - self.vars['icognoid'] = 'wsf' - self.vars['fno'] = '0' - self.vars['sub'] = 'Say' - self.vars['islearning'] = '1' - self.vars['cleanslate'] = 'false' - self.cookieJar = cookielib.CookieJar() - self.opener = build_opener(HTTPCookieProcessor(self.cookieJar)) - self.opener.open(self.bot.baseUrl) - - def think_thought(self, thought): - self.vars['stimulus'] = thought.text - data = urlencode(self.vars) - data_to_digest = data[9:self.bot.endIndex] - data_digest = hashlib.md5(data_to_digest.encode('utf-8')).hexdigest() - data = data + '&icognocheck=' + data_digest - url_response = self.opener.open(self.bot.serviceUrl, data.encode('utf-8')) - response = str(url_response.read()) - response_values = re.split(r'\\r|\r', response) - #self.vars['??'] = _utils_string_at_index(response_values, 0) - self.vars['sessionid'] = _utils_string_at_index(response_values, 1) - self.vars['logurl'] = _utils_string_at_index(response_values, 2) - self.vars['vText8'] = _utils_string_at_index(response_values, 3) - self.vars['vText7'] = _utils_string_at_index(response_values, 4) - self.vars['vText6'] = _utils_string_at_index(response_values, 5) - self.vars['vText5'] = _utils_string_at_index(response_values, 6) - self.vars['vText4'] = _utils_string_at_index(response_values, 7) - self.vars['vText3'] = _utils_string_at_index(response_values, 8) - self.vars['vText2'] = _utils_string_at_index(response_values, 9) - self.vars['prevref'] = _utils_string_at_index(response_values, 10) - #self.vars['??'] = _utils_string_at_index(response_values, 11) - self.vars['emotionalhistory'] = _utils_string_at_index(response_values, 12) - self.vars['ttsLocMP3'] = _utils_string_at_index(response_values, 13) - self.vars['ttsLocTXT'] = _utils_string_at_index(response_values, 14) - self.vars['ttsLocTXT3'] = _utils_string_at_index(response_values, 15) - self.vars['ttsText'] = _utils_string_at_index(response_values, 16) - self.vars['lineRef'] = _utils_string_at_index(response_values, 17) - self.vars['lineURL'] = _utils_string_at_index(response_values, 18) - self.vars['linePOST'] = _utils_string_at_index(response_values, 19) - self.vars['lineChoices'] = _utils_string_at_index(response_values, 20) - self.vars['lineChoicesAbbrev'] = _utils_string_at_index(response_values, 21) - self.vars['typingData'] = _utils_string_at_index(response_values, 22) - self.vars['divert'] = _utils_string_at_index(response_values, 23) - response_thought = ChatterBotThought() - response_thought.text = _utils_string_at_index(response_values, 16) - return response_thought - -################################################# -# Pandorabots impl -################################################# - -class _Pandorabots(ChatterBot): - - def __init__(self, botid): - self.botid = botid - - def create_session(self): - return _PandorabotsSession(self) - -class _PandorabotsSession(ChatterBotSession): - - def __init__(self, bot): - self.vars = {} - self.vars['botid'] = bot.botid - self.vars['custid'] = uuid.uuid1() - - def think_thought(self, thought): - self.vars['input'] = thought.text - data = urlencode(self.vars) - url_response = urlopen('http://www.pandorabots.com/pandora/talk-xml', data) - response = url_response.read() - response_dom = xml.dom.minidom.parseString(response) - response_thought = ChatterBotThought() - that_elements = response_dom.getElementsByTagName('that') - if that_elements is None or len(that_elements) == 0 or that_elements[0] is None: - return '' - that_elements_child_nodes = that_elements[0].childNodes - if that_elements_child_nodes is None or len(that_elements_child_nodes) == 0 or that_elements_child_nodes[0] is None: - return '' - that_elements_child_nodes_data = that_elements_child_nodes[0].data - if that_elements_child_nodes_data is None: - return '' - response_thought.text = that_elements_child_nodes_data.strip() - return response_thought - -################################################# -# Utils -################################################# - -def _utils_string_at_index(strings, index): - if len(strings) > index: - return strings[index] - else: - return '' \ No newline at end of file diff --git a/development/jenkins.py b/development/jenkins.py deleted file mode 100644 index 4f5bf33..0000000 --- a/development/jenkins.py +++ /dev/null @@ -1,531 +0,0 @@ -""" -Manage jenkins jobs - -Prerequisites: -The jenkinsapi module is required https://pypi.python.org/pypi/jenkinsapi -To install the module using pip: - sudo pip install jenkinsapi - -The plugin polls the jenkins server at 'jenkins_url' every 'jenkins_poll_interval' seconds. - -The results are checked by profanity every 'prof_cb_interval'. -New failures are reported in the jenkins window, and a desktop notification is sent. - -The 'prof_remind_interval' specifies the time between reminder notifications of broken builds - -""" - -import prof -import os -import threading -import time -import webbrowser -import urllib2 -import base64 -import jenkinsapi -from jenkinsapi.jenkins import Jenkins - -# Settings -jenkins_url = "http://localhost:8080" -username = None -password = None -jenkins_poll_interval = 5 -prof_cb_interval = 5 -prof_remind_interval = 10 -enable_notify = True -enable_remind = True - -# Global state -last_state = {} -STATE_SUCCESS = "SUCCESS" -STATE_UNSTABLE = "UNSTABLE" -STATE_FAILURE = "FAILURE" -STATE_QUEUED = "QUEUED" -STATE_RUNNING = "RUNNING" -STATE_NOBUILDS = "NOBUILDS" -STATE_UNKNOWN = "UNKNOWN" - -win_tag = "Jenkins" - -poll_fail = False -poll_fail_message = None - -job_list = None -changes_list = None - - -def _help(): - prof.win_show(win_tag, "Commands:") - prof.win_show(win_tag, " /jenkins help - Show this help") - prof.win_show(win_tag, " /jenkins jobs - List all jobs") - prof.win_show(win_tag, " /jenkins failing - List all failing jobs") - prof.win_show(win_tag, " /jenkins passing - List all passing jobs") - prof.win_show(win_tag, " /jenkins unstable - List all unstable jobs") - prof.win_show(win_tag, " /jenkins build [job] - Trigger build for job") - prof.win_show(win_tag, " /jenkins open [job] - Open job in browser") - prof.win_show(win_tag, " /jenkins log [job] - Show the latest build log") - prof.win_show(win_tag, " /jenkins remind on|off - Enable/disable reminder notifications") - prof.win_show(win_tag, " /jenkins notify on|off - Enable/disable build notifications") - prof.win_show(win_tag, " /jenkins settings - Show current settings") - - -def _settings(): - prof.win_show(win_tag, "Jenkins settings:") - prof.win_show(win_tag, " Jenkins URL : " + jenkins_url) - prof.win_show(win_tag, " Jenkins poll interval : " + str(jenkins_poll_interval) + " seconds") - prof.win_show(win_tag, " Profanity update interval : " + str(prof_cb_interval) + " seconds") - prof.win_show(win_tag, " Reminder interval : " + str(prof_remind_interval) + " seconds") - prof.win_show(win_tag, " Notifications enabled : " + str(enable_notify)) - prof.win_show(win_tag, " Reminders enabled : " + str(enable_remind)) - - -def _safe_remove(jobname, state): - if jobname in last_state[state]: - last_state[state].remove(jobname) - - -def _set_state(jobname, state): - if not jobname in last_state[state]: - _safe_remove(jobname, STATE_SUCCESS) - _safe_remove(jobname, STATE_UNSTABLE) - _safe_remove(jobname, STATE_FAILURE) - _safe_remove(jobname, STATE_QUEUED) - _safe_remove(jobname, STATE_RUNNING) - _safe_remove(jobname, STATE_NOBUILDS) - _safe_remove(jobname, STATE_UNKNOWN) - last_state[state].append(jobname) - return True - else: - return False - - -def _open_job_url(url): - savout = os.dup(1) - saverr = os.dup(2) - os.close(1) - os.close(2) - os.open(os.devnull, os.O_RDWR) - try: - webbrowser.open(url, new=2) - finally: - os.dup2(savout, 1) - os.dup2(saverr, 2) - - -class JobList(): - def __init__(self): - self.jobs = [] - - def add_job(self, name, build_number, state): - self.jobs.append((name, build_number, state)) - - def get_jobs(self, in_state=None): - if not in_state: - return self.jobs - else: - result = [] - for name, build_number, state in self.jobs: - if state == in_state: - result.append((name, build_number, state)) - return result - - def get_job(self, jobname): - for name, build_number, state in self.jobs: - if name == jobname: - return name, build_number - return None - - def contains_job(self, jobname): - for name, build_number, state in self.jobs: - if name == jobname: - return True - return False - - def num_in_state(self, given_state): - count = 0 - for name, build_number, state in self.jobs: - if state == given_state: - count = count + 1 - return count - - -class JobUpdates(): - def __init__(self): - self.states = {} - self.states[STATE_FAILURE] = [] - self.states[STATE_SUCCESS] = [] - self.states[STATE_UNSTABLE] = [] - self.states[STATE_QUEUED] = [] - self.states[STATE_RUNNING] = [] - - def add_update(self, state, name, build_number=None): - if build_number: - self.states[state].append((name, build_number)) - else: - self.states[state].append(name) - - def get_in_state(self, state): - return self.states[state] - - -def _process_build(name, build, new_job_list, new_changes_list): - if build.get_status() == STATE_FAILURE: - new_job_list.add_job(name, build.get_number(), STATE_FAILURE) - changed = _set_state(name, STATE_FAILURE) - if changed: - new_changes_list.add_update(STATE_FAILURE, name, build.get_number()) - elif build.get_status() == STATE_SUCCESS: - new_job_list.add_job(name, build.get_number(), STATE_SUCCESS) - changed = _set_state(name, STATE_SUCCESS) - if changed: - new_changes_list.add_update(STATE_SUCCESS, name, build.get_number()) - elif build.get_status() == STATE_UNSTABLE: - new_job_list.add_job(name, build.get_number(), STATE_UNSTABLE) - changed = _set_state(name, STATE_UNSTABLE) - if changed: - new_changes_list.add_update(STATE_UNSTABLE, name, build.get_number()) - - -def _process_queued_or_running(name, job, new_job_list, new_changes_list): - if job.is_queued(): - new_job_list.add_job(name, None, STATE_QUEUED) - changed = _set_state(name, STATE_QUEUED) - if changed: - new_changes_list.add_update(STATE_QUEUED, name) - elif job.is_running(): - new_job_list.add_job(name, None, STATE_RUNNING) - changed = _set_state(name, STATE_RUNNING) - if changed: - new_changes_list.add_update(STATE_RUNNING, name) - - -def _jenkins_poll(): - global poll_fail - global poll_fail_message - global job_list - global changes_list - - job_ac = [] - - while True: - time.sleep(jenkins_poll_interval) - try: - j = Jenkins(jenkins_url, username, password) - except Exception, e: - poll_fail = True - poll_fail_message = str(e) - else: - poll_fail = False - poll_fail_message = None - new_job_list = JobList() - new_changes_list = JobUpdates() - for name, job in j.get_jobs(): - if not job.is_queued_or_running(): - build = job.get_last_build_or_none() - if build: - _process_build(name, build, new_job_list, new_changes_list) - else: - new_job_list.add_job(name, None, STATE_NOBUILDS) - else: - _process_queued_or_running(name, job, new_job_list, new_changes_list) - if not job_list: - job_ac.append(name) - - if not job_list: - prof.completer_add("/jenkins build", job_ac) - prof.completer_add("/jenkins open", job_ac) - prof.completer_add("/jenkins log", job_ac) - - job_list = new_job_list - changes_list = new_changes_list - - -def _prof_callback(): - global changes_list - if poll_fail: - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show(win_tag, "Could not connect to jenkins, see the logs.") - if poll_fail_message: - prof.log_warning("Jenkins poll failed: " + str(poll_fail_message)) - else: - prof.log_warning("Jenkins poll failed") - elif changes_list: - for name in changes_list.get_in_state(STATE_QUEUED): - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show_themed(win_tag, None, None, "cyan", name + " " + STATE_QUEUED) - for name in changes_list.get_in_state(STATE_RUNNING): - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show_themed(win_tag, None, None, "cyan", name + " " + STATE_RUNNING) - for name, build_number in changes_list.get_in_state(STATE_SUCCESS): - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show_themed(win_tag, None, None, "green", name + " #" + str(build_number) + " " + STATE_SUCCESS) - if enable_notify: - prof.notify(name + " " + STATE_SUCCESS, 5000, "Jenkins") - for name, build_number in changes_list.get_in_state(STATE_UNSTABLE): - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show_themed(win_tag, None, None, "yellow", name + " #" + str(build_number) + " " + STATE_UNSTABLE) - if enable_notify: - prof.notify(name + " " + STATE_UNSTABLE, 5000, "Jenkins") - for name, build_number in changes_list.get_in_state(STATE_FAILURE): - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - prof.win_show_themed(win_tag, None, None, "red", name + " #" + str(build_number) + " " + STATE_FAILURE) - if enable_notify: - prof.notify(name + " " + STATE_FAILURE, 5000, "Jenkins") - - changes_list = None - - -def _handle_input(win, line): - pass - - -def _list_jobs(jobs): - for name, build_number, state in jobs: - if state == STATE_SUCCESS: - prof.win_show_themed(win_tag, None, None, "green", " " + name + " #" + str(build_number) + " " + STATE_SUCCESS) - elif state == STATE_UNSTABLE: - prof.win_show_themed(win_tag, None, None, "yellow", " " + name + " #" + str(build_number) + " " + STATE_UNSTABLE) - elif state == STATE_FAILURE: - prof.win_show_themed(win_tag, None, None, "red", " " + name + " #" + str(build_number) + " " + STATE_FAILURE) - elif state == STATE_NOBUILDS: - prof.win_show(win_tag, " " + name + ", no builds") - else: - prof.win_show_themed(win_tag, None, None, "cyan", " " + name + " " + state) - - -def _build_job(job): - try: - request = urllib2.Request(jenkins_url + "/job/" + job + "/build"); - if username: - basicauth = base64.encodestring("%s:%s" %(username, password)).replace("\n", "") - request.add_header("Authorization", "Basic %s" %basicauth); - request.add_data("") - urllib2.urlopen(request) - except Exception, e: - prof.win_show(win_tag, "Failed to build " + job + ", see the logs.") - prof.log_warning("Failed to build " + job + ": " + str(e)) - else: - prof.win_show(win_tag, "Build request sent for " + job) - - -def _job_log(job): - name = job[0] - build_no = job[1] - if build_no: - try: - response = urllib2.urlopen(jenkins_url + "/job/" + name + "/" + str(build_no) + "/consoleText") - except Exception, e: - prof.win_show(win_tag, "Unable to fetch log for " + name + "#" + str(build_no) + ", see the logs.") - prof.log_warning("Unable to fetch log for " + name + "#" + str(build_no) + ": " + str(e)) - else: - log_str = "Log for " + name + " #" + str(build_no) + ":\n" + response.read() - prof.win_show(win_tag, log_str) - else: - prof.win_show(win_tag, "No build found for " + name) - - -def _cmd_jenkins(cmd=None, arg=None): - global enable_remind - global enable_notify - - if not prof.win_exists(win_tag): - prof.win_create(win_tag, _handle_input) - - prof.win_focus(win_tag) - - if cmd == "jobs": - if job_list and job_list.get_jobs(): - prof.win_show(win_tag, "Jobs:") - _list_jobs(job_list.get_jobs()) - else: - prof.win_show(win_tag, "No job data yet.") - elif cmd == "failing": - if job_list: - jobs_in_state = job_list.get_jobs(STATE_FAILURE) - if jobs_in_state: - prof.win_show(win_tag, "Failing jobs:") - _list_jobs(jobs_in_state) - else: - prof.win_show(win_tag, "No failing jobs.") - else: - prof.win_show(win_tag, "No job data yet.") - elif cmd == "passing": - if job_list: - jobs_in_state = job_list.get_jobs(STATE_SUCCESS) - if jobs_in_state: - prof.win_show(win_tag, "Passing jobs:") - _list_jobs(jobs_in_state) - else: - prof.win_show(win_tag, "No passing jobs.") - else: - prof.win_show(win_tag, "No job data yet.") - elif cmd == "unstable": - if job_list: - jobs_in_state = job_list.get_jobs(STATE_UNSTABLE) - if jobs_in_state: - prof.win_show(win_tag, "Unstable jobs:") - _list_jobs(jobs_in_state) - else: - prof.win_show(win_tag, "No unstable jobs.") - else: - prof.win_show(win_tag, "No job data yet.") - elif cmd == "build": - if not arg: - prof.win_show(win_tag, "You must supply a job argument.") - elif job_list and job_list.contains_job(arg): - _build_job(arg) - else: - prof.win_show(win_tag, "No such job: " + arg) - elif cmd == "open": - if not arg: - prof.win_show(win_tag, "You must supply a job argument.") - elif job_list and job_list.contains_job(arg): - _open_job_url(jenkins_url + "/job/" + arg) - else: - prof.win_show(win_tag, "No such job: " + arg) - elif cmd == "remind": - if not arg: - prof.win_show(win_tag, "You must specify either 'on' or 'off'.") - elif arg == "on": - enable_remind = True - prof.win_show(win_tag, "Reminder notifications enabled.") - elif arg == "off": - enable_remind = False - prof.win_show(win_tag, "Reminder notifications disabled.") - else: - prof.win_show(win_tag, "You must specify either 'on' or 'off'.") - elif cmd == "notify": - if not arg: - prof.win_show(win_tag, "You must specify either 'on' or 'off'.") - elif arg == "on": - enable_notify = True - prof.win_show(win_tag, "Build notifications enabled.") - elif arg == "off": - enable_notify = False - prof.win_show(win_tag, "Build notifications disabled.") - else: - prof.win_show(win_tag, "You must specify either 'on' or 'off'.") - elif cmd == "settings": - _settings() - elif cmd == "help": - _help() - elif cmd == "log": - if not arg: - prof.win_show(win_tag, "You must specify a job.") - else: - job = job_list.get_job(arg) - if job: - _job_log(job) - else: - prof.win_show(win_tag, "No job found: " + arg) - else: - prof.win_show(win_tag, "Unknown command.") - - -def _remind(): - if enable_remind and job_list: - notify_string = "" - failing = job_list.num_in_state(STATE_FAILURE) - unstable = job_list.num_in_state(STATE_UNSTABLE) - - if failing == 1: - notify_string = notify_string + "1 failing build" - if failing > 1: - notify_string = notify_string + str(failing) + " failing builds" - - if failing > 0 and unstable > 0: - notify_string = notify_string + "\n" - - if unstable == 1: - notify_string = notify_string + "1 unstable build" - if unstable > 1: - notify_string = notify_string + str(unstable) + " unstable builds" - - if not notify_string == "": - prof.notify(notify_string, 5000, "Jenkins") - - -def prof_init(version, status, account_name, fulljid): - last_state[STATE_SUCCESS] = [] - last_state[STATE_UNSTABLE] = [] - last_state[STATE_FAILURE] = [] - last_state[STATE_QUEUED] = [] - last_state[STATE_RUNNING] = [] - last_state[STATE_NOBUILDS] = [] - last_state[STATE_UNKNOWN] = [] - - jenkins_t = threading.Thread(target=_jenkins_poll) - jenkins_t.daemon = True; - jenkins_t.start() - - prof.register_timed(_prof_callback, prof_cb_interval) - prof.register_timed(_remind, prof_remind_interval) - - prof.completer_add( - "/jenkins", [ - "help", - "jobs", - "failing", - "passing", - "unstable", - "build", - "open", - "log", - "remind", - "notify", - "settings" - ] - ); - prof.completer_add( - "/jenkins remind", [ - "on", - "off" - ] - ); - prof.completer_add( - "/jenkins notify", [ - "on", - "off" - ] - ); - - synopsis = [ - "/jenkins jobs|failing|passing|unstable", - "/jenkins build ", - "/jenkins open ", - "/jenkins log ", - "/jenkins remind on|off", - "/jenkins notify on|off", - "/jenkins settings" - ] - description = "Monitor, run and view Jenkins jobs." - args = [ - [ "jobs", "List all jobs" ], - [ "failing", "List all failing jobs" ], - [ "passing", "List all passing jobs" ], - [ "unstable", "List all unstable jobs" ], - [ "build ", "Trigger build for job" ], - [ "open ", "Open job in browser" ], - [ "log ", "Show the latest build log for job" ], - [ "remind on|off", "Enable/disable reminder notifications" ], - [ "notify on|off", "Enable/disable build notifications" ], - [ "settings", "Show current settings" ] - ] - examples = [ - "/kenkins failing", - "/kenkins build stabber-build", - "/kenkins remind off" - ] - - prof.register_command("/jenkins", 0, 2, synopsis, description, args, examples, _cmd_jenkins) - - -def prof_on_start(): - prof.win_create(win_tag, _handle_input) - prof.win_show(win_tag, "Jenkins plugin started.") diff --git a/development/microblog.c b/development/microblog.c deleted file mode 100644 index ab8e48a..0000000 --- a/development/microblog.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2020 Stefan Kropp - * - * This file is part of profanity. - * - * profanity is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * profanity is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with profanity. If not, see . - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !!! Status: Development / Testing !!!! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * File: microblog.c - * - * The microblog plugin can be used for Movim Users. If profanity gets a message - * "urn:xmpp:microblog:0", it will display the from, title and ID information of - * the blog post. - * - * Profanity will display a message like this, in the main Window: - * - * Blog from user@domain.tld - Title of the post (ID of the post) - * - * Compile: - * - * gcc -shared -fpic -g3 -O0 -Wextra -pedantic \ - * -L/usr/lib/profanity -lprofanity `pkg-config --libs --cflags libxml-2.0` \ - * -o microblog.so microblog.c - * - * Install: - * - * cp microblog.so \ - * ~/.local/share/profanity/plugins/ - * - * Documentation: - * - * https://profanity-im.github.io/plugins.html - * - */ - -#define _GNU_SOURCE - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define PLUGIN_NAME "microblog" -#define PLUGIN_VERSION "0.0.1-DEV" - -#define XMPP_URN_MICROBLOG "urn:xmpp:microblog:0" - -/** - * PubSubEvent is the struct with all data of the stanza, which should be - * displayed or processed by the plugin.. - */ -typedef struct { - char *id; // id of the item - char *from; // jid from - char *title; // title of the item -} PubSubEvent; - -// Enable or disable Plugin - -static bool enabled = true; - -/** - * Parse the char* stanza and return the information in event. - * The function will return true on success, otherwise false. - */ -bool parse(const char *stanza, PubSubEvent *event) { - bool result = false; - // stanza and event are mandatory - if (stanza == NULL || event == NULL || strlen(stanza) == 0) { - return result; - } - - xmlDocPtr doc; - xmlNode *root_element = NULL; - - doc = xmlReadMemory(stanza, strlen(stanza), NULL, NULL, 0); - if (doc == NULL) { - return result; - } - - xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc); - xmlXPathRegisterNs(xpathCtx, BAD_CAST "ev", - BAD_CAST "http://jabber.org/protocol/pubsub#event"); - xmlXPathRegisterNs(xpathCtx, BAD_CAST "a", - BAD_CAST "http://www.w3.org/2005/Atom"); - - xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression( - "//message/ev:event/ev:items/attribute::node", xpathCtx); - - if (xpathObj != NULL && xpathObj->nodesetval != NULL && - xpathObj->nodesetval->nodeTab[0] != NULL) { - if (xpathObj->nodesetval->nodeTab[0]->children != NULL && - xpathObj->nodesetval->nodeTab[0]->children->content != NULL) { - if (strcmp(xpathObj->nodesetval->nodeTab[0]->children->content, - XMPP_URN_MICROBLOG) == 0) { - xpathObj = - xmlXPathEvalExpression("//message/attribute::from", xpathCtx); - assert(xpathObj != NULL); - - event->from = - strdup(xpathObj->nodesetval->nodeTab[0]->children->content); - xmlXPathFreeObject(xpathObj); - - xpathObj = xmlXPathEvalExpression( - "//message/ev:event/ev:items/ev:item/a:entry/a:title", xpathCtx); - assert(xpathObj != NULL); - - event->title = - strdup(xpathObj->nodesetval->nodeTab[0]->children->content); - xmlXPathFreeObject(xpathObj); - - xpathObj = xmlXPathEvalExpression( - "//message/ev:event/ev:items/ev:item/attribute::id", xpathCtx); - assert(xpathObj != NULL); - - event->id = strdup(xpathObj->nodesetval->nodeTab[0]->children->content); - xmlXPathFreeObject(xpathObj); - result = true; - } - } - } - - if (xpathCtx) { - xmlXPathFreeContext(xpathCtx); - } - if (doc) { - xmlFreeDoc(doc); - } - return result; -} - -void prof_init(const char *const version, const char *const status, - const char *const account_name, const char *const fulljid) { - char *s = NULL; - asprintf(&s, "Loaded Plugin %s %s", PLUGIN_NAME, PLUGIN_VERSION); - prof_cons_show(s); - free(s); -} - -void prof_on_start(void) {} - -void prof_on_shutdown(void) {} - -void prof_on_unload(void) { - char *s = NULL; - asprintf(&s, "Unloading Plugin %s %s", PLUGIN_NAME, PLUGIN_VERSION); - prof_cons_show(s); - free(s); -} - -int prof_on_message_stanza_receive(const char *const stanza) { - if (enabled) { - PubSubEvent event; - event.id = NULL; - event.from = NULL; - event.title = NULL; - if (parse(stanza, &event)) { - int size = - strlen(event.id) + strlen(event.from) + strlen(event.title) + 30; - char *message = calloc(size, sizeof(char)); - snprintf(message, size, "Blog from %s - %s (%s)", event.from, event.title, - event.id); - prof_cons_show(message); - prof_cons_alert(); - free(message); - free(event.id); - free(event.from); - free(event.title); - } - } - return 1; -} diff --git a/stable/ascii.py b/src/ascii.py similarity index 100% rename from stable/ascii.py rename to src/ascii.py diff --git a/stable/autocorrector.py b/src/autocorrector.py similarity index 100% rename from stable/autocorrector.py rename to src/autocorrector.py diff --git a/stable/browser.py b/src/browser.py similarity index 100% rename from stable/browser.py rename to src/browser.py diff --git a/stable/pid/Makefile b/src/c/pid/Makefile similarity index 100% rename from stable/pid/Makefile rename to src/c/pid/Makefile diff --git a/stable/pid/pid.c b/src/c/pid/pid.c similarity index 100% rename from stable/pid/pid.c rename to src/c/pid/pid.c diff --git a/stable/clients.py b/src/clients.py similarity index 100% rename from stable/clients.py rename to src/clients.py diff --git a/stable/emoticons.py b/src/emoticons.py similarity index 100% rename from stable/emoticons.py rename to src/emoticons.py diff --git a/stable/htmlstrip.py b/src/htmlstrip.py similarity index 100% rename from stable/htmlstrip.py rename to src/htmlstrip.py diff --git a/stable/imgur.py b/src/imgur.py similarity index 100% rename from stable/imgur.py rename to src/imgur.py diff --git a/stable/paste.py b/src/paste.py similarity index 100% rename from stable/paste.py rename to src/paste.py diff --git a/stable/platform-info.py b/src/platform-info.py similarity index 100% rename from stable/platform-info.py rename to src/platform-info.py diff --git a/stable/presence_notify.py b/src/presence_notify.py similarity index 100% rename from stable/presence_notify.py rename to src/presence_notify.py diff --git a/stable/say.py b/src/say.py similarity index 100% rename from stable/say.py rename to src/say.py diff --git a/stable/sounds.py b/src/sounds.py similarity index 100% rename from stable/sounds.py rename to src/sounds.py diff --git a/stable/syscmd.py b/src/syscmd.py similarity index 100% rename from stable/syscmd.py rename to src/syscmd.py diff --git a/stable/whoami.py b/src/whoami.py similarity index 100% rename from stable/whoami.py rename to src/whoami.py diff --git a/stable/wikipedia-prof.py b/src/wikipedia-prof.py similarity index 100% rename from stable/wikipedia-prof.py rename to src/wikipedia-prof.py diff --git a/tests/RubyTest.rb b/tests/RubyTest.rb deleted file mode 100644 index d607ee5..0000000 --- a/tests/RubyTest.rb +++ /dev/null @@ -1,161 +0,0 @@ -module RubyTest - - def self.prof_init(version, status) - Prof::cons_show("RubyTest: init, " + version + ", " + status) - Prof::register_command("/ruby", 0, 1, "/ruby [arg]", "RubyTest", "RubyTest", cmd_ruby) - Prof::register_command("/rb_upper", 1, 1, "/rb_upper string", "RubyTest", "RubyTest", cmd_upper) - Prof::register_command("/rb_notify", 0, 0, "/rb_notify", "RubyTest", "RubyTest", cmd_notify) - Prof::register_command("/rb_vercheck", 0, 0, "/rb_vercheck", "RubyTest", "RubyTest", cmd_vercheck) - Prof::register_ac("/rb_complete", [ "aaaa", "bbbb", "bcbcbc" ]) - Prof::register_ac("/rb_complete aaaa", [ "one", "two", "three", "four" ]) - Prof::register_ac("/rb_complete bcbcbc", [ "james", "jim", "jane", "bob" ]) - Prof::register_command("/rb_complete", 0, 2, "/rb_complete [arg1] [arg2]", "RubyTest", "RubyTest", cmd_ac) - Prof::register_timed(timer_test, 30) - end - - def self.prof_on_start - Prof::cons_show("RubyTest: prof_on_start") - Prof::log_debug("RubyTest: logged debug"); - Prof::log_info("RubyTest: logged info"); - Prof::log_warning("RubyTest: logged warning"); - Prof::log_error("RubyTest: logged error"); - end - - def self.prof_on_shutdown - Prof::log_info("RubyTest: prof_on_shutdown"); - end - - def self.prof_on_connect(account_name, fulljid) - Prof::cons_show("RubyTest: prof_on_connect, " + account_name + ", " + fulljid) - end - - def self.prof_on_disconnect(account_name, fulljid) - Prof::cons_show("RubyTest: prof_on_disconnect, " + account_name + ", " + fulljid) - end - - def self.prof_pre_chat_message_display(jid, message) - Prof::cons_show("RubyTest: prof_pre_chat_message_display, " + jid + ", " + message) - Prof::cons_alert - return message + "[RB_pre_chat_message_display]" - end - - def self.prof_post_chat_message_display(jid, message) - Prof::cons_show("RubyTest: prof_post_chat_message_display, " + jid + ", " + message) - Prof::cons_alert - end - - def self.prof_pre_chat_message_send(jid, message) - Prof::cons_show("RubyTest: prof_pre_chat_message_send, " + jid + ", " + message) - Prof::cons_alert - return message + "[RB_pre_chat_message_send]" - end - - def self.prof_post_chat_message_send(jid, message) - Prof::cons_show("RubyTest: prof_post_chat_message_send, " + jid + ", " + message) - Prof::cons_alert - end - - def self.prof_pre_room_message_display(room, nick, message) - Prof::cons_show("RubyTest: prof_pre_room_message_display, " + room + ", " + nick + ", " + message) - Prof::cons_alert - return message + "[RB_pre_room_message_display]" - end - - def self.prof_post_room_message_display(room, nick, message) - Prof::cons_show("RubyTest: prof_post_room_message_display, " + room + ", " + nick + ", " + message) - Prof::cons_alert - end - - def self.prof_pre_room_message_send(room, message) - Prof::cons_show("RubyTest: prof_pre_room_message_send, " + room + ", " + message) - Prof::cons_alert - return message + "[RB_pre_room_message_send]" - end - - def self.prof_post_room_message_send(room, message) - Prof::cons_show("RubyTest: prof_post_room_message_send, " + room + ", " + message) - Prof::cons_alert - end - - def self.prof_pre_priv_message_display(room, nick, message) - Prof::cons_show("RubyTest: prof_pre_priv_message_display, " + room + ", " + nick + ", " + message) - Prof::cons_alert - return message + "[RB_pre_priv_message_display]" - end - - def self.prof_post_priv_message_display(room, nick, message) - Prof::cons_show("RubyTest: prof_post_priv_message_display, " + room + ", " + nick + ", " + message) - Prof::cons_alert - end - - def self.prof_pre_priv_message_send(room, nick, message) - Prof::cons_show("RubyTest: prof_pre_priv_message_send, " + room + ", " + nick + ", " + message) - Prof::cons_alert - return message + "[RB_pre_priv_message_send]" - end - - def self.prof_post_priv_message_send(room, nick, message) - Prof::cons_show("RubyTest: prof_post_priv_message_send, " + room + ", " + nick + ", " + message) - Prof::cons_alert - end - - def self.cmd_ruby - return Proc.new { | msg | - if msg - Prof::cons_show("RubyTest: /ruby command called, arg = " + msg) - else - Prof::cons_show("RubyTest: /ruby command called with no arg") - end - } - end - - def self.cmd_ac - return Proc.new { | arg1, arg2 | - Prof::cons_show("RubyTest: /rb_complete called") - } - end - - def self.cmd_notify - return Proc.new { - Prof::notify("RubyTest: notify", 2000, "Plugins") - } - end - - def self.cmd_vercheck - return Proc.new { - Prof::send_line("/vercheck") - Prof::cons_show("RubyTest: sent \"/vercheck\" command") - } - end - - def self.timer_test - return Proc.new { - Prof::cons_show("RubyTest: timer fired.") - Prof::cons_alert - } - end - - def self.cmd_upper - return Proc.new { | line | - win_tag = "Ruby Plygin" - if (Prof::win_exists(win_tag) == false) - Prof::win_create(win_tag, handle_upper) - end - Prof::win_focus(win_tag) - if (line) - handle_upper.call(win_tag, line) - end - } - end - - def self.handle_upper - return Proc.new { | win, line | - upper = line.upcase - Prof::win_show(win, upper) - Prof::win_show_red(win, upper + " red") - Prof::win_show_yellow(win, upper + " yellow") - Prof::win_show_green(win, upper + " green") - Prof::win_show_cyan(win, upper + " cyan") - } - end -end diff --git a/tests/RubyThread.rb b/tests/RubyThread.rb deleted file mode 100644 index be87bd1..0000000 --- a/tests/RubyThread.rb +++ /dev/null @@ -1,23 +0,0 @@ -module RubyThread - @counter = 0 - - def self.inc_counter() - while true - sleep(1) - @counter = @counter + 1 - end - end - - def self.cmd_rcount() - return Proc.new { - instance_eval { - Prof::cons_show("RCounter: " + @counter) - } - } - end - - def self.prof_init(version, status) - Thread.new { self.inc_counter() } - Prof::register_command("/rcount", 0, 0, "/rcount", "Ruby threaded example", "Ruby threaded example", cmd_rcount) - end -end diff --git a/tests/enc_c/Makefile b/tests/enc_c/Makefile deleted file mode 100644 index 5ff24d9..0000000 --- a/tests/enc_c/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) - LINK_FLAGS := -fno-common -flat_namespace -bundle -undefined suppress -else - LINK_FLAGS := -shared -fpic -endif - -all: enc_c.so - -%.so:%.o - $(CC) $(LINK_FLAGS) -lprofanity -o $@ $^ - -%.o:%.c - $(CC) $(INCLUDE) -D_GNU_SOURCE -D_BSD_SOURCE -fpic -g3 -O0 -std=c99 \ - -Wextra -pedantic -c -o $@ $< - -clean: - $(RM) enc_c.so diff --git a/tests/enc_c/enc_c.c b/tests/enc_c/enc_c.c deleted file mode 100644 index 55ee6f3..0000000 --- a/tests/enc_c/enc_c.c +++ /dev/null @@ -1,220 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -static char *chat_msg_hook = NULL; -static char *room_msg_hook = NULL; - -void -cmd_enc(char **args) -{ - if (args[0] && strcmp(args[0], "end") == 0) { - prof_encryption_reset(args[1]); - - } else if (args[0] && (strcmp(args[0], "chat_title") == 0)) { - if (args[1] && (strcmp(args[1], "set") == 0)) { - prof_chat_set_titlebar_enctext(args[2], args[3]); - } else if (args[1] && (strcmp(args[1], "reset") == 0)) { - prof_chat_unset_titlebar_enctext(args[2]); - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - - } else if (args[0] && (strcmp(args[0], "chat_ch") == 0)) { - if (args[1] && (strcmp(args[1], "set") == 0)) { - if (args[2] && (strcmp(args[2], "in") == 0)) { - prof_chat_set_incoming_char(args[3], args[4]); - } else if (args[2] && (strcmp(args[2], "out") == 0)) { - prof_chat_set_outgoing_char(args[3], args[4]); - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - } else if (args[1] && (strcmp(args[1], "reset") == 0)) { - if (args[2] && (strcmp(args[2], "in") == 0)) { - prof_chat_unset_incoming_char(args[3]); - } else if (args[2] && (strcmp(args[2], "out") == 0)) { - prof_chat_unset_outgoing_char(args[3]); - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - - } else if (args[0] && (strcmp(args[0], "room_title") == 0)) { - if (args[1] && (strcmp(args[1], "set") == 0)) { - prof_room_set_titlebar_enctext(args[2], args[3]); - } else if (args[1] && (strcmp(args[1], "reset") == 0)) { - prof_room_unset_titlebar_enctext(args[2]); - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - - } else if (args[0] && (strcmp(args[0], "room_ch") == 0)) { - if (args[1] && (strcmp(args[1], "set") == 0)) { - prof_room_set_message_char(args[2], args[3]); - } else if (args[1] && (strcmp(args[1], "reset") == 0)) { - prof_room_unset_message_char(args[2]); - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } - - } else if (args[0] && (strcmp(args[0], "chat_show") == 0)) { - prof_chat_show(args[1], args[2]); - - } else if (args[0] && (strcmp(args[0], "chat_show_themed") == 0)) { - prof_chat_show_themed(args[1], "enc_c", "chat_msg", NULL, "c", args[2]); - - } else if (args[0] && (strcmp(args[0], "room_show") == 0)) { - prof_room_show(args[1], args[2]); - - } else if (args[0] && (strcmp(args[0], "room_show_themed") == 0)) { - prof_room_show_themed(args[1], "enc_c", "room_msg", NULL, "C", args[2]); - - } else if (args[0] && (strcmp(args[0], "chat_msg") == 0)) { - if (chat_msg_hook) { - free(chat_msg_hook); - } - chat_msg_hook = strdup(args[1]); - - } else if (args[0] && (strcmp(args[0], "room_msg") == 0)) { - if (room_msg_hook) { - free(room_msg_hook); - } - room_msg_hook = strdup(args[1]); - - } else { - prof_cons_bad_cmd_usage("/enc_c"); - } -} - -void -prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid) -{ - char *synopsis[] = { - "/enc_c end ", - "/enc_c chat_title set ", - "/enc_c chat_title unset ", - "/enc_c chat_ch set in ", - "/enc_c chat_ch reset in ", - "/enc_c chat_ch set out ", - "/enc_c chat_ch reset out ", - "/enc_c chat_show ", - "/enc_c chat_show_themed ", - "/enc_c room_title set ", - "/enc_c room_title unset ", - "/enc_c room_ch set ", - "/enc_c room_ch reset ", - "/enc_c room_show ", - "/enc_c room_show_themed ", - "/enc_c chat_msg none", - "/enc_c chat_msg modify", - "/enc_c chat_msg block", - "/enc_c room_msg none", - "/enc_c room_msg modify", - "/enc_c room_msg block", - NULL - }; - char *description = "Various enc things"; - char *args[][2] = { - { "end ", "User to end the session with" }, - { "chat_title set ", "Set encryption text in titlebar for recipient" }, - { "chat_title reset ", "Reset encryption text in titlebar for recipient" }, - { "chat_ch set in ", "Set incoming char for recipient" }, - { "chat_ch reset in ", "Reset incoming char for recipient" }, - { "chat_ch set out ", "Set outgoing char for recipient" }, - { "chat_ch reset out ", "Reset outgoing char for recipient" }, - { "chat_show ", "Show chat message" }, - { "chat_show_themed ", "Show themed chat message" }, - { "room_title set ", "Set encryption text in titlebar for room" }, - { "room_title reset ", "Reset encryption text in titlebar for room" }, - { "room_ch set ", "Set char for room" }, - { "room_ch reset ", "Reset char for room" }, - { "room_show ", "Show chat room message" }, - { "room_show_themed ", "Show themed chat room message" }, - { "chat_msg none", "Preserve chat messages" }, - { "chat_msg modify", "Modify chat messages" }, - { "chat_msg block", "Block chat messages" }, - { "room_msg none", "Preserve chat room messages" }, - { "room_msg modify", "Modify chat room messages" }, - { "room_msg block", "Block chat room messages" }, - { NULL, NULL } - }; - char *examples[] = { NULL }; - - prof_register_command("/enc_c", 2, 5, synopsis, description, args, examples, cmd_enc); - - char *cmd_ac[] = { - "end", - "chat_title", - "chat_ch", - "chat_show", - "chat_show_themed", - "room_title", - "room_ch", - "room_show", - "room_show_themed", - "chat_msg", - "room_msg", - NULL - }; - prof_completer_add("/enc_c", cmd_ac); - - char *chat_title_ac[] = { "set", "reset", NULL }; - prof_completer_add("/enc_c chat_title", chat_title_ac); - - char *chat_ch_ac[] = { "set", "reset", NULL }; - prof_completer_add("/enc_c chat_ch", chat_ch_ac); - - char *chat_ch_set_ac[] = { "in", "out", NULL }; - prof_completer_add("/enc_c chat_ch set", chat_ch_set_ac); - - char *chat_ch_reset_ac[] = { "in", "out", NULL }; - prof_completer_add("/enc_c chat_ch reset", chat_ch_reset_ac); - - char *room_title_ac[] = { "set", "reset", NULL }; - prof_completer_add("/enc_c room_title", room_title_ac); - - char *room_ch_ac[] = { "set", "reset", NULL }; - prof_completer_add("/enc_c room_ch", room_ch_ac); - - char *chat_msg_ac[] = { "none", "modify", "block", NULL }; - prof_completer_add("/enc_c chat_msg", chat_msg_ac); - - char *room_msg_ac[] = { "none", "modify", "block", NULL }; - prof_completer_add("/enc_c room_msg", room_msg_ac); -} - -char* -prof_pre_chat_message_send(const char * const barejid, const char *message) -{ - if (chat_msg_hook && (strcmp(chat_msg_hook, "modify") == 0)) { - char buf[strlen("[c modified] ") + strlen(message) + 1]; - sprintf(buf, "%s%s", "[c modified] ", message); - return strdup(buf); - } else if (chat_msg_hook && (strcmp(chat_msg_hook, "block") == 0)) { - prof_chat_show_themed(barejid, NULL, NULL, "bold_red", "!", "C plugin blocked message"); - return NULL; - } else { - return strdup(message); - } -} - -char* -prof_pre_room_message_send(const char * const roomjid, const char *message) -{ - if (room_msg_hook && (strcmp(room_msg_hook, "modify") == 0)) { - char buf[strlen("[c modified] ") + strlen(message) + 1]; - sprintf(buf, "%s%s", "[c modified] ", message); - return strdup(buf); - } else if (room_msg_hook && (strcmp(room_msg_hook, "block") == 0)) { - prof_room_show_themed(roomjid, NULL, NULL, "bold_red", "!", "C plugin blocked message"); - return NULL; - } else { - return strdup(message); - } -} \ No newline at end of file diff --git a/tests/enc_py.py b/tests/enc_py.py deleted file mode 100644 index 9abaaff..0000000 --- a/tests/enc_py.py +++ /dev/null @@ -1,157 +0,0 @@ -import prof - -chat_msg_hook = None -room_msg_hook = None - -def _cmd_enc(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None): - global chat_msg_hook - global room_msg_hook - - if arg1 == "end": - prof.encryption_reset(arg2) - - elif arg1 == "chat_title" and arg2 == "set": - prof.chat_set_titlebar_enctext(arg3, arg4) - - elif arg1 == "chat_title" and arg2 == "reset": - prof.chat_unset_titlebar_enctext(arg3) - - elif arg1 == "chat_ch" and arg2 == "set" and arg3 == "in": - prof.chat_set_incoming_char(arg4, arg5) - - elif arg1 == "chat_ch" and arg2 == "reset" and arg3 == "in": - prof.chat_unset_incoming_char(arg4) - - elif arg1 == "chat_ch" and arg2 == "set" and arg3 == "out": - prof.chat_set_outgoing_char(arg4, arg5) - - elif arg1 == "chat_ch" and arg2 == "reset" and arg3 == "out": - prof.chat_unset_outgoing_char(arg4) - - elif arg1 == "room_title" and arg2 == "set": - prof.room_set_titlebar_enctext(arg3, arg4) - - elif arg1 == "room_title" and arg2 == "reset": - prof.room_unset_titlebar_enctext(arg3) - - elif arg1 == "room_ch" and arg2 == "set": - prof.room_set_message_char(arg3, arg4) - - elif arg1 == "room_ch" and arg2 == "reset": - prof.room_unset_message_char(arg3) - - elif arg1 == "chat_show": - prof.chat_show(arg2, arg3) - - elif arg1 == "chat_show_themed": - prof.chat_show_themed(arg2, "enc_py", "chat_msg", None, "p", arg3) - - elif arg1 == "room_show": - prof.room_show(arg2, arg3) - - elif arg1 == "room_show_themed": - prof.room_show_themed(arg2, "enc_py", "room_msg", None, "P", arg3) - - elif arg1 == "chat_msg": - chat_msg_hook = arg2 - - elif arg1 == "room_msg": - room_msg_hook = arg2 - - else: - prof.cons_bad_cmd_usage("/enc_py") - - -def prof_init(version, status, account_name, fulljid): - synopsis = [ - "/enc_py end ", - "/enc_py chat_title set ", - "/enc_py chat_title unset ", - "/enc_py chat_ch set in ", - "/enc_py chat_ch reset in ", - "/enc_py chat_ch set out ", - "/enc_py chat_ch reset out ", - "/enc_py chat_show ", - "/enc_py chat_show_themed ", - "/enc_py room_title set ", - "/enc_py room_title unset " - "/enc_py room_ch set ", - "/enc_py room_ch reset ", - "/enc_py room_show ", - "/enc_py room_show_themed " - "/enc_py chat_msg none", - "/enc_py chat_msg modify", - "/enc_py chat_msg block", - "/enc_py room_msg none", - "/enc_py room_msg modify", - "/enc_py room_msg block" - ] - description = "Various enc things" - args = [ - [ "end ", "User to end the session with" ], - [ "chat_title set ", "Set encryption text in titlebar for recipient" ], - [ "chat_title reset ", "Reset encryption text in titlebar for recipient" ], - [ "chat_ch set in ", "Set incoming char for recipient" ], - [ "chat_ch reset in ", "Reset incoming char for recipient" ], - [ "chat_ch set out ", "Set outgoing char for recipient" ], - [ "chat_ch reset out ", "Reset outgoing char for recipient" ], - [ "chat_show ", "Show chat message" ], - [ "chat_show_themed ", "Show themed chat message" ], - [ "room_title set ", "Set encryption text in titlebar for room" ], - [ "room_title reset ", "Reset encryption text in titlebar for room" ], - [ "room_ch set ", "Set char for room" ], - [ "room_ch reset ", "Reset char for room" ], - [ "room_show ", "Show chat room message" ], - [ "room_show_themed ", "Show themed chat room message" ], - [ "chat_msg none", "Preserve chat messages" ], - [ "chat_msg modify", "Modify chat messages" ], - [ "chat_msg block", "Block chat messages" ], - [ "room_msg none", "Preserve chat room messages" ], - [ "room_msg modify", "Modify chat room messages" ], - [ "room_msg block", "Block chat room messages" ] - ] - examples = [] - - prof.register_command("/enc_py", 2, 5, synopsis, description, args, examples, _cmd_enc) - prof.completer_add("/enc_py", [ - "end", - "chat_title", - "chat_ch", - "chat_show", - "chat_show_themed", - "room_title", - "room_ch", - "room_show", - "room_show_themed", - "chat_msg", - "room_msg" - ]) - prof.completer_add("/enc_py chat_title", [ "set", "reset" ]) - prof.completer_add("/enc_py chat_ch", [ "set", "reset" ]) - prof.completer_add("/enc_py chat_ch set", [ "in", "out" ]) - prof.completer_add("/enc_py chat_ch reset", [ "in", "out" ]) - prof.completer_add("/enc_py room_title", [ "set", "reset" ]) - prof.completer_add("/enc_py room_ch", [ "set", "reset" ]) - prof.completer_add("/enc_py chat_msg", [ "none", "modify", "block" ]) - prof.completer_add("/enc_py room_msg", [ "none", "modify", "block" ]) - - -def prof_pre_chat_message_send(barejid, message): - if chat_msg_hook == "modify": - return "[py modified] " + message - elif chat_msg_hook == "block": - prof.chat_show_themed(barejid, None, None, "bold_red", "!", "Python plugin blocked message") - return None - else: - prof.log_info("none") - return message - - -def prof_pre_room_message_send(roomjid, message): - if room_msg_hook == "modify": - return "[py modified] " + message - elif room_msg_hook == "block": - prof.room_show_themed(roomjid, None, None, "bold_red", "!", "Python plugin blocked message") - return None - else: - return message diff --git a/tests/luatest.lua b/tests/luatest.lua deleted file mode 100644 index c3da958..0000000 --- a/tests/luatest.lua +++ /dev/null @@ -1,116 +0,0 @@ -local luatest = {} - -local function cmd_lua(msg) - if msg then - prof_cons_show("luatest: /lua command called, arg = " .. msg) - else - prof_cons_show("luatest: /lua command called with no arg") - end - prof_cons_alert() - prof_notify("luatest: notify", 8000, "Plugins") - prof_send_line("/account list") - prof_cons_show("luatest: sent \"/account list\" command") -end - -local function timer_test() - prof_cons_show("luatest: timer fired.") - recipient = prof_get_current_recipient() - if recipient then - prof_cons_show(" current recipient = " .. recipient) - end - prof_cons_alert() -end - -local function handle_bracket(win, line) - prof_win_show(win, "(" .. line .. ")") - prof_win_show_red(win, "Red") - prof_win_show_yellow(win, "Yellow") - prof_win_show_green(win, "Green") - prof_win_show_cyan(win, "Cyan") -end - -local function cmd_bracket(line) - win_tag = "Parenthesise echo"; - if prof_win_exists(win_tag) == false then - prof_win_create(win_tag, handle_bracket); - end - - prof_win_focus(win_tag); - - if line then - handle_bracket(win_tag, line) - end -end - -function luatest.prof_init(version, status) - prof_cons_show("luatest: init, " .. version .. ", " .. status) - - prof_register_command("/lua", 0, 1, "/lua", "luatest", "luatest", cmd_lua) - prof_register_command("/bracket", 0, 1, "/bracket", "Parenthesise input string", "Parenthesise input string", cmd_bracket); - - prof_register_ac("/lcomplete", { "football", "footy", "tennis" }) - prof_register_ac("/lcomplete football", { "goal", "out", "try", "given" }) - prof_register_ac("/lcomplete tennis", { "test", "prod", "dev", "stage" }) - prof_register_command("/lcomplete", 0, 2, "/lcomplete", "Lua completion", "Lua completion", cmd_bracket) - - prof_register_timed(timer_test, 10) -end - -function luatest.prof_on_start() - prof_cons_show("luatest: on_start") - prof_log_debug("luatest: logged debug"); - prof_log_info("luatest: logged info"); - prof_log_warning("luatest: logged warning"); - prof_log_error("luatest: logged error"); -end - -function luatest.prof_on_connect(account_name, fulljid) - prof_cons_show("luatest: on_connect, " .. account_name .. ", " .. fulljid) -end - -function luatest.prof_on_disconnect(account_name, fulljid) - prof_cons_show("luatest: on_disconnect, " .. account_name .. ", " .. fulljid) - prof_log_info("luatest: on_disconnect, " .. account_name .. ", " .. fulljid) -end - -function luatest.prof_on_message_received(jid, message) - prof_cons_show("luatest: on_message_received, " .. jid .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_room_message_received(room, nick, message) - prof_cons_show("luatest: on_room_message_received, " .. room .. ", " .. nick .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_private_message_received(room, nick, message) - prof_cons_show("luatest: on_private_message_received, " .. room .. ", " .. nick .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_message_send(jid, message) - prof_cons_show("luatest: on_message_send, " .. jid .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_private_message_send(room, nick, message) - prof_cons_show("luatest: on_private_message_send, " .. room .. ", " .. nick .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_room_message_send(room, message) - prof_cons_show("luatest: on_room_message_send, " .. room .. ", " .. message) - prof_cons_alert() - return message .. "[LUA]" -end - -function luatest.prof_on_shutdown() - prof_log_info("luatest: on_shutdown") -end - -return luatest diff --git a/tests/python-test.py b/tests/python-test.py deleted file mode 100644 index 235db06..0000000 --- a/tests/python-test.py +++ /dev/null @@ -1,704 +0,0 @@ -import prof - -import threading -import time - -plugin_win = "Python Test" - -count = 0 -ping_id = 1 -count_thread = None -thread_stop = None - -def _inc_counter(): - global count - global thread_stop - - while not thread_stop.is_set(): - time.sleep(5) - count = count + 1 - - -def _handle_win_input(win, line): - prof.win_show(win, "Input received: " + line) - - -def _consalert(): - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.cons_alert() - prof.win_show(plugin_win, "called -> prof.cons_alert") - - -def _consshow(msg): - if not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.cons_show(msg) - prof.win_show(plugin_win, "called -> prof.cons_show: " + msg) - - -def _consshow_t(group, key, dflt, msg): - if not group or not key or not dflt or not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - groupval = None if group == "none" else group - keyval = None if key == "none" else key - dfltval = None if dflt == "none" else dflt - prof.cons_show_themed(groupval, keyval, dfltval, msg) - prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg) - - -def _constest(): - res = prof.current_win_is_console() - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - if res: - prof.win_show(plugin_win, "called -> prof.current_win_is_console: true") - else: - prof.win_show(plugin_win, "called -> prof.current_win_is_console: false") - - -def _winshow(msg): - if not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.win_show(plugin_win, msg) - prof.win_show(plugin_win, "called -> prof.win_show: " + msg) - - -def _winshow_t(group, key, dflt, msg): - if not group or not key or not dflt or not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - groupval = None if group == "none" else group - keyval = None if key == "none" else key - dfltval = None if dflt == "none" else dflt - prof.win_show_themed(plugin_win, groupval, keyval, dfltval, msg) - prof.win_show(plugin_win, "called -> prof_win_show_themed: " + group + ", " + key + ", " + dflt + ", " + msg) - - -def _sendline(line): - if not line: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.send_line(line) - prof.win_show(plugin_win, "called -> prof.send_line: " + line) - - -def _notify(msg): - if not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.notify(msg, 5000, "python-test plugin") - prof.win_show(plugin_win, "called -> prof.notify: " + msg) - - -def _get(subject): - if subject == "recipient": - prof.win_create(plugin_win, _handle_win_input) - recipient = prof.get_current_recipient(); - if recipient: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof.get_current_recipient: " + recipient) - else: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_recipient: ") - elif subject == "room": - prof.win_create(plugin_win, _handle_win_input) - room = prof.get_current_muc() - if room: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_muc: " + room) - nick = prof.get_room_nick(room) - if nick: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_room_nick('" + room + "'): " + nick) - else: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_muc: ") - elif subject == "nick": - prof.win_create(plugin_win, _handle_win_input) - nick = prof.get_current_nick() - if nick: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_nick: " + nick) - else: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_nick: ") - elif subject == "occupants": - prof.win_create(plugin_win, _handle_win_input) - occupants = prof.get_current_occupants() - if occupants: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_occupants:") - for occupant in occupants: - prof.win_show(plugin_win, occupant) - else: - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "called -> prof_get_current_occupants: ") - else: - prof.cons_bad_cmd_usage("/python-test") - - -def _log(level, msg): - if not level or not msg: - prof.cons_bad_cmd_usage("/python-test") - return - - if level == "debug": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.log_debug(msg) - prof.win_show(plugin_win, "called -> prof.log_debug: " + msg) - elif level == "info": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.log_info(msg) - prof.win_show(plugin_win, "called -> prof.log_info: " + msg) - elif level == "warning": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.log_warning(msg) - prof.win_show(plugin_win, "called -> prof.log_warning: " + msg) - elif level == "error": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.log_error(msg) - prof.win_show(plugin_win, "called -> prof.log_error: " + msg) - else: - prof.cons_bad_cmd_usage("/python-test") - - -def _count(): - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.win_show(plugin_win, "Count: " + str(count)) - - -def _ping(jid): - global ping_id - - if not jid: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - res = prof.send_stanza("") - ping_id = ping_id + 1 - if res: - prof.win_show(plugin_win, "Ping sent successfully") - else: - prof.win_show(plugin_win, "Error sending ping") - - -def _boolean(op, group, key, value_str): - if op != "get" and op != "set": - prof.cons_bad_cmd_usage("/python-test") - return - - if group == None or key == None: - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "set" and value_str != "true" and value_str != "false": - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "get": - dflt = False - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - res = prof.settings_boolean_get(group, key, dflt) - if res: - prof.win_show(plugin_win, "Boolean setting: TRUE") - else: - prof.win_show(plugin_win, "Boolean setting: FALSE") - elif op == "set": - value = False - if value_str == "true": - value = True - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.settings_boolean_set(group, key, value) - prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) - - -def _string(op, group, key, value): - if op != "get" and op != "set": - prof.cons_bad_cmd_usage("/python-test") - return - - if group == None or key == None: - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "set" and not value: - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "get": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - res = prof.settings_string_get(group, key, None) - if res: - prof.win_show(plugin_win, "String setting: " + res) - else: - prof.win_show(plugin_win, "String setting: None") - elif op == "set": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.settings_string_set(group, key, 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): - if op != "get" and op != "set": - prof.cons_bad_cmd_usage("/python-test") - return - - if group == None or key == None: - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "get": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - res = prof.settings_int_get(group, key, 0) - prof.win_show(plugin_win, "Integer setting: " + str(res)) - elif op == "set": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.settings_int_set(group, key, int(value)) - prof.win_show(plugin_win, "Set [" + group + "] " + key + " to " + str(value)) - - -def _incoming(barejid, resource, message): - if not barejid or not resource or not message: - prof.cons_bad_cmd_usage("/python-test") - return - - prof.incoming_message(barejid, resource, message) - - -def _completer(op, item): - if not item: - prof.cons_bad_cmd_usage("/python-test") - return - - if op == "add": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.completer_add("/python-test", [item]) - prof.win_show(plugin_win, "Added \"" + item + "\" to /python-test completer") - prof.completer_add("/python-test completer remove", [item]) - elif op == "remove": - prof.win_create(plugin_win, _handle_win_input) - prof.win_focus(plugin_win) - prof.completer_remove("/python-test", [item]) - prof.win_show(plugin_win, "Removed \"" + item + "\" to /python-test completer") - prof.completer_remove("/python-test completer remove", [item]) - else: - prof.cons_bad_cmd_usage("/python-test") - - -def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None): - if subcmd == "consalert": _consalert() - elif subcmd == "consshow": _consshow(arg1) - elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4) - elif subcmd == "constest": _constest() - elif subcmd == "winshow": _winshow(arg1) - elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4) - elif subcmd == "sendline": _sendline(arg1) - elif subcmd == "notify": _notify(arg1) - elif subcmd == "get": _get(arg1) - elif subcmd == "log": _log(arg1, arg2) - elif subcmd == "count": _count() - elif subcmd == "ping": _ping(arg1) - elif subcmd == "boolean": _boolean(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 == "incoming": _incoming(arg1, arg2, arg3) - elif subcmd == "completer": _completer(arg1, arg2) - else: prof.cons_bad_cmd_usage("/python-test") - - -def timed_callback(): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "timed -> timed_callback called") - - -def prof_init(version, status, account_name, fulljid): - global count - global ping_id - global thread_stop - - count = 0 - ping_id = 1 - - thread_stop = threading.Event() - count_thread = threading.Thread(target=_inc_counter) - count_thread.daemon = True - count_thread.start() - - prof.disco_add_feature("urn:xmpp:profanity:python_test_plugin"); - - prof.win_create(plugin_win, _handle_win_input) - if account_name and fulljid: - prof.win_show(plugin_win, "fired -> prof_init: " + version + ", " + status + ", " + account_name + ", " + fulljid) - else: - prof.win_show(plugin_win, "fired -> prof_init: " + version + ", " + status) - - synopsis = [ - "/python-test consalert", - "/python-test consshow ", - "/python-test consshow_t ", - "/python-test constest", - "/python-test winshow ", - "/python-test winshow_t ", - "/python-test notify ", - "/python-test sendline ", - "/python-test get recipient|room|nick|occupants", - "/python-test log debug|info|warning|error ", - "/python-test count", - "/python-test ping ", - "/python-test boolean get ", - "/python-test boolean set ", - "/python-test string get ", - "/python-test string set ", - "/python-test string_list get ", - "/python-test string_list add ", - "/python-test string_list remove ", - "/python-test string_list remove_all ", - "/python-test int get ", - "/python-test int set ", - "/python-test incoming ", - "/python-test completer add|remove ", - "/python-test file" - ] - description = "Python test plugins. All commands focus the plugin window." - args = [ - [ "consalert", "Highlight the console window in the status bar" ], - [ "consshow ", "Show the message in the console window" ], - [ "consshow_t ", "Show the themed message in the console window. " ], - [ "constest", "Show whether the command was run in the console." ], - [ "winshow ", "Show the message in the plugin window" ], - [ "winshow_t ", "Show the themed message in the plugin window. " ], - [ "notify ", "Send a desktop notification with message" ], - [ "sendline ", "Pass line to profanity to process" ], - [ "get recipient", "Show the current chat recipient, if in a chat window" ], - [ "get room", "Show the current room JID, if ina a chat room"], - [ "get nick", "Show nickname in current room, if ina a chat room"], - [ "get occupants", "Show occupants in current room, if ina a chat room"], - [ "log debug|info|warning|error ", "Log a message at the specified level" ], - [ "count", "Show the counter, incremented every 5 seconds by a worker thread" ], - [ "ping ", "Send an XMPP ping to the specified Jabber ID" ], - [ "boolean get ", "Get a boolean setting" ], - [ "boolean set ", "Set a boolean setting" ], - [ "string get ", "Get a string setting" ], - [ "string set ", "Set a string setting" ], - [ "string_list get ", "Get a string list setting" ], - [ "string_list add ", "Add a string to a string list setting" ], - [ "string_list remove ", "Remove a string from a string list setting" ], - [ "string_list remove_all ", "Remove all strings from a string list setting" ], - [ "int get ", "Get a integer setting" ], - [ "int set ", "Set a integer setting" ], - [ "incoming ", "Show an incoming message." ], - [ "completer add ", "Add an autocomplete item to the /c-test command." ], - [ "completer remove ", "Remove an autocomplete item from the /c-test command." ], - [ "file", "Complete a file path." ] - ] - examples = [ - "/python-test sendline /about", - "/python-test log debug \"Test debug message\"", - "/python-test consshow_t c-test cons.show none \"This is themed\"", - "/python-test consshow_t none none bold_cyan \"This is bold_cyan\"", - "/python-test ping buddy@server.org" - ] - - prof.register_command("/python-test", 1, 5, synopsis, description, args, examples, _cmd_pythontest) - - prof.completer_add("/python-test", - [ - "consalert", - "consshow", - "consshow_t", - "constest", - "winshow", - "winshow_t", - "notify", - "sendline", - "get", - "log", - "count", - "ping", - "boolean", - "string", - "string_list", - "int", - "incoming", - "completer", - "file" - ] - ) - prof.completer_add("/python-test get", - [ "recipient", "room", "nick", "occupants" ] - ) - prof.completer_add("/python-test log", - [ "debug", "info", "warning", "error" ] - ) - prof.completer_add("/python-test boolean", - [ "get", "set" ] - ) - prof.completer_add("/python-test string", - [ "get", "set" ] - ) - prof.completer_add("/python-test string_list", - [ "get", "add", "remove", "remove_all" ] - ) - prof.completer_add("/python-test int", - [ "get", "set" ] - ) - prof.completer_add("/python-test completer", - [ "add", "remove" ] - ) - - prof.filepath_completer_add("/python-test file") - - prof.register_timed(timed_callback, 5) - - -def prof_on_start(): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_start") - - -def prof_on_shutdown(): - global thread_stop - - prof.win_create(plugin_win, _handle_win_input) - 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): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_connect: " + account_name + ", " + fulljid) - - -def prof_on_disconnect(account_name, fulljid): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_disconnect: " + account_name + ", " + fulljid) - - -def prof_pre_chat_message_display(barejid, resource, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + barejid + "/" + resource + ", " + message) - - -def prof_post_chat_message_display(barejid, resource, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_chat_message_display: " + barejid + "/" + resource + ", " + message) - - -def prof_pre_chat_message_send(barejid, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_chat_message_send: " + barejid + ", " + message) - return message - - -def prof_post_chat_message_send(barejid, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + barejid + ", " + message) - - -def prof_pre_room_message_display(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_room_message_display: " + barejid + ", " + nick + ", " + message) - - -def prof_post_room_message_display(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_room_message_display: " + barejid + ", " + nick + ", " + message) - - -def prof_pre_room_message_send(barejid, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + barejid + ", " + message) - return message - - -def prof_post_room_message_send(barejid, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_room_message_send: " + barejid + ", " + message) - - -def prof_on_room_history_message(barejid, nick, message, timestamp): - prof.win_create(plugin_win, _handle_win_input) - if timestamp: - prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message + ", " + timestamp) - else: - prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message) - - -def prof_pre_priv_message_display(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + barejid + ", " + nick + ", " + message) - - -def prof_post_priv_message_display(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_priv_message_display: " + barejid + ", " + nick + ", " + message) - - -def prof_pre_priv_message_send(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_pre_priv_message_send: " + barejid + ", " + nick + ", " + message) - return message - - -def prof_post_priv_message_send(barejid, nick, message): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + barejid + ", " + nick + ", " + message) - - -def prof_on_message_stanza_send(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_message_stanza_send: " + stanza) - - -def prof_on_message_stanza_receive(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_message_stanza_receive: " + stanza) - return True - - -def prof_on_presence_stanza_send(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_send: " + stanza) - - -def prof_on_presence_stanza_receive(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_presence_stanza_receive: " + stanza) - return True - - -def prof_on_iq_stanza_send(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_send: " + stanza) - - -def prof_on_iq_stanza_receive(stanza): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_receive: " + stanza) - return True - - -def prof_on_contact_offline(barejid, resource, status): - prof.win_create(plugin_win, _handle_win_input) - if status: - prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource + " \"" + status + "\"") - else: - prof.win_show(plugin_win, "fired -> prof_on_contact_offline: " + barejid + "/" + resource) - - -def prof_on_contact_presence(barejid, resource, presence, status, priority): - prof.win_create(plugin_win, _handle_win_input) - if status: - prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority) + " \"" + status + "\"") - else: - prof.win_show(plugin_win, "fired -> prof_on_contact_presence: " + barejid + "/" + resource + " " + presence + " " + str(priority)) - - -def prof_on_chat_win_focus(barejid): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_chat_win_focus: " + barejid) - - -def prof_on_room_win_focus(barejid): - prof.win_create(plugin_win, _handle_win_input) - prof.win_show(plugin_win, "fired -> prof_on_room_win_focus: " + barejid) diff --git a/tests/test-c-plugin/Makefile b/tests/test-c-plugin/Makefile deleted file mode 100644 index de67612..0000000 --- a/tests/test-c-plugin/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) - LINK_FLAGS := -fno-common -flat_namespace -bundle -undefined suppress -else - LINK_FLAGS := -shared -fpic -endif - -all: test-c-plugin.so - -%.so:%.o - $(CC) $(LINK_FLAGS) -lprofanity -o $@ $^ - -%.o:%.c - $(CC) $(INCLUDE) -D_GNU_SOURCE -D_BSD_SOURCE -fpic -g3 -O0 -std=c99 \ - -pedantic -c -o $@ $< - -clean: - $(RM) test-c-plugin.so diff --git a/tests/test-c-plugin/test-c-plugin.c b/tests/test-c-plugin/test-c-plugin.c deleted file mode 100644 index ef9236f..0000000 --- a/tests/test-c-plugin/test-c-plugin.c +++ /dev/null @@ -1,1051 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include - -static PROF_WIN_TAG plugin_win = "C Test"; -static pthread_t worker_thread; -static int count = 0; -static int ping_id = 1; - -void* -inc_counter(void *arg) -{ - while (1) { - sleep(5); - count++; - } -} - -void -handle_win_input(PROF_WIN_TAG win, char *line) -{ - char *str = "Input received: "; - char buf[strlen(str) + strlen(line) + 1]; - sprintf(buf, "%s%s", str, line); - prof_win_show(win, buf); -} - -void -consalert(void) -{ - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_cons_alert(); - prof_win_show(plugin_win, "called -> prof_cons_alert"); -} - -void -consshow(char *msg) -{ - if (msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_cons_show(msg); - char *str = "called -> prof_cons_show: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); -} - -void -consshow_t(char *group, char *key, char *def, char *msg) -{ - if (group == NULL || key == NULL || def == NULL || msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *groupval = strcmp(group, "none") == 0 ? NULL : group; - char *keyval = strcmp(key, "none") == 0 ? NULL : key; - char *defval = strcmp(def, "none") == 0 ? NULL : def; - prof_cons_show_themed(groupval, keyval, defval, msg); - char *str = "called -> prof_cons_show_themed: "; - char buf[strlen(str) + strlen(group) + 2 + strlen(key) + 2 + strlen(def) + 2 + strlen(msg)]; - sprintf(buf, "%s%s, %s, %s, %s", str, group, key, def, msg); - prof_win_show(plugin_win, buf); -} - -void -constest(void) -{ - int res = prof_current_win_is_console(); - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - if (res) { - prof_win_show(plugin_win, "called -> prof_current_win_is_console: true"); - } else { - prof_win_show(plugin_win, "called -> prof_current_win_is_console: false"); - } -} - -void -winshow(char *msg) -{ - if (msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_win_show(plugin_win, msg); - char *str = "called -> prof_win_show: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); -} - -void -winshow_t(char *group, char *key, char *def, char *msg) -{ - if (group == NULL || key == NULL || def == NULL || msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *groupval = strcmp(group, "none") == 0 ? NULL : group; - char *keyval = strcmp(key, "none") == 0 ? NULL : key; - char *defval = strcmp(def, "none") == 0 ? NULL : def; - prof_win_show_themed(plugin_win, groupval, keyval, defval, msg); - char *str = "called -> prof_win_show_themed: "; - char buf[strlen(str) + strlen(group) + 2 + strlen(key) + 2 + strlen(def) + 2 + strlen(msg)]; - sprintf(buf, "%s%s, %s, %s, %s", str, group, key, def, msg); - prof_win_show(plugin_win, buf); -} - -void -sendline(char *line) -{ - if (line == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_send_line(line); - char *str = "called -> prof_send_line: "; - char buf[strlen(str) + strlen(line)]; - sprintf(buf, "%s%s", str, line); - prof_win_show(plugin_win, buf); -} - -void -donotify(char *msg) -{ - if (msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_notify(msg, 5000, "c-test plugin"); - char *str = "called -> prof_notify: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); -} - -void -getsubject(char *subject) -{ - if (subject == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(subject, "recipient") == 0) { - prof_win_create(plugin_win, handle_win_input); - char *recipient = prof_get_current_recipient(); - if (recipient) { - prof_win_focus(plugin_win); - char *str = "called -> prof_get_current_recipient: "; - char buf[strlen(str) + strlen(recipient)]; - sprintf(buf, "%s%s", str, recipient); - prof_win_show(plugin_win, buf); - } else { - prof_win_focus(plugin_win); - prof_win_show(plugin_win, "called -> prof_get_current_recipient: "); - } - } else if (strcmp(subject, "room") == 0) { - prof_win_create(plugin_win, handle_win_input); - char *room = prof_get_current_muc(); - if (room) { - prof_win_focus(plugin_win); - char *str = "called -> prof_get_current_muc: "; - char buf[strlen(str) + strlen(room)]; - sprintf(buf, "%s%s", str, room); - prof_win_show(plugin_win, buf); - char *nick = prof_get_room_nick(room); - if (nick) { - prof_win_focus(plugin_win); - char *str1 = "called -> prof_get_room_nick('"; - char *str2 = "'): "; - char buf1[strlen(str1) + strlen(room) + strlen(str2) + strlen(nick)]; - sprintf(buf1, "%s%s%s%s", str1, room, str2, nick); - prof_win_show(plugin_win, buf1); - } - } else { - prof_win_focus(plugin_win); - prof_win_show(plugin_win, "called -> prof_get_current_muc: "); - } - } else if (strcmp(subject, "nick") == 0) { - prof_win_create(plugin_win, handle_win_input); - char *nick = prof_get_current_nick(); - if (nick) { - prof_win_focus(plugin_win); - char *str = "called -> prof_get_current_nick: "; - char buf[strlen(str) + strlen(nick)]; - sprintf(buf, "%s%s", str, nick); - prof_win_show(plugin_win, buf); - } else { - prof_win_focus(plugin_win); - prof_win_show(plugin_win, "called -> prof_get_current_nick: "); - } - } else if (strcmp(subject, "occupants") == 0) { - prof_win_create(plugin_win, handle_win_input); - char **occupants = prof_get_current_occupants(); - if (occupants) { - prof_win_focus(plugin_win); - prof_win_show(plugin_win, "called -> prof_get_current_occupants:"); - int i = 0; - while(occupants[i] != NULL) { - prof_win_show(plugin_win, occupants[i]); - i++; - } - } else { - prof_win_focus(plugin_win); - prof_win_show(plugin_win, "called -> prof_get_current_occupants: "); - } - } else { - prof_cons_bad_cmd_usage("/c-test"); - } -} - -void -logmsg(char *level, char *msg) -{ - if (level == NULL || msg == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(level, "debug") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_log_debug(msg); - char *str = "called -> prof_log_debug: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); - } else if (strcmp(level, "info") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_log_info(msg); - char *str = "called -> prof_log_info: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); - } else if (strcmp(level, "warning") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_log_warning(msg); - char *str = "called -> prof_log_warning: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); - } else if (strcmp(level, "error") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_log_error(msg); - char *str = "called -> prof_log_error: "; - char buf[strlen(str) + strlen(msg)]; - sprintf(buf, "%s%s", str, msg); - prof_win_show(plugin_win, buf); - } else { - prof_cons_bad_cmd_usage("/c-test"); - } -} - -void -docount(void) -{ - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char buf[100]; - sprintf(buf, "Count: %d", count); - prof_win_show(plugin_win, buf); -} - -void -doping(char *jid) -{ - if (jid == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *strstart = ""; - char *idstart = "' id='cplugin-"; - char idbuf[strlen(idstart) + 10]; - sprintf(idbuf, "%s%d", idstart, ping_id); - char buf[strlen(strstart) + strlen(jid) + strlen(idbuf) + strlen(strend)]; - sprintf(buf, "%s%s%s%s", strstart, jid, idbuf, strend); - int res = prof_send_stanza(buf); - ping_id++; - if (res) { - prof_win_show(plugin_win, "Ping sent successfully"); - } else { - prof_win_show(plugin_win, "Error sending ping"); - } -} - -void -booleansetting(char *op, char *group, char *key, char *value_str) -{ - if (op == NULL || group == NULL || key == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if ((strcmp(op, "get") != 0) && (strcmp(op, "set") != 0)) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if ((strcmp(op, "set") == 0) && (strcmp(value_str, "true") != 0) && (strcmp(value_str, "false") != 0)) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(op, "get") == 0) { - int dflt = 0; - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - int res = prof_settings_boolean_get(group, key, dflt); - if (res) { - prof_win_show(plugin_win, "Boolean setting: TRUE"); - } else { - prof_win_show(plugin_win, "Boolean setting: FALSE"); - } - } else if (strcmp(op, "set") == 0) { - int value = 0; - if (strcmp(value_str, "true") == 0) { - value = 1; - } - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_settings_boolean_set(group, key, value); - char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value_str)]; - sprintf(buf, "Set [%s] %s to %s", group, key, value_str); - prof_win_show(plugin_win, buf); - } -} - -void -stringsetting(char *op, char *group, char *key, char *value) -{ - if (op == NULL || group == NULL || key == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if ((strcmp(op, "get") != 0) && (strcmp(op, "set") != 0)) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if ((strcmp(op, "set") == 0) && (value == NULL)) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(op, "get") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *res = prof_settings_string_get(group, key, NULL); - if (res) { - char buf[16 + strlen(res)]; - sprintf(buf, "String setting: %s", res); - prof_win_show(plugin_win, buf); - } else { - prof_win_show(plugin_win, "String setting: NULL"); - } - } else if (strcmp(op, "set") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - prof_settings_string_set(group, key, value); - char buf[5 + strlen(group) + 2 + strlen(key) + 4 + strlen(value)]; - sprintf(buf, "Set [%s] %s to %s", group, key, value); - 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 -intsetting(char *op, char *group, char *key, char *value) -{ - if (op == NULL || group == NULL || key == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if ((strcmp(op, "get") != 0) && (strcmp(op, "set") != 0)) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(op, "get") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - int res = prof_settings_int_get(group, key, 0); - char buf[256]; - sprintf(buf, "Integer setting: %d", res); - prof_win_show(plugin_win, buf); - } else if (strcmp(op, "set") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - int int_value = atoi(value); - prof_settings_int_set(group, key, int_value); - char buf[256]; - sprintf(buf, "Set [%s] %s to %d", group, key, int_value); - prof_win_show(plugin_win, buf); - } -} - -void -incomingmsg(char *barejid, char *resource, char *message) -{ - prof_incoming_message(barejid, resource, message); -} - -void -completer(char *op, char *item) -{ - if (item == NULL) { - prof_cons_bad_cmd_usage("/c-test"); - return; - } - - if (strcmp(op, "add") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *ac[] = { item, NULL }; - prof_completer_add("/c-test", ac); - char buf[256]; - sprintf(buf, "Added \"%s\" to /c-test completer", item); - prof_win_show(plugin_win, buf); - prof_completer_add("/c-test completer remove", ac); - } else if (strcmp(op, "remove") == 0) { - prof_win_create(plugin_win, handle_win_input); - prof_win_focus(plugin_win); - char *ac[] = { item, NULL }; - prof_completer_remove("/c-test", ac); - char buf[256]; - sprintf(buf, "Removed \"%s\" from /c-test completer", item); - prof_win_show(plugin_win, buf); - prof_completer_remove("/c-test completer remove", ac); - } else { - prof_cons_bad_cmd_usage("/c-test"); - } -} - -void -cmd_ctest(char **args) -{ - if (strcmp(args[0], "consalert") == 0) consalert(); - else if (strcmp(args[0], "consshow") == 0) consshow(args[1]); - else if (strcmp(args[0], "consshow_t") == 0) consshow_t(args[1], args[2], args[3], args[4]); - else if (strcmp(args[0], "constest") == 0) constest(); - else if (strcmp(args[0], "winshow") == 0) winshow(args[1]); - else if (strcmp(args[0], "winshow_t") == 0) winshow_t(args[1], args[2], args[3], args[4]); - else if (strcmp(args[0], "sendline") == 0) sendline(args[1]); - else if (strcmp(args[0], "notify") == 0) donotify(args[1]); - else if (strcmp(args[0], "get") == 0) getsubject(args[1]); - else if (strcmp(args[0], "log") == 0) logmsg(args[1], args[2]); - else if (strcmp(args[0], "count") == 0) docount(); - 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], "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], "incoming") == 0) incomingmsg(args[1], args[2], args[3]); - else if (strcmp(args[0], "completer") == 0) completer(args[1], args[2]); - else prof_cons_bad_cmd_usage("/c-test"); -} - -void -timed_callback(void) -{ - prof_win_create(plugin_win, handle_win_input); - prof_win_show(plugin_win, "timed -> timed_callback called"); -} - -void -prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid) -{ - pthread_create(&worker_thread, NULL, inc_counter, NULL); - - prof_disco_add_feature("urn:xmpp:profanity:c_test_plugin"); - - prof_win_create(plugin_win, handle_win_input); - - char buf[256]; - if (account_name != NULL && fulljid != NULL) { - sprintf(buf, "fired -> prof_init: %s, %s, %s, %s", version, status, account_name, fulljid); - } else { - sprintf(buf, "fired -> prof_init: %s, %s", version, status); - } - prof_win_show(plugin_win, buf); - - char *synopsis[] = { - "/c-test consalert", - "/c-test consshow ", - "/c-test consshow_t ", - "/c-test constest", - "/c-test winshow ", - "/c-test winshow_t ", - "/c-test notify ", - "/c-test sendline ", - "/c-test get recipient|room|nick|occupants", - "/c-test log debug|info|warning|error ", - "/c-test count", - "/c-test ping ", - "/c-test boolean get ", - "/c-test boolean set ", - "/c-test string get ", - "/c-test string set ", - "/c-test-test string_list get ", - "/c-test string_list add ", - "/c-test string_list remove ", - "/c-test string_list remove_all ", - "/c-test int get ", - "/c-test int set ", - "/c-test incoming ", - "/c-test completer add|remove ", - "/c-test file", - NULL - }; - char *description = "C test plugin. All commands focus the plugin window."; - char *args[][2] = { - { "consalert", "Highlight the console window in the status bar" }, - { "consshow ", "Show the message in the console window" }, - { "consshow_t ", "Show the themed message in the console window. " }, - { "constest", "Show whether the command was run in the console." }, - { "winshow ", "Show the message in the plugin window" }, - { "winshow_t ", "Show the themed message in the plugin window. " }, - { "notify ", "Send a desktop notification with message" }, - { "sendline ", "Pass line to profanity to process" }, - { "get recipient", "Show the current chat recipient, if in a chat window" }, - { "get room", "Show the current room JID, if in a chat room" }, - { "get nick", "Show nickname in current room, if in a chat room" }, - { "get occupants", "Show occupants in current room, if in a chat room" }, - { "log debug|info|warning|error ", "Log a message at the specified level" }, - { "count", "Show the counter, incremented every 5 seconds by a worker thread" }, - { "ping ", "Send an XMPP ping to the specified Jabber ID" }, - { "boolean get ", "Get a boolean setting" }, - { "boolean set ", "Set a boolean setting" }, - { "string get ", "Get a string setting" }, - { "string set ", "Set a string setting" }, - { "string_list get ", "Get a string list setting" }, - { "string_list add ", "Add a string to a string list setting" }, - { "string_list remove ", "Remove a string from a string list setting" }, - { "string_list remove_all ", "Remove all strings from a string list setting" }, - { "int get ", "Get a integer setting" }, - { "int set ", "Set a integer setting" }, - { "incoming ", "Show an incoming message." }, - { "completer add ", "Add an autocomplete item to the /c-test command." }, - { "completer remove ", "Remove an autocomplete item from the /c-test command." }, - { "file", "Complete a file path." }, - { NULL, NULL } - }; - - char *examples[] = { - "/c-test sendline /about", - "/c-test log debug \"Test debug message\"", - "/c-test consshow_t c-test cons.show none \"This is themed\"", - "/c-test consshow_t none none bold_cyan \"This is bold_cyan\"", - "/c-test ping buddy@server.org", - NULL - }; - - prof_register_command("/c-test", 1, 5, synopsis, description, args, examples, cmd_ctest); - - char *cmd_ac[] = { - "consalert", - "consshow", - "consshow_t", - "constest", - "winshow", - "winshow_t", - "notify", - "sendline", - "get", - "log", - "count", - "ping", - "boolean", - "string", - "string_list", - "int", - "incoming", - "completer", - "file", - NULL - }; - prof_completer_add("/c-test", cmd_ac); - - char *get_ac[] = { "recipient", "room", "nick", "occupants", NULL }; - prof_completer_add("/c-test get", get_ac); - - char *log_ac[] = { "debug", "info", "warning", "error", NULL }; - prof_completer_add("/c-test log", log_ac); - - char *boolean_ac[] = { "get", "set", NULL }; - prof_completer_add("/c-test boolean", boolean_ac); - - char *string_ac[] = { "get", "set", NULL }; - 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 }; - prof_completer_add("/c-test int", int_ac); - - char *completer_ac[] = { "add", "remove", NULL }; - prof_completer_add("/c-test completer", completer_ac); - - prof_filepath_completer_add("/c-test file"); - - prof_register_timed(timed_callback, 5); -} - -void -prof_on_start(void) -{ - prof_win_create(plugin_win, handle_win_input); - prof_win_show(plugin_win, "fired -> prof_on_start"); -} - -void -prof_on_shutdown(void) -{ - prof_win_create(plugin_win, handle_win_input); - 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 -prof_on_connect(const char * const account_name, const char * const fulljid) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_connect: "; - char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1]; - sprintf(buf, "%s%s, %s", str, account_name, fulljid); - prof_win_show(plugin_win, buf); -} - -void -prof_on_disconnect(const char * const account_name, const char * const fulljid) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_disconnect: "; - char buf[strlen(str) + strlen(account_name) + 2 + strlen(fulljid) + 1]; - sprintf(buf, "%s%s, %s", str, account_name, fulljid); - prof_win_show(plugin_win, buf); -} - -char* -prof_pre_chat_message_display(const char * const barejid, const char *const resource, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_chat_message_display: "; - char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s/%s, %s", str, barejid, resource, message); - prof_win_show(plugin_win, buf); - - return NULL; -} - -void -prof_post_chat_message_display(const char * const barejid, const char *const resource, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_chat_message_display: "; - char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s/%s, %s", str, barejid, resource, message); - prof_win_show(plugin_win, buf); -} - -char* -prof_pre_chat_message_send(const char * const barejid, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_chat_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s", str, barejid, message); - prof_win_show(plugin_win, buf); - - return strdup(message); -} - -void -prof_post_chat_message_send(const char * const barejid, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_chat_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s", str, barejid, message); - prof_win_show(plugin_win, buf); -} - -char* -prof_pre_room_message_display(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_room_message_display: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); - - return NULL; -} - -void -prof_post_room_message_display(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_room_message_display: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); -} - -char * -prof_pre_room_message_send(const char * const barejid, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_room_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s", str, barejid, message); - prof_win_show(plugin_win, buf); - - return strdup(message); -} - -void -prof_post_room_message_send(const char * const barejid, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_room_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s", str, barejid, message); - prof_win_show(plugin_win, buf); -} - -void -prof_on_room_history_message(const char * const barejid, const char *const nick, const char *const message, const char *const timestamp) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_room_history_message: "; - if (timestamp == NULL) { - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); - } else { - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 2 + strlen(timestamp) + 1]; - sprintf(buf, "%s%s, %s, %s, %s", str, barejid, nick, message, timestamp); - prof_win_show(plugin_win, buf); - } -} - -char * -prof_pre_priv_message_display(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_priv_message_display: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); - - return NULL; -} - -void -prof_post_priv_message_display(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_priv_message_display: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); -} - -char * -prof_pre_priv_message_send(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_pre_priv_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); - - return strdup(message); -} - -void -prof_post_priv_message_send(const char * const barejid, const char * const nick, const char *message) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_post_priv_message_send: "; - char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1]; - sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message); - prof_win_show(plugin_win, buf); -} - -char* -prof_on_message_stanza_send(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_message_stanza_send: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return NULL; - // char *new_stanza = strdup("Art thou not Romeo, and a Montague?"); - // return (char *)new_stanza; -} - -int -prof_on_message_stanza_receive(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_message_stanza_receive: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return 1; -} - -char* -prof_on_presence_stanza_send(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_presence_stanza_send: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return NULL; -} - -int -prof_on_presence_stanza_receive(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_presence_stanza_receive: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return 1; -} - -char* -prof_on_iq_stanza_send(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_iq_stanza_send: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return NULL; -} - -int -prof_on_iq_stanza_receive(const char *const stanza) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_iq_stanza_receive: "; - char buf[strlen(str) + strlen(stanza) + 1]; - sprintf(buf, "%s%s", str, stanza); - prof_win_show(plugin_win, buf); - - return 1; -} - -void -prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status) -{ - prof_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_contact_offline: "; - int status_len = status == NULL ? 0 : strlen(status) + 2; - char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 1 + status_len + 1]; - if (status) { - sprintf(buf, "%s%s/%s \"%s\"", str, barejid, resource, status); - } else { - sprintf(buf, "%s%s/%s", str, barejid, resource); - } - prof_win_show(plugin_win, buf); -} - -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_win_create(plugin_win, handle_win_input); - - char *str = "fired -> prof_on_contact_presence: "; - int status_len = status == NULL ? 0 : strlen(status) + 2; - char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 1 + strlen(presence) + 1 + 10 + status_len + 1]; - if (status) { - sprintf(buf, "%s%s/%s %s %d \"%s\"", str, barejid, resource, presence, priority, status); - } else { - sprintf(buf, "%s%s/%s %s %d", str, barejid, resource, presence, priority); - } - prof_win_show(plugin_win, buf); -} - -void -prof_on_chat_win_focus(const char *const barejid) -{ - prof_win_create(plugin_win, handle_win_input); - char *str = "fired -> prof_on_chat_win_focus: "; - char buf[strlen(str) + strlen(barejid) + 1]; - sprintf(buf, "%s%s", str, barejid); - prof_win_show(plugin_win, buf); -} - -void -prof_on_room_win_focus(const char *const barejid) -{ - prof_win_create(plugin_win, handle_win_input); - char *str = "fired -> prof_on_room_win_focus: "; - char buf[strlen(str) + strlen(barejid) + 1]; - sprintf(buf, "%s%s", str, barejid); - prof_win_show(plugin_win, buf); -}