possible fix for retry loop on pgp key annoucement

This commit is contained in:
Daniel Gultsch 2017-12-05 19:16:53 +01:00
parent 0e6d3db926
commit 97821f0633
6 changed files with 13 additions and 14 deletions

View File

@ -209,12 +209,11 @@ public class PgpEngine {
});
}
public void generateSignature(final Account account, String status,
final UiCallback<Account> callback) {
public void generateSignature(Intent intent, final Account account, String status, final UiCallback<Account> callback) {
if (account.getPgpId() == 0) {
return;
}
Intent params = new Intent();
Intent params = intent == null ? new Intent() : intent;
params.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, account.getPgpId());

View File

@ -913,7 +913,7 @@ public class ConversationActivity extends XmppActivity
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
item.setChecked(true);
} else {
announcePgp(conversation.getAccount(), conversation, onOpenPGPKeyPublished);
announcePgp(conversation.getAccount(), conversation,null, onOpenPGPKeyPublished);
}
} else {
showInstallPgpDialog();
@ -1420,7 +1420,7 @@ public class ConversationActivity extends XmppActivity
// associate selected PGP keyId with the account
mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
// we need to announce the key as described in XEP-027
announcePgp(mSelectedConversation.getAccount(), null, onOpenPGPKeyPublished);
announcePgp(mSelectedConversation.getAccount(), null, null, onOpenPGPKeyPublished);
} else {
choosePgpSignId(mSelectedConversation.getAccount());
}
@ -1430,7 +1430,7 @@ public class ConversationActivity extends XmppActivity
}
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
if (xmppConnectionServiceBound) {
announcePgp(mSelectedConversation.getAccount(), mSelectedConversation, onOpenPGPKeyPublished);
announcePgp(mSelectedConversation.getAccount(), mSelectedConversation,data, onOpenPGPKeyPublished);
this.mPostponedActivityResult = null;
} else {
this.mPostponedActivityResult = new Pair<>(requestCode, data);

View File

@ -1510,7 +1510,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
return;
}
if (conversation.getAccount().getPgpSignature() == null) {
activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished);
activity.announcePgp(conversation.getAccount(), conversation, null, activity.onOpenPGPKeyPublished);
return;
}
if (!mSendingPgpMessage.compareAndSet(false, true)) {

View File

@ -346,7 +346,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
private void publishOpenPGPPublicKey(Account account) {
if (ManageAccountActivity.this.hasPgp()) {
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
announcePgp(selectedAccount, null,null, onOpenPGPKeyPublished);
} else {
this.showInstallPgpDialog();
}
@ -378,12 +378,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
if (requestCode == REQUEST_CHOOSE_PGP_ID) {
if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
selectedAccount.setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
announcePgp(selectedAccount, null, null, onOpenPGPKeyPublished);
} else {
choosePgpSignId(selectedAccount);
}
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
announcePgp(selectedAccount, null, data, onOpenPGPKeyPublished);
}
this.mPostponedActivityResult = null;
} else {

View File

@ -94,7 +94,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
if (resultCode == RESULT_OK) {
if (xmppConnectionServiceBound && mAccount != null) {
if (requestCode == REQUEST_ANNOUNCE_PGP) {
announcePgp(mAccount, null, onPresenceChanged);
announcePgp(mAccount, null,data, onPresenceChanged);
}
this.mPostponedActivityResult = null;
} else {
@ -116,7 +116,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
finish();
} else {
xmppConnectionService.changeStatus(mAccount, status, statusMessage, false);
announcePgp(mAccount, null, onPresenceChanged);
announcePgp(mAccount, null,null, onPresenceChanged);
}
}
}

View File

@ -543,7 +543,7 @@ public abstract class XmppActivity extends Activity {
startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
}
protected void announcePgp(Account account, final Conversation conversation, final Runnable onSuccess) {
protected void announcePgp(Account account, final Conversation conversation, Intent intent, final Runnable onSuccess) {
if (account.getPgpId() == 0) {
choosePgpSignId(account);
} else {
@ -554,7 +554,7 @@ public abstract class XmppActivity extends Activity {
if (status == null) {
status = "";
}
xmppConnectionService.getPgpEngine().generateSignature(account, status, new UiCallback<Account>() {
xmppConnectionService.getPgpEngine().generateSignature(intent, account, status, new UiCallback<Account>() {
@Override
public void userInputRequried(PendingIntent pi, Account account) {