use Account.getDomain() for direct access to domain jid
This commit is contained in:
parent
b347d57848
commit
a0920b83e2
|
@ -208,7 +208,7 @@ public class ImportBackupService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Jid jid = backupFileHeader.getJid();
|
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();
|
countCursor.moveToFirst();
|
||||||
int count = countCursor.getInt(0);
|
int count = countCursor.getInt(0);
|
||||||
Log.d(Config.LOGTAG, "restored " + count + " messages");
|
Log.d(Config.LOGTAG, "restored " + count + " messages");
|
||||||
|
|
|
@ -24,9 +24,9 @@ public class SignupUtils {
|
||||||
public static Intent getTokenRegistrationIntent(final Activity activity, Jid jid, String preAuth) {
|
public static Intent getTokenRegistrationIntent(final Activity activity, Jid jid, String preAuth) {
|
||||||
final Intent intent = new Intent(activity, MagicCreateActivity.class);
|
final Intent intent = new Intent(activity, MagicCreateActivity.class);
|
||||||
if (jid.isDomainJid()) {
|
if (jid.isDomainJid()) {
|
||||||
intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain());
|
intent.putExtra(MagicCreateActivity.EXTRA_DOMAIN, jid.getDomain().toEscapedString());
|
||||||
} else {
|
} 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_USERNAME, jid.getEscapedLocal());
|
||||||
}
|
}
|
||||||
intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth);
|
intent.putExtra(MagicCreateActivity.EXTRA_PRE_AUTH, preAuth);
|
||||||
|
|
|
@ -232,10 +232,14 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
||||||
return next != null && !next.equals(previousFull);
|
return next != null && !next.equals(previousFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServer() {
|
public Jid getDomain() {
|
||||||
return jid.getDomain();
|
return jid.getDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServer() {
|
||||||
|
return jid.getDomain().toEscapedString();
|
||||||
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +373,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
values.put(UUID, uuid);
|
values.put(UUID, uuid);
|
||||||
values.put(USERNAME, jid.getLocal());
|
values.put(USERNAME, jid.getLocal());
|
||||||
values.put(SERVER, jid.getDomain());
|
values.put(SERVER, jid.getDomain().toEscapedString());
|
||||||
values.put(PASSWORD, password);
|
values.put(PASSWORD, password);
|
||||||
values.put(OPTIONS, options);
|
values.put(OPTIONS, options);
|
||||||
synchronized (this.keys) {
|
synchronized (this.keys) {
|
||||||
|
@ -587,7 +591,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
||||||
|
|
||||||
public boolean isBlocked(final ListItem contact) {
|
public boolean isBlocked(final ListItem contact) {
|
||||||
final Jid jid = contact.getJid();
|
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) {
|
public boolean isBlocked(final Jid jid) {
|
||||||
|
|
|
@ -134,12 +134,12 @@ public class Contact implements ListItem, Blockable {
|
||||||
return this.systemName;
|
return this.systemName;
|
||||||
} else if (!TextUtils.isEmpty(this.serverName)) {
|
} else if (!TextUtils.isEmpty(this.serverName)) {
|
||||||
return 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;
|
return this.presenceName;
|
||||||
} else if (jid.getLocal() != null) {
|
} else if (jid.getLocal() != null) {
|
||||||
return JidHelper.localPartOrFallback(jid);
|
return JidHelper.localPartOrFallback(jid);
|
||||||
} else {
|
} else {
|
||||||
return jid.getDomain();
|
return jid.getDomain().toEscapedString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ public class Contact implements ListItem, Blockable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServer() {
|
public String getServer() {
|
||||||
return getJid().getDomain();
|
return getJid().getDomain().toEscapedString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAvatar(Avatar avatar) {
|
public boolean setAvatar(Avatar avatar) {
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
if (conversation.getContact().isOwnServer()) {
|
if (conversation.getContact().isOwnServer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String contact = conversation.getJid().getDomain();
|
final String contact = conversation.getJid().getDomain().toEscapedString();
|
||||||
final String account = conversation.getAccount().getServer();
|
final String account = conversation.getAccount().getServer();
|
||||||
if (Config.OMEMO_EXCEPTIONS.CONTACT_DOMAINS.contains(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) {
|
if (Config.OMEMO_EXCEPTIONS.CONTACT_DOMAINS.contains(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -351,7 +351,7 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
|
|
||||||
public IqPacket generateSetPassword(final Account account, final String newPassword) {
|
public IqPacket generateSetPassword(final Account account, final String newPassword) {
|
||||||
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
|
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 Element query = packet.addChild("query", Namespace.REGISTER);
|
||||||
final Jid jid = account.getJid();
|
final Jid jid = account.getJid();
|
||||||
query.addChild("username").setContent(jid.getLocal());
|
query.addChild("username").setContent(jid.getLocal());
|
||||||
|
@ -442,7 +442,7 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) {
|
public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) {
|
||||||
final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
|
final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
|
||||||
register.setFrom(account.getJid().asBareJid());
|
register.setFrom(account.getJid().asBareJid());
|
||||||
register.setTo(Jid.of(account.getServer()));
|
register.setTo(account.getDomain());
|
||||||
register.setId(id);
|
register.setId(id);
|
||||||
Element query = register.query(Namespace.REGISTER);
|
Element query = register.query(Namespace.REGISTER);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
|
@ -265,7 +265,7 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
private void retrieveUrl() {
|
private void retrieveUrl() {
|
||||||
changeStatus(STATUS_CHECKING);
|
changeStatus(STATUS_CHECKING);
|
||||||
final Account account = message.getConversation().getAccount();
|
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) -> {
|
mXmppConnectionService.sendIqPacket(message.getConversation().getAccount(), request, (a, packet) -> {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
String download = packet.query().getAttribute("download");
|
String download = packet.query().getAttribute("download");
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SlotRequester {
|
||||||
Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD_LEGACY);
|
Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD_LEGACY);
|
||||||
requestHttpUploadLegacy(account, host, file, mime, callback);
|
requestHttpUploadLegacy(account, host, file, mime, callback);
|
||||||
} else {
|
} else {
|
||||||
requestP1S3(account, Jid.of(account.getServer()), file.getName(), md5, callback);
|
requestP1S3(account, account.getDomain(), file.getName(), md5, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractParser {
|
||||||
|
|
||||||
public static MucOptions.User parseItem(Conversation conference, Element item, Jid fullJid) {
|
public static MucOptions.User parseItem(Conversation conference, Element item, Jid fullJid) {
|
||||||
final String local = conference.getJid().getLocal();
|
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 affiliation = item.getAttribute("affiliation");
|
||||||
String role = item.getAttribute("role");
|
String role = item.getAttribute("role");
|
||||||
String nick = item.getAttribute("nick");
|
String nick = item.getAttribute("nick");
|
||||||
|
|
|
@ -617,7 +617,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
cursor.getString(cursor.getColumnIndex(Account.USERNAME)),
|
cursor.getString(cursor.getColumnIndex(Account.USERNAME)),
|
||||||
cursor.getString(cursor.getColumnIndex(Account.SERVER)),
|
cursor.getString(cursor.getColumnIndex(Account.SERVER)),
|
||||||
null
|
null
|
||||||
).getDomain();
|
).getDomain().toEscapedString();
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
Log.e(Config.LOGTAG, "Failed to migrate Account SERVER "
|
Log.e(Config.LOGTAG, "Failed to migrate Account SERVER "
|
||||||
+ cursor.getString(cursor.getColumnIndex(Account.SERVER))
|
+ cursor.getString(cursor.getColumnIndex(Account.SERVER))
|
||||||
|
|
|
@ -2205,7 +2205,7 @@ public class XmppConnectionService extends Service {
|
||||||
callback.onAccountCreated(account);
|
callback.onAccountCreated(account);
|
||||||
if (Config.X509_VERIFICATION) {
|
if (Config.X509_VERIFICATION) {
|
||||||
try {
|
try {
|
||||||
getMemorizingTrustManager().getNonInteractive(account.getJid().getDomain()).checkClientTrusted(chain, "RSA");
|
getMemorizingTrustManager().getNonInteractive(account.getServer()).checkClientTrusted(chain, "RSA");
|
||||||
} catch (CertificateException e) {
|
} catch (CertificateException e) {
|
||||||
callback.informUser(R.string.certificate_chain_is_not_trusted);
|
callback.informUser(R.string.certificate_chain_is_not_trusted);
|
||||||
}
|
}
|
||||||
|
@ -4160,7 +4160,7 @@ public class XmppConnectionService extends Service {
|
||||||
mucServers.addAll(account.getXmppConnection().getMucServers());
|
mucServers.addAll(account.getXmppConnection().getMucServers());
|
||||||
for (Bookmark bookmark : account.getBookmarks()) {
|
for (Bookmark bookmark : account.getBookmarks()) {
|
||||||
final Jid jid = bookmark.getJid();
|
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) {
|
if (s != null) {
|
||||||
mucServers.add(s);
|
mucServers.add(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -816,7 +816,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
|
|
||||||
private String getUserModeDomain() {
|
private String getUserModeDomain() {
|
||||||
if (mAccount != null && mAccount.getJid().getDomain() != null) {
|
if (mAccount != null && mAccount.getJid().getDomain() != null) {
|
||||||
return mAccount.getJid().getDomain();
|
return mAccount.getServer();
|
||||||
} else {
|
} else {
|
||||||
return Config.DOMAIN_LOCK;
|
return Config.DOMAIN_LOCK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
|
||||||
issuedWarning = true;
|
issuedWarning = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (suspiciousSubDomain(contactJid.getDomain())) {
|
if (suspiciousSubDomain(contactJid.getDomain().toEscapedString())) {
|
||||||
binding.jidLayout.setError(getActivity().getString(R.string.this_looks_like_channel));
|
binding.jidLayout.setError(getActivity().getString(R.string.this_looks_like_channel));
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.add_anway);
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setText(R.string.add_anway);
|
||||||
issuedWarning = true;
|
issuedWarning = true;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
final Account account = extractAccount(intent);
|
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);
|
final String state = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
|
||||||
if (!Intent.ACTION_VIEW.equals(action) || state == null || !END_CARD.contains(RtpEndUserState.valueOf(state))) {
|
if (!Intent.ACTION_VIEW.equals(action) || state == null || !END_CARD.contains(RtpEndUserState.valueOf(state))) {
|
||||||
resetIntent(account, with, RtpEndUserState.RETRACTED, actionToMedia(intent.getAction()));
|
resetIntent(account, with, RtpEndUserState.RETRACTED, actionToMedia(intent.getAction()));
|
||||||
|
@ -246,7 +246,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Account account = extractAccount(intent);
|
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);
|
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
|
||||||
if (sessionId != null) {
|
if (sessionId != null) {
|
||||||
Log.d(Config.LOGTAG, "reinitializing from onNewIntent()");
|
Log.d(Config.LOGTAG, "reinitializing from onNewIntent()");
|
||||||
|
@ -268,7 +268,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
final Account account = extractAccount(intent);
|
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);
|
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
|
||||||
if (sessionId != null) {
|
if (sessionId != null) {
|
||||||
if (initializeActivityWithRunningRtpSession(account, with, sessionId)) {
|
if (initializeActivityWithRunningRtpSession(account, with, sessionId)) {
|
||||||
|
@ -831,7 +831,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
Log.d(Config.LOGTAG, "attempting retry");
|
Log.d(Config.LOGTAG, "attempting retry");
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final Account account = extractAccount(intent);
|
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 lastAction = intent.getStringExtra(EXTRA_LAST_ACTION);
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
final Set<Media> media = actionToMedia(lastAction == null ? action : lastAction);
|
final Set<Media> media = actionToMedia(lastAction == null ? action : lastAction);
|
||||||
|
|
|
@ -870,7 +870,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
protected Account extractAccount(Intent intent) {
|
protected Account extractAccount(Intent intent) {
|
||||||
final String jid = intent != null ? intent.getStringExtra(EXTRA_ACCOUNT) : null;
|
final String jid = intent != null ? intent.getStringExtra(EXTRA_ACCOUNT) : null;
|
||||||
try {
|
try {
|
||||||
return jid != null ? xmppConnectionService.findAccountByJid(Jid.of(jid)) : null;
|
return jid != null ? xmppConnectionService.findAccountByJid(Jid.ofEscaped(jid)) : null;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class IrregularUnicodeDetector {
|
||||||
builder.append('@');
|
builder.append('@');
|
||||||
}
|
}
|
||||||
if (jid.getDomain() != null) {
|
if (jid.getDomain() != null) {
|
||||||
String[] labels = jid.getDomain().split("\\.");
|
String[] labels = jid.getDomain().toEscapedString().split("\\.");
|
||||||
for (int i = 0; i < labels.length; ++i) {
|
for (int i = 0; i < labels.length; ++i) {
|
||||||
SpannableString spannableString = new SpannableString(labels[i]);
|
SpannableString spannableString = new SpannableString(labels[i]);
|
||||||
colorize(spannableString, patternTuple.domain.get(i), color);
|
colorize(spannableString, patternTuple.domain.get(i), color);
|
||||||
|
@ -263,7 +263,7 @@ public class IrregularUnicodeDetector {
|
||||||
} else {
|
} else {
|
||||||
localPattern = null;
|
localPattern = null;
|
||||||
}
|
}
|
||||||
String domain = jid.getDomain();
|
String domain = jid.getDomain().toEscapedString();
|
||||||
final List<Pattern> domainPatterns = new ArrayList<>();
|
final List<Pattern> domainPatterns = new ArrayList<>();
|
||||||
if (domain != null) {
|
if (domain != null) {
|
||||||
for (String label : domain.split("\\.")) {
|
for (String label : domain.split("\\.")) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class JidHelper {
|
||||||
|
|
||||||
public static String localPartOrFallback(Jid jid) {
|
public static String localPartOrFallback(Jid jid) {
|
||||||
if (LOCAL_PART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) {
|
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('.');
|
final int index = domain.indexOf('.');
|
||||||
return index > 1 ? domain.substring(0, index) : domain;
|
return index > 1 ? domain.substring(0, index) : domain;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class InvalidJid implements Jid {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDomain() {
|
public Jid getDomain() {
|
||||||
throw new AssertionError("Not implemented");
|
throw new AssertionError("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,14 @@ public interface Jid extends Comparable<Jid>, Serializable, CharSequence {
|
||||||
|
|
||||||
static Jid ofDomainAndResource(CharSequence domain, CharSequence resource) {
|
static Jid ofDomainAndResource(CharSequence domain, CharSequence resource) {
|
||||||
try {
|
try {
|
||||||
return new WrappedJid(
|
return new WrappedJid(
|
||||||
JidCreate.domainFullFrom(
|
JidCreate.domainFullFrom(
|
||||||
Domainpart.from(domain.toString()),
|
Domainpart.from(domain.toString()),
|
||||||
Resourcepart.from(resource.toString())
|
Resourcepart.from(resource.toString())
|
||||||
));
|
));
|
||||||
} catch (XmppStringprepException e) {
|
} catch (XmppStringprepException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Jid ofLocalAndDomainEscaped(CharSequence local, CharSequence domain) {
|
static Jid ofLocalAndDomainEscaped(CharSequence local, CharSequence domain) {
|
||||||
|
@ -138,7 +138,7 @@ public interface Jid extends Comparable<Jid>, Serializable, CharSequence {
|
||||||
|
|
||||||
String getEscapedLocal();
|
String getEscapedLocal();
|
||||||
|
|
||||||
String getDomain();
|
Jid getDomain();
|
||||||
|
|
||||||
String getResource();
|
String getResource();
|
||||||
|
|
||||||
|
|
|
@ -65,9 +65,8 @@ public class WrappedJid implements eu.siacs.conversations.xmpp.Jid {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDomain() {
|
public eu.siacs.conversations.xmpp.Jid getDomain() {
|
||||||
final Domainpart domainpart = inner.getDomain();
|
return new WrappedJid(inner.asDomainBareJid());
|
||||||
return domainpart == null ? null : domainpart.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class XmppConnection implements Runnable {
|
||||||
throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String domain = account.getJid().getDomain();
|
final String domain = account.getServer();
|
||||||
final List<Resolver.Result> results;
|
final List<Resolver.Result> results;
|
||||||
final boolean hardcoded = extended && !account.getHostname().isEmpty();
|
final boolean hardcoded = extended && !account.getHostname().isEmpty();
|
||||||
if (hardcoded) {
|
if (hardcoded) {
|
||||||
|
@ -434,7 +434,7 @@ public class XmppConnection implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
keyManager = null;
|
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());
|
sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
|
||||||
final SSLSocketFactory factory = sc.getSocketFactory();
|
final SSLSocketFactory factory = sc.getSocketFactory();
|
||||||
final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
|
final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
|
||||||
|
@ -930,7 +930,7 @@ public class XmppConnection implements Runnable {
|
||||||
private void sendRegistryRequest() {
|
private void sendRegistryRequest() {
|
||||||
final IqPacket register = new IqPacket(IqPacket.TYPE.GET);
|
final IqPacket register = new IqPacket(IqPacket.TYPE.GET);
|
||||||
register.query(Namespace.REGISTER);
|
register.query(Namespace.REGISTER);
|
||||||
register.setTo(Jid.of(account.getServer()));
|
register.setTo(account.getDomain());
|
||||||
sendUnmodifiedIqPacket(register, (account, packet) -> {
|
sendUnmodifiedIqPacket(register, (account, packet) -> {
|
||||||
if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
|
if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
|
||||||
return;
|
return;
|
||||||
|
@ -1172,18 +1172,18 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
final boolean requestDiscoItemsFirst = !account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY);
|
final boolean requestDiscoItemsFirst = !account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY);
|
||||||
if (requestDiscoItemsFirst) {
|
if (requestDiscoItemsFirst) {
|
||||||
sendServiceDiscoveryItems(Jid.of(account.getServer()));
|
sendServiceDiscoveryItems(account.getDomain());
|
||||||
}
|
}
|
||||||
if (discoveryResult == null) {
|
if (discoveryResult == null) {
|
||||||
sendServiceDiscoveryInfo(Jid.of(account.getServer()));
|
sendServiceDiscoveryInfo(account.getDomain());
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server caps came from cache");
|
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();
|
discoverMamPreferences();
|
||||||
sendServiceDiscoveryInfo(account.getJid().asBareJid());
|
sendServiceDiscoveryInfo(account.getJid().asBareJid());
|
||||||
if (!requestDiscoItemsFirst) {
|
if (!requestDiscoItemsFirst) {
|
||||||
sendServiceDiscoveryItems(Jid.of(account.getServer()));
|
sendServiceDiscoveryItems(account.getDomain());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mWaitForDisco.get()) {
|
if (!mWaitForDisco.get()) {
|
||||||
|
@ -1202,24 +1202,24 @@ public class XmppConnection implements Runnable {
|
||||||
boolean advancedStreamFeaturesLoaded;
|
boolean advancedStreamFeaturesLoaded;
|
||||||
synchronized (XmppConnection.this.disco) {
|
synchronized (XmppConnection.this.disco) {
|
||||||
ServiceDiscoveryResult result = new ServiceDiscoveryResult(packet);
|
ServiceDiscoveryResult result = new ServiceDiscoveryResult(packet);
|
||||||
if (jid.equals(Jid.of(account.getServer()))) {
|
if (jid.equals(account.getDomain())) {
|
||||||
mXmppConnectionService.databaseBackend.insertDiscoveryResult(result);
|
mXmppConnectionService.databaseBackend.insertDiscoveryResult(result);
|
||||||
}
|
}
|
||||||
disco.put(jid, result);
|
disco.put(jid, result);
|
||||||
advancedStreamFeaturesLoaded = disco.containsKey(Jid.of(account.getServer()))
|
advancedStreamFeaturesLoaded = disco.containsKey(account.getDomain())
|
||||||
&& disco.containsKey(account.getJid().asBareJid());
|
&& 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();
|
enableAdvancedStreamFeatures();
|
||||||
}
|
}
|
||||||
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
|
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not query disco info for " + jid.toString());
|
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;
|
final boolean advancedStreamFeaturesLoaded;
|
||||||
if (serverOrAccount) {
|
if (serverOrAccount) {
|
||||||
synchronized (XmppConnection.this.disco) {
|
synchronized (XmppConnection.this.disco) {
|
||||||
disco.put(jid, ServiceDiscoveryResult.empty());
|
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 {
|
} else {
|
||||||
advancedStreamFeaturesLoaded = false;
|
advancedStreamFeaturesLoaded = false;
|
||||||
|
@ -1285,7 +1285,7 @@ public class XmppConnection implements Runnable {
|
||||||
for (final Element element : elements) {
|
for (final Element element : elements) {
|
||||||
if (element.getName().equals("item")) {
|
if (element.getName().equals("item")) {
|
||||||
final Jid jid = InvalidJid.getNullForInvalid(element.getAttributeAsJid("jid"));
|
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);
|
items.add(jid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1559,7 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
public List<String> getMucServersWithholdAccount() {
|
public List<String> getMucServersWithholdAccount() {
|
||||||
List<String> servers = getMucServers();
|
List<String> servers = getMucServers();
|
||||||
servers.remove(account.getServer());
|
servers.remove(account.getDomain());
|
||||||
return servers;
|
return servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1764,7 +1764,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean carbons() {
|
public boolean carbons() {
|
||||||
return hasDiscoFeature(Jid.of(account.getServer()), "urn:xmpp:carbons:2");
|
return hasDiscoFeature(account.getDomain(), "urn:xmpp:carbons:2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bookmarksConversion() {
|
public boolean bookmarksConversion() {
|
||||||
|
@ -1776,19 +1776,19 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean blocking() {
|
public boolean blocking() {
|
||||||
return hasDiscoFeature(Jid.of(account.getServer()), Namespace.BLOCKING);
|
return hasDiscoFeature(account.getDomain(), Namespace.BLOCKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean spamReporting() {
|
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() {
|
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() {
|
public boolean register() {
|
||||||
return hasDiscoFeature(Jid.of(account.getServer()), Namespace.REGISTER);
|
return hasDiscoFeature(account.getDomain(), Namespace.REGISTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean invite() {
|
public boolean invite() {
|
||||||
|
@ -1837,7 +1837,7 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
public boolean push() {
|
public boolean push() {
|
||||||
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.PUSH)
|
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.PUSH)
|
||||||
|| hasDiscoFeature(Jid.of(account.getServer()), Namespace.PUSH);
|
|| hasDiscoFeature(account.getDomain(), Namespace.PUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean rosterVersioning() {
|
public boolean rosterVersioning() {
|
||||||
|
@ -1849,7 +1849,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean p1S3FileTransfer() {
|
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) {
|
public boolean httpUpload(long filesize) {
|
||||||
|
@ -1903,7 +1903,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean externalServiceDiscovery() {
|
public boolean externalServiceDiscovery() {
|
||||||
return hasDiscoFeature(Jid.of(account.getServer()),Namespace.EXTERNAL_SERVICE_DISCOVERY);
|
return hasDiscoFeature(account.getDomain(),Namespace.EXTERNAL_SERVICE_DISCOVERY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,7 +601,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeakReference<JingleRtpConnection> findJingleRtpConnection(Account account, Jid with, String sessionId) {
|
public WeakReference<JingleRtpConnection> 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);
|
final AbstractJingleConnection connection = connections.get(id);
|
||||||
if (connection instanceof JingleRtpConnection) {
|
if (connection instanceof JingleRtpConnection) {
|
||||||
return new WeakReference<>((JingleRtpConnection) connection);
|
return new WeakReference<>((JingleRtpConnection) connection);
|
||||||
|
|
|
@ -1104,7 +1104,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
private void discoverIceServers(final OnIceServersDiscovered onIceServersDiscovered) {
|
private void discoverIceServers(final OnIceServersDiscovered onIceServersDiscovered) {
|
||||||
if (id.account.getXmppConnection().getFeatures().externalServiceDiscovery()) {
|
if (id.account.getXmppConnection().getFeatures().externalServiceDiscovery()) {
|
||||||
final IqPacket request = new IqPacket(IqPacket.TYPE.GET);
|
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);
|
request.addChild("services", Namespace.EXTERNAL_SERVICE_DISCOVERY);
|
||||||
xmppConnectionService.sendIqPacket(id.account, request, (account, response) -> {
|
xmppConnectionService.sendIqPacket(id.account, request, (account, response) -> {
|
||||||
ImmutableList.Builder<PeerConnection.IceServer> listBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<PeerConnection.IceServer> listBuilder = new ImmutableList.Builder<>();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class AbstractStanza extends Element {
|
||||||
public boolean fromServer(final Account account) {
|
public boolean fromServer(final Account account) {
|
||||||
final Jid from = getFrom();
|
final Jid from = getFrom();
|
||||||
return from == null
|
return from == null
|
||||||
|| from.equals(Jid.of(account.getServer()))
|
|| from.equals(account.getDomain())
|
||||||
|| from.equals(account.getJid().asBareJid())
|
|| from.equals(account.getJid().asBareJid())
|
||||||
|| from.equals(account.getJid());
|
|| from.equals(account.getJid());
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class AbstractStanza extends Element {
|
||||||
public boolean toServer(final Account account) {
|
public boolean toServer(final Account account) {
|
||||||
final Jid to = getTo();
|
final Jid to = getTo();
|
||||||
return to == null
|
return to == null
|
||||||
|| to.equals(Jid.of(account.getServer()))
|
|| to.equals(account.getDomain())
|
||||||
|| to.equals(account.getJid().asBareJid())
|
|| to.equals(account.getJid().asBareJid())
|
||||||
|| to.equals(account.getJid());
|
|| to.equals(account.getJid());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.android.PhoneNumberContact;
|
import eu.siacs.conversations.android.PhoneNumberContact;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import rocks.xmpp.addr.Jid;
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
|
|
||||||
public class Entry implements Comparable<Entry> {
|
public class Entry implements Comparable<Entry> {
|
||||||
private final List<Jid> jids;
|
private final List<Jid> jids;
|
||||||
|
|
|
@ -49,9 +49,9 @@ import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
|
||||||
import eu.siacs.conversations.utils.SerialSingleThreadExecutor;
|
import eu.siacs.conversations.utils.SerialSingleThreadExecutor;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xml.Namespace;
|
import eu.siacs.conversations.xml.Namespace;
|
||||||
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
||||||
import rocks.xmpp.addr.Jid;
|
|
||||||
|
|
||||||
public class QuickConversationsService extends AbstractQuickConversationsService {
|
public class QuickConversationsService extends AbstractQuickConversationsService {
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
import io.michaelrocks.libphonenumber.android.NumberParseException;
|
import io.michaelrocks.libphonenumber.android.NumberParseException;
|
||||||
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil;
|
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil;
|
||||||
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
||||||
import rocks.xmpp.addr.Jid;
|
|
||||||
|
|
||||||
public class PhoneNumberUtilWrapper {
|
public class PhoneNumberUtilWrapper {
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import eu.siacs.conversations.ui.EnterPhoneNumberActivity;
|
||||||
import eu.siacs.conversations.ui.StartConversationActivity;
|
import eu.siacs.conversations.ui.StartConversationActivity;
|
||||||
import eu.siacs.conversations.ui.TosActivity;
|
import eu.siacs.conversations.ui.TosActivity;
|
||||||
import eu.siacs.conversations.ui.VerifyActivity;
|
import eu.siacs.conversations.ui.VerifyActivity;
|
||||||
import rocks.xmpp.addr.Jid;
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
|
|
||||||
public class SignupUtils {
|
public class SignupUtils {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue