Check if encryption key on reply

pull/194/merge
M66B 3 years ago
parent 86e81ee738
commit a5c26a1a2a

@ -161,6 +161,7 @@ import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode; import org.jsoup.nodes.TextNode;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import org.jsoup.select.NodeFilter; import org.jsoup.select.NodeFilter;
import org.openintents.openpgp.IOpenPgpService2;
import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection; import org.openintents.openpgp.util.OpenPgpServiceConnection;
@ -1205,11 +1206,6 @@ public class FragmentCompose extends FragmentBase {
tvNoInternetAttachments.setVisibility(View.GONE); tvNoInternetAttachments.setVisibility(View.GONE);
final String pkg = Helper.getOpenKeychainPackage(getContext());
Log.i("PGP binding to " + pkg);
pgpService = new OpenPgpServiceConnection(getContext(), pkg);
pgpService.bindToService();
return view; return view;
} }
@ -1374,6 +1370,10 @@ public class FragmentCompose extends FragmentBase {
state = State.NONE; state = State.NONE;
Runnable load = new Runnable() {
@Override
public void run() {
try {
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (working < 0) { if (working < 0) {
Bundle a = getArguments(); Bundle a = getArguments();
@ -1410,12 +1410,12 @@ public class FragmentCompose extends FragmentBase {
setArguments(a); setArguments(a);
} }
draftLoader.execute(this, args, "compose:new"); draftLoader.execute(FragmentCompose.this, args, "compose:new");
} else { } else {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("action", "edit"); args.putString("action", "edit");
args.putLong("id", working); args.putLong("id", working);
draftLoader.execute(this, args, "compose:edit"); draftLoader.execute(FragmentCompose.this, args, "compose:edit");
} }
} else { } else {
working = savedInstanceState.getLong("fair:working"); working = savedInstanceState.getLong("fair:working");
@ -1428,8 +1428,28 @@ public class FragmentCompose extends FragmentBase {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("action", working < 0 ? "new" : "edit"); args.putString("action", working < 0 ? "new" : "edit");
args.putLong("id", working); args.putLong("id", working);
draftLoader.execute(this, args, "compose:instance"); draftLoader.execute(FragmentCompose.this, args, "compose:instance");
}
} catch (Throwable ex) {
Log.e(ex);
}
}
};
final String pkg = Helper.getOpenKeychainPackage(getContext());
Log.i("PGP binding to " + pkg);
pgpService = new OpenPgpServiceConnection(getContext(), pkg, new OpenPgpServiceConnection.OnBound() {
@Override
public void onBound(IOpenPgpService2 service) {
load.run();
}
@Override
public void onError(Exception e) {
load.run();
} }
});
pgpService.bindToService();
} }
@Override @Override
@ -4623,13 +4643,25 @@ public class FragmentCompose extends FragmentBase {
data.draft.plain_only = true; data.draft.plain_only = true;
// Encryption // Encryption
List<Address> recipients = new ArrayList<>();
if (data.draft.to != null)
recipients.addAll(Arrays.asList(data.draft.to));
if (data.draft.cc != null)
recipients.addAll(Arrays.asList(data.draft.cc));
if (data.draft.bcc != null)
recipients.addAll(Arrays.asList(data.draft.bcc));
if (EntityMessage.PGP_SIGNONLY.equals(ref.ui_encrypt) || if (EntityMessage.PGP_SIGNONLY.equals(ref.ui_encrypt) ||
EntityMessage.PGP_SIGNENCRYPT.equals(ref.ui_encrypt)) { EntityMessage.PGP_SIGNENCRYPT.equals(ref.ui_encrypt)) {
if (Helper.isOpenKeychainInstalled(context) && selected.sign_key != null) if (Helper.isOpenKeychainInstalled(context) &&
selected.sign_key != null &&
hasPgpKey(context, recipients))
data.draft.ui_encrypt = ref.ui_encrypt; data.draft.ui_encrypt = ref.ui_encrypt;
} else if (EntityMessage.SMIME_SIGNONLY.equals(ref.ui_encrypt) || } else if (EntityMessage.SMIME_SIGNONLY.equals(ref.ui_encrypt) ||
EntityMessage.SMIME_SIGNENCRYPT.equals(ref.ui_encrypt)) { EntityMessage.SMIME_SIGNENCRYPT.equals(ref.ui_encrypt)) {
if (ActivityBilling.isPro(context) && selected.sign_key_alias != null) if (ActivityBilling.isPro(context) &&
selected.sign_key_alias != null &&
hasSmimeKey(context, recipients))
data.draft.ui_encrypt = ref.ui_encrypt; data.draft.ui_encrypt = ref.ui_encrypt;
} }

Loading…
Cancel
Save