PgpService: feed result intent back into decryption
This commit is contained in:
parent
4596cad3cb
commit
8696cf2235
|
@ -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) {
|
||||
|
@ -51,7 +51,7 @@ public class PgpDecryptionService {
|
|||
}
|
||||
|
||||
public synchronized void decrypt(final List<Message> list) {
|
||||
for(Message message : list) {
|
||||
for (Message message : list) {
|
||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ public class PgpDecryptionService {
|
|||
this.pendingNotifications.remove(message);
|
||||
}
|
||||
|
||||
public void giveUpCurrentDecryption(){
|
||||
public void giveUpCurrentDecryption() {
|
||||
Message message;
|
||||
synchronized (this) {
|
||||
if(currentMessage != null) {
|
||||
if (currentMessage != null) {
|
||||
return;
|
||||
}
|
||||
message = messages.peekFirst();
|
||||
|
@ -81,7 +81,7 @@ public class PgpDecryptionService {
|
|||
}
|
||||
discard(message);
|
||||
}
|
||||
synchronized (message){
|
||||
synchronized (message) {
|
||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -221,7 +227,7 @@ public class PgpDecryptionService {
|
|||
if (pendingIntent == null) {
|
||||
return false;
|
||||
} else {
|
||||
for(Message message : messages) {
|
||||
for (Message message : messages) {
|
||||
if (message.getConversation() == conversation) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue