|
|
@ -1249,18 +1249,26 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
private void onEncrypt(final EntityMessage draft) {
|
|
|
|
private void onEncrypt(final EntityMessage draft) {
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(draft.encrypt) ||
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(draft.encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.encrypt)) {
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.encrypt)) {
|
|
|
|
|
|
|
|
|
|
|
|
String sender = null;
|
|
|
|
|
|
|
|
if (draft.from != null && draft.from.length > 0)
|
|
|
|
|
|
|
|
sender = ((InternetAddress) draft.from[0]).getAddress();
|
|
|
|
|
|
|
|
Log.i("Alias sender=" + sender);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", draft.id);
|
|
|
|
args.putLong("id", draft.id);
|
|
|
|
args.putInt("type", draft.encrypt);
|
|
|
|
args.putInt("type", draft.encrypt);
|
|
|
|
args.putString("sender", sender);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Helper.selectKeyAlias(getActivity(), sender, new Helper.IKeyAlias() {
|
|
|
|
new SimpleTask<EntityIdentity>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected EntityIdentity onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
EntityMessage draft = db.message().getMessage(id);
|
|
|
|
|
|
|
|
if (draft == null || draft.identity == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return db.identity().getIdentity(draft.identity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onExecuted(final Bundle args, EntityIdentity identity) {
|
|
|
|
|
|
|
|
Helper.selectKeyAlias(getActivity(), identity.sign_key_alias, new Helper.IKeyAlias() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSelected(String alias) {
|
|
|
|
public void onSelected(String alias) {
|
|
|
|
args.putString("alias", alias);
|
|
|
|
args.putString("alias", alias);
|
|
|
@ -1281,6 +1289,13 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
snackbar.show();
|
|
|
|
snackbar.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(this, args, "compose:alias");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (pgpService.isBound())
|
|
|
|
if (pgpService.isBound())
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1923,8 +1938,10 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
bpContent.setContent(imessage.getContent(), imessage.getContentType());
|
|
|
|
bpContent.setContent(imessage.getContent(), imessage.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store selected alias
|
|
|
|
if (alias == null)
|
|
|
|
if (alias == null)
|
|
|
|
throw new IllegalArgumentException("Key alias missing");
|
|
|
|
throw new IllegalArgumentException("Key alias missing");
|
|
|
|
|
|
|
|
db.identity().setIdentitySignKeyAlias(identity.id, alias);
|
|
|
|
|
|
|
|
|
|
|
|
// Get private key
|
|
|
|
// Get private key
|
|
|
|
PrivateKey privkey = KeyChain.getPrivateKey(context, alias);
|
|
|
|
PrivateKey privkey = KeyChain.getPrivateKey(context, alias);
|
|
|
|