From 1b25aa84cb17fd52d1983701553de27e38ebf3eb Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 19 Jan 2017 22:33:29 +0000 Subject: Add titlebar encryption text to plugins api --- src/plugins/python_api.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/plugins/python_api.c') 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 } }; -- cgit 1.4.1-2-gfad0 41267ae1c506310ff2f402ed0fefe98f91af8b59'>unittests/test_cmd_presence.h
blob: 620921aed1f39bd7c421f83cfab02ad0cafcd567 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13