diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/api.c | 80 | ||||
-rw-r--r-- | src/plugins/api.h | 4 | ||||
-rw-r--r-- | src/plugins/c_api.c | 28 | ||||
-rw-r--r-- | src/plugins/profapi.c | 4 | ||||
-rw-r--r-- | src/plugins/profapi.h | 4 | ||||
-rw-r--r-- | src/plugins/python_api.c | 98 |
6 files changed, 218 insertions, 0 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index d4109937..a1cbd35e 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -645,3 +645,83 @@ api_chat_unset_outgoing_char(const char *const barejid) return 1; } + +int +api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext) +{ + if (enctext == NULL) { + return 0; + } + + if (roomjid == NULL) { + return 0; + } + + ProfMucWin *mucwin = wins_get_muc(roomjid); + if (mucwin == NULL) { + return 0; + } + + mucwin_set_enctext(mucwin, enctext); + + return 1; +} + +int +api_room_unset_titlebar_enctext(const char *const roomjid) +{ + if (roomjid == NULL) { + return 0; + } + + ProfMucWin *mucwin = wins_get_muc(roomjid); + if (mucwin == NULL) { + return 0; + } + + mucwin_unset_enctext(mucwin); + + return 1; +} + +int +api_room_set_message_char(const char *const roomjid, const char *const ch) +{ + if (ch == NULL) { + return 0; + } + + if (strlen(ch) != 1) { + return 0; + } + + if (roomjid == NULL) { + return 0; + } + + ProfMucWin *mucwin = wins_get_muc(roomjid); + if (mucwin == NULL) { + return 0; + } + + mucwin_set_message_char(mucwin, ch); + + return 1; +} + +int +api_room_unset_message_char(const char *const roomjid) +{ + if (roomjid == NULL) { + return 0; + } + + ProfMucWin *mucwin = wins_get_muc(roomjid); + if (mucwin == NULL) { + return 0; + } + + mucwin_unset_message_char(mucwin); + + return 1; +} diff --git a/src/plugins/api.h b/src/plugins/api.h index 465365a0..75c159a3 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -104,5 +104,9 @@ int api_chat_set_incoming_char(const char *const barejid, const char *const ch); int api_chat_unset_incoming_char(const char *const barejid); int api_chat_set_outgoing_char(const char *const barejid, const char *const ch); int api_chat_unset_outgoing_char(const char *const barejid); +int api_room_set_titlebar_enctext(const char *const roomjid, const char *const enctext); +int api_room_unset_titlebar_enctext(const char *const roomjid); +int api_room_set_message_char(const char *const roomjid, const char *const ch); +int api_room_unset_message_char(const char *const roomjid); #endif diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 6968657f..5cd23732 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -383,6 +383,30 @@ c_api_chat_unset_outgoing_char(const char *barejid) return api_chat_unset_outgoing_char(barejid); } +static int +c_api_room_set_titlebar_enctext(const char *roomjid, const char *enctext) +{ + return api_room_set_titlebar_enctext(roomjid, enctext); +} + +static int +c_api_room_unset_titlebar_enctext(const char *roomjid) +{ + return api_room_unset_titlebar_enctext(roomjid); +} + +static int +c_api_room_set_message_char(const char *roomjid, const char *ch) +{ + return api_room_set_message_char(roomjid, ch); +} + +static int +c_api_room_unset_message_char(const char *roomjid) +{ + return api_room_unset_message_char(roomjid); +} + void c_command_callback(PluginCommand *command, gchar **args) { @@ -457,6 +481,10 @@ c_api_init(void) prof_chat_unset_incoming_char = c_api_chat_unset_incoming_char; prof_chat_set_outgoing_char = c_api_chat_set_outgoing_char; prof_chat_unset_outgoing_char = c_api_chat_unset_outgoing_char; + prof_room_set_titlebar_enctext = c_api_room_set_titlebar_enctext; + prof_room_unset_titlebar_enctext = c_api_room_unset_titlebar_enctext; + prof_room_set_message_char = c_api_room_set_message_char; + prof_room_unset_message_char = c_api_room_unset_message_char; } static char * diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index c0085d64..e9d3cff6 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -101,3 +101,7 @@ int (*prof_chat_set_incoming_char)(const char *barejid, const char *ch) = NULL; int (*prof_chat_unset_incoming_char)(const char *barejid) = NULL; int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch) = NULL; int (*prof_chat_unset_outgoing_char)(const char *barejid) = NULL; +int (*prof_room_set_titlebar_enctext)(const char *roomjid, const char *enctext) = NULL; +int (*prof_room_unset_titlebar_enctext)(const char *roomjid) = NULL; +int (*prof_room_set_message_char)(const char *roomjid, const char *ch) = NULL; +int (*prof_room_unset_message_char)(const char *roomjid) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index ac71293a..d17152fc 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -113,5 +113,9 @@ int (*prof_chat_set_incoming_char)(const char *barejid, const char *ch); int (*prof_chat_unset_incoming_char)(const char *barejid); int (*prof_chat_set_outgoing_char)(const char *barejid, const char *ch); int (*prof_chat_unset_outgoing_char)(const char *barejid); +int (*prof_room_set_titlebar_enctext)(const char *roomjid, const char *enctext); +int (*prof_room_unset_titlebar_enctext)(const char *roomjid); +int (*prof_room_set_message_char)(const char *roomjid, const char *ch); +int (*prof_room_unset_message_char)(const char *roomjid); #endif diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 4e6f4bb5..4e5bdfb5 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -1190,6 +1190,100 @@ python_api_chat_unset_outgoing_char(PyObject *self, PyObject *args) } } +static PyObject* +python_api_room_set_titlebar_enctext(PyObject *self, PyObject *args) +{ + PyObject *roomjid = NULL; + PyObject *enctext = NULL; + if (!PyArg_ParseTuple(args, "OO", &roomjid, &enctext)) { + Py_RETURN_NONE; + } + + char *roomjid_str = python_str_or_unicode_to_string(roomjid); + char *enctext_str = python_str_or_unicode_to_string(enctext); + + allow_python_threads(); + int res = api_room_set_titlebar_enctext(roomjid_str, enctext_str); + free(roomjid_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_room_unset_titlebar_enctext(PyObject *self, PyObject *args) +{ + PyObject *roomjid = NULL; + if (!PyArg_ParseTuple(args, "O", &roomjid)) { + Py_RETURN_NONE; + } + + char *roomjid_str = python_str_or_unicode_to_string(roomjid); + + allow_python_threads(); + int res = api_room_unset_titlebar_enctext(roomjid_str); + free(roomjid_str); + disable_python_threads(); + + if (res) { + return Py_BuildValue("O", Py_True); + } else { + return Py_BuildValue("O", Py_False); + } +} + +static PyObject* +python_api_room_set_message_char(PyObject *self, PyObject *args) +{ + PyObject *roomjid = NULL; + PyObject *ch = NULL; + if (!PyArg_ParseTuple(args, "OO", &roomjid, &ch)) { + Py_RETURN_NONE; + } + + char *roomjid_str = python_str_or_unicode_to_string(roomjid); + char *ch_str = python_str_or_unicode_to_string(ch); + + allow_python_threads(); + int res = api_room_set_message_char(roomjid_str, ch_str); + free(roomjid_str); + free(ch_str); + disable_python_threads(); + + if (res) { + return Py_BuildValue("O", Py_True); + } else { + return Py_BuildValue("O", Py_False); + } +} + +static PyObject* +python_api_room_unset_message_char(PyObject *self, PyObject *args) +{ + PyObject *roomjid = NULL; + if (!PyArg_ParseTuple(args, "O", &roomjid)) { + Py_RETURN_NONE; + } + + char *roomjid_str = python_str_or_unicode_to_string(roomjid); + + allow_python_threads(); + int res = api_room_unset_message_char(roomjid_str); + free(roomjid_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) { @@ -1305,6 +1399,10 @@ static PyMethodDef apiMethods[] = { { "chat_unset_incoming_char", python_api_chat_unset_incoming_char, METH_VARARGS, "Reset the incoming message prefix character for specified contact" }, { "chat_set_outgoing_char", python_api_chat_set_outgoing_char, METH_VARARGS, "Set the outgoing message prefix character for specified contact" }, { "chat_unset_outgoing_char", python_api_chat_unset_outgoing_char, METH_VARARGS, "Reset the outgoing message prefix character for specified contact" }, + { "room_set_titlebar_enctext", python_api_room_set_titlebar_enctext, METH_VARARGS, "Set the encryption status in the title bar for the specified room" }, + { "room_unset_titlebar_enctext", python_api_room_unset_titlebar_enctext, METH_VARARGS, "Reset the encryption status in the title bar for the specified room" }, + { "room_set_message_char", python_api_room_set_message_char, METH_VARARGS, "Set the message prefix character for specified room" }, + { "room_unset_message_char", python_api_room_unset_message_char, METH_VARARGS, "Reset the message prefix character for specified room" }, { NULL, NULL, 0, NULL } }; |