mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge remote-tracking branch 'origin/master' into clear
This commit is contained in:
commit
cde6bae5ad
@ -10,6 +10,7 @@
|
||||
- Add main.help.header theme option
|
||||
- Look for system TLS certificate path by default (/tls certpath)
|
||||
- Allow plugins to complete file paths with prof.filepath_completer_add function
|
||||
- Add encryption settings functions to plugins api
|
||||
- Bug fixes: https://github.com/boothj5/profanity/milestone/15?closed=1
|
||||
|
||||
0.5.0
|
||||
|
@ -339,3 +339,19 @@ End any encrypted session with the specified user.
|
||||
@param barejid Jabber ID of the recipient
|
||||
*/
|
||||
void prof_encryption_reset(char *barejid);
|
||||
|
||||
/**
|
||||
Set the text to display in the titlebar encryption indicator.
|
||||
@param barejid Jabber ID of the recipient
|
||||
@param enctext The text to display
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_chat_set_titlebar_enctext(char *barejid, char *enctext);
|
||||
|
||||
/**
|
||||
Let profanity decide what to show in the titlebar encryption indicator
|
||||
@param barejid Jabber ID of the recipient
|
||||
@return 1 on success, 0 on failure
|
||||
*/
|
||||
int prof_chat_unset_titlebar_enctext(char *barejid);
|
||||
|
||||
|
@ -630,3 +630,35 @@ def encryption_reset(barejid):
|
||||
::
|
||||
prof.encryption_reset("alice@server.org")
|
||||
"""
|
||||
|
||||
|
||||
def chat_set_titlebar_enctext(barejid, enctext):
|
||||
"""Set the text to display in the titlebar encryption indicator.
|
||||
|
||||
:param barejid: Jabber ID of the recipient
|
||||
:param enctext: The text to display
|
||||
:type barejid: str or unicode
|
||||
:type enctext: str or unicode
|
||||
:return: ``True`` if the text was set successfully, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.chat_set_titlebar_enctext("bob@chat.org", "safe")
|
||||
"""
|
||||
|
||||
|
||||
def chat_unset_titlebar_enctext(barejid):
|
||||
"""Let profanity decide what to show in the titlebar encryption indicator.
|
||||
|
||||
:param barejid: Jabber ID of the recipient
|
||||
:type barejid: str or unicode
|
||||
:return: ``True`` if the text was unset successfully, ``False`` otherwise
|
||||
:rtype: boolean
|
||||
|
||||
Example:
|
||||
::
|
||||
prof.chat_unset_titlebar_enctext("bob@chat.org")
|
||||
"""
|
||||
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
@ -385,6 +385,24 @@ chatwin_get_string(ProfChatWin *chatwin)
|
||||
return resstr;
|
||||
}
|
||||
|
||||
void
|
||||
chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext)
|
||||
{
|
||||
if (chatwin->enctext) {
|
||||
free(chatwin->enctext);
|
||||
}
|
||||
chatwin->enctext = strdup(enctext);
|
||||
}
|
||||
|
||||
void
|
||||
chatwin_unset_enctext(ProfChatWin *chatwin)
|
||||
{
|
||||
if (chatwin->enctext) {
|
||||
free(chatwin->enctext);
|
||||
chatwin->enctext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_chatwin_history(ProfChatWin *chatwin, const char *const contact)
|
||||
{
|
||||
|
@ -319,6 +319,20 @@ _show_privacy(ProfChatWin *chatwin)
|
||||
int trusted_attrs = theme_attrs(THEME_TITLE_TRUSTED);
|
||||
int untrusted_attrs = theme_attrs(THEME_TITLE_UNTRUSTED);
|
||||
|
||||
if (chatwin->enctext) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, encrypted_attrs);
|
||||
wprintw(win, chatwin->enctext);
|
||||
wattroff(win, encrypted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatwin->is_otr) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
@ -353,7 +367,11 @@ _show_privacy(ProfChatWin *chatwin)
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
} else if (chatwin->pgp_send || chatwin->pgp_recv) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatwin->pgp_send || chatwin->pgp_recv) {
|
||||
GString *pgpmsg = g_string_new("PGP ");
|
||||
if (chatwin->pgp_send && !chatwin->pgp_recv) {
|
||||
g_string_append(pgpmsg, "send");
|
||||
@ -373,19 +391,21 @@ _show_privacy(ProfChatWin *chatwin)
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
g_string_free(pgpmsg, TRUE);
|
||||
} else {
|
||||
if (prefs_get_boolean(PREF_ENC_WARN)) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, unencrypted_attrs);
|
||||
wprintw(win, "unencrypted");
|
||||
wattroff(win, unencrypted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_ENC_WARN)) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, unencrypted_attrs);
|
||||
wprintw(win, "unencrypted");
|
||||
wattroff(win, unencrypted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,8 @@ void chatwin_otr_trust(ProfChatWin *chatwin);
|
||||
void chatwin_otr_untrust(ProfChatWin *chatwin);
|
||||
void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data);
|
||||
#endif
|
||||
void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext);
|
||||
void chatwin_unset_enctext(ProfChatWin *chatwin);
|
||||
|
||||
// MUC window
|
||||
void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason);
|
||||
|
@ -155,6 +155,7 @@ typedef struct prof_chat_win_t {
|
||||
char *resource_override;
|
||||
gboolean history_shown;
|
||||
unsigned long memcheck;
|
||||
char *enctext;
|
||||
} ProfChatWin;
|
||||
|
||||
typedef struct prof_muc_win_t {
|
||||
|
@ -146,6 +146,7 @@ win_create_chat(const char *const barejid)
|
||||
new_win->history_shown = FALSE;
|
||||
new_win->unread = 0;
|
||||
new_win->state = chat_state_new();
|
||||
new_win->enctext = NULL;
|
||||
|
||||
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
||||
|
||||
@ -430,6 +431,7 @@ win_free(ProfWin* window)
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
free(chatwin->barejid);
|
||||
free(chatwin->resource_override);
|
||||
free(chatwin->enctext);
|
||||
chat_state_free(chatwin->state);
|
||||
break;
|
||||
}
|
||||
|
@ -67,6 +67,9 @@ void chatwin_otr_untrust(ProfChatWin *chatwin) {}
|
||||
void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) {}
|
||||
#endif
|
||||
|
||||
void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) {}
|
||||
void chatwin_unset_enctext(ProfChatWin *chatwin) {}
|
||||
|
||||
void ui_sigwinch_handler(int sig) {}
|
||||
|
||||
unsigned long ui_get_idle_time(void)
|
||||
|
Loading…
Reference in New Issue
Block a user