From 6205574bcbb86a4f63fea7fae67c6a0c67df45ec Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 9 Jan 2020 15:49:49 +0100 Subject: [PATCH] support ?roster;ibr=y xmpp uris --- .../siacs/conversations/utils/SignupUtils.java | 4 ++-- .../ui/PublishProfilePictureActivity.java | 4 ++-- .../ui/StartConversationActivity.java | 17 ++++++++--------- .../conversations/ui/UriHandlerActivity.java | 15 +++++++++++---- .../eu/siacs/conversations/utils/XmppUri.java | 1 + 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java index f03a9a7bc..e4fc28393 100644 --- a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java +++ b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java @@ -20,10 +20,10 @@ public class SignupUtils { 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); intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, domain); - intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preauth); + intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth); return intent; } diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index e46c4c40d..022daa56a 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -95,11 +95,11 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC }); this.cancelButton.setOnClickListener(v -> { if (mInitialAccountSetup) { - Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); + final Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) { - StartConversationActivity.addInviteUri(intent, getIntent()); intent.putExtra("init", true); } + StartConversationActivity.addInviteUri(intent, getIntent()); startActivity(intent); } finish(); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 55c619356..b57943fbc 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -857,7 +857,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne showJoinConferenceDialog(invite.getJid().asBareJid().toString()); 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); return false; } else if (contacts.size() == 1) { @@ -1279,7 +1280,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne public static void addInviteUri(Intent to, Intent from) { 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 boolean forceDialog = false; + boolean forceDialog = false; - public Invite(final Uri uri) { + + Invite(final String uri) { super(uri); } - public Invite(final String uri) { - super(uri); - } - - public Invite(Uri uri, boolean safeSource) { + Invite(Uri uri, boolean safeSource) { super(uri, safeSource); } diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java index b2e39dd51..67736c90c 100644 --- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java @@ -89,16 +89,23 @@ public class UriHandlerActivity extends AppCompatActivity { final XmppUri xmppUri = new XmppUri(uri); final List 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 Jid jid = xmppUri.getJid(); - if (jid.isDomainJid()) { + if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) { + if (jid.isDomainJid()) { + intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth); + startActivity(intent); + 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; } - Log.d(Config.LOGTAG,"attempting to register on "+jid+" with preauth="+preauth); - return; } if (accounts.size() == 0) { diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java index 33224e980..df8ea09bc 100644 --- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java +++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java @@ -29,6 +29,7 @@ public class XmppUri { public static final String ACTION_JOIN = "join"; public static final String ACTION_MESSAGE = "message"; public static final String ACTION_REGISTER = "register"; + public static final String ACTION_ROSTER = "roster"; public XmppUri(String uri) { try {