Make /sendfile in OMEMO session configurable

`/omemo sendfile on` allows unencrypted file transfer in an OMEMO
session.

Regards https://github.com/profanity-im/profanity/pull/1270
This commit is contained in:
Michael Vetter
2020-02-17 08:31:46 +01:00
parent 674a8aaf7e
commit 36713a2ed7
7 changed files with 54 additions and 10 deletions

View File

@@ -4802,8 +4802,10 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args)
{
ProfMucWin *mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
if (mucwin->is_omemo) { //no pgp or otr available in MUCs
cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename);
// only omemo, no pgp/otr available in MUCs
if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_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);
return TRUE;
@@ -4814,12 +4816,15 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args)
{
ProfChatWin *chatwin = (ProfChatWin*)window;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
if (chatwin->pgp_send || chatwin->is_omemo || chatwin->is_otr) {
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);
return TRUE;
}
if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE))
|| (chatwin->pgp_send)
|| (chatwin->is_otr)) {
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);
return TRUE;
}
break;
}
case WIN_PRIVATE:
@@ -8575,6 +8580,19 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args)
#endif
}
gboolean
cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args)
{
#ifdef HAVE_OMEMO
_cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OMEMO session via /sendfile", PREF_OMEMO_SENDFILE);
return TRUE;
#else
cons_show("This version of Profanity has not been built with OMEMO support enabled");
return TRUE;
#endif
}
gboolean
cmd_save(ProfWin *window, const char *const command, gchar **args)
{