Add titlebar encryption text to plugins api
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 *
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user