avoid unnecessary call to Jid.ofDomain()

This commit is contained in:
Daniel Gultsch 2020-05-21 07:57:57 +02:00
parent aa1e69d277
commit 574bccfc59
9 changed files with 11 additions and 11 deletions

View file

@ -62,7 +62,7 @@ public class WelcomeActivity extends XmppActivity implements XmppConnectionServi
if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) { if (xmppUri.isAction(XmppUri.ACTION_REGISTER)) {
intent = SignupUtils.getTokenRegistrationIntent(this, jid, preauth); intent = SignupUtils.getTokenRegistrationIntent(this, jid, preauth);
} else if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter("ibr"))) { } else if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter("ibr"))) {
intent = SignupUtils.getTokenRegistrationIntent(this, Jid.ofDomain(jid.getDomain()), preauth); intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString()); intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
} else { } else {
intent = null; intent = null;

View file

@ -468,7 +468,7 @@ public class Contact implements ListItem, Blockable {
} }
boolean isOwnServer() { boolean isOwnServer() {
return account.getJid().getDomain().equals(jid.asBareJid().toString()); return account.getJid().getDomain().equals(jid.asBareJid());
} }
public void setCommonName(String cn) { public void setCommonName(String cn) {

View file

@ -42,7 +42,7 @@ public abstract class AbstractParser {
for(Element child : element.getChildren()) { for(Element child : element.getChildren()) {
if ("delay".equals(child.getName()) && "urn:xmpp:delay".equals(child.getNamespace())) { if ("delay".equals(child.getName()) && "urn:xmpp:delay".equals(child.getNamespace())) {
final Jid f = to == null ? null : InvalidJid.getNullForInvalid(child.getAttributeAsJid("from")); final Jid f = to == null ? null : InvalidJid.getNullForInvalid(child.getAttributeAsJid("from"));
if (f != null && (to.asBareJid().equals(f) || to.getDomain().equals(f.toString()))) { if (f != null && (to.asBareJid().equals(f) || to.getDomain().equals(f))) {
continue; continue;
} }
final String stamp = child.getAttribute("stamp"); final String stamp = child.getAttribute("stamp");

View file

@ -452,7 +452,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null || xP1S3 != null) && !isMucStatusMessage) { if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null || xP1S3 != null) && !isMucStatusMessage) {
final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain()); final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain().toEscapedString());
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), conversationIsProbablyMuc, false, query, false); final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), conversationIsProbablyMuc, false, query, false);
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI; final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;

View file

@ -29,9 +29,9 @@ public final class BlockContactDialog {
builder.setTitle(isBlocked ? R.string.action_unblock_participant : R.string.action_block_participant); builder.setTitle(isBlocked ? R.string.action_unblock_participant : R.string.action_block_participant);
value = blockable.getJid().toEscapedString(); value = blockable.getJid().toEscapedString();
res = isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text; res = isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text;
} else if (blockable.getJid().getLocal() == null || blockable.getAccount().isBlocked(Jid.ofDomain(blockable.getJid().getDomain()))) { } else if (blockable.getJid().getLocal() == null || blockable.getAccount().isBlocked(blockable.getJid().getDomain())) {
builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain); builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain);
value = Jid.ofDomain(blockable.getJid().getDomain()).toString(); value =blockable.getJid().getDomain().toEscapedString();
res = isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text; res = isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text;
} else { } else {
int resBlockAction = blockable instanceof Conversation && ((Conversation) blockable).isWithStranger() ? R.string.block_stranger : R.string.action_block_contact; int resBlockAction = blockable instanceof Conversation && ((Conversation) blockable).isWithStranger() ? R.string.block_stranger : R.string.action_block_contact;

View file

@ -2207,7 +2207,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
updateSnackBar(conversation); updateSnackBar(conversation);
return true; return true;
case R.id.block_domain: case R.id.block_domain:
blockable = conversation.getAccount().getRoster().getContact(Jid.ofDomain(jid.getDomain())); blockable = conversation.getAccount().getRoster().getContact(jid.getDomain());
break; break;
default: default:
blockable = conversation; blockable = conversation;

View file

@ -409,7 +409,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (mAccount.isOptionSet(Account.OPTION_FIXED_USERNAME)) { if (mAccount.isOptionSet(Account.OPTION_FIXED_USERNAME)) {
preset = jid.asBareJid(); preset = jid.asBareJid();
} else { } else {
preset = Jid.ofDomain(jid.getDomain()); preset = jid.getDomain();
} }
final Intent intent = SignupUtils.getTokenRegistrationIntent(this, preset, mAccount.getKey(Account.PRE_AUTH_REGISTRATION_TOKEN)); final Intent intent = SignupUtils.getTokenRegistrationIntent(this, preset, mAccount.getKey(Account.PRE_AUTH_REGISTRATION_TOKEN));
StartConversationActivity.addInviteUri(intent, getIntent()); StartConversationActivity.addInviteUri(intent, getIntent());

View file

@ -100,7 +100,7 @@ public class UriHandlerActivity extends AppCompatActivity {
return; return;
} }
if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter("ibr"))) { if (xmppUri.isAction(XmppUri.ACTION_ROSTER) && "y".equals(xmppUri.getParameter("ibr"))) {
intent = SignupUtils.getTokenRegistrationIntent(this, Jid.ofDomain(jid.getDomain()), preauth); intent = SignupUtils.getTokenRegistrationIntent(this, jid.getDomain(), preauth);
intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString()); intent.putExtra(StartConversationActivity.EXTRA_INVITE_URI, xmppUri.toString());
startActivity(intent); startActivity(intent);
return; return;

View file

@ -870,7 +870,7 @@ public class XmppConnection implements Runnable {
saslMechanism = new ScramSha256(tagWriter, account, mXmppConnectionService.getRNG()); saslMechanism = new ScramSha256(tagWriter, account, mXmppConnectionService.getRNG());
} else if (mechanisms.contains("SCRAM-SHA-1")) { } else if (mechanisms.contains("SCRAM-SHA-1")) {
saslMechanism = new ScramSha1(tagWriter, account, mXmppConnectionService.getRNG()); saslMechanism = new ScramSha1(tagWriter, account, mXmppConnectionService.getRNG());
} else if (mechanisms.contains("PLAIN") && !account.getJid().getDomain().equals("nimbuzz.com")) { } else if (mechanisms.contains("PLAIN") && !account.getJid().getDomain().toEscapedString().equals("nimbuzz.com")) {
saslMechanism = new Plain(tagWriter, account); saslMechanism = new Plain(tagWriter, account);
} else if (mechanisms.contains("DIGEST-MD5")) { } else if (mechanisms.contains("DIGEST-MD5")) {
saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG()); saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG());
@ -1155,7 +1155,7 @@ public class XmppConnection implements Runnable {
} }
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": starting service discovery"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": starting service discovery");
mPendingServiceDiscoveries.set(0); mPendingServiceDiscoveries.set(0);
if (smVersion == 0 || Patches.DISCO_EXCEPTIONS.contains(account.getJid().getDomain())) { if (smVersion == 0 || Patches.DISCO_EXCEPTIONS.contains(account.getJid().getDomain().toEscapedString())) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not wait for service discovery"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not wait for service discovery");
mWaitForDisco.set(false); mWaitForDisco.set(false);
} else { } else {