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 {
|
public class PgpDecryptionService {
|
||||||
|
|
||||||
private final XmppConnectionService mXmppConnectionService;
|
|
||||||
private OpenPgpApi openPgpApi = null;
|
|
||||||
|
|
||||||
protected final ArrayDeque<Message> messages = new ArrayDeque();
|
protected final ArrayDeque<Message> messages = new ArrayDeque();
|
||||||
protected final HashSet<Message> pendingNotifications = new HashSet<>();
|
protected final HashSet<Message> pendingNotifications = new HashSet<>();
|
||||||
Message currentMessage;
|
private final XmppConnectionService mXmppConnectionService;
|
||||||
|
private OpenPgpApi openPgpApi = null;
|
||||||
|
private Message currentMessage;
|
||||||
private PendingIntent pendingIntent;
|
private PendingIntent pendingIntent;
|
||||||
|
private Intent userInteractionResult;
|
||||||
|
|
||||||
|
|
||||||
public PgpDecryptionService(XmppConnectionService service) {
|
public PgpDecryptionService(XmppConnectionService service) {
|
||||||
|
@ -111,6 +111,12 @@ public class PgpDecryptionService {
|
||||||
continueDecryption();
|
continueDecryption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void continueDecryption(Intent userInteractionResult) {
|
||||||
|
this.pendingIntent = null;
|
||||||
|
this.userInteractionResult = userInteractionResult;
|
||||||
|
continueDecryption();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void continueDecryption() {
|
public synchronized void continueDecryption() {
|
||||||
if (currentMessage == null) {
|
if (currentMessage == null) {
|
||||||
decryptNext();
|
decryptNext();
|
||||||
|
@ -126,7 +132,7 @@ public class PgpDecryptionService {
|
||||||
|
|
||||||
private void executeApi(Message message) {
|
private void executeApi(Message message) {
|
||||||
synchronized (message) {
|
synchronized (message) {
|
||||||
Intent params = new Intent();
|
Intent params = userInteractionResult != null ? userInteractionResult : new Intent();
|
||||||
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
||||||
if (message.getType() == Message.TYPE_TEXT) {
|
if (message.getType() == Message.TYPE_TEXT) {
|
||||||
InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
|
InputStream is = new ByteArrayInputStream(message.getBody().getBytes());
|
||||||
|
|
|
@ -1746,7 +1746,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
final Intent data) {
|
final Intent data) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
|
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) {
|
} else if (requestCode == ConversationActivity.REQUEST_TRUST_KEYS_TEXT) {
|
||||||
final String body = mEditMessage.getText().toString();
|
final String body = mEditMessage.getText().toString();
|
||||||
Message message = new Message(conversation, body, conversation.getNextEncryption());
|
Message message = new Message(conversation, body, conversation.getNextEncryption());
|
||||||
|
|
Loading…
Reference in a new issue