diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-02-22 20:08:58 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-02-22 20:49:04 +0100 |
commit | 00de4cd49ccfc311207cb8fe926ebc0c118d3e08 (patch) | |
tree | 130d49c0efddc98d48532e39489ea50a27ad9425 /src/main/java/de/pixart/messenger/services | |
parent | 72ce4b07c1bd53b1842f213925c9c1f6d5a99003 (diff) |
bump mam namespace
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/MessageArchiveService.java | 28 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 5 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java index b01cd8f8b..ff1775612 100644 --- a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java +++ b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java @@ -14,6 +14,7 @@ import de.pixart.messenger.R; import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.generator.AbstractGenerator; +import de.pixart.messenger.utils.Xmlns; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.OnAdvancedStreamFeaturesLoaded; import de.pixart.messenger.xmpp.OnIqPacketReceived; @@ -154,6 +155,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { this.mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { + Element fin = packet.findChild("fin", Xmlns.MAM); if (packet.getType() == IqPacket.TYPE.TIMEOUT) { synchronized (MessageArchiveService.this.queries) { MessageArchiveService.this.queries.remove(query); @@ -161,7 +163,11 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { query.callback(false); } } - } else if (packet.getType() != IqPacket.TYPE.RESULT) { + } else if (packet.getType() == IqPacket.TYPE.RESULT && fin != null) { + processFin(fin); + } else if (packet.getType() == IqPacket.TYPE.RESULT && query.isLegacy()) { + //do nothing + } else { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": error executing mam: " + packet.toString()); finalizeQuery(query, true); } @@ -214,12 +220,16 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { return queryInProgress(conversation, null); } - public void processFin(Element fin, Jid from) { - if (fin == null) { - return; + public void processFinLagecy(Element fin, Jid from) { + Query query = findQuery(fin.getAttribute("queryid")); + if (query != null && query.validFrom(from)) { + processFin(fin); } + } + + public void processFin(Element fin) { Query query = findQuery(fin.getAttribute("queryid")); - if (query == null || !query.validFrom(from)) { + if (query == null) { return; } boolean complete = fin.getAttributeAsBoolean("complete"); @@ -317,6 +327,14 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { return query; } + public boolean isLegacy() { + if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) { + return account.getXmppConnection().getFeatures().mamLegacy(); + } else { + return conversation.getMucOptions().mamLegacy(); + } + } + public Query next(String reference) { Query query = page(reference); query.pagingOrder = PagingOrder.NORMAL; diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index a1932ce1e..43aa7c292 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -3789,12 +3789,13 @@ public class XmppConnectionService extends Service { } public void fetchMamPreferences(Account account, final OnMamPreferencesFetched callback) { + final boolean lagecy = account.getXmppConnection().getFeatures().mamLegacy(); IqPacket request = new IqPacket(IqPacket.TYPE.GET); - request.addChild("prefs", "urn:xmpp:mam:0"); + request.addChild("prefs",lagecy ? Xmlns.MAM_LAGECY : Xmlns.MAM); sendIqPacket(account, request, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { - Element prefs = packet.findChild("prefs", "urn:xmpp:mam:0"); + Element prefs = packet.findChild("prefs",lagecy ? Xmlns.MAM_LAGECY : Xmlns.MAM); if (packet.getType() == IqPacket.TYPE.RESULT && prefs != null) { callback.onPreferencesFetched(prefs); } else { |