Show OTR coloured status

Customisable within theme files e.g.:
titlebar.unencrypted=red
titlebar.encrypted=green
titlebar.trusted=red
titlebar.untrusted=green

Shows [unencrypted] for all non-OTR chat

Disable with '/otr warn off'
This commit is contained in:
James Booth
2014-01-16 22:44:23 +00:00
parent 6c59bb26da
commit 4f98bc8c25
11 changed files with 161 additions and 39 deletions

View File

@@ -983,6 +983,16 @@ _cons_titlebar_setting(void)
}
}
static void
_cons_otrwarn_setting(void)
{
if (prefs_get_boolean(PREF_OTR_WARN)) {
cons_show("Warn non-OTR (/otr warn) : ON");
} else {
cons_show("Warn non-OTR (/otr warn) : OFF");
}
}
static void
_cons_show_ui_prefs(void)
{
@@ -996,6 +1006,7 @@ _cons_show_ui_prefs(void)
cons_mouse_setting();
cons_statuses_setting();
cons_titlebar_setting();
cons_otrwarn_setting();
wins_refresh_console();
cons_alert();
@@ -1564,6 +1575,7 @@ console_init_module(void)
cons_chlog_setting = _cons_chlog_setting;
cons_grlog_setting = _cons_grlog_setting;
cons_otr_log_setting = _cons_otr_log_setting;
cons_otrwarn_setting = _cons_otrwarn_setting;
cons_show_log_prefs = _cons_show_log_prefs;
cons_autoaway_setting = _cons_autoaway_setting;
cons_show_presence_prefs = _cons_show_presence_prefs;

View File

@@ -525,15 +525,6 @@ _get_recipient_string(ProfWin *window)
g_string_append(result, window->from);
}
if (window->is_otr) {
g_string_append(result, " [OTR]");
if (window->is_trusted) {
g_string_append(result, " (trusted)");
} else {
g_string_append(result, " (untrusted)");
}
}
return result;
}

View File

@@ -25,7 +25,10 @@
#include "common.h"
#include "config/theme.h"
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/windows.h"
#include "ui/window.h"
#define CONSOLE_TITLE "Profanity. Type /help for help information."
@@ -150,6 +153,68 @@ _title_bar_draw(void)
for (i = 0; i < 45; i++)
waddch(win, ' ');
mvwprintw(win, 0, 0, " %s", current_title);
#ifdef HAVE_LIBOTR
// show privacy
if (current_recipient != NULL) {
ProfWin *current = wins_get_by_recipient(current_recipient);
if (current != NULL) {
if (current->type == WIN_CHAT) {
if (!current->is_otr) {
if (prefs_get_boolean(PREF_OTR_WARN)) {
wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET);
wattron(win, COLOUR_TITLE_UNENCRYPTED);
wprintw(win, "unencrypted");
wattroff(win, COLOUR_TITLE_UNENCRYPTED);
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET);
}
} else {
wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET);
wattron(win, COLOUR_TITLE_ENCRYPTED);
wprintw(win, "OTR");
wattroff(win, COLOUR_TITLE_ENCRYPTED);
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET);
if (current->is_trusted) {
wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET);
wattron(win, COLOUR_TITLE_TRUSTED);
wprintw(win, "trusted");
wattroff(win, COLOUR_TITLE_TRUSTED);
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET);
} else {
wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET);
wattron(win, COLOUR_TITLE_UNTRUSTED);
wprintw(win, "untrusted");
wattroff(win, COLOUR_TITLE_UNTRUSTED);
wattron(win, COLOUR_TITLE_BRACKET);
wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET);
}
}
}
}
}
#endif
// show contact typing
if (typing) {
wprintw(win, " (typing...)");
}

View File

@@ -221,6 +221,7 @@ void (*cons_log_setting)(void);
void (*cons_chlog_setting)(void);
void (*cons_grlog_setting)(void);
void (*cons_otr_log_setting)(void);
void (*cons_otrwarn_setting)(void);
void (*cons_autoaway_setting)(void);
void (*cons_reconnect_setting)(void);
void (*cons_autoping_setting)(void);