Skip to content

Commit

Permalink
allow gpg to be disabled (mitigation to astroidmail#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed May 23, 2018
1 parent cb5033e commit 714b785
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/config.cc
Expand Up @@ -268,6 +268,7 @@ namespace Astroid {
/* crypto */
default_config.put ("crypto.gpg.path", "gpg2");
default_config.put ("crypto.gpg.always_trust", true);
default_config.put ("crypto.gpg.enabled", true);

/* saved searches */
default_config.put ("saved_searches.show_on_startup", false);
Expand Down
6 changes: 6 additions & 0 deletions src/crypto.cc
Expand Up @@ -17,6 +17,7 @@ namespace Astroid {
config = astroid->config ("crypto");
gpgpath = ustring (config.get<std::string> ("gpg.path"));
always_trust = config.get<bool> ("gpg.always_trust");
gpgenabled = config.get<bool> ("gpg.enabled");

LOG (debug) << "crypto: gpg: " << gpgpath;

Expand All @@ -26,6 +27,11 @@ namespace Astroid {
protocol == "application/pgp-signature")) {

isgpg = true;
if (! gpgenabled) {
ready = false;
return;
}

create_gpg_context ();

} else {
Expand Down
1 change: 1 addition & 0 deletions src/crypto.hh
Expand Up @@ -17,6 +17,7 @@ namespace Astroid {

bool ready = false;
bool isgpg = false;
bool gpgenabled = true;

GMimeObject * decrypt_and_verify (GMimeObject * mo);
GMimeMessage * decrypt_message (GMimeMessage * in);
Expand Down
14 changes: 8 additions & 6 deletions src/modes/edit_message.cc
Expand Up @@ -104,6 +104,8 @@ namespace Astroid {

tmpfile_path = astroid->standard_paths ().runtime_dir;

gpgenabled = astroid->config ("crypto").get<bool> ("gpg.enabled");

set_label ("New message");

path ui = Resource (false, "ui/edit-message.glade").get_path ();
Expand Down Expand Up @@ -491,7 +493,7 @@ namespace Astroid {
auto row = *iter;
Account * a = row[from_columns.account];

if (a->has_gpg) {
if (gpgenabled && a->has_gpg) {
if (!switch_encrypt->get_active () && !switch_sign->get_active ()) {
switch_encrypt->set_active (false);
switch_sign->set_active (true);
Expand Down Expand Up @@ -736,12 +738,12 @@ namespace Astroid {
switch_signature->set_sensitive (a->has_signature);
switch_signature->set_active (a->has_signature && a->signature_default_on);

encryption_revealer->set_reveal_child (a->has_gpg);
switch_sign->set_sensitive (a->has_gpg);
switch_encrypt->set_sensitive (a->has_gpg);
encryption_revealer->set_reveal_child (gpgenabled && a->has_gpg);
switch_sign->set_sensitive (gpgenabled && a->has_gpg);
switch_encrypt->set_sensitive (gpgenabled && a->has_gpg);

switch_encrypt->set_active (false);
switch_sign->set_active (a->has_gpg && a->always_gpg_sign);
switch_sign->set_active (gpgenabled && a->has_gpg && a->always_gpg_sign);
}

void EditMessage::switch_signature_set () {
Expand Down Expand Up @@ -1194,7 +1196,7 @@ namespace Astroid {
}
c->markdown = switch_markdown->get_active ();

if (c->account->has_gpg) {
if (gpgenabled && c->account->has_gpg) {
c->encrypt = switch_encrypt->get_active ();
c->sign = switch_sign->get_active ();
}
Expand Down
2 changes: 2 additions & 0 deletions src/modes/edit_message.hh
Expand Up @@ -50,6 +50,8 @@ namespace Astroid {
Gtk::Revealer *reply_revealer;
Gtk::Revealer *encryption_revealer;

bool gpgenabled;

# ifndef DISABLE_EMBEDDED
bool embed_editor = true;
# else
Expand Down

0 comments on commit 714b785

Please sign in to comment.