From f4accf64efaed7af4c76cc594d08ae5ed91f3849 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 30 Mar 2016 23:19:10 +0100 Subject: [PATCH] Added presence hooks to test plugins --- tests/python-test.py | 14 +++++++++++++ tests/test-c-plugin/test-c-plugin.c | 32 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/tests/python-test.py b/tests/python-test.py index e8f5ef7..f2fed0c 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -469,3 +469,17 @@ def prof_on_iq_stanza_receive(stanza): _create_win() prof.win_show(plugin_win, "fired -> prof_on_iq_stanza_receive: " + stanza) return True + +def prof_on_contact_offline(barejid, resource, status): + _create_win() + 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): + _create_win() + 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)) diff --git a/tests/test-c-plugin/test-c-plugin.c b/tests/test-c-plugin/test-c-plugin.c index a5afed0..9182af5 100644 --- a/tests/test-c-plugin/test-c-plugin.c +++ b/tests/test-c-plugin/test-c-plugin.c @@ -792,3 +792,35 @@ prof_on_iq_stanza_receive(const char *const stanza) return 1; } + +void +prof_on_contact_offline(const char *const barejid, const char *const resource, const char *const status) +{ + create_win(); + + 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) +{ + create_win(); + + 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); +}