diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-02-22 20:21:47 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-02-22 20:49:04 +0100 |
commit | 836a2fa6eb8342599890d619886dd8af198fe60e (patch) | |
tree | 1639deb3569229b61c13180b555fce96897c133f /src/main/java/de/pixart | |
parent | 472a08daad551e312ca7ca3b3bf30957f7f99b35 (diff) |
migrate domain and host exemption into seperate class
Diffstat (limited to 'src/main/java/de/pixart')
3 files changed, 27 insertions, 5 deletions
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<String> DISCO_EXCEPTIONS = Arrays.asList( + "nimbuzz.com" + ); + public static final List<XmppConnection.Identity> SUFFICIENT_PUSH = Arrays.asList( + XmppConnection.Identity.EJABBERD + ); + public static final List<XmppConnection.Identity> 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"); |