aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java8
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java4
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java9
-rw-r--r--src/main/java/de/pixart/messenger/services/MessageArchiveService.java28
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java5
-rw-r--r--src/main/java/de/pixart/messenger/utils/Xmlns.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java9
7 files changed, 48 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index 8ec3cbfd4..dc34d11a9 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Set;
import de.pixart.messenger.R;
+import de.pixart.messenger.utils.Xmlns;
import de.pixart.messenger.xmpp.forms.Data;
import de.pixart.messenger.xmpp.forms.Field;
import de.pixart.messenger.xmpp.jid.InvalidJidException;
@@ -373,8 +374,11 @@ public class MucOptions {
}
public boolean mamSupport() {
- // Update with "urn:xmpp:mam:1" once we support it
- return hasFeature("urn:xmpp:mam:0");
+ return hasFeature(Xmlns.MAM) || hasFeature(Xmlns.MAM_LAGECY);
+ }
+
+ public boolean mamLegacy() {
+ return hasFeature(Xmlns.MAM_LAGECY) && !hasFeature(Xmlns.MAM);
}
public boolean nonanonymous() {
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index 971d43952..0158aeba1 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -229,10 +229,10 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket queryMessageArchiveManagement(final MessageArchiveService.Query mam) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
- final Element query = packet.query("urn:xmpp:mam:0");
+ final Element query = packet.query(mam.isLegacy() ? Xmlns.MAM_LAGECY : Xmlns.MAM);
query.setAttribute("queryid", mam.getQueryId());
final Data data = new Data();
- data.setFormType("urn:xmpp:mam:0");
+ data.setFormType(mam.isLegacy() ? Xmlns.MAM_LAGECY : Xmlns.MAM);
if (mam.muc()) {
packet.setTo(mam.getWith());
} else if (mam.getWith() != null) {
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index b1d67b933..88cdefc8c 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -299,15 +299,16 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final boolean isForwarded;
boolean isCarbon = false;
String serverMsgId = null;
- final Element fin = original.findChild("fin", "urn:xmpp:mam:0");
+ final Element fin = original.findChild("fin", Xmlns.MAM_LAGECY);
if (fin != null) {
- mXmppConnectionService.getMessageArchiveService().processFin(fin, original.getFrom());
+ mXmppConnectionService.getMessageArchiveService().processFinLagecy(fin, original.getFrom());
return;
}
- final Element result = original.findChild("result", "urn:xmpp:mam:0");
+ final boolean mamLagecy = original.hasChild("result", Xmlns.MAM_LAGECY);
+ final Element result = original.findChild("result", mamLagecy ? Xmlns.MAM_LAGECY : Xmlns.MAM);
final MessageArchiveService.Query query = result == null ? null : mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid"));
if (query != null && query.validFrom(original.getFrom())) {
- Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", "urn:xmpp:mam:0");
+ Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", mamLagecy ? Xmlns.MAM_LAGECY : Xmlns.MAM);
if (f == null) {
return;
}
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 {
diff --git a/src/main/java/de/pixart/messenger/utils/Xmlns.java b/src/main/java/de/pixart/messenger/utils/Xmlns.java
index 675d2db80..6383defe1 100644
--- a/src/main/java/de/pixart/messenger/utils/Xmlns.java
+++ b/src/main/java/de/pixart/messenger/utils/Xmlns.java
@@ -7,4 +7,6 @@ public final class Xmlns {
public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams";
public static final String HTTP_UPLOAD = "urn:xmpp:http:upload";
public static final String STANZA_IDS = "urn:xmpp:sid:0";
+ public static final String MAM = "urn:xmpp:mam:1";
+ public static final String MAM_LAGECY = "urn:xmpp:mam:0";
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 9cb852ea9..0e05a2775 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1659,8 +1659,13 @@ public class XmppConnection implements Runnable {
}
public boolean mam() {
- return hasDiscoFeature(account.getJid().toBareJid(), "urn:xmpp:mam:0")
- || hasDiscoFeature(account.getServer(), "urn:xmpp:mam:0");
+ return hasDiscoFeature(account.getJid().toBareJid(), Xmlns.MAM)
+ || hasDiscoFeature(account.getJid().toBareJid(), Xmlns.MAM_LAGECY);
+ }
+
+ public boolean mamLegacy() {
+ return !hasDiscoFeature(account.getJid().toBareJid(), Xmlns.MAM)
+ && hasDiscoFeature(account.getJid().toBareJid(), Xmlns.MAM_LAGECY);
}
public boolean push() {