diff options
-rwxr-xr-x | install-all.sh | 2 | ||||
-rw-r--r-- | src/plugins/api.c | 7 | ||||
-rw-r--r-- | src/plugins/api.h | 1 | ||||
-rw-r--r-- | src/plugins/c_api.c | 7 | ||||
-rw-r--r-- | src/plugins/profapi.c | 1 | ||||
-rw-r--r-- | src/plugins/profapi.h | 2 | ||||
-rw-r--r-- | src/plugins/python_api.c | 19 | ||||
-rw-r--r-- | src/xmpp/connection.c | 11 | ||||
-rw-r--r-- | src/xmpp/iq.c | 12 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 | ||||
-rw-r--r-- | tests/unittests/xmpp/stub_xmpp.c | 6 |
11 files changed, 62 insertions, 7 deletions
diff --git a/install-all.sh b/install-all.sh index 0ea0817d..cbb8aad8 100755 --- a/install-all.sh +++ b/install-all.sh @@ -34,7 +34,7 @@ fedora_prepare() echo Profanity installer... installing dependencies echo - sudo dnf -y install gcc git autoconf automake openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr3-devel readline-devel libtool gpgme-devel + sudo dnf -y install gcc git autoconf automake openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool gpgme-devel } opensuse_prepare() diff --git a/src/plugins/api.c b/src/plugins/api.c index e81467a9..81b464ca 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -325,3 +325,10 @@ api_win_show_themed(const char *tag, const char *const group, const char *const return 1; } + +int +api_send_stanza(const char *const stanza) +{ + return jabber_send_stanza(stanza); +} + diff --git a/src/plugins/api.h b/src/plugins/api.h index 6494097e..2ded857c 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -70,5 +70,6 @@ int api_win_focus(const char *tag); int api_win_show(const char *tag, const char *line); int api_win_show_themed(const char *tag, const char *const group, const char *const key, const char *const def, const char *line); +int api_send_stanza(const char *const stanza); #endif diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index f2cce6a6..82b89bfd 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -188,6 +188,12 @@ c_api_win_show_themed(char *tag, char *group, char *key, char *def, char *line) return api_win_show_themed(tag, group, key, def, line); } +static int +c_api_send_stanza(char *stanza) +{ + return api_send_stanza(stanza); +} + void c_command_callback(PluginCommand *command, gchar **args) { @@ -236,4 +242,5 @@ c_api_init(void) prof_win_focus = c_api_win_focus; prof_win_show = c_api_win_show; prof_win_show_themed = c_api_win_show_themed; + prof_send_stanza = c_api_send_stanza; } diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 84670c33..33bc1694 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -69,3 +69,4 @@ int (*prof_win_focus)(PROF_WIN_TAG win) = NULL; int (*prof_win_show)(PROF_WIN_TAG win, char *line) = NULL; int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line) = NULL; +int (*prof_send_stanza)(char *stanza) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index 77288f94..5e212110 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -69,5 +69,7 @@ int (*prof_win_focus)(PROF_WIN_TAG win); int (*prof_win_show)(PROF_WIN_TAG win, char *line); int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line); +int (*prof_send_stanza)(char *stanza); + #endif diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 42222065..7d0ebc89 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -433,6 +433,24 @@ python_api_win_show_themed(PyObject *self, PyObject *args) return Py_BuildValue(""); } +static PyObject* +python_api_send_stanza(PyObject *self, PyObject *args) +{ + const char *stanza = NULL; + if (!PyArg_ParseTuple(args, "s", &stanza)) { + return Py_BuildValue("i", 0); + } + + allow_python_threads(); + int res = api_send_stanza(stanza); + disable_python_threads(); + if (res) { + return Py_BuildValue("i", 1); + } else { + return Py_BuildValue("i", 0); + } +} + void python_command_callback(PluginCommand *command, gchar **args) { @@ -522,6 +540,7 @@ static PyMethodDef apiMethods[] = { { "win_focus", python_api_win_focus, METH_VARARGS, "Focus a window." }, { "win_show", python_api_win_show, METH_VARARGS, "Show text in the window." }, { "win_show_themed", python_api_win_show_themed, METH_VARARGS, "Show themed text in the window." }, + { "send_stanza", python_api_send_stanza, METH_VARARGS, "Send an XMPP stanza." }, { NULL, NULL, 0, NULL } }; diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 35fd9938..b70614de 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -480,6 +480,17 @@ jabber_conn_is_secured(void) } } +gboolean +jabber_send_stanza(const char *const stanza) +{ + if (jabber_conn.conn_status != JABBER_CONNECTED) { + return FALSE; + } else { + xmpp_send_raw(jabber_conn.conn, stanza, strlen(stanza)); + return TRUE; + } +} + static jabber_conn_status_t _jabber_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port, const char *const tls_policy) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index c2c56cd6..7a052633 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -637,13 +637,13 @@ _caps_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, } if (query == NULL) { - log_warning("No query element found."); + log_info("No query element found."); return 0; } char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { - log_warning("No node attribute found"); + log_info("No node attribute found"); return 0; } @@ -715,14 +715,14 @@ _caps_response_handler_for_jid(xmpp_conn_t *const conn, xmpp_stanza_t *const sta } if (query == NULL) { - log_warning("No query element found."); + log_info("No query element found."); free(jid); return 0; } char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { - log_warning("No node attribute found"); + log_info("No node attribute found"); free(jid); return 0; } @@ -774,14 +774,14 @@ _caps_response_handler_legacy(xmpp_conn_t *const conn, xmpp_stanza_t *const stan } if (query == NULL) { - log_warning("No query element found."); + log_info("No query element found."); free(expected_node); return 0; } char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE); if (node == NULL) { - log_warning("No node attribute found"); + log_info("No node attribute found"); free(expected_node); return 0; } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 7e3a2c84..8a7d4850 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -159,6 +159,7 @@ void jabber_free_uuid(char *uuid); TLSCertificate* jabber_get_tls_peer_cert(void); #endif gboolean jabber_conn_is_secured(void); +gboolean jabber_send_stanza(const char *const stanza); // message functions char* message_send_chat(const char *const barejid, const char *const msg); diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index dc630198..3ba7f2b3 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -64,6 +64,12 @@ GList * jabber_get_available_resources(void) return NULL; } +gboolean +jabber_send_stanza(const char *const stanza) +{ + return TRUE; +} + // message functions char* message_send_chat(const char * const barejid, const char * const msg) { |