aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java204
1 files changed, 102 insertions, 102 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 85ad64206..730215cdd 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -134,8 +134,7 @@ import de.pixart.messenger.xmpp.Patches;
import de.pixart.messenger.xmpp.XmppConnection;
import de.pixart.messenger.xmpp.chatstate.ChatState;
import de.pixart.messenger.xmpp.forms.Data;
-import de.pixart.messenger.xmpp.jid.InvalidJidException;
-import de.pixart.messenger.xmpp.jid.Jid;
+import de.pixart.messenger.xmpp.jid.OtrJidHelper;
import de.pixart.messenger.xmpp.jingle.JingleConnectionManager;
import de.pixart.messenger.xmpp.jingle.OnJinglePacketReceived;
import de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket;
@@ -145,6 +144,7 @@ import de.pixart.messenger.xmpp.stanzas.IqPacket;
import de.pixart.messenger.xmpp.stanzas.MessagePacket;
import de.pixart.messenger.xmpp.stanzas.PresencePacket;
import me.leolin.shortcutbadger.ShortcutBadger;
+import rocks.xmpp.addr.Jid;
public class XmppConnectionService extends Service {
@@ -205,7 +205,7 @@ public class XmppConnectionService extends Service {
Element error = packet.findChild("error");
String text = error != null ? error.findChildContent("text") : null;
if (text != null) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": received iq error - " + text);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received iq error - " + text);
}
}
}
@@ -296,7 +296,7 @@ public class XmppConnectionService extends Service {
synchronized (mInProgressAvatarFetches) {
for (Iterator<String> iterator = mInProgressAvatarFetches.iterator(); iterator.hasNext(); ) {
final String KEY = iterator.next();
- if (KEY.startsWith(account.getJid().toBareJid() + "_")) {
+ if (KEY.startsWith(account.getJid().asBareJid() + "_")) {
iterator.remove();
}
}
@@ -313,7 +313,7 @@ public class XmppConnectionService extends Service {
if (flexible && catchup) {
sendIqPacket(account, mIqGenerator.purgeOfflineMessages(), (acc, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
- Log.d(Config.LOGTAG, acc.getJid().toBareJid() + ": successfully purged offline messages");
+ Log.d(Config.LOGTAG, acc.getJid().asBareJid() + ": successfully purged offline messages");
}
});
}
@@ -339,8 +339,8 @@ public class XmppConnectionService extends Service {
}
if (account.getStatus() == Account.State.ONLINE) {
synchronized (mLowPingTimeoutMode) {
- if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode");
+ if (mLowPingTimeoutMode.remove(account.getJid().asBareJid())) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": leaving low ping timeout mode");
}
}
if (account.setShowErrorNotification(true)) {
@@ -349,10 +349,10 @@ public class XmppConnectionService extends Service {
mMessageArchiveService.executePendingQueries(account);
if (connection != null && connection.getFeatures().csi()) {
if (checkListeners()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " sending csi//inactive");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " sending csi//inactive");
connection.sendInactive();
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " sending csi//active");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " sending csi//active");
connection.sendActive();
}
}
@@ -361,7 +361,7 @@ public class XmppConnectionService extends Service {
if (conversation.getAccount() == account
&& !account.pendingConferenceJoins.contains(conversation)) {
if (!conversation.startOtrIfNeeded()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
}
checkDeletedFiles(conversation);
sendUnsentMessages(conversation);
@@ -380,7 +380,7 @@ public class XmppConnectionService extends Service {
} else if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) {
resetSendingToWaiting(account);
if (account.isEnabled() && isInLowPingTimeoutMode(account)) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": went into offline state during low ping mode. reconnecting now");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": went into offline state during low ping mode. reconnecting now");
reconnectAccount(account, true, false);
} else {
int timeToReconnect = mRandom.nextInt(10) + 2;
@@ -395,11 +395,11 @@ public class XmppConnectionService extends Service {
final int next = connection.getTimeToNextAttempt();
final boolean lowPingTimeoutMode = isInLowPingTimeoutMode(account);
if (next <= 0) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error connecting account. reconnecting now. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode));
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. reconnecting now. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode));
reconnectAccount(account, true, false);
} else {
final int attempt = connection.getAttempt() + 1;
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt + " time. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode));
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt + " time. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode));
scheduleWakeUpCall(next, account.getUuid().hashCode());
}
}
@@ -410,7 +410,7 @@ public class XmppConnectionService extends Service {
private boolean isInLowPingTimeoutMode(Account account) {
synchronized (mLowPingTimeoutMode) {
- return mLowPingTimeoutMode.contains(account.getJid().toBareJid());
+ return mLowPingTimeoutMode.contains(account.getJid().asBareJid());
}
}
@@ -433,7 +433,7 @@ public class XmppConnectionService extends Service {
public final CountDownLatch restoredFromDatabaseLatch = new CountDownLatch(1);
private static String generateFetchKey(Account account, final Avatar avatar) {
- return account.getJid().toBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
+ return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
}
public boolean areMessagesInitialized() {
@@ -525,7 +525,7 @@ public class XmppConnectionService extends Service {
if ("never".equals(compressPictures)
|| ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri))
|| (mimeType != null && mimeType.endsWith("/gif"))) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": not compressing picture. sending as file");
+ Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": not compressing picture. sending as file");
attachFileToConversation(conversation, uri, mimeType, callback);
return;
}
@@ -715,7 +715,7 @@ public class XmppConnectionService extends Service {
}
final boolean lowTimeout = isInLowPingTimeoutMode(account);
account.getXmppConnection().sendPing();
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action=" + action + ", lowTimeout=" + Boolean.toString(lowTimeout) + ")");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " send ping (action=" + action + ", lowTimeout=" + Boolean.toString(lowTimeout) + ")");
scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode());
}
}
@@ -753,11 +753,11 @@ public class XmppConnectionService extends Service {
long lastSent = account.getXmppConnection().getLastPingSent();
long pingInterval = isUiAction ? Config.PING_MIN_INTERVAL * 1000 : Config.PING_MAX_INTERVAL * 1000;
long msToNextPing = (Math.max(lastReceived, lastSent) + pingInterval) - SystemClock.elapsedRealtime();
- int pingTimeout = mLowPingTimeoutMode.contains(account.getJid().toBareJid()) ? Config.LOW_PING_TIMEOUT * 1000 : Config.PING_TIMEOUT * 1000;
+ int pingTimeout = mLowPingTimeoutMode.contains(account.getJid().asBareJid()) ? Config.LOW_PING_TIMEOUT * 1000 : Config.PING_TIMEOUT * 1000;
long pingTimeoutIn = (lastSent + pingTimeout) - SystemClock.elapsedRealtime();
if (lastSent > lastReceived) {
if (pingTimeoutIn < 0) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": ping timeout");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ping timeout");
this.reconnectAccount(account, true, interactive);
} else {
int secs = (int) (pingTimeoutIn / 1000);
@@ -767,15 +767,15 @@ public class XmppConnectionService extends Service {
pingCandidates.add(account);
if (isAccountPushed) {
pingNow = true;
- if (mLowPingTimeoutMode.add(account.getJid().toBareJid())) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": entering low ping timeout mode");
+ if (mLowPingTimeoutMode.add(account.getJid().asBareJid())) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": entering low ping timeout mode");
}
} else if (msToNextPing <= 0) {
pingNow = true;
} else {
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
- if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode");
+ if (mLowPingTimeoutMode.remove(account.getJid().asBareJid())) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": leaving low ping timeout mode");
}
}
@@ -983,7 +983,7 @@ public class XmppConnectionService extends Service {
private void dismissErrorNotifications() {
for (final Account account : this.accounts) {
if (account.hasErrorStatus()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": dismissing error notification");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": dismissing error notification");
if (account.setShowErrorNotification(false)) {
databaseBackend.updateAccount(account);
}
@@ -1359,8 +1359,8 @@ public class XmppConnectionService extends Service {
SessionImpl otrSession = conversation.getOtrSession();
if (otrSession != null && otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
- message.setCounterpart(Jid.fromSessionID(otrSession.getSessionID()));
- } catch (InvalidJidException e) {
+ message.setCounterpart(OtrJidHelper.fromSessionID(otrSession.getSessionID()));
+ } catch (IllegalArgumentException e) {
break;
}
if (message.needsUploading()) {
@@ -1370,13 +1370,13 @@ public class XmppConnectionService extends Service {
}
} else if (otrSession == null) {
if (message.fixCounterpart()) {
- conversation.startOtrSession(message.getCounterpart().getResourcepart(), true);
+ conversation.startOtrSession(message.getCounterpart().getResource(), true);
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not fix counterpart for OTR message to contact " + message.getCounterpart());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not fix counterpart for OTR message to contact " + message.getCounterpart());
break;
}
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " OTR session with " + message.getContact() + " is in wrong state: " + otrSession.getSessionStatus().toString());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " OTR session with " + message.getContact() + " is in wrong state: " + otrSession.getSessionStatus().toString());
}
break;
case Message.ENCRYPTION_AXOLOTL:
@@ -1431,8 +1431,8 @@ public class XmppConnectionService extends Service {
break;
case Message.ENCRYPTION_OTR:
if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": create otr session without starting for " + message.getContact().getJid());
- conversation.startOtrSession(message.getCounterpart().getResourcepart(), false);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": create otr session without starting for " + message.getContact().getJid());
+ conversation.startOtrSession(message.getCounterpart().getResource(), false);
}
break;
case Message.ENCRYPTION_AXOLOTL:
@@ -1508,10 +1508,10 @@ public class XmppConnectionService extends Service {
public void fetchRosterFromServer(final Account account) {
final IqPacket iqPacket = new IqPacket(IqPacket.TYPE.GET);
if (!"".equals(account.getRosterVersion())) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": fetching roster version " + account.getRosterVersion());
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching roster");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": fetching roster");
}
iqPacket.query(Namespace.ROSTER).setAttribute("ver", account.getRosterVersion());
sendIqPacket(account, iqPacket, mIqParser);
@@ -1550,7 +1550,7 @@ public class XmppConnectionService extends Service {
}
account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks.values()));
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not fetch bookmarks");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not fetch bookmarks");
}
}
};
@@ -1558,7 +1558,7 @@ public class XmppConnectionService extends Service {
}
public void pushBookmarks(Account account) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": pushing bookmarks");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": pushing bookmarks");
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
Element query = iqPacket.query("jabber:iq:private");
Element storage = query.addChild("storage", "storage:bookmarks");
@@ -1648,8 +1648,8 @@ public class XmppConnectionService extends Service {
for (Bundle phoneContact : phoneContacts) {
Jid jid;
try {
- jid = Jid.fromString(phoneContact.getString("jid"));
- } catch (final InvalidJidException e) {
+ jid = Jid.of(phoneContact.getString("jid"));
+ } catch (final IllegalArgumentException e) {
continue;
}
final Contact contact = account.getRoster().getContact(jid);
@@ -1817,7 +1817,7 @@ public class XmppConnectionService extends Service {
}
for (final Conversation conversation : haystack) {
if ((account == null || conversation.getAccount() == account)
- && (conversation.getJid().toBareJid().equals(jid.toBareJid()))) {
+ && (conversation.getJid().asBareJid().equals(jid.asBareJid()))) {
return conversation;
}
}
@@ -1861,7 +1861,7 @@ public class XmppConnectionService extends Service {
conversation.setContactJid(jid);
} else {
conversation.setMode(Conversation.MODE_SINGLE);
- conversation.setContactJid(jid.toBareJid());
+ conversation.setContactJid(jid.asBareJid());
}
databaseBackend.updateConversation(conversation);
loadMessagesFromDb = conversation.messagesLoaded.compareAndSet(true,false);
@@ -1871,13 +1871,13 @@ public class XmppConnectionService extends Service {
if (contact != null) {
conversationName = contact.getDisplayName();
} else {
- conversationName = jid.getLocalpart();
+ conversationName = jid.getLocal();
}
if (muc) {
conversation = new Conversation(conversationName, account, jid,
Conversation.MODE_MULTI);
} else {
- conversation = new Conversation(conversationName, account, jid.toBareJid(),
+ conversation = new Conversation(conversationName, account, jid.asBareJid(),
Conversation.MODE_SINGLE);
}
this.databaseBackend.createConversation(conversation);
@@ -1935,7 +1935,7 @@ public class XmppConnectionService extends Service {
conversation.setContactJid(jid);
} else {
conversation.setMode(Conversation.MODE_SINGLE);
- conversation.setContactJid(jid.toBareJid());
+ conversation.setContactJid(jid.asBareJid());
}
databaseBackend.updateConversation(conversation);
loadMessagesFromDb = conversation.messagesLoaded.compareAndSet(true,false);
@@ -1945,13 +1945,13 @@ public class XmppConnectionService extends Service {
if (contact != null) {
conversationName = contact.getDisplayName();
} else {
- conversationName = jid.getLocalpart();
+ conversationName = jid.getLocal();
}
if (muc) {
conversation = new Conversation(conversationName, account, jid,
Conversation.MODE_MULTI);
} else {
- conversation = new Conversation(conversationName, account, jid.toBareJid(),
+ conversation = new Conversation(conversationName, account, jid.asBareJid(),
Conversation.MODE_SINGLE);
}
this.databaseBackend.createConversation(conversation);
@@ -2041,7 +2041,7 @@ public class XmppConnectionService extends Service {
callback.onAccountCreated(account);
if (Config.X509_VERIFICATION) {
try {
- getMemorizingTrustManager().getNonInteractive(account.getJid().getDomainpart()).checkClientTrusted(chain, "RSA");
+ getMemorizingTrustManager().getNonInteractive(account.getJid().getDomain()).checkClientTrusted(chain, "RSA");
} catch (CertificateException e) {
callback.informUser(R.string.certificate_chain_is_not_trusted);
}
@@ -2057,16 +2057,16 @@ public class XmppConnectionService extends Service {
}
public void updateKeyInAccount(final Account account, final String alias) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": update key in account " + alias);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": update key in account " + alias);
try {
X509Certificate[] chain = KeyChain.getCertificateChain(XmppConnectionService.this, alias);
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " loaded certificate chain");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " loaded certificate chain");
Pair<Jid, String> info = CryptoHelper.extractJidAndName(chain[0]);
if (info == null) {
showErrorToastInUi(R.string.certificate_does_not_contain_jid);
return;
}
- if (account.getJid().toBareJid().equals(info.first)) {
+ if (account.getJid().asBareJid().equals(info.first)) {
account.setPrivateKeyAlias(alias);
account.setDisplayName(info.second);
databaseBackend.updateAccount(account);
@@ -2133,7 +2133,7 @@ public class XmppConnectionService extends Service {
}
final Runnable runnable = () -> {
if (!databaseBackend.deleteAccount(account)) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": unable to delete account");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to delete account");
}
};
mDatabaseWriterExecutor.execute(runnable);
@@ -2444,7 +2444,7 @@ public class XmppConnectionService extends Service {
Account account = conversation.getAccount();
final MucOptions mucOptions = conversation.getMucOptions();
final Jid joinJid = mucOptions.getSelf().getFullJid();
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": joining conversation " + joinJid.toString());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": joining conversation " + joinJid.toString());
PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, mucOptions.nonanonymous() || onConferenceJoined != null);
packet.setTo(joinJid);
Element x = packet.addChild("x", "http://jabber.org/protocol/muc");
@@ -2536,7 +2536,7 @@ public class XmppConnectionService extends Service {
}
} else {
success = false;
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not request affiliation " + affiliations[i] + " in " + conversation.getJid().toBareJid());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not request affiliation " + affiliations[i] + " in " + conversation.getJid().asBareJid());
}
++i;
if (i >= affiliations.length) {
@@ -2548,7 +2548,7 @@ public class XmppConnectionService extends Service {
Jid jid = iterator.next();
if (!members.contains(jid)) {
iterator.remove();
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
changed = true;
}
}
@@ -2557,7 +2557,7 @@ public class XmppConnectionService extends Service {
updateConversation(conversation);
}
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": retrieved members for " + conversation.getJid().toBareJid() + ": " + conversation.getMucOptions().getMembers());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved members for " + conversation.getJid().asBareJid() + ": " + conversation.getMucOptions().getMembers());
getAvatarService().clear(conversation);
updateMucRosterUi();
updateConversationUi();
@@ -2567,7 +2567,7 @@ public class XmppConnectionService extends Service {
for (String affiliation : affiliations) {
sendIqPacket(account, mIqGenerator.queryAffiliation(conversation, affiliation), callback);
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching members for " + conversation.getName());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": fetching members for " + conversation.getName());
}
public void providePasswordForMuc(Conversation conversation, String password) {
@@ -2603,8 +2603,8 @@ public class XmppConnectionService extends Service {
}
Bookmark bookmark = conversation.getBookmark();
- if (bookmark != null && !full.getResourcepart().equals(bookmark.getNick())) {
- bookmark.setNick(full.getResourcepart());
+ if (bookmark != null && !full.getResource().equals(bookmark.getNick())) {
+ bookmark.setNick(full.getResource());
pushBookmarks(bookmark.getAccount());
}
}
@@ -2670,7 +2670,7 @@ public class XmppConnectionService extends Service {
if (bookmark != null) {
bookmark.setConversation(null);
}
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": leaving muc " + conversation.getJid());
+ Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": leaving muc " + conversation.getJid());
} else {
account.pendingConferenceLeaves.add(conversation);
}
@@ -2699,7 +2699,7 @@ public class XmppConnectionService extends Service {
final String subject,
final Iterable<Jid> jids,
final UiCallback<Conversation> callback) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": creating adhoc conference with " + jids.toString());
if (account.getStatus() == Account.State.ONLINE) {
try {
String server = findConferenceServer(account);
@@ -2709,7 +2709,7 @@ public class XmppConnectionService extends Service {
}
return false;
}
- final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null);
+ final Jid jid = Jid.of(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null);
final Conversation conversation = findOrCreateConversation(account, jid, true, false, true);
joinMuc(conversation, new OnConferenceJoined() {
@Override
@@ -2724,7 +2724,7 @@ public class XmppConnectionService extends Service {
invite(conversation, invite);
}
if (account.countPresences() > 1) {
- directInvite(conversation, account.getJid().toBareJid());
+ directInvite(conversation, account.getJid().asBareJid());
}
saveConversationAsBookmark(conversation, subject);
if (callback != null) {
@@ -2743,7 +2743,7 @@ public class XmppConnectionService extends Service {
}
});
return true;
- } catch (InvalidJidException e) {
+ } catch (IllegalArgumentException e) {
if (callback != null) {
callback.error(R.string.conference_creation_failed, null);
}
@@ -2763,7 +2763,7 @@ public class XmppConnectionService extends Service {
public void fetchConferenceConfiguration(final Conversation conversation, final OnConferenceConfigurationFetched callback) {
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
- request.setTo(conversation.getJid().toBareJid());
+ request.setTo(conversation.getJid().asBareJid());
request.query("http://jabber.org/protocol/disco#info");
sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {
@Override
@@ -2787,7 +2787,7 @@ public class XmppConnectionService extends Service {
if (callback != null) {
callback.onConferenceConfigurationFetched(conversation);
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetched muc configuration for " + conversation.getJid().toBareJid() + " - " + features.toString());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": fetched muc configuration for " + conversation.getJid().asBareJid() + " - " + features.toString());
updateConversationUi();
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
if (callback != null) {
@@ -2799,7 +2799,7 @@ public class XmppConnectionService extends Service {
}
public void pushNodeConfiguration(Account account, final String node, final Bundle options, final OnConfigurationPushed callback) {
- pushNodeConfiguration(account, account.getJid().toBareJid(), node, options, callback);
+ pushNodeConfiguration(account, account.getJid().asBareJid(), node, options, callback);
}
public void pushNodeConfiguration(Account account, final Jid jid, final String node, final Bundle options, final OnConfigurationPushed callback) {
@@ -2835,7 +2835,7 @@ public class XmppConnectionService extends Service {
public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConfigurationPushed callback) {
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
- request.setTo(conversation.getJid().toBareJid());
+ request.setTo(conversation.getJid().asBareJid());
request.query("http://jabber.org/protocol/muc#owner");
sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {
@Override
@@ -2844,7 +2844,7 @@ public class XmppConnectionService extends Service {
Data data = Data.parse(packet.query().findChild("x", Namespace.DATA));
data.submit(options);
IqPacket set = new IqPacket(IqPacket.TYPE.SET);
- set.setTo(conversation.getJid().toBareJid());
+ set.setTo(conversation.getJid().asBareJid());
set.query("http://jabber.org/protocol/muc#owner").addChild(data);
sendIqPacket(account, set, new OnIqPacketReceived() {
@Override
@@ -2881,7 +2881,7 @@ public class XmppConnectionService extends Service {
}
public void changeAffiliationInConference(final Conversation conference, Jid user, final MucOptions.Affiliation affiliation, final OnAffiliationChanged callback) {
- final Jid jid = user.toBareJid();
+ final Jid jid = user.asBareJid();
IqPacket request = this.mIqGenerator.changeAffiliation(conference, jid, affiliation.toString());
sendIqPacket(conference.getAccount(), request, new OnIqPacketReceived() {
@Override
@@ -2963,7 +2963,7 @@ public class XmppConnectionService extends Service {
leaveMuc(conversation, true);
} else {
if (conversation.endOtrIfNeeded()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": ended otr session with "
+ conversation.getJid());
}
@@ -3014,7 +3014,7 @@ public class XmppConnectionService extends Service {
final Account account = conversation.getAccount();
final Session otrSession = conversation.getOtrSession();
Log.d(Config.LOGTAG,
- account.getJid().toBareJid() + " otr session established with "
+ account.getJid().asBareJid() + " otr session established with "
+ conversation.getJid() + "/"
+ otrSession.getSessionID().getUserID());
conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {
@@ -3023,8 +3023,8 @@ public class XmppConnectionService extends Service {
public void onMessageFound(Message message) {
SessionID id = otrSession.getSessionID();
try {
- message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
- } catch (InvalidJidException e) {
+ message.setCounterpart(Jid.of(id.getAccountID() + "/" + id.getUserID()));
+ } catch (IllegalArgumentException e) {
return;
}
if (message.needsUploading()) {
@@ -3125,7 +3125,7 @@ public class XmppConnectionService extends Service {
getAvatarService().clear(account);
databaseBackend.updateAccount(account);
}
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": published avatar "+(avatar.size/1024)+"KiB");
+ Log.d(Config.LOGTAG,account.getJid().asBareJid()+": published avatar "+(avatar.size/1024)+"KiB");
if (callback != null) {
callback.success(avatar);
}
@@ -3138,7 +3138,7 @@ public class XmppConnectionService extends Service {
});
} else {
Element error = result.findChild("error");
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server rejected avatar "+(avatar.size/1024)+"KiB "+(error!=null?error.toString():""));
+ Log.d(Config.LOGTAG,account.getJid().asBareJid()+": server rejected avatar "+(avatar.size/1024)+"KiB "+(error!=null?error.toString():""));
if (callback != null) {
callback.error(R.string.error_publish_avatar_server_reject, avatar);
}
@@ -3149,7 +3149,7 @@ public class XmppConnectionService extends Service {
public void republishAvatarIfNeeded(Account account) {
if (account.getAxolotlService().isPepBroken()) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": skipping republication of avatar because pep is broken");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": skipping republication of avatar because pep is broken");
return;
}
IqPacket packet = this.mIqGenerator.retrieveAvatarMetaData(null);
@@ -3180,10 +3180,10 @@ public class XmppConnectionService extends Service {
if (serverAvatar == null && account.getAvatar() != null) {
Avatar avatar = fileBackend.getStoredPepAvatar(account.getAvatar());
if (avatar != null) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": avatar on server was null. republishing");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": avatar on server was null. republishing");
publishAvatar(account, fileBackend.getStoredPepAvatar(account.getAvatar()), null);
} else {
- Log.e(Config.LOGTAG, account.getJid().toBareJid() + ": error rereading avatar");
+ Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": error rereading avatar");
}
}
}
@@ -3222,13 +3222,13 @@ public class XmppConnectionService extends Service {
synchronized (mInProgressAvatarFetches) {
mInProgressAvatarFetches.remove(generateFetchKey(account, avatar));
}
- final String ERROR = account.getJid().toBareJid()
+ final String ERROR = account.getJid().asBareJid()
+ ": fetching avatar for " + avatar.owner + " failed ";
if (result.getType() == IqPacket.TYPE.RESULT) {
avatar.image = mIqParser.avatarData(result);
if (avatar.image != null) {
if (getFileBackend().save(avatar)) {
- if (account.getJid().toBareJid().equals(avatar.owner)) {
+ if (account.getJid().asBareJid().equals(avatar.owner)) {
if (account.setAvatar(avatar.getFilename())) {
databaseBackend.updateAccount(account);
}
@@ -3246,7 +3246,7 @@ public class XmppConnectionService extends Service {
if (callback != null) {
callback.success(avatar);
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": successfully fetched pep avatar for " + avatar.owner);
return;
}
@@ -3285,11 +3285,11 @@ public class XmppConnectionService extends Service {
if (image != null) {
avatar.image = image;
if (getFileBackend().save(avatar)) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": successfully fetched vCard avatar for " + avatar.owner);
if (avatar.owner.isBareJid()) {
- if (account.getJid().toBareJid().equals(avatar.owner) && account.getAvatar() == null) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": had no avatar. replacing with vcard");
+ if (account.getJid().asBareJid().equals(avatar.owner) && account.getAvatar() == null) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": had no avatar. replacing with vcard");
account.setAvatar(avatar.getFilename());
databaseBackend.updateAccount(account);
getAvatarService().clear(account);
@@ -3302,7 +3302,7 @@ public class XmppConnectionService extends Service {
}
updateConversationUi();
} else {
- Conversation conversation = find(account, avatar.owner.toBareJid());
+ Conversation conversation = find(account, avatar.owner.asBareJid());
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
MucOptions.User user = conversation.getMucOptions().findUserByFullJid(avatar.owner);
if (user != null) {
@@ -3334,7 +3334,7 @@ public class XmppConnectionService extends Service {
if (items != null) {
Avatar avatar = Avatar.parseMetadata(items);
if (avatar != null) {
- avatar.owner = account.getJid().toBareJid();
+ avatar.owner = account.getJid().asBareJid();
if (fileBackend.isAvatarCached(avatar)) {
if (account.setAvatar(avatar.getFilename())) {
databaseBackend.updateAccount(account);
@@ -3420,7 +3420,7 @@ public class XmppConnectionService extends Service {
}
public void invite(Conversation conversation, Jid contact) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": inviting " + contact + " to " + conversation.getJid().toBareJid());
+ Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": inviting " + contact + " to " + conversation.getJid().asBareJid());
MessagePacket packet = mMessageGenerator.invite(conversation, contact);
sendMessagePacket(conversation.getAccount(), packet);
}
@@ -3431,7 +3431,7 @@ public class XmppConnectionService extends Service {
}
public void resetSendingToWaiting(Account account) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": reset 'sending' messages to 'waiting'");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": reset 'sending' messages to 'waiting'");
for (Conversation conversation : getConversations()) {
if (conversation.getAccount() == account) {
conversation.findUnsentTextMessages(new Conversation.OnMessageFound() {
@@ -3454,7 +3454,7 @@ public class XmppConnectionService extends Service {
return null;
}
for (Conversation conversation : getConversations()) {
- if (conversation.getJid().toBareJid().equals(recipient) && conversation.getAccount() == account) {
+ if (conversation.getJid().asBareJid().equals(recipient) && conversation.getAccount() == account) {
final Message message = conversation.findSentMessageWithUuidOrRemoteId(uuid);
if (message != null) {
markMessage(message, status, errorMessage);
@@ -3630,7 +3630,7 @@ public class XmppConnectionService extends Service {
public Account findAccountByJid(final Jid accountJid) {
for (Account account : this.accounts) {
- if (account.getJid().toBareJid().equals(accountJid.toBareJid())) {
+ if (account.getJid().asBareJid().equals(accountJid.asBareJid())) {
return account;
}
}
@@ -3701,7 +3701,7 @@ public class XmppConnectionService extends Service {
&& markable != null
&& (markable.trusted() || isPrivateAndNonAnonymousMuc)
&& markable.getRemoteMsgId() != null) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
+ Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": sending read marker to " + markable.getCounterpart().toString());
Account account = conversation.getAccount();
final Jid to = markable.getCounterpart();
final boolean groupChat = conversation.getMode() == Conversation.MODE_MULTI;
@@ -3787,7 +3787,7 @@ public class XmppConnectionService extends Service {
}
for (Bookmark bookmark : account.getBookmarks()) {
final Jid jid = bookmark.getJid();
- final String s = jid == null ? null : jid.getDomainpart();
+ final String s = jid == null ? null : jid.getDomain();
if (s != null && !mucServers.contains(s)) {
mucServers.add(s);
}
@@ -3873,7 +3873,7 @@ public class XmppConnectionService extends Service {
}
private void sendOfflinePresence(final Account account) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending offline presence");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending offline presence");
sendPresencePacket(account, mPresenceGenerator.sendOfflinePresence(account));
}
@@ -3905,7 +3905,7 @@ public class XmppConnectionService extends Service {
ArrayList<Contact> contacts = new ArrayList<>();
for (Account account : getAccounts()) {
if ((account.isEnabled() || accountJid != null)
- && (accountJid == null || accountJid.equals(account.getJid().toBareJid().toString()))) {
+ && (accountJid == null || accountJid.equals(account.getJid().asBareJid().toString()))) {
Contact contact = account.getRoster().getContactFromRoster(jid);
if (contact != null) {
contacts.add(contact);
@@ -3917,7 +3917,7 @@ public class XmppConnectionService extends Service {
public Conversation findFirstMuc(Jid jid) {
for (Conversation conversation : getConversations()) {
- if (conversation.getAccount().isEnabled() && conversation.getJid().toBareJid().equals(jid.toBareJid()) && conversation.getMode() == Conversation.MODE_MULTI) {
+ if (conversation.getAccount().isEnabled() && conversation.getJid().asBareJid().equals(jid.asBareJid()) && conversation.getMode() == Conversation.MODE_MULTI) {
return conversation;
}
}
@@ -4004,17 +4004,17 @@ public class XmppConnectionService extends Service {
public boolean removeBlockedConversations(final Account account, final Jid blockedJid) {
boolean removed = false;
synchronized (this.conversations) {
- boolean domainJid = blockedJid.isDomainJid();
+ boolean domainJid = blockedJid.getLocal() == null;
for (Conversation conversation : this.conversations) {
- boolean jidMatches = (domainJid && blockedJid.getDomainpart().equals(conversation.getJid().getDomainpart()))
- || blockedJid.equals(conversation.getJid().toBareJid());
+ boolean jidMatches = (domainJid && blockedJid.getDomain().equals(conversation.getJid().getDomain()))
+ || blockedJid.equals(conversation.getJid().asBareJid());
if (conversation.getAccount() == account
&& conversation.getMode() == Conversation.MODE_SINGLE
&& jidMatches) {
this.conversations.remove(conversation);
markRead(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED);
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": archiving conversation " + conversation.getJid().toBareJid() + " because jid was blocked");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conversation " + conversation.getJid().asBareJid() + " because jid was blocked");
updateConversation(conversation);
removed = true;
}
@@ -4046,7 +4046,7 @@ public class XmppConnectionService extends Service {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.ERROR) {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not publish nick");
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not publish nick");
}
}
});
@@ -4077,7 +4077,7 @@ public class XmppConnectionService extends Service {
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
request.setTo(jid);
request.query("http://jabber.org/protocol/disco#info");
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": making disco request for " + key.second + " to " + jid);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid);
sendIqPacket(account, request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket discoPacket) {
@@ -4087,7 +4087,7 @@ public class XmppConnectionService extends Service {
databaseBackend.insertDiscoveryResult(disco);
injectServiceDiscorveryResult(account.getRoster(), presence.getHash(), presence.getVer(), disco);
} else {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco.getVer());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco.getVer());
}
}
account.inProgressDiscoFetches.remove(key);
@@ -4163,9 +4163,9 @@ public class XmppConnectionService extends Service {
public void saveConversationAsBookmark(Conversation conversation, String name) {
Account account = conversation.getAccount();
- Bookmark bookmark = new Bookmark(account, conversation.getJid().toBareJid());
+ Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
if (!conversation.getJid().isBareJid()) {
- bookmark.setNick(conversation.getJid().getResourcepart());
+ bookmark.setNick(conversation.getJid().getResource());
}
if (name != null && !name.trim().isEmpty()) {
bookmark.setBookmarkName(name.trim());