~singpolyma/cheogram-android

6205574bcbb86a4f63fea7fae67c6a0c67df45ec — Daniel Gultsch 4 years ago d039c48
support ?roster;ibr=y xmpp uris
M src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java => src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java +2 -2
@@ 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;
    }


M src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java => src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +2 -2
@@ 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();

M src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java => src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +7 -8
@@ 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) {
			super(uri);
		}

		public Invite(final String uri) {
		Invite(final String uri) {
			super(uri);
		}

		public Invite(Uri uri, boolean safeSource) {
		Invite(Uri uri, boolean safeSource) {
			super(uri, safeSource);
		}


M src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java => src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +11 -4
@@ 89,16 89,23 @@ public class UriHandlerActivity extends AppCompatActivity {
        final XmppUri xmppUri = new XmppUri(uri);
        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 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) {

M src/main/java/eu/siacs/conversations/utils/XmppUri.java => src/main/java/eu/siacs/conversations/utils/XmppUri.java +1 -0
@@ 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 {