Allow chat prefix char to be set by plugins
This commit is contained in:
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user