diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/api.c | 38 | ||||
-rw-r--r-- | src/plugins/api.h | 3 | ||||
-rw-r--r-- | src/plugins/c_api.c | 14 | ||||
-rw-r--r-- | src/plugins/profapi.c | 4 | ||||
-rw-r--r-- | src/plugins/profapi.h | 3 | ||||
-rw-r--r-- | src/plugins/python_api.c | 49 |
6 files changed, 111 insertions, 0 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index 3488d84c..e0b2afb1 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -523,3 +523,41 @@ api_encryption_reset(const char *const barejid) } #endif } + +int +api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext) +{ + if (enctext == NULL) { + return 0; + } + + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_set_enctext(chatwin, enctext); + + return 1; +} + +int +api_chat_unset_titlebar_enctext(const char *const barejid) +{ + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_unset_enctext(chatwin); + + return 1; +} diff --git a/src/plugins/api.h b/src/plugins/api.h index c05e7038..64784924 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -98,4 +98,7 @@ void api_disco_add_feature(char *plugin_name, char *feature); void api_encryption_reset(const char *const barejid); +int api_chat_set_titlebar_enctext(const char *const barejid, const char *const enctext); +int api_chat_unset_titlebar_enctext(const char *const barejid); + #endif diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index ed613389..3721c726 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -347,6 +347,18 @@ c_api_encryption_reset(const char *barejid) api_encryption_reset(barejid); } +static int +c_api_chat_set_titlebar_enctext(const char *barejid, const char *enctext) +{ + return api_chat_set_titlebar_enctext(barejid, enctext); +} + +static int +c_api_chat_unset_titlebar_enctext(const char *barejid) +{ + return api_chat_unset_titlebar_enctext(barejid); +} + void c_command_callback(PluginCommand *command, gchar **args) { @@ -415,6 +427,8 @@ c_api_init(void) prof_incoming_message = c_api_incoming_message; _prof_disco_add_feature = c_api_disco_add_feature; prof_encryption_reset = c_api_encryption_reset; + prof_chat_set_titlebar_enctext = c_api_chat_set_titlebar_enctext; + prof_chat_unset_titlebar_enctext = c_api_chat_unset_titlebar_enctext; } static char * diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 8a6ef5aa..b9dd9e6f 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -94,3 +94,7 @@ void (*prof_incoming_message)(char *barejid, char *resource, char *message) = NU void (*_prof_disco_add_feature)(const char *filename, char *feature) = NULL; void (*prof_encryption_reset)(const char *barejid) = NULL; + +int (*prof_chat_set_titlebar_enctext)(const char *barejid, const char *enctext) = NULL; +int (*prof_chat_unset_titlebar_enctext)(const char *barejid) = NULL; + diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index 223af77f..291f8958 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -107,4 +107,7 @@ void (*_prof_disco_add_feature)(const char *filename, char *feature); void (*prof_encryption_reset)(const char *barejid); +int (*prof_chat_set_titlebar_enctext)(const char *barejid, const char *enctext); +int (*prof_chat_unset_titlebar_enctext)(const char *barejid); + #endif 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 } }; |