From 836a2fa6eb8342599890d619886dd8af198fe60e Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 22 Feb 2017 20:21:47 +0100 Subject: migrate domain and host exemption into seperate class --- .../pixart/messenger/services/XmppConnectionService.java | 7 ++++--- src/main/java/de/pixart/messenger/xmpp/Patches.java | 16 ++++++++++++++++ .../java/de/pixart/messenger/xmpp/XmppConnection.java | 9 +++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/main/java/de/pixart/messenger/xmpp/Patches.java (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 7736aa0ba..72a78362a 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -50,6 +50,7 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection; import java.io.FileDescriptor; import java.io.FileNotFoundException; import java.math.BigInteger; +import java.net.URL; import java.security.SecureRandom; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -98,8 +99,8 @@ import de.pixart.messenger.generator.AbstractGenerator; import de.pixart.messenger.generator.IqGenerator; import de.pixart.messenger.generator.MessageGenerator; import de.pixart.messenger.generator.PresenceGenerator; -import de.pixart.messenger.http.HttpConnectionManager; import de.pixart.messenger.http.AesGcmURLStreamHandlerFactory; +import de.pixart.messenger.http.HttpConnectionManager; import de.pixart.messenger.parser.AbstractParser; import de.pixart.messenger.parser.IqParser; import de.pixart.messenger.parser.MessageParser; @@ -130,6 +131,7 @@ import de.pixart.messenger.xmpp.OnMessagePacketReceived; import de.pixart.messenger.xmpp.OnPresencePacketReceived; import de.pixart.messenger.xmpp.OnStatusChanged; import de.pixart.messenger.xmpp.OnUpdateBlocklist; +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; @@ -144,7 +146,6 @@ 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 java.net.URL; public class XmppConnectionService extends Service { @@ -1247,7 +1248,7 @@ public class XmppConnectionService extends Service { account.deactivateGracePeriod(); MessagePacket packet = null; final boolean addToConversation = (conversation.getMode() != Conversation.MODE_MULTI - || account.getServerIdentity() != XmppConnection.Identity.SLACK) + || !Patches.BAD_MUC_REFLECTION.contains(account.getServerIdentity())) && !message.edited(); boolean saveInDb = addToConversation; message.setStatus(Message.STATUS_WAITING); diff --git a/src/main/java/de/pixart/messenger/xmpp/Patches.java b/src/main/java/de/pixart/messenger/xmpp/Patches.java new file mode 100644 index 000000000..85b32e3d5 --- /dev/null +++ b/src/main/java/de/pixart/messenger/xmpp/Patches.java @@ -0,0 +1,16 @@ +package de.pixart.messenger.xmpp; + +import java.util.Arrays; +import java.util.List; + +public class Patches { + public static final List DISCO_EXCEPTIONS = Arrays.asList( + "nimbuzz.com" + ); + public static final List SUFFICIENT_PUSH = Arrays.asList( + XmppConnection.Identity.EJABBERD + ); + public static final List BAD_MUC_REFLECTION = Arrays.asList( + XmppConnection.Identity.SLACK + ); +} \ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 4a93d1eb6..aba117b77 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -1118,10 +1118,15 @@ public class XmppConnection implements Runnable { synchronized (this.disco) { this.disco.clear(); } + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery"); mPendingServiceDiscoveries.set(0); - mWaitForDisco.set(smVersion != 0 && !account.getJid().getDomainpart().equalsIgnoreCase("nimbuzz.com")); + if (smVersion == 0 || Patches.DISCO_EXCEPTIONS.contains(account.getJid().getDomainpart())) { + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": do not wait for service discovery"); + mWaitForDisco.set(false); + } else { + mWaitForDisco.set(true); + } lastDiscoStarted = SystemClock.elapsedRealtime(); - Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery"); mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); Element caps = streamFeatures.findChild("c"); final String hash = caps == null ? null : caps.getAttribute("hash"); -- cgit v1.2.3