possible fix for retry loop on pgp key annoucement
This commit is contained in:
parent
0e6d3db926
commit
97821f0633
|
@ -209,12 +209,11 @@ public class PgpEngine {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateSignature(final Account account, String status,
|
public void generateSignature(Intent intent, final Account account, String status, final UiCallback<Account> callback) {
|
||||||
final UiCallback<Account> callback) {
|
|
||||||
if (account.getPgpId() == 0) {
|
if (account.getPgpId() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Intent params = new Intent();
|
Intent params = intent == null ? new Intent() : intent;
|
||||||
params.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
|
params.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
|
||||||
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||||
params.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, account.getPgpId());
|
params.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, account.getPgpId());
|
||||||
|
|
|
@ -913,7 +913,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
|
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
announcePgp(conversation.getAccount(), conversation, onOpenPGPKeyPublished);
|
announcePgp(conversation.getAccount(), conversation,null, onOpenPGPKeyPublished);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showInstallPgpDialog();
|
showInstallPgpDialog();
|
||||||
|
@ -1420,7 +1420,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
// associate selected PGP keyId with the account
|
// associate selected PGP keyId with the account
|
||||||
mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
|
mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
|
||||||
// we need to announce the key as described in XEP-027
|
// we need to announce the key as described in XEP-027
|
||||||
announcePgp(mSelectedConversation.getAccount(), null, onOpenPGPKeyPublished);
|
announcePgp(mSelectedConversation.getAccount(), null, null, onOpenPGPKeyPublished);
|
||||||
} else {
|
} else {
|
||||||
choosePgpSignId(mSelectedConversation.getAccount());
|
choosePgpSignId(mSelectedConversation.getAccount());
|
||||||
}
|
}
|
||||||
|
@ -1430,7 +1430,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
announcePgp(mSelectedConversation.getAccount(), mSelectedConversation, onOpenPGPKeyPublished);
|
announcePgp(mSelectedConversation.getAccount(), mSelectedConversation,data, onOpenPGPKeyPublished);
|
||||||
this.mPostponedActivityResult = null;
|
this.mPostponedActivityResult = null;
|
||||||
} else {
|
} else {
|
||||||
this.mPostponedActivityResult = new Pair<>(requestCode, data);
|
this.mPostponedActivityResult = new Pair<>(requestCode, data);
|
||||||
|
|
|
@ -1510,7 +1510,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (conversation.getAccount().getPgpSignature() == null) {
|
if (conversation.getAccount().getPgpSignature() == null) {
|
||||||
activity.announcePgp(conversation.getAccount(), conversation, activity.onOpenPGPKeyPublished);
|
activity.announcePgp(conversation.getAccount(), conversation, null, activity.onOpenPGPKeyPublished);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mSendingPgpMessage.compareAndSet(false, true)) {
|
if (!mSendingPgpMessage.compareAndSet(false, true)) {
|
||||||
|
|
|
@ -346,7 +346,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
||||||
|
|
||||||
private void publishOpenPGPPublicKey(Account account) {
|
private void publishOpenPGPPublicKey(Account account) {
|
||||||
if (ManageAccountActivity.this.hasPgp()) {
|
if (ManageAccountActivity.this.hasPgp()) {
|
||||||
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
|
announcePgp(selectedAccount, null,null, onOpenPGPKeyPublished);
|
||||||
} else {
|
} else {
|
||||||
this.showInstallPgpDialog();
|
this.showInstallPgpDialog();
|
||||||
}
|
}
|
||||||
|
@ -378,12 +378,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
||||||
if (requestCode == REQUEST_CHOOSE_PGP_ID) {
|
if (requestCode == REQUEST_CHOOSE_PGP_ID) {
|
||||||
if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
||||||
selectedAccount.setPgpSignId(data.getExtras().getLong(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 {
|
} else {
|
||||||
choosePgpSignId(selectedAccount);
|
choosePgpSignId(selectedAccount);
|
||||||
}
|
}
|
||||||
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
||||||
announcePgp(selectedAccount, null, onOpenPGPKeyPublished);
|
announcePgp(selectedAccount, null, data, onOpenPGPKeyPublished);
|
||||||
}
|
}
|
||||||
this.mPostponedActivityResult = null;
|
this.mPostponedActivityResult = null;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (xmppConnectionServiceBound && mAccount != null) {
|
if (xmppConnectionServiceBound && mAccount != null) {
|
||||||
if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
if (requestCode == REQUEST_ANNOUNCE_PGP) {
|
||||||
announcePgp(mAccount, null, onPresenceChanged);
|
announcePgp(mAccount, null,data, onPresenceChanged);
|
||||||
}
|
}
|
||||||
this.mPostponedActivityResult = null;
|
this.mPostponedActivityResult = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,7 +116,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
xmppConnectionService.changeStatus(mAccount, status, statusMessage, false);
|
xmppConnectionService.changeStatus(mAccount, status, statusMessage, false);
|
||||||
announcePgp(mAccount, null, onPresenceChanged);
|
announcePgp(mAccount, null,null, onPresenceChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,7 +543,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
|
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) {
|
if (account.getPgpId() == 0) {
|
||||||
choosePgpSignId(account);
|
choosePgpSignId(account);
|
||||||
} else {
|
} else {
|
||||||
|
@ -554,7 +554,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
status = "";
|
status = "";
|
||||||
}
|
}
|
||||||
xmppConnectionService.getPgpEngine().generateSignature(account, status, new UiCallback<Account>() {
|
xmppConnectionService.getPgpEngine().generateSignature(intent, account, status, new UiCallback<Account>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi, Account account) {
|
public void userInputRequried(PendingIntent pi, Account account) {
|
||||||
|
|
Loading…
Reference in New Issue