Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ cmd_ac_init(void)
autocomplete_add(ox_ac, "announce");
autocomplete_add(ox_ac, "discover");
autocomplete_add(ox_ac, "request");
autocomplete_add(ox_ac, "encryptfile");

autocomplete_add(ox_log_ac, "on");
autocomplete_add(ox_log_ac, "off");
Expand Down Expand Up @@ -2582,6 +2583,11 @@ _ox_autocomplete(ProfWin* window, const char* const input, gboolean previous)
return found;
}

found = autocomplete_param_with_func(input, "/ox encryptfile", prefs_autocomplete_boolean_choice, previous, NULL);
if (found) {
return found;
}

if (strncmp(input, "/ox announce ", 13) == 0) {
return cmd_ac_complete_filepath(input, "/ox announce", previous);
}
Expand Down
2 changes: 2 additions & 0 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ static const struct cmd_t command_defs[] = {
"/ox start [<contact>]",
"/ox end",
"/ox log on|off|redact",
"/ox encryptfile on|off",
"/ox char <char>",
"/ox announce <file>",
"/ox discover <jid>",
Expand All @@ -1760,6 +1761,7 @@ static const struct cmd_t command_defs[] = {
{ "end", "End PGP encrypted chat with the current recipient." },
{ "log on|off", "Enable or disable plaintext logging of PGP encrypted messages." },
{ "log redact", "Log PGP encrypted messages, but replace the contents with [redacted]." },
{ "encryptfile on|off", "Encrypt files locally using AES-GCM (XEP-0454) before uploading them when using OX." },
{ "char <char>", "Set the character to be displayed next to PGP encrypted messages." },
{ "announce <file>", "Announce a public key by pushing it on the XMPP Server" },
{ "discover <jid>", "Discover public keys of a jid. The OpenPGP Key IDs will be displayed" },
Expand Down
24 changes: 23 additions & 1 deletion src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4897,6 +4897,8 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
}

gboolean omemo_enabled = FALSE;
gboolean ox_enabled = FALSE;
gboolean ox_encryptfile = FALSE;
gboolean sendfile_enabled = TRUE;

switch (window->type) {
Expand All @@ -4912,6 +4914,8 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
ProfChatWin* chatwin = (ProfChatWin*)window;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
omemo_enabled = chatwin->is_omemo == TRUE;
ox_enabled = chatwin->is_ox == TRUE;
ox_encryptfile = prefs_get_boolean(PREF_OX_ENCRYPTFILE) == TRUE;
sendfile_enabled = !((chatwin->pgp_send == TRUE && !prefs_get_boolean(PREF_PGP_SENDFILE))
|| (chatwin->is_otr == TRUE && !prefs_get_boolean(PREF_OTR_SENDFILE)));
break;
Expand All @@ -4936,7 +4940,7 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
goto out;
}

if (omemo_enabled) {
if (omemo_enabled || (ox_enabled && ox_encryptfile)) {
#ifdef HAVE_OMEMO
char* err = NULL;
alt_scheme = OMEMO_AESGCM_URL_SCHEME;
Expand All @@ -4949,6 +4953,15 @@ cmd_sendfile(ProfWin* window, const char* const command, gchar** args)
}
goto out;
}
#else
if (ox_enabled && ox_encryptfile) {
cons_show_error("OX encrypted file sharing requires OMEMO to be enabled at compile time (for AES-GCM file encryption helper).");
win_println(window, THEME_ERROR, "-", "To send raw files with only the link encrypted, run '/ox encryptfile off'.");
if (fh) {
fclose(fh);
}
goto out;
}
#endif
}

Expand Down Expand Up @@ -7568,6 +7581,15 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}

else if (g_strcmp0(args[0], "encryptfile") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
return TRUE;
}
_cmd_set_boolean_preference(args[1], "Encrypting files locally using AES-GCM before sending via OX", PREF_OX_ENCRYPTFILE);
return TRUE;
}

// The '/ox keys' command - same like in pgp
// Should we move this to a common command
// e.g. '/openpgp keys'?.
Expand Down
9 changes: 9 additions & 0 deletions src/config/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,7 @@ _get_group(preference_t pref)
case PREF_OMEMO_TRUST_MODE:
return PREF_GROUP_OMEMO;
case PREF_OX_LOG:
case PREF_OX_ENCRYPTFILE:
return PREF_GROUP_OX;
case PREF_SPELLCHECK_ENABLE:
case PREF_SPELLCHECK_LANG:
Expand Down Expand Up @@ -2222,6 +2223,8 @@ _get_key(preference_t pref)
return "stamp.incoming";
case PREF_OX_LOG:
return "log";
case PREF_OX_ENCRYPTFILE:
return "encryptfile";
case PREF_MOOD:
return "mood";
case PREF_VCARD_PHOTO_CMD:
Expand Down Expand Up @@ -2293,6 +2296,12 @@ _get_default_boolean(preference_t pref)
case PREF_PGP_PUBKEY_AUTOIMPORT:
default:
return FALSE;
case PREF_OX_ENCRYPTFILE:
#ifdef HAVE_OMEMO
return TRUE;
#else
return FALSE;
#endif
}
}

Expand Down
1 change: 1 addition & 0 deletions src/config/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ typedef enum {
PREF_INCOMING_STAMP,
PREF_NOTIFY_ROOM_OFFLINE,
PREF_OX_LOG,
PREF_OX_ENCRYPTFILE,
PREF_MOOD,
PREF_STROPHE_VERBOSITY,
PREF_STROPHE_SM_ENABLED,
Expand Down
6 changes: 6 additions & 0 deletions src/ui/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,12 @@ cons_show_ox_prefs(void)
auto_gchar gchar* ch = prefs_get_ox_char();
cons_show("OX char (/ox char) : %s", ch);

if (prefs_get_boolean(PREF_OX_ENCRYPTFILE)) {
cons_show("OX encrypt file (/ox encryptfile): ON");
} else {
cons_show("OX encrypt file (/ox encryptfile): OFF");
}

cons_alert(NULL);
}

Expand Down
Loading