trigger registration dialog on roster;ibr=y only if no accounts are configured
fixes #4065
This commit is contained in:
parent
53908dd56e
commit
c5e90199c3
|
@ -25,12 +25,19 @@ public class PresenceGenerator extends AbstractGenerator {
|
|||
return packet;
|
||||
}
|
||||
|
||||
public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
|
||||
public PresencePacket requestPresenceUpdatesFrom(final Contact contact) {
|
||||
return requestPresenceUpdatesFrom(contact, null);
|
||||
}
|
||||
|
||||
public PresencePacket requestPresenceUpdatesFrom(final Contact contact, final String preAuth) {
|
||||
PresencePacket packet = subscription("subscribe", contact);
|
||||
String displayName = contact.getAccount().getDisplayName();
|
||||
if (!TextUtils.isEmpty(displayName)) {
|
||||
packet.addChild("nick", Namespace.NICK).setContent(displayName);
|
||||
}
|
||||
if (preAuth != null) {
|
||||
packet.addChild("preauth", Namespace.PARS).setAttribute("token", preAuth);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
|
|
@ -3448,15 +3448,23 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
public void createContact(Contact contact, boolean autoGrant) {
|
||||
public void createContact(final Contact contact, final boolean autoGrant) {
|
||||
createContact(contact, autoGrant, null);
|
||||
}
|
||||
|
||||
public void createContact(final Contact contact, final boolean autoGrant, final String preAuth) {
|
||||
if (autoGrant) {
|
||||
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
|
||||
contact.setOption(Contact.Options.ASKING);
|
||||
}
|
||||
pushContactToServer(contact);
|
||||
pushContactToServer(contact, preAuth);
|
||||
}
|
||||
|
||||
public void pushContactToServer(final Contact contact) {
|
||||
pushContactToServer(contact, null);
|
||||
}
|
||||
|
||||
private void pushContactToServer(final Contact contact, final String preAuth) {
|
||||
contact.resetOption(Contact.Options.DIRTY_DELETE);
|
||||
contact.setOption(Contact.Options.DIRTY_PUSH);
|
||||
final Account account = contact.getAccount();
|
||||
|
@ -3472,7 +3480,7 @@ public class XmppConnectionService extends Service {
|
|||
sendPresencePacket(account, mPresenceGenerator.sendPresenceUpdatesTo(contact));
|
||||
}
|
||||
if (ask) {
|
||||
sendPresencePacket(account, mPresenceGenerator.requestPresenceUpdatesFrom(contact));
|
||||
sendPresencePacket(account, mPresenceGenerator.requestPresenceUpdatesFrom(contact, preAuth));
|
||||
}
|
||||
} else {
|
||||
syncRoster(contact.getAccount());
|
||||
|
|
|
@ -526,7 +526,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
} else if (contact.showInRoster()) {
|
||||
throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists));
|
||||
} else {
|
||||
xmppConnectionService.createContact(contact, true);
|
||||
final String preAuth = invite == null ? null : invite.getParameter(XmppUri.PARAMETER_PRE_AUTH);
|
||||
xmppConnectionService.createContact(contact, true, preAuth);
|
||||
if (invite != null && invite.hasFingerprints()) {
|
||||
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ public class UriHandlerActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
public void onNewIntent(final Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleIntent(intent);
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class UriHandlerActivity extends AppCompatActivity {
|
|||
startActivity(intent);
|
||||
return;
|
||||
}
|
||||
if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter(XmppUri.PARAMETER_IBR))) {
|
||||
if (accounts.size() == 0 && xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter(XmppUri.PARAMETER_IBR))) {
|
||||
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preAuth);
|
||||
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
|
||||
startActivity(intent);
|
||||
|
|
Loading…
Reference in New Issue