migrate domain and host exemption into seperate class

This commit is contained in:
Daniel Gultsch 2017-02-19 13:05:40 +01:00
parent abaabae853
commit 0d00ff0c15
4 changed files with 29 additions and 5 deletions

View file

@ -126,6 +126,7 @@ import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
import eu.siacs.conversations.xmpp.OnPresencePacketReceived; import eu.siacs.conversations.xmpp.OnPresencePacketReceived;
import eu.siacs.conversations.xmpp.OnStatusChanged; import eu.siacs.conversations.xmpp.OnStatusChanged;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.Patches;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
@ -1200,7 +1201,7 @@ public class XmppConnectionService extends Service {
account.deactivateGracePeriod(); account.deactivateGracePeriod();
MessagePacket packet = null; MessagePacket packet = null;
final boolean addToConversation = (conversation.getMode() != Conversation.MODE_MULTI final boolean addToConversation = (conversation.getMode() != Conversation.MODE_MULTI
|| account.getServerIdentity() != XmppConnection.Identity.SLACK) || !Patches.BAD_MUC_REFLECTION.contains(account.getServerIdentity()))
&& !message.edited(); && !message.edited();
boolean saveInDb = addToConversation; boolean saveInDb = addToConversation;
message.setStatus(Message.STATUS_WAITING); message.setStatus(Message.STATUS_WAITING);

View file

@ -0,0 +1,17 @@
package eu.siacs.conversations.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
);
}

View file

@ -1088,10 +1088,15 @@ public class XmppConnection implements Runnable {
synchronized (this.disco) { synchronized (this.disco) {
this.disco.clear(); this.disco.clear();
} }
mPendingServiceDiscoveries.set(0);
mWaitForDisco.set(smVersion != 0 && !account.getJid().getDomainpart().equalsIgnoreCase("nimbuzz.com"));
lastDiscoStarted = SystemClock.elapsedRealtime();
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery"); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery");
mPendingServiceDiscoveries.set(0);
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();
mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
Element caps = streamFeatures.findChild("c"); Element caps = streamFeatures.findChild("c");
final String hash = caps == null ? null : caps.getAttribute("hash"); final String hash = caps == null ? null : caps.getAttribute("hash");

View file

@ -15,6 +15,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.OnIqPacketReceived;
import eu.siacs.conversations.xmpp.Patches;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.InvalidJidException;
@ -110,7 +111,7 @@ public class PushManagementService {
} }
public boolean availableAndUseful(Account account) { public boolean availableAndUseful(Account account) {
return account.getServerIdentity() == XmppConnection.Identity.EJABBERD && available(account); return Patches.SUFFICIENT_PUSH.contains(account.getServerIdentity()) && available(account);
} }
private boolean playServicesAvailable() { private boolean playServicesAvailable() {