diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/api.c | 84 | ||||
-rw-r--r-- | src/plugins/api.h | 4 | ||||
-rw-r--r-- | src/plugins/c_api.c | 28 | ||||
-rw-r--r-- | src/plugins/profapi.c | 5 | ||||
-rw-r--r-- | src/plugins/profapi.h | 4 | ||||
-rw-r--r-- | src/plugins/python_api.c | 98 |
6 files changed, 222 insertions, 1 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index e0b2afb1..d4109937 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -561,3 +561,87 @@ api_chat_unset_titlebar_enctext(const char *const barejid) return 1; } + +int +api_chat_set_incoming_char(const char *const barejid, const char *const ch) +{ + if (ch == NULL) { + return 0; + } + + if (strlen(ch) != 1) { + return 0; + } + + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_set_incoming_char(chatwin, ch); + + return 1; +} + +int +api_chat_unset_incoming_char(const char *const barejid) +{ + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_unset_incoming_char(chatwin); + + return 1; +} + +int +api_chat_set_outgoing_char(const char *const barejid, const char *const ch) +{ + if (ch == NULL) { + return 0; + } + + if (strlen(ch) != 1) { + return 0; + } + + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_set_outgoing_char(chatwin, ch); + + return 1; +} + +int +api_chat_unset_outgoing_char(const char *const barejid) +{ + if (barejid == NULL) { + return 0; + } + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin == NULL) { + return 0; + } + + chatwin_unset_outgoing_char(chatwin); + + return 1; +} diff --git a/src/plugins/api.h b/src/plugins/api.h index 64784924..465365a0 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -100,5 +100,9 @@ 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); +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); #endif diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 3721c726..6968657f 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -359,6 +359,30 @@ c_api_chat_unset_titlebar_enctext(const char *barejid) return api_chat_unset_titlebar_enctext(barejid); } +static int +c_api_chat_set_incoming_char(const char *barejid, const char *ch) +{ + return api_chat_set_incoming_char(barejid, ch); +} + +static int +c_api_chat_unset_incoming_char(const char *barejid) +{ + return api_chat_unset_incoming_char(barejid); +} + +static int +c_api_chat_set_outgoing_char(const char *barejid, const char *ch) +{ + return api_chat_set_outgoing_char(barejid, ch); +} + +static int +c_api_chat_unset_outgoing_char(const char *barejid) +{ + return api_chat_unset_outgoing_char(barejid); +} + void c_command_callback(PluginCommand *command, gchar **args) { @@ -429,6 +453,10 @@ c_api_init(void) 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; + prof_chat_set_incoming_char = c_api_chat_set_incoming_char; + 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; } static char * diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index b9dd9e6f..c0085d64 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -97,4 +97,7 @@ 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; - +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; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index 291f8958..ac71293a 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -109,5 +109,9 @@ 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); +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); #endif diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 27b4adf8..4e6f4bb5 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -1096,6 +1096,100 @@ python_api_chat_unset_titlebar_enctext(PyObject *self, PyObject *args) } } +static PyObject* +python_api_chat_set_incoming_char(PyObject *self, PyObject *args) +{ + PyObject *barejid = NULL; + PyObject *ch = NULL; + if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) { + Py_RETURN_NONE; + } + + char *barejid_str = python_str_or_unicode_to_string(barejid); + char *ch_str = python_str_or_unicode_to_string(ch); + + allow_python_threads(); + int res = api_chat_set_incoming_char(barejid_str, ch_str); + free(barejid_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_chat_unset_incoming_char(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_incoming_char(barejid_str); + free(barejid_str); + disable_python_threads(); + + if (res) { + return Py_BuildValue("O", Py_True); + } else { + return Py_BuildValue("O", Py_False); + } +} + +static PyObject* +python_api_chat_set_outgoing_char(PyObject *self, PyObject *args) +{ + PyObject *barejid = NULL; + PyObject *ch = NULL; + if (!PyArg_ParseTuple(args, "OO", &barejid, &ch)) { + Py_RETURN_NONE; + } + + char *barejid_str = python_str_or_unicode_to_string(barejid); + char *ch_str = python_str_or_unicode_to_string(ch); + + allow_python_threads(); + int res = api_chat_set_outgoing_char(barejid_str, ch_str); + free(barejid_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_chat_unset_outgoing_char(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_outgoing_char(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) { @@ -1207,6 +1301,10 @@ static PyMethodDef apiMethods[] = { { "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" }, + { "chat_set_incoming_char", python_api_chat_set_incoming_char, METH_VARARGS, "Set the incoming message prefix character for specified contact" }, + { "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" }, { NULL, NULL, 0, NULL } }; |