support ?roster;ibr=y xmpp uris

This commit is contained in:
Daniel Gultsch 2020-01-09 15:49:49 +01:00
parent d039c4870f
commit 6205574bcb
5 changed files with 24 additions and 17 deletions

View file

@ -20,10 +20,10 @@ public class SignupUtils {
return true; return true;
} }
public static Intent getTokenRegistrationIntent(final Activity activity, String domain, String preauth) { public static Intent getTokenRegistrationIntent(final Activity activity, String domain, String preAuth) {
final Intent intent = new Intent(activity, MagicCreateActivity.class); final Intent intent = new Intent(activity, MagicCreateActivity.class);
intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, domain); intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, domain);
intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preauth); intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth);
return intent; return intent;
} }

View file

@ -95,11 +95,11 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
}); });
this.cancelButton.setOnClickListener(v -> { this.cancelButton.setOnClickListener(v -> {
if (mInitialAccountSetup) { if (mInitialAccountSetup) {
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); final Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) { if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
StartConversationActivity.addInviteUri(intent, getIntent());
intent.putExtra("init", true); intent.putExtra("init", true);
} }
StartConversationActivity.addInviteUri(intent, getIntent());
startActivity(intent); startActivity(intent);
} }
finish(); finish();

View file

@ -857,7 +857,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
showJoinConferenceDialog(invite.getJid().asBareJid().toString()); showJoinConferenceDialog(invite.getJid().asBareJid().toString());
return false; return false;
} }
} else if (contacts.size() == 0) { } else if (contacts.size() == 0) { //TODO or init mode
//TODO if init mode; prefill dialog with account jid
showCreateContactDialog(invite.getJid().toString(), invite); showCreateContactDialog(invite.getJid().toString(), invite);
return false; return false;
} else if (contacts.size() == 1) { } else if (contacts.size() == 1) {
@ -1279,7 +1280,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public static void addInviteUri(Intent to, Intent from) { public static void addInviteUri(Intent to, Intent from) {
if (from != null && from.hasExtra(EXTRA_INVITE_URI)) { if (from != null && from.hasExtra(EXTRA_INVITE_URI)) {
to.putExtra(EXTRA_INVITE_URI, from.getStringExtra(EXTRA_INVITE_URI)); final String invite = from.getStringExtra(EXTRA_INVITE_URI);
to.putExtra(EXTRA_INVITE_URI, invite);
} }
} }
@ -1287,17 +1289,14 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public String account; public String account;
public boolean forceDialog = false; boolean forceDialog = false;
public Invite(final Uri uri) {
Invite(final String uri) {
super(uri); super(uri);
} }
public Invite(final String uri) { Invite(Uri uri, boolean safeSource) {
super(uri);
}
public Invite(Uri uri, boolean safeSource) {
super(uri, safeSource); super(uri, safeSource);
} }

View file

@ -89,17 +89,24 @@ public class UriHandlerActivity extends AppCompatActivity {
final XmppUri xmppUri = new XmppUri(uri); final XmppUri xmppUri = new XmppUri(uri);
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true); final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true);
if (SignupUtils.isSupportTokenRegistry() && xmppUri.isJidValid() && xmppUri.isAction(XmppUri.ACTION_REGISTER)) { if (SignupUtils.isSupportTokenRegistry() && xmppUri.isJidValid()) {
final String preauth = xmppUri.getParamater("preauth"); final String preauth = xmppUri.getParamater("preauth");
final Jid jid = xmppUri.getJid(); final Jid jid = xmppUri.getJid();
if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
if (jid.isDomainJid()) { if (jid.isDomainJid()) {
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth); intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
startActivity(intent); startActivity(intent);
return; return;
} }
Log.d(Config.LOGTAG,"attempting to register on "+jid+" with preauth="+preauth);
return; return;
} }
if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParamater("ibr"))) {
intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
startActivity(intent);
return;
}
}
if (accounts.size() == 0) { if (accounts.size() == 0) {
if (xmppUri.isJidValid()) { if (xmppUri.isJidValid()) {

View file

@ -29,6 +29,7 @@ public class XmppUri {
public static final String ACTION_JOIN = "join"; public static final String ACTION_JOIN = "join";
public static final String ACTION_MESSAGE = "message"; public static final String ACTION_MESSAGE = "message";
public static final String ACTION_REGISTER = "register"; public static final String ACTION_REGISTER = "register";
public static final String ACTION_ROSTER = "roster";
public XmppUri(String uri) { public XmppUri(String uri) {
try { try {