Add titlebar encryption text to plugins api

This commit is contained in:
James Booth
2017-01-19 22:33:29 +00:00
parent 68496db0b4
commit 1b25aa84cb
14 changed files with 219 additions and 14 deletions

View File

@@ -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)
{

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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;
}