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>2017-01-19 22:33:29 +0000
committerJames Booth <boothj5@gmail.com>2017-01-19 22:33:29 +0000
commit1b25aa84cb17fd52d1983701553de27e38ebf3eb (patch)
tree7e578e98be237b37ac76f3186a0bdd11543d9452 /src/plugins/python_api.c
parent68496db0b427a18c09c00fb47264c3aea352393e (diff)
downloadprofani-tty-1b25aa84cb17fd52d1983701553de27e38ebf3eb.tar.gz
Add titlebar encryption text to plugins api
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r--src/plugins/python_api.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index b92cdc88..27b4adf8 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -1049,6 +1049,53 @@ python_api_encryption_reset(PyObject *self, PyObject *args)
     Py_RETURN_NONE;
 }
 
+static PyObject*
+python_api_chat_set_titlebar_enctext(PyObject *self, PyObject *args)
+{
+    PyObject *barejid = NULL;
+    PyObject *enctext = NULL;
+    if (!PyArg_ParseTuple(args, "OO", &barejid, &enctext)) {
+        Py_RETURN_NONE;
+    }
+
+    char *barejid_str = python_str_or_unicode_to_string(barejid);
+    char *enctext_str = python_str_or_unicode_to_string(enctext);
+
+    allow_python_threads();
+    int res = api_chat_set_titlebar_enctext(barejid_str, enctext_str);
+    free(barejid_str);
+    free(enctext_str);
+    disable_python_threads();
+
+    if (res) {
+        return Py_BuildValue("O", Py_True);
+    } else {
+        return Py_BuildValue("O", Py_False);
+    }
+}
+
+static PyObject*
+python_api_chat_unset_titlebar_enctext(PyObject *self, PyObject *args)
+{
+    PyObject *barejid = NULL;
+    if (!PyArg_ParseTuple(args, "O", &barejid)) {
+        Py_RETURN_NONE;
+    }
+
+    char *barejid_str = python_str_or_unicode_to_string(barejid);
+
+    allow_python_threads();
+    int res = api_chat_unset_titlebar_enctext(barejid_str);
+    free(barejid_str);
+    disable_python_threads();
+
+    if (res) {
+        return Py_BuildValue("O", Py_True);
+    } else {
+        return Py_BuildValue("O", Py_False);
+    }
+}
+
 void
 python_command_callback(PluginCommand *command, gchar **args)
 {
@@ -1158,6 +1205,8 @@ static PyMethodDef apiMethods[] = {
     { "incoming_message", python_api_incoming_message, METH_VARARGS, "Show an incoming message." },
     { "disco_add_feature", python_api_disco_add_feature, METH_VARARGS, "Add a feature to disco info response." },
     { "encryption_reset", python_api_encryption_reset, METH_VARARGS, "End encrypted chat session with barejid, if one exists" },
+    { "chat_set_titlebar_enctext", python_api_chat_set_titlebar_enctext, METH_VARARGS, "Set the encryption status in the title bar for the specified contact" },
+    { "chat_unset_titlebar_enctext", python_api_chat_unset_titlebar_enctext, METH_VARARGS, "Reset the encryption status in the title bar for the specified recipient" },
     { NULL, NULL, 0, NULL }
 };