mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Make /sendfile in OTR session configurable
`/otr sendfile on` allows unencrypted file transfer in an OMEMO session. Regards https://github.com/profanity-im/profanity/pull/1270
This commit is contained in:
parent
36713a2ed7
commit
86bcadcbe3
@ -173,6 +173,7 @@ static Autocomplete bookmark_property_ac;
|
||||
static Autocomplete otr_ac;
|
||||
static Autocomplete otr_log_ac;
|
||||
static Autocomplete otr_policy_ac;
|
||||
static Autocomplete otr_sendfile_ac;
|
||||
static Autocomplete omemo_ac;
|
||||
static Autocomplete omemo_log_ac;
|
||||
static Autocomplete omemo_policy_ac;
|
||||
@ -605,6 +606,7 @@ cmd_ac_init(void)
|
||||
autocomplete_add(otr_ac, "question");
|
||||
autocomplete_add(otr_ac, "answer");
|
||||
autocomplete_add(otr_ac, "char");
|
||||
autocomplete_add(otr_ac, "sendfile");
|
||||
|
||||
otr_log_ac = autocomplete_new();
|
||||
autocomplete_add(otr_log_ac, "on");
|
||||
@ -616,6 +618,10 @@ cmd_ac_init(void)
|
||||
autocomplete_add(otr_policy_ac, "opportunistic");
|
||||
autocomplete_add(otr_policy_ac, "always");
|
||||
|
||||
otr_sendfile_ac = autocomplete_new();
|
||||
autocomplete_add(otr_sendfile_ac, "on");
|
||||
autocomplete_add(otr_sendfile_ac, "off");
|
||||
|
||||
omemo_ac = autocomplete_new();
|
||||
autocomplete_add(omemo_ac, "gen");
|
||||
autocomplete_add(omemo_ac, "log");
|
||||
@ -1190,6 +1196,7 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(otr_ac);
|
||||
autocomplete_reset(otr_log_ac);
|
||||
autocomplete_reset(otr_policy_ac);
|
||||
autocomplete_reset(otr_sendfile_ac);
|
||||
autocomplete_reset(omemo_ac);
|
||||
autocomplete_reset(omemo_log_ac);
|
||||
autocomplete_reset(omemo_policy_ac);
|
||||
@ -1335,6 +1342,7 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(otr_ac);
|
||||
autocomplete_free(otr_log_ac);
|
||||
autocomplete_free(otr_policy_ac);
|
||||
autocomplete_free(otr_sendfile_ac);
|
||||
autocomplete_free(omemo_ac);
|
||||
autocomplete_free(omemo_log_ac);
|
||||
autocomplete_free(omemo_policy_ac);
|
||||
@ -2234,6 +2242,11 @@ _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/otr sendfile", otr_sendfile_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/otr", otr_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
|
@ -1695,7 +1695,8 @@ static struct cmd_t command_defs[] =
|
||||
{ "untrust", cmd_otr_untrust },
|
||||
{ "secret", cmd_otr_secret },
|
||||
{ "question", cmd_otr_question },
|
||||
{ "answer", cmd_otr_answer })
|
||||
{ "answer", cmd_otr_answer },
|
||||
{ "sendfile", cmd_otr_sendfile })
|
||||
CMD_NOMAINFUNC
|
||||
CMD_TAGS(
|
||||
CMD_TAG_CHAT,
|
||||
@ -1712,7 +1713,8 @@ static struct cmd_t command_defs[] =
|
||||
"/otr answer <answer>",
|
||||
"/otr policy manual|opportunistic|always [<contact>]",
|
||||
"/otr log on|off|redact",
|
||||
"/otr char <char>")
|
||||
"/otr char <char>",
|
||||
"/otr sendfile on|off")
|
||||
CMD_DESC(
|
||||
"Off The Record (OTR) commands to manage keys, and perform OTR encryption during chat sessions.")
|
||||
CMD_ARGS(
|
||||
@ -1734,7 +1736,8 @@ static struct cmd_t command_defs[] =
|
||||
{ "policy always <contact>", "Set the OTR policy to always for a specific contact." },
|
||||
{ "log on|off", "Enable or disable plaintext logging of OTR encrypted messages." },
|
||||
{ "log redact", "Log OTR encrypted messages, but replace the contents with [redacted]. This is the default." },
|
||||
{ "char <char>", "Set the character to be displayed next to OTR encrypted messages." })
|
||||
{ "char <char>", "Set the character to be displayed next to OTR encrypted messages." },
|
||||
{ "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OTR session."})
|
||||
CMD_EXAMPLES(
|
||||
"/otr log off",
|
||||
"/otr policy manual",
|
||||
@ -2266,7 +2269,7 @@ static struct cmd_t command_defs[] =
|
||||
{ "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." },
|
||||
{ "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." },
|
||||
{ "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." },
|
||||
{ "sendfile", "Allow /sendfile to send unencrypted files while in an OMEMO session."},
|
||||
{ "sendfile on|off", "Allow /sendfile to send unencrypted files while in an OMEMO session."},
|
||||
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."})
|
||||
CMD_EXAMPLES(
|
||||
"/omemo gen",
|
||||
|
@ -4819,7 +4819,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args)
|
||||
|
||||
if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE))
|
||||
|| (chatwin->pgp_send)
|
||||
|| (chatwin->is_otr)) {
|
||||
|| (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) {
|
||||
cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename);
|
||||
win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet.");
|
||||
free(filename);
|
||||
@ -4829,7 +4829,8 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
case WIN_PRIVATE:
|
||||
{
|
||||
break; //we don't support encryption in private muc windows anyway
|
||||
//we don't support encryption in private muc windows
|
||||
break;
|
||||
}
|
||||
default:
|
||||
cons_show_error("Unsupported window for file transmission.");
|
||||
@ -7809,6 +7810,19 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args)
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
_cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE);
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
cons_show("This version of Profanity has not been built with OTR support enabled");
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_command_list(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
@ -201,6 +201,7 @@ gboolean cmd_otr_untrust(ProfWin *window, const char *const command, gchar **arg
|
||||
gboolean cmd_otr_secret(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_question(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args);
|
||||
|
@ -1790,6 +1790,7 @@ _get_group(preference_t pref)
|
||||
return PREF_GROUP_CONNECTION;
|
||||
case PREF_OTR_LOG:
|
||||
case PREF_OTR_POLICY:
|
||||
case PREF_OTR_SENDFILE:
|
||||
return PREF_GROUP_OTR;
|
||||
case PREF_PGP_LOG:
|
||||
return PREF_GROUP_PGP;
|
||||
@ -1916,6 +1917,8 @@ _get_key(preference_t pref)
|
||||
return "log";
|
||||
case PREF_OTR_POLICY:
|
||||
return "policy";
|
||||
case PREF_OTR_SENDFILE:
|
||||
return "sendfile";
|
||||
case PREF_LOG_ROTATE:
|
||||
return "rotate";
|
||||
case PREF_LOG_SHARED:
|
||||
|
@ -135,6 +135,7 @@ typedef enum {
|
||||
PREF_LOG_SHARED,
|
||||
PREF_OTR_LOG,
|
||||
PREF_OTR_POLICY,
|
||||
PREF_OTR_SENDFILE,
|
||||
PREF_RESOURCE_TITLE,
|
||||
PREF_RESOURCE_MESSAGE,
|
||||
PREF_INPBLOCK_DYNAMIC,
|
||||
|
@ -2070,6 +2070,12 @@ cons_show_otr_prefs(void)
|
||||
char ch = prefs_get_otr_char();
|
||||
cons_show("OTR char (/otr char) : %c", ch);
|
||||
|
||||
if (prefs_get_boolean(PREF_OTR_SENDFILE)) {
|
||||
cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): ON");
|
||||
} else {
|
||||
cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): OFF");
|
||||
}
|
||||
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user