mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added setting /otr log on|off|redact
This commit is contained in:
parent
443b240ce4
commit
60820007ee
@ -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", "Off The Record encryption commands.",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust",
|
||||
"---------------------------------------------",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log", "Off The Record encryption commands.",
|
||||
{ "/otr gen|myfp|theirfp|start|end|trust|untrust|log",
|
||||
"-------------------------------------------------",
|
||||
"gen - Generate your private key.",
|
||||
"myfp - Show your fingerprint.",
|
||||
"theirfp - Show contacts fingerprint.",
|
||||
@ -581,6 +581,7 @@ static struct cmd_t command_defs[] =
|
||||
"end - End the current OTR session,",
|
||||
"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.",
|
||||
NULL } } },
|
||||
|
||||
{ "/outtype",
|
||||
@ -834,6 +835,7 @@ static Autocomplete roster_ac;
|
||||
static Autocomplete group_ac;
|
||||
static Autocomplete bookmark_ac;
|
||||
static Autocomplete otr_ac;
|
||||
static Autocomplete otr_log_ac;
|
||||
|
||||
/*
|
||||
* Initialise command autocompleter and history
|
||||
@ -994,6 +996,12 @@ cmd_init(void)
|
||||
autocomplete_add(otr_ac, "theirfp");
|
||||
autocomplete_add(otr_ac, "trust");
|
||||
autocomplete_add(otr_ac, "untrust");
|
||||
autocomplete_add(otr_ac, "log");
|
||||
|
||||
otr_log_ac = autocomplete_new();
|
||||
autocomplete_add(otr_log_ac, "on");
|
||||
autocomplete_add(otr_log_ac, "off");
|
||||
autocomplete_add(otr_log_ac, "redact");
|
||||
|
||||
cmd_history_init();
|
||||
}
|
||||
@ -1026,6 +1034,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(group_ac);
|
||||
autocomplete_free(bookmark_ac);
|
||||
autocomplete_free(otr_ac);
|
||||
autocomplete_free(otr_log_ac);
|
||||
}
|
||||
|
||||
// Command autocompletion functions
|
||||
@ -1100,6 +1109,7 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(group_ac);
|
||||
autocomplete_reset(bookmark_ac);
|
||||
autocomplete_reset(otr_ac);
|
||||
autocomplete_reset(otr_log_ac);
|
||||
bookmark_autocomplete_reset();
|
||||
}
|
||||
|
||||
@ -1325,7 +1335,7 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
}
|
||||
|
||||
gchar *cmds[] = { "/help", "/prefs", "/log", "/disco", "/close", "/wins" };
|
||||
Autocomplete completers[] = { help_ac, prefs_ac, log_ac, disco_ac, close_ac, wins_ac, otr_ac };
|
||||
Autocomplete completers[] = { help_ac, prefs_ac, log_ac, disco_ac, close_ac, wins_ac };
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
|
||||
result = autocomplete_param_with_ac(input, size, cmds[i], completers[i]);
|
||||
@ -1569,6 +1579,11 @@ _otr_autocomplete(char *input, int *size)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/otr log", otr_log_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, size, "/otr", otr_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
|
@ -2302,6 +2302,29 @@ gboolean
|
||||
cmd_otr(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
if (strcmp(args[0], "log") == 0) {
|
||||
char *choice = args[1];
|
||||
if (g_strcmp0(choice, "on") == 0) {
|
||||
prefs_set_string(PREF_OTR_LOG, "on");
|
||||
cons_show("OTR messages will be logged as plaintext.");
|
||||
if (!prefs_get_boolean(PREF_CHLOG)) {
|
||||
cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
||||
}
|
||||
} else if (g_strcmp0(choice, "off") == 0) {
|
||||
prefs_set_string(PREF_OTR_LOG, "off");
|
||||
cons_show("OTR message logging disabled.");
|
||||
} else if (g_strcmp0(choice, "redact") == 0) {
|
||||
prefs_set_string(PREF_OTR_LOG, "redact");
|
||||
cons_show("OTR messages will be logged as '[redacted]'.");
|
||||
if (!prefs_get_boolean(PREF_CHLOG)) {
|
||||
cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (jabber_get_connection_status() != JABBER_CONNECTED) {
|
||||
cons_show("You must be connected with an account to load OTR information.");
|
||||
return TRUE;
|
||||
|
@ -304,6 +304,7 @@ _get_group(preference_t pref)
|
||||
return "notifications";
|
||||
case PREF_CHLOG:
|
||||
case PREF_GRLOG:
|
||||
case PREF_OTR_LOG:
|
||||
return "logging";
|
||||
case PREF_AUTOAWAY_CHECK:
|
||||
case PREF_AUTOAWAY_MODE:
|
||||
@ -365,6 +366,8 @@ _get_key(preference_t pref)
|
||||
return "autoaway.message";
|
||||
case PREF_CONNECT_ACCOUNT:
|
||||
return "account";
|
||||
case PREF_OTR_LOG:
|
||||
return "otr";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@ -390,6 +393,8 @@ _get_default_string(preference_t pref)
|
||||
{
|
||||
case PREF_AUTOAWAY_MODE:
|
||||
return "off";
|
||||
case PREF_OTR_LOG:
|
||||
return "redact";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ typedef enum {
|
||||
PREF_AUTOAWAY_CHECK,
|
||||
PREF_AUTOAWAY_MODE,
|
||||
PREF_AUTOAWAY_MESSAGE,
|
||||
PREF_CONNECT_ACCOUNT
|
||||
PREF_CONNECT_ACCOUNT,
|
||||
PREF_OTR_LOG
|
||||
} preference_t;
|
||||
|
||||
void prefs_load(void);
|
||||
|
@ -1133,6 +1133,20 @@ _cons_grlog_setting(void)
|
||||
cons_show("Groupchat logging (/grlog) : OFF");
|
||||
}
|
||||
|
||||
static void
|
||||
_cons_otr_log_setting(void)
|
||||
{
|
||||
char *value = prefs_get_string(PREF_OTR_LOG);
|
||||
|
||||
if (strcmp(value, "on") == 0) {
|
||||
cons_show("OTR logging (/otr log) : ON");
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
cons_show("OTR logging (/otr log) : OFF");
|
||||
} else {
|
||||
cons_show("OTR logging (/otr log) : Redacted");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cons_show_log_prefs(void)
|
||||
{
|
||||
@ -1141,6 +1155,7 @@ _cons_show_log_prefs(void)
|
||||
cons_log_setting();
|
||||
cons_chlog_setting();
|
||||
cons_grlog_setting();
|
||||
cons_otr_log_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
cons_alert();
|
||||
@ -1548,6 +1563,7 @@ console_init_module(void)
|
||||
cons_log_setting = _cons_log_setting;
|
||||
cons_chlog_setting = _cons_chlog_setting;
|
||||
cons_grlog_setting = _cons_grlog_setting;
|
||||
cons_otr_log_setting = _cons_otr_log_setting;
|
||||
cons_show_log_prefs = _cons_show_log_prefs;
|
||||
cons_autoaway_setting = _cons_autoaway_setting;
|
||||
cons_show_presence_prefs = _cons_show_presence_prefs;
|
||||
|
@ -222,6 +222,7 @@ void (*cons_history_setting)(void);
|
||||
void (*cons_log_setting)(void);
|
||||
void (*cons_chlog_setting)(void);
|
||||
void (*cons_grlog_setting)(void);
|
||||
void (*cons_otr_log_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