From a0920b83e2531d3aec14e39c490a5c373b4868fe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 17 May 2020 10:24:46 +0200 Subject: [PATCH] use Account.getDomain() for direct access to domain jid --- .../services/ImportBackupService.java | 2 +- .../conversations/utils/SignupUtils.java | 4 +- .../siacs/conversations/entities/Account.java | 10 +++-- .../siacs/conversations/entities/Contact.java | 6 +-- .../conversations/entities/Conversation.java | 2 +- .../conversations/generator/IqGenerator.java | 4 +- .../http/HttpDownloadConnection.java | 2 +- .../conversations/http/SlotRequester.java | 2 +- .../conversations/parser/AbstractParser.java | 2 +- .../persistance/DatabaseBackend.java | 2 +- .../services/XmppConnectionService.java | 4 +- .../conversations/ui/EditAccountActivity.java | 2 +- .../conversations/ui/EnterJidDialog.java | 2 +- .../conversations/ui/RtpSessionActivity.java | 8 ++-- .../siacs/conversations/ui/XmppActivity.java | 2 +- .../utils/IrregularUnicodeDetector.java | 4 +- .../siacs/conversations/utils/JidHelper.java | 2 +- .../siacs/conversations/xmpp/InvalidJid.java | 2 +- .../java/eu/siacs/conversations/xmpp/Jid.java | 18 ++++---- .../siacs/conversations/xmpp/WrappedJid.java | 5 +-- .../conversations/xmpp/XmppConnection.java | 44 +++++++++---------- .../xmpp/jingle/JingleConnectionManager.java | 2 +- .../xmpp/jingle/JingleRtpConnection.java | 2 +- .../xmpp/stanzas/AbstractStanza.java | 4 +- .../siacs/conversations/entities/Entry.java | 2 +- .../services/QuickConversationsService.java | 2 +- .../utils/PhoneNumberUtilWrapper.java | 2 +- .../conversations/utils/SignupUtils.java | 2 +- 28 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java index 54444ae40..8596b1c3f 100644 --- a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java +++ b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java @@ -208,7 +208,7 @@ public class ImportBackupService extends Service { } } final Jid jid = backupFileHeader.getJid(); - Cursor countCursor = db.rawQuery("select count(messages.uuid) from messages join conversations on conversations.uuid=messages.conversationUuid join accounts on conversations.accountUuid=accounts.uuid where accounts.username=? and accounts.server=?", new String[]{jid.getEscapedLocal(), jid.getDomain()}); + Cursor countCursor = db.rawQuery("select count(messages.uuid) from messages join conversations on conversations.uuid=messages.conversationUuid join accounts on conversations.accountUuid=accounts.uuid where accounts.username=? and accounts.server=?", new String[]{jid.getEscapedLocal(), jid.getDomain().toEscapedString()}); countCursor.moveToFirst(); int count = countCursor.getInt(0); Log.d(Config.LOGTAG, "restored " + count + " messages"); diff --git a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java index b58d8414b..fb088234a 100644 --- a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java +++ b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java @@ -24,9 +24,9 @@ public class SignupUtils { public static Intent getTokenRegistrationIntent(final Activity activity, Jid jid, String preAuth) { final Intent intent = new Intent(activity, MagicCreateActivity.class); if (jid.isDomainJid()) { - intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain()); + intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain().toEscapedString()); } else { - intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain()); + intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain().toEscapedString()); intent.putExtra(MagicCreateActivity.EXTRA_USERNAME, jid.getEscapedLocal()); } intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth); diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index e56d97cc3..d2d25e321 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -232,10 +232,14 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable return next != null && !next.equals(previousFull); } - public String getServer() { + public Jid getDomain() { return jid.getDomain(); } + public String getServer() { + return jid.getDomain().toEscapedString(); + } + public String getPassword() { return password; } @@ -369,7 +373,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable final ContentValues values = new ContentValues(); values.put(UUID, uuid); values.put(USERNAME, jid.getLocal()); - values.put(SERVER, jid.getDomain()); + values.put(SERVER, jid.getDomain().toEscapedString()); values.put(PASSWORD, password); values.put(OPTIONS, options); synchronized (this.keys) { @@ -587,7 +591,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable public boolean isBlocked(final ListItem contact) { final Jid jid = contact.getJid(); - return jid != null && (blocklist.contains(jid.asBareJid()) || blocklist.contains(Jid.ofDomain(jid.getDomain()))); + return jid != null && (blocklist.contains(jid.asBareJid()) || blocklist.contains(jid.getDomain())); } public boolean isBlocked(final Jid jid) { diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index c29c4162e..9aedb27d4 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -134,12 +134,12 @@ public class Contact implements ListItem, Blockable { return this.systemName; } else if (!TextUtils.isEmpty(this.serverName)) { return this.serverName; - } else if (!TextUtils.isEmpty(this.presenceName) && ((QuickConversationsService.isQuicksy() && Config.QUICKSY_DOMAIN.equals(jid.getDomain())) ||mutualPresenceSubscription())) { + } else if (!TextUtils.isEmpty(this.presenceName) && ((QuickConversationsService.isQuicksy() && Config.QUICKSY_DOMAIN.equals(jid.getDomain().toEscapedString())) ||mutualPresenceSubscription())) { return this.presenceName; } else if (jid.getLocal() != null) { return JidHelper.localPartOrFallback(jid); } else { - return jid.getDomain(); + return jid.getDomain().toEscapedString(); } } @@ -413,7 +413,7 @@ public class Contact implements ListItem, Blockable { } public String getServer() { - return getJid().getDomain(); + return getJid().getDomain().toEscapedString(); } public boolean setAvatar(Avatar avatar) { diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index e6f1b27cd..1e88f8d82 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -139,7 +139,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl if (conversation.getContact().isOwnServer()) { return false; } - final String contact = conversation.getJid().getDomain(); + final String contact = conversation.getJid().getDomain().toEscapedString(); final String account = conversation.getAccount().getServer(); if (Config.OMEMO_EXCEPTIONS.CONTACT_DOMAINS.contains(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) { return false; diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index dc3740128..1e5a0ed14 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -351,7 +351,7 @@ public class IqGenerator extends AbstractGenerator { public IqPacket generateSetPassword(final Account account, final String newPassword) { final IqPacket packet = new IqPacket(IqPacket.TYPE.SET); - packet.setTo(Jid.of(account.getServer())); + packet.setTo(account.getDomain()); final Element query = packet.addChild("query", Namespace.REGISTER); final Jid jid = account.getJid(); query.addChild("username").setContent(jid.getLocal()); @@ -442,7 +442,7 @@ public class IqGenerator extends AbstractGenerator { public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) { final IqPacket register = new IqPacket(IqPacket.TYPE.SET); register.setFrom(account.getJid().asBareJid()); - register.setTo(Jid.of(account.getServer())); + register.setTo(account.getDomain()); register.setId(id); Element query = register.query(Namespace.REGISTER); if (data != null) { diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index f79190c5e..e01eb2578 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -265,7 +265,7 @@ public class HttpDownloadConnection implements Transferable { private void retrieveUrl() { changeStatus(STATUS_CHECKING); final Account account = message.getConversation().getAccount(); - IqPacket request = mXmppConnectionService.getIqGenerator().requestP1S3Url(Jid.of(account.getJid().getDomain()), mUrl.getHost()); + IqPacket request = mXmppConnectionService.getIqGenerator().requestP1S3Url(account.getDomain(), mUrl.getHost()); mXmppConnectionService.sendIqPacket(message.getConversation().getAccount(), request, (a, packet) -> { if (packet.getType() == IqPacket.TYPE.RESULT) { String download = packet.query().getAttribute("download"); diff --git a/src/main/java/eu/siacs/conversations/http/SlotRequester.java b/src/main/java/eu/siacs/conversations/http/SlotRequester.java index 6a8c37c28..d9f4cdc20 100644 --- a/src/main/java/eu/siacs/conversations/http/SlotRequester.java +++ b/src/main/java/eu/siacs/conversations/http/SlotRequester.java @@ -61,7 +61,7 @@ public class SlotRequester { Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD_LEGACY); requestHttpUploadLegacy(account, host, file, mime, callback); } else { - requestP1S3(account, Jid.of(account.getServer()), file.getName(), md5, callback); + requestP1S3(account, account.getDomain(), file.getName(), md5, callback); } } diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 349eca253..5136481a7 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -106,7 +106,7 @@ public abstract class AbstractParser { public static MucOptions.User parseItem(Conversation conference, Element item, Jid fullJid) { final String local = conference.getJid().getLocal(); - final String domain = conference.getJid().getDomain(); + final String domain = conference.getJid().getDomain().toEscapedString(); String affiliation = item.getAttribute("affiliation"); String role = item.getAttribute("role"); String nick = item.getAttribute("nick"); diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 84288b649..8c021ff30 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -617,7 +617,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { cursor.getString(cursor.getColumnIndex(Account.USERNAME)), cursor.getString(cursor.getColumnIndex(Account.SERVER)), null - ).getDomain(); + ).getDomain().toEscapedString(); } catch (IllegalArgumentException ignored) { Log.e(Config.LOGTAG, "Failed to migrate Account SERVER " + cursor.getString(cursor.getColumnIndex(Account.SERVER)) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1b2f9b4dc..061fe7ec9 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2205,7 +2205,7 @@ public class XmppConnectionService extends Service { callback.onAccountCreated(account); if (Config.X509_VERIFICATION) { try { - getMemorizingTrustManager().getNonInteractive(account.getJid().getDomain()).checkClientTrusted(chain, "RSA"); + getMemorizingTrustManager().getNonInteractive(account.getServer()).checkClientTrusted(chain, "RSA"); } catch (CertificateException e) { callback.informUser(R.string.certificate_chain_is_not_trusted); } @@ -4160,7 +4160,7 @@ public class XmppConnectionService extends Service { mucServers.addAll(account.getXmppConnection().getMucServers()); for (Bookmark bookmark : account.getBookmarks()) { final Jid jid = bookmark.getJid(); - final String s = jid == null ? null : jid.getDomain(); + final String s = jid == null ? null : jid.getDomain().toEscapedString(); if (s != null) { mucServers.add(s); } diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 28ff0b209..89de15d0b 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -816,7 +816,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private String getUserModeDomain() { if (mAccount != null && mAccount.getJid().getDomain() != null) { - return mAccount.getJid().getDomain(); + return mAccount.getServer(); } else { return Config.DOMAIN_LOCK; } diff --git a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java index 6ad8859b9..fef479e37 100644 --- a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java @@ -168,7 +168,7 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected issuedWarning = true; return; } - if (suspiciousSubDomain(contactJid.getDomain())) { + if (suspiciousSubDomain(contactJid.getDomain().toEscapedString())) { binding.jidLayout.setError(getActivity().getString(R.string.this_looks_like_channel)); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.add_anway); issuedWarning = true; diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 8f1ed25e9..a6ac2ba1b 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -129,7 +129,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe final Intent intent = getIntent(); final String action = intent.getAction(); final Account account = extractAccount(intent); - final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); + final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH)); final String state = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE); if (!Intent.ACTION_VIEW.equals(action) || state == null || !END_CARD.contains(RtpEndUserState.valueOf(state))) { resetIntent(account, with, RtpEndUserState.RETRACTED, actionToMedia(intent.getAction())); @@ -246,7 +246,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe return; } final Account account = extractAccount(intent); - final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); + final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH)); final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID); if (sessionId != null) { Log.d(Config.LOGTAG, "reinitializing from onNewIntent()"); @@ -268,7 +268,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe final Intent intent = getIntent(); final String action = intent.getAction(); final Account account = extractAccount(intent); - final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); + final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH)); final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID); if (sessionId != null) { if (initializeActivityWithRunningRtpSession(account, with, sessionId)) { @@ -831,7 +831,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe Log.d(Config.LOGTAG, "attempting retry"); final Intent intent = getIntent(); final Account account = extractAccount(intent); - final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); + final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH)); final String lastAction = intent.getStringExtra(EXTRA_LAST_ACTION); final String action = intent.getAction(); final Set media = actionToMedia(lastAction == null ? action : lastAction); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index b2b0e3d6f..887d3374b 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -870,7 +870,7 @@ public abstract class XmppActivity extends ActionBarActivity { protected Account extractAccount(Intent intent) { final String jid = intent != null ? intent.getStringExtra(EXTRA_ACCOUNT) : null; try { - return jid != null ? xmppConnectionService.findAccountByJid(Jid.of(jid)) : null; + return jid != null ? xmppConnectionService.findAccountByJid(Jid.ofEscaped(jid)) : null; } catch (IllegalArgumentException e) { return null; } diff --git a/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java b/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java index ac06e2799..832e0dc56 100644 --- a/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java +++ b/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java @@ -89,7 +89,7 @@ public class IrregularUnicodeDetector { builder.append('@'); } if (jid.getDomain() != null) { - String[] labels = jid.getDomain().split("\\."); + String[] labels = jid.getDomain().toEscapedString().split("\\."); for (int i = 0; i < labels.length; ++i) { SpannableString spannableString = new SpannableString(labels[i]); colorize(spannableString, patternTuple.domain.get(i), color); @@ -263,7 +263,7 @@ public class IrregularUnicodeDetector { } else { localPattern = null; } - String domain = jid.getDomain(); + String domain = jid.getDomain().toEscapedString(); final List domainPatterns = new ArrayList<>(); if (domain != null) { for (String label : domain.split("\\.")) { diff --git a/src/main/java/eu/siacs/conversations/utils/JidHelper.java b/src/main/java/eu/siacs/conversations/utils/JidHelper.java index bffaea0cd..603899fca 100644 --- a/src/main/java/eu/siacs/conversations/utils/JidHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/JidHelper.java @@ -43,7 +43,7 @@ public class JidHelper { public static String localPartOrFallback(Jid jid) { if (LOCAL_PART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) { - final String domain = jid.getDomain(); + final String domain = jid.getDomain().toEscapedString(); final int index = domain.indexOf('.'); return index > 1 ? domain.substring(0, index) : domain; } else { diff --git a/src/main/java/eu/siacs/conversations/xmpp/InvalidJid.java b/src/main/java/eu/siacs/conversations/xmpp/InvalidJid.java index 251f28ffa..a990dc5c1 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/InvalidJid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/InvalidJid.java @@ -94,7 +94,7 @@ public class InvalidJid implements Jid { } @Override - public String getDomain() { + public Jid getDomain() { throw new AssertionError("Not implemented"); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/Jid.java index dff9f745f..622a132fb 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/Jid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/Jid.java @@ -80,14 +80,14 @@ public interface Jid extends Comparable, Serializable, CharSequence { static Jid ofDomainAndResource(CharSequence domain, CharSequence resource) { try { - return new WrappedJid( - JidCreate.domainFullFrom( - Domainpart.from(domain.toString()), - Resourcepart.from(resource.toString()) - )); - } catch (XmppStringprepException e) { - throw new IllegalArgumentException(e); - } + return new WrappedJid( + JidCreate.domainFullFrom( + Domainpart.from(domain.toString()), + Resourcepart.from(resource.toString()) + )); + } catch (XmppStringprepException e) { + throw new IllegalArgumentException(e); + } } static Jid ofLocalAndDomainEscaped(CharSequence local, CharSequence domain) { @@ -138,7 +138,7 @@ public interface Jid extends Comparable, Serializable, CharSequence { String getEscapedLocal(); - String getDomain(); + Jid getDomain(); String getResource(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java b/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java index 3b5ed162a..878b3c302 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java @@ -65,9 +65,8 @@ public class WrappedJid implements eu.siacs.conversations.xmpp.Jid { } @Override - public String getDomain() { - final Domainpart domainpart = inner.getDomain(); - return domainpart == null ? null : domainpart.toString(); + public eu.siacs.conversations.xmpp.Jid getDomain() { + return new WrappedJid(inner.asDomainBareJid()); } @Override diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 24a7a74df..5f4481318 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -289,7 +289,7 @@ public class XmppConnection implements Runnable { throw new IOException(e.getMessage()); } } else { - final String domain = account.getJid().getDomain(); + final String domain = account.getServer(); final List results; final boolean hardcoded = extended && !account.getHostname().isEmpty(); if (hardcoded) { @@ -434,7 +434,7 @@ public class XmppConnection implements Runnable { } else { keyManager = null; } - final String domain = account.getJid().getDomain(); + final String domain = account.getServer(); sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG()); final SSLSocketFactory factory = sc.getSocketFactory(); final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive); @@ -930,7 +930,7 @@ public class XmppConnection implements Runnable { private void sendRegistryRequest() { final IqPacket register = new IqPacket(IqPacket.TYPE.GET); register.query(Namespace.REGISTER); - register.setTo(Jid.of(account.getServer())); + register.setTo(account.getDomain()); sendUnmodifiedIqPacket(register, (account, packet) -> { if (packet.getType() == IqPacket.TYPE.TIMEOUT) { return; @@ -1172,18 +1172,18 @@ public class XmppConnection implements Runnable { } final boolean requestDiscoItemsFirst = !account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY); if (requestDiscoItemsFirst) { - sendServiceDiscoveryItems(Jid.of(account.getServer())); + sendServiceDiscoveryItems(account.getDomain()); } if (discoveryResult == null) { - sendServiceDiscoveryInfo(Jid.of(account.getServer())); + sendServiceDiscoveryInfo(account.getDomain()); } else { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server caps came from cache"); - disco.put(Jid.of(account.getServer()), discoveryResult); + disco.put(account.getDomain(), discoveryResult); } discoverMamPreferences(); sendServiceDiscoveryInfo(account.getJid().asBareJid()); if (!requestDiscoItemsFirst) { - sendServiceDiscoveryItems(Jid.of(account.getServer())); + sendServiceDiscoveryItems(account.getDomain()); } if (!mWaitForDisco.get()) { @@ -1202,24 +1202,24 @@ public class XmppConnection implements Runnable { boolean advancedStreamFeaturesLoaded; synchronized (XmppConnection.this.disco) { ServiceDiscoveryResult result = new ServiceDiscoveryResult(packet); - if (jid.equals(Jid.of(account.getServer()))) { + if (jid.equals(account.getDomain())) { mXmppConnectionService.databaseBackend.insertDiscoveryResult(result); } disco.put(jid, result); - advancedStreamFeaturesLoaded = disco.containsKey(Jid.of(account.getServer())) + advancedStreamFeaturesLoaded = disco.containsKey(account.getDomain()) && disco.containsKey(account.getJid().asBareJid()); } - if (advancedStreamFeaturesLoaded && (jid.equals(Jid.of(account.getServer())) || jid.equals(account.getJid().asBareJid()))) { + if (advancedStreamFeaturesLoaded && (jid.equals(account.getDomain()) || jid.equals(account.getJid().asBareJid()))) { enableAdvancedStreamFeatures(); } } else if (packet.getType() == IqPacket.TYPE.ERROR) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not query disco info for " + jid.toString()); - final boolean serverOrAccount = jid.equals(Jid.of(account.getServer())) || jid.equals(account.getJid().asBareJid()); + final boolean serverOrAccount = jid.equals(account.getDomain()) || jid.equals(account.getJid().asBareJid()); final boolean advancedStreamFeaturesLoaded; if (serverOrAccount) { synchronized (XmppConnection.this.disco) { disco.put(jid, ServiceDiscoveryResult.empty()); - advancedStreamFeaturesLoaded = disco.containsKey(Jid.of(account.getServer())) && disco.containsKey(account.getJid().asBareJid()); + advancedStreamFeaturesLoaded = disco.containsKey(account.getDomain()) && disco.containsKey(account.getJid().asBareJid()); } } else { advancedStreamFeaturesLoaded = false; @@ -1285,7 +1285,7 @@ public class XmppConnection implements Runnable { for (final Element element : elements) { if (element.getName().equals("item")) { final Jid jid = InvalidJid.getNullForInvalid(element.getAttributeAsJid("jid")); - if (jid != null && !jid.equals(Jid.of(account.getServer()))) { + if (jid != null && !jid.equals(account.getDomain())) { items.add(jid); } } @@ -1559,7 +1559,7 @@ public class XmppConnection implements Runnable { public List getMucServersWithholdAccount() { List servers = getMucServers(); - servers.remove(account.getServer()); + servers.remove(account.getDomain()); return servers; } @@ -1764,7 +1764,7 @@ public class XmppConnection implements Runnable { } public boolean carbons() { - return hasDiscoFeature(Jid.of(account.getServer()), "urn:xmpp:carbons:2"); + return hasDiscoFeature(account.getDomain(), "urn:xmpp:carbons:2"); } public boolean bookmarksConversion() { @@ -1776,19 +1776,19 @@ public class XmppConnection implements Runnable { } public boolean blocking() { - return hasDiscoFeature(Jid.of(account.getServer()), Namespace.BLOCKING); + return hasDiscoFeature(account.getDomain(), Namespace.BLOCKING); } public boolean spamReporting() { - return hasDiscoFeature(Jid.of(account.getServer()), "urn:xmpp:reporting:reason:spam:0"); + return hasDiscoFeature(account.getDomain(), "urn:xmpp:reporting:reason:spam:0"); } public boolean flexibleOfflineMessageRetrieval() { - return hasDiscoFeature(Jid.of(account.getServer()), Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL); + return hasDiscoFeature(account.getDomain(), Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL); } public boolean register() { - return hasDiscoFeature(Jid.of(account.getServer()), Namespace.REGISTER); + return hasDiscoFeature(account.getDomain(), Namespace.REGISTER); } public boolean invite() { @@ -1837,7 +1837,7 @@ public class XmppConnection implements Runnable { public boolean push() { return hasDiscoFeature(account.getJid().asBareJid(), Namespace.PUSH) - || hasDiscoFeature(Jid.of(account.getServer()), Namespace.PUSH); + || hasDiscoFeature(account.getDomain(), Namespace.PUSH); } public boolean rosterVersioning() { @@ -1849,7 +1849,7 @@ public class XmppConnection implements Runnable { } public boolean p1S3FileTransfer() { - return hasDiscoFeature(Jid.of(account.getServer()), Namespace.P1_S3_FILE_TRANSFER); + return hasDiscoFeature(account.getDomain(), Namespace.P1_S3_FILE_TRANSFER); } public boolean httpUpload(long filesize) { @@ -1903,7 +1903,7 @@ public class XmppConnection implements Runnable { } public boolean externalServiceDiscovery() { - return hasDiscoFeature(Jid.of(account.getServer()),Namespace.EXTERNAL_SERVICE_DISCOVERY); + return hasDiscoFeature(account.getDomain(),Namespace.EXTERNAL_SERVICE_DISCOVERY); } } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 51aa3b64b..9ac971c2d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -601,7 +601,7 @@ public class JingleConnectionManager extends AbstractConnectionManager { } public WeakReference findJingleRtpConnection(Account account, Jid with, String sessionId) { - final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, Jid.ofEscaped(with), sessionId); + final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, with, sessionId); final AbstractJingleConnection connection = connections.get(id); if (connection instanceof JingleRtpConnection) { return new WeakReference<>((JingleRtpConnection) connection); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 9b0e4a78d..0af69ca28 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -1104,7 +1104,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web private void discoverIceServers(final OnIceServersDiscovered onIceServersDiscovered) { if (id.account.getXmppConnection().getFeatures().externalServiceDiscovery()) { final IqPacket request = new IqPacket(IqPacket.TYPE.GET); - request.setTo(Jid.of(id.account.getJid().getDomain())); + request.setTo(id.account.getDomain()); request.addChild("services", Namespace.EXTERNAL_SERVICE_DISCOVERY); xmppConnectionService.sendIqPacket(id.account, request, (account, response) -> { ImmutableList.Builder listBuilder = new ImmutableList.Builder<>(); diff --git a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java index 2255b3bd6..c0b3d07bd 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java +++ b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java @@ -33,7 +33,7 @@ public class AbstractStanza extends Element { public boolean fromServer(final Account account) { final Jid from = getFrom(); return from == null - || from.equals(Jid.of(account.getServer())) + || from.equals(account.getDomain()) || from.equals(account.getJid().asBareJid()) || from.equals(account.getJid()); } @@ -41,7 +41,7 @@ public class AbstractStanza extends Element { public boolean toServer(final Account account) { final Jid to = getTo(); return to == null - || to.equals(Jid.of(account.getServer())) + || to.equals(account.getDomain()) || to.equals(account.getJid().asBareJid()) || to.equals(account.getJid()); } diff --git a/src/quicksy/java/eu/siacs/conversations/entities/Entry.java b/src/quicksy/java/eu/siacs/conversations/entities/Entry.java index 2dd25881d..6ff19f09d 100644 --- a/src/quicksy/java/eu/siacs/conversations/entities/Entry.java +++ b/src/quicksy/java/eu/siacs/conversations/entities/Entry.java @@ -11,7 +11,7 @@ import java.util.List; import eu.siacs.conversations.android.PhoneNumberContact; import eu.siacs.conversations.xml.Element; -import rocks.xmpp.addr.Jid; +import eu.siacs.conversations.xmpp.Jid; public class Entry implements Comparable { private final List jids; diff --git a/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java index 319f160f7..f8e73b447 100644 --- a/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java +++ b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -49,9 +49,9 @@ import eu.siacs.conversations.utils.PhoneNumberUtilWrapper; import eu.siacs.conversations.utils.SerialSingleThreadExecutor; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.stanzas.IqPacket; import io.michaelrocks.libphonenumber.android.Phonenumber; -import rocks.xmpp.addr.Jid; public class QuickConversationsService extends AbstractQuickConversationsService { diff --git a/src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java b/src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java index 0b52997e8..5f68c2a06 100644 --- a/src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java +++ b/src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java @@ -7,10 +7,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import eu.siacs.conversations.xmpp.Jid; import io.michaelrocks.libphonenumber.android.NumberParseException; import io.michaelrocks.libphonenumber.android.PhoneNumberUtil; import io.michaelrocks.libphonenumber.android.Phonenumber; -import rocks.xmpp.addr.Jid; public class PhoneNumberUtilWrapper { diff --git a/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java b/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java index 64e1d49a9..12c18c645 100644 --- a/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java +++ b/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java @@ -14,7 +14,7 @@ import eu.siacs.conversations.ui.EnterPhoneNumberActivity; import eu.siacs.conversations.ui.StartConversationActivity; import eu.siacs.conversations.ui.TosActivity; import eu.siacs.conversations.ui.VerifyActivity; -import rocks.xmpp.addr.Jid; +import eu.siacs.conversations.xmpp.Jid; public class SignupUtils {