about summary refs log tree commit diff stats
path: root/src/plugins/python_api.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-03-23 22:57:03 +0000
committerJames Booth <boothj5@gmail.com>2016-03-23 22:57:03 +0000
commit4c913aa08baa5e27972ee10d453e440c13fb7fb7 (patch)
treed507c4d8917dd230f9a275855146238b50fd0415 /src/plugins/python_api.c
parent503fc9e393708cab48de47bc80d4f6a0c0f6cc43 (diff)
downloadprofani-tty-4c913aa08baa5e27972ee10d453e440c13fb7fb7.tar.gz
Added prof_send_stanza to plugins API
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r--src/plugins/python_api.c19
1 files changed, 19 insertions, 0 deletions
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 }
 };