mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
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:
parent
6c59bb26da
commit
4f98bc8c25
@ -60,6 +60,8 @@ test_sources = \
|
||||
src/config/accounts.h \
|
||||
src/config/preferences.c src/config/preferences.h \
|
||||
src/config/theme.c src/config/theme.h \
|
||||
src/ui/windows.c src/ui/windows.h \
|
||||
src/ui/window.c src/ui/window.h \
|
||||
tests/xmpp/mock_xmpp.h tests/xmpp/mock_xmpp.c \
|
||||
tests/ui/mock_ui.h tests/ui/mock_ui.c \
|
||||
tests/config/mock_accounts.h tests/config/mock_accounts.c \
|
||||
|
@ -571,9 +571,9 @@ static struct cmd_t command_defs[] =
|
||||
|
||||
{ "/otr",
|
||||
cmd_otr, parse_args, 1, 2, NULL,
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log", "Off The Record encryption commands.",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log",
|
||||
"-------------------------------------------------",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn", "Off The Record encryption commands.",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log|warn",
|
||||
"------------------------------------------------------",
|
||||
"gen - Generate your private key.",
|
||||
"myfp - Show your fingerprint.",
|
||||
"theirfp - Show contacts fingerprint.",
|
||||
@ -582,6 +582,7 @@ static struct cmd_t command_defs[] =
|
||||
"trust - Indicate that you have verified the contact's fingerprint.",
|
||||
"untrust - Indicate the the contact's fingerprint is not verified,",
|
||||
"log - How to log OTR messages, options are 'on', 'off' and 'redact', with redaction being the default.",
|
||||
"warn - Show when unencrypted messaging is being used in the title bar, options are 'on' and 'off' with 'on' being the default.",
|
||||
NULL } } },
|
||||
|
||||
{ "/outtype",
|
||||
@ -997,6 +998,7 @@ cmd_init(void)
|
||||
autocomplete_add(otr_ac, "trust");
|
||||
autocomplete_add(otr_ac, "untrust");
|
||||
autocomplete_add(otr_ac, "log");
|
||||
autocomplete_add(otr_ac, "warn");
|
||||
|
||||
otr_log_ac = autocomplete_new();
|
||||
autocomplete_add(otr_log_ac, "on");
|
||||
@ -1588,6 +1590,12 @@ _otr_autocomplete(char *input, int *size)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/otr warn",
|
||||
prefs_autocomplete_boolean_choice);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/otr", otr_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
|
@ -2327,6 +2327,12 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
||||
cons_show("Usage: %s", help.usage);
|
||||
}
|
||||
return TRUE;
|
||||
} else if (strcmp(args[0], "warn") == 0) {
|
||||
gboolean result = _cmd_set_boolean_preference(args[1], help,
|
||||
"OTR warning message", PREF_OTR_WARN);
|
||||
// update the current window
|
||||
ui_switch_win(wins_get_current_num());
|
||||
return result;
|
||||
}
|
||||
|
||||
if (jabber_get_connection_status() != JABBER_CONNECTED) {
|
||||
@ -2493,7 +2499,11 @@ _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
||||
GString *disabled = g_string_new(display);
|
||||
g_string_append(disabled, " disabled.");
|
||||
|
||||
if (strcmp(arg, "on") == 0) {
|
||||
if (arg == NULL) {
|
||||
char usage[strlen(help.usage) + 8];
|
||||
sprintf(usage, "Usage: %s", help.usage);
|
||||
cons_show(usage);
|
||||
} else if (strcmp(arg, "on") == 0) {
|
||||
cons_show(enabled->str);
|
||||
prefs_set_boolean(pref, TRUE);
|
||||
} else if (strcmp(arg, "off") == 0) {
|
||||
|
@ -293,6 +293,7 @@ _get_group(preference_t pref)
|
||||
case PREF_HISTORY:
|
||||
case PREF_MOUSE:
|
||||
case PREF_STATUSES:
|
||||
case PREF_OTR_WARN:
|
||||
return "ui";
|
||||
case PREF_STATES:
|
||||
case PREF_OUTTYPE:
|
||||
@ -368,6 +369,8 @@ _get_key(preference_t pref)
|
||||
return "account";
|
||||
case PREF_OTR_LOG:
|
||||
return "otr";
|
||||
case PREF_OTR_WARN:
|
||||
return "otr.warn";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -380,6 +383,7 @@ _get_default_boolean(preference_t pref)
|
||||
{
|
||||
case PREF_STATUSES:
|
||||
case PREF_AUTOAWAY_CHECK:
|
||||
case PREF_OTR_WARN:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -58,7 +58,8 @@ typedef enum {
|
||||
PREF_AUTOAWAY_MODE,
|
||||
PREF_AUTOAWAY_MESSAGE,
|
||||
PREF_CONNECT_ACCOUNT,
|
||||
PREF_OTR_LOG
|
||||
PREF_OTR_LOG,
|
||||
PREF_OTR_WARN
|
||||
} preference_t;
|
||||
|
||||
void prefs_load(void);
|
||||
|
@ -64,6 +64,10 @@ static struct colours_t {
|
||||
NCURSES_COLOR_T statusbar;
|
||||
NCURSES_COLOR_T titlebartext;
|
||||
NCURSES_COLOR_T titlebarbrackets;
|
||||
NCURSES_COLOR_T titlebarunencrypted;
|
||||
NCURSES_COLOR_T titlebarencrypted;
|
||||
NCURSES_COLOR_T titlebaruntrusted;
|
||||
NCURSES_COLOR_T titlebartrusted;
|
||||
NCURSES_COLOR_T statusbartext;
|
||||
NCURSES_COLOR_T statusbarbrackets;
|
||||
NCURSES_COLOR_T statusbaractive;
|
||||
@ -197,6 +201,10 @@ theme_init_colours(void)
|
||||
// title bar
|
||||
init_pair(10, colour_prefs.titlebartext, colour_prefs.titlebar);
|
||||
init_pair(11, colour_prefs.titlebarbrackets, colour_prefs.titlebar);
|
||||
init_pair(12, colour_prefs.titlebarunencrypted, colour_prefs.titlebar);
|
||||
init_pair(13, colour_prefs.titlebarencrypted, colour_prefs.titlebar);
|
||||
init_pair(14, colour_prefs.titlebaruntrusted, colour_prefs.titlebar);
|
||||
init_pair(15, colour_prefs.titlebartrusted, colour_prefs.titlebar);
|
||||
|
||||
// status bar
|
||||
init_pair(20, colour_prefs.statusbartext, colour_prefs.statusbar);
|
||||
@ -280,6 +288,22 @@ _load_colours(void)
|
||||
_set_colour(titlebarbrackets_val, &colour_prefs.titlebarbrackets, COLOR_CYAN);
|
||||
g_free(titlebarbrackets_val);
|
||||
|
||||
gchar *titlebarunencrypted_val = g_key_file_get_string(theme, "colours", "titlebar.unencrypted", NULL);
|
||||
_set_colour(titlebarunencrypted_val, &colour_prefs.titlebarunencrypted, COLOR_RED);
|
||||
g_free(titlebarunencrypted_val);
|
||||
|
||||
gchar *titlebarencrypted_val = g_key_file_get_string(theme, "colours", "titlebar.encrypted", NULL);
|
||||
_set_colour(titlebarencrypted_val, &colour_prefs.titlebarencrypted, COLOR_WHITE);
|
||||
g_free(titlebarencrypted_val);
|
||||
|
||||
gchar *titlebaruntrusted_val = g_key_file_get_string(theme, "colours", "titlebar.untrusted", NULL);
|
||||
_set_colour(titlebaruntrusted_val, &colour_prefs.titlebaruntrusted, COLOR_RED);
|
||||
g_free(titlebaruntrusted_val);
|
||||
|
||||
gchar *titlebartrusted_val = g_key_file_get_string(theme, "colours", "titlebar.trusted", NULL);
|
||||
_set_colour(titlebartrusted_val, &colour_prefs.titlebartrusted, COLOR_WHITE);
|
||||
g_free(titlebartrusted_val);
|
||||
|
||||
gchar *statusbartext_val = g_key_file_get_string(theme, "colours", "statusbar.text", NULL);
|
||||
_set_colour(statusbartext_val, &colour_prefs.statusbartext, COLOR_WHITE);
|
||||
g_free(statusbartext_val);
|
||||
|
@ -32,31 +32,35 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#define COLOUR_TEXT COLOR_PAIR(1)
|
||||
#define COLOUR_SPLASH COLOR_PAIR(2)
|
||||
#define COLOUR_ERROR COLOR_PAIR(3)
|
||||
#define COLOUR_INCOMING COLOR_PAIR(4)
|
||||
#define COLOUR_INPUT_TEXT COLOR_PAIR(5)
|
||||
#define COLOUR_TIME COLOR_PAIR(6)
|
||||
#define COLOUR_TITLE_TEXT COLOR_PAIR(10)
|
||||
#define COLOUR_TITLE_BRACKET COLOR_PAIR(11)
|
||||
#define COLOUR_STATUS_TEXT COLOR_PAIR(20)
|
||||
#define COLOUR_STATUS_BRACKET COLOR_PAIR(21)
|
||||
#define COLOUR_STATUS_ACTIVE COLOR_PAIR(22)
|
||||
#define COLOUR_STATUS_NEW COLOR_PAIR(23)
|
||||
#define COLOUR_ME COLOR_PAIR(30)
|
||||
#define COLOUR_THEM COLOR_PAIR(31)
|
||||
#define COLOUR_ROOMINFO COLOR_PAIR(40)
|
||||
#define COLOUR_ONLINE COLOR_PAIR(50)
|
||||
#define COLOUR_OFFLINE COLOR_PAIR(51)
|
||||
#define COLOUR_AWAY COLOR_PAIR(52)
|
||||
#define COLOUR_CHAT COLOR_PAIR(53)
|
||||
#define COLOUR_DND COLOR_PAIR(54)
|
||||
#define COLOUR_XA COLOR_PAIR(55)
|
||||
#define COLOUR_TYPING COLOR_PAIR(60)
|
||||
#define COLOUR_GONE COLOR_PAIR(61)
|
||||
#define COLOUR_SUBSCRIBED COLOR_PAIR(70)
|
||||
#define COLOUR_UNSUBSCRIBED COLOR_PAIR(71)
|
||||
#define COLOUR_TEXT COLOR_PAIR(1)
|
||||
#define COLOUR_SPLASH COLOR_PAIR(2)
|
||||
#define COLOUR_ERROR COLOR_PAIR(3)
|
||||
#define COLOUR_INCOMING COLOR_PAIR(4)
|
||||
#define COLOUR_INPUT_TEXT COLOR_PAIR(5)
|
||||
#define COLOUR_TIME COLOR_PAIR(6)
|
||||
#define COLOUR_TITLE_TEXT COLOR_PAIR(10)
|
||||
#define COLOUR_TITLE_BRACKET COLOR_PAIR(11)
|
||||
#define COLOUR_TITLE_UNENCRYPTED COLOR_PAIR(12)
|
||||
#define COLOUR_TITLE_ENCRYPTED COLOR_PAIR(13)
|
||||
#define COLOUR_TITLE_UNTRUSTED COLOR_PAIR(14)
|
||||
#define COLOUR_TITLE_TRUSTED COLOR_PAIR(15)
|
||||
#define COLOUR_STATUS_TEXT COLOR_PAIR(20)
|
||||
#define COLOUR_STATUS_BRACKET COLOR_PAIR(21)
|
||||
#define COLOUR_STATUS_ACTIVE COLOR_PAIR(22)
|
||||
#define COLOUR_STATUS_NEW COLOR_PAIR(23)
|
||||
#define COLOUR_ME COLOR_PAIR(30)
|
||||
#define COLOUR_THEM COLOR_PAIR(31)
|
||||
#define COLOUR_ROOMINFO COLOR_PAIR(40)
|
||||
#define COLOUR_ONLINE COLOR_PAIR(50)
|
||||
#define COLOUR_OFFLINE COLOR_PAIR(51)
|
||||
#define COLOUR_AWAY COLOR_PAIR(52)
|
||||
#define COLOUR_CHAT COLOR_PAIR(53)
|
||||
#define COLOUR_DND COLOR_PAIR(54)
|
||||
#define COLOUR_XA COLOR_PAIR(55)
|
||||
#define COLOUR_TYPING COLOR_PAIR(60)
|
||||
#define COLOUR_GONE COLOR_PAIR(61)
|
||||
#define COLOUR_SUBSCRIBED COLOR_PAIR(70)
|
||||
#define COLOUR_UNSUBSCRIBED COLOR_PAIR(71)
|
||||
|
||||
void theme_init(const char * const theme_name);
|
||||
void theme_init_colours(void);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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...)");
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user