PgpService: feed result intent back into decryption

This commit is contained in:
Daniel Gultsch 2017-11-22 13:36:00 +01:00
parent 4596cad3cb
commit 8696cf2235
2 changed files with 203 additions and 197 deletions

View file

@ -25,13 +25,13 @@ import eu.siacs.conversations.services.XmppConnectionService;
public class PgpDecryptionService {
private final XmppConnectionService mXmppConnectionService;
private OpenPgpApi openPgpApi = null;
protected final ArrayDeque<Message> messages = new ArrayDeque();
protected final HashSet<Message> pendingNotifications = new HashSet<>();
Message currentMessage;
private final XmppConnectionService mXmppConnectionService;
private OpenPgpApi openPgpApi = null;
private Message currentMessage;
private PendingIntent pendingIntent;
private Intent userInteractionResult;
public PgpDecryptionService(XmppConnectionService service) {
@ -111,6 +111,12 @@ public class PgpDecryptionService {
continueDecryption();
}
public synchronized void continueDecryption(Intent userInteractionResult) {
this.pendingIntent = null;
this.userInteractionResult = userInteractionResult;
continueDecryption();
}
public synchronized void continueDecryption() {
if (currentMessage == null) {
decryptNext();
@ -126,7 +132,7 @@ public class PgpDecryptionService {
private void executeApi(Message message) {
synchronized (message) {
Intent params = new Intent();
Intent params = userInteractionResult != null ? userInteractionResult : new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
if (message.getType() == Message.TYPE_TEXT) {
InputStream is = new ByteArrayInputStream(message.getBody().getBytes());

View file

@ -1746,7 +1746,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
final Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
activity.getSelectedConversation().getAccount().getPgpDecryptionService().continueDecryption(true);
activity.getSelectedConversation().getAccount().getPgpDecryptionService().continueDecryption(data);
} else if (requestCode == ConversationActivity.REQUEST_TRUST_KEYS_TEXT) {
final String body = mEditMessage.getText().toString();
Message message = new Message(conversation, body, conversation.getNextEncryption());