aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/generator
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-10-26 17:53:03 +0200
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-10-26 17:53:03 +0200
commit8d7727fcdc400dcd05babe4ec9b78fa0d1f56717 (patch)
tree45472c1966b93fe5febffa068710fcd3a8da8af2 /src/main/java/de/pixart/messenger/generator
parent6df9c91b30c01beeb5d3f25d68f599e0dbe4c319 (diff)
support for delete bookmarks2
Diffstat (limited to 'src/main/java/de/pixart/messenger/generator')
-rw-r--r--src/main/java/de/pixart/messenger/generator/AbstractGenerator.java10
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java23
2 files changed, 24 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
index 68a9ea213..545784586 100644
--- a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
@@ -19,6 +19,7 @@ import de.pixart.messenger.entities.Account;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.utils.PhoneHelper;
+import de.pixart.messenger.xmpp.XmppConnection;
import de.pixart.messenger.xmpp.jingle.stanzas.Content;
public abstract class AbstractGenerator {
@@ -38,7 +39,6 @@ public abstract class AbstractGenerator {
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
Namespace.NICK + "+notify",
- Namespace.BOOKMARK + "+notify",
"urn:xmpp:ping",
"jabber:iq:version",
"http://jabber.org/protocol/chatstates"
@@ -112,7 +112,8 @@ public abstract class AbstractGenerator {
}
public List<String> getFeatures(Account account) {
- ArrayList<String> features = new ArrayList<>(Arrays.asList(FEATURES));
+ final XmppConnection connection = account.getXmppConnection();
+ final ArrayList<String> features = new ArrayList<>(Arrays.asList(FEATURES));
if (mXmppConnectionService.confirmMessages()) {
features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
}
@@ -131,6 +132,11 @@ public abstract class AbstractGenerator {
if (mXmppConnectionService.broadcastLastActivity()) {
features.add(Namespace.IDLE);
}
+ if (connection != null && connection.getFeatures().bookmarks2()) {
+ features.add(Namespace.BOOKMARK + "+notify");
+ } else {
+ features.add(Namespace.BOOKMARKS + "+notify");
+ }
Collections.sort(features);
return features;
}
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index 812ffcb9e..bb6355688 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -58,12 +58,6 @@ public class IqGenerator extends AbstractGenerator {
return packet;
}
- public IqPacket purgeOfflineMessages() {
- final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
- packet.addChild("offline", Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL).addChild("purge");
- return packet;
- }
-
public IqPacket versionResponse(final IqPacket request) {
final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
Element query = packet.query("jabber:iq:version");
@@ -97,6 +91,12 @@ public class IqGenerator extends AbstractGenerator {
return packet;
}
+ public IqPacket purgeOfflineMessages() {
+ final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
+ packet.addChild("offline", Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL).addChild("purge");
+ return packet;
+ }
+
protected IqPacket publish(final String node, final Element item, final Bundle options) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
@@ -142,6 +142,15 @@ public class IqGenerator extends AbstractGenerator {
return packet;
}
+ public IqPacket deleteItem(final String node, final String id) {
+ IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
+ final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
+ final Element retract = pubsub.addChild("retract");
+ retract.setAttribute("node", node);
+ retract.addChild("item").setAttribute("id", id);
+ return packet;
+ }
+
public IqPacket publishAvatar(Avatar avatar, Bundle options) {
final Element item = new Element("item");
item.setAttribute("id", avatar.sha1sum);
@@ -565,4 +574,4 @@ public class IqGenerator extends AbstractGenerator {
}
return packet;
}
-}
+} \ No newline at end of file