aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-10-26 18:28:26 +0200
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-10-26 18:28:26 +0200
commit57e0f4a21d127667df11192711c7077439cfbb36 (patch)
treeead4bbcb1c7f031da55c060bacb47ee01b7fd4f3
parent004867686b670c368038a45324b44dee2c465d66 (diff)
bookmarks2. introduce #compat namespace
-rw-r--r--src/main/java/de/pixart/messenger/Config.java1
-rw-r--r--src/main/java/de/pixart/messenger/entities/Bookmark.java4
-rw-r--r--src/main/java/de/pixart/messenger/generator/AbstractGenerator.java2
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java6
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java6
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java4
-rw-r--r--src/main/java/de/pixart/messenger/utils/Namespace.java3
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java2
9 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index e4fcdb8ad..d29672063 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -117,6 +117,7 @@ public final class Config {
public static final int ExportLogs_Hour = 4; //Time - hours: valid values from 0 to 23
public static final int ExportLogs_Minute = 0; //Time - minutes: valid values from 0 to 59
+ public static final boolean USE_BOOKMARKS2 = false;
public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb
public static final boolean USE_DIRECT_JINGLE_CANDIDATES = true;
public static final boolean DISABLE_HTTP_UPLOAD = false;
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java
index d017eefed..a5fa6fb35 100644
--- a/src/main/java/de/pixart/messenger/entities/Bookmark.java
+++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java
@@ -62,7 +62,7 @@ public class Bookmark extends Element implements ListItem {
return Collections.emptyMap();
}
final Element items = pubsub.findChild("items");
- if (items != null && Namespace.BOOKMARK.equals(items.getAttribute("node"))) {
+ if (items != null && Namespace.BOOKMARKS2.equals(items.getAttribute("node"))) {
final Map<Jid, Bookmark> bookmarks = new HashMap<>();
for (Element item : items.getChildren()) {
if (item.getName().equals("item")) {
@@ -89,7 +89,7 @@ public class Bookmark extends Element implements ListItem {
}
public static Bookmark parseFromItem(Element item, Account account) {
- final Element conference = item.findChild("conference", Namespace.BOOKMARK);
+ final Element conference = item.findChild("conference", Namespace.BOOKMARKS2);
if (conference == null) {
return null;
}
diff --git a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
index 545784586..f47c2d8f1 100644
--- a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
@@ -133,7 +133,7 @@ public abstract class AbstractGenerator {
features.add(Namespace.IDLE);
}
if (connection != null && connection.getFeatures().bookmarks2()) {
- features.add(Namespace.BOOKMARK + "+notify");
+ features.add(Namespace.BOOKMARKS + "+notify");
} else {
features.add(Namespace.BOOKMARKS + "+notify");
}
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index 4e9edeac9..f7e94b0c6 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -126,7 +126,7 @@ public class IqGenerator extends AbstractGenerator {
}
public IqPacket retrieveBookmarks() {
- return retrieve(Namespace.BOOKMARK, null);
+ return retrieve(Namespace.BOOKMARKS2, null);
}
public IqPacket publishNick(String nick) {
@@ -243,13 +243,15 @@ public class IqGenerator extends AbstractGenerator {
public Element publishBookmarkItem(final Bookmark bookmark) {
final String name = bookmark.getBookmarkName();
final String nick = bookmark.getNick();
- final Element conference = new Element("conference", Namespace.BOOKMARK);
+ final boolean autojoin = bookmark.autojoin();
+ final Element conference = new Element("conference", Namespace.BOOKMARKS2);
if (name != null) {
conference.setAttribute("name", name);
}
if (nick != null) {
conference.addChild("nick").setContent(nick);
}
+ conference.setAttribute("autojoin", String.valueOf(autojoin));
return conference;
}
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 1b9fb2f58..9917f2c51 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -325,7 +325,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring bookmark PEP event because bookmark conversion was not detected");
}
- } else if (Namespace.BOOKMARK.equals(node) && account.getJid().asBareJid().equals(from)) {
+ } else if (Namespace.BOOKMARKS2.equals(node) && account.getJid().asBareJid().equals(from)) {
final Element item = items.findChild("item");
final Element retract = items.findChild("retract");
if (item != null) {
@@ -353,7 +353,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (Namespace.NICK.equals(node)) {
Log.d(Config.LOGTAG, "parsing nick delete event from " + from);
setNick(account, from, null);
- } else if (Namespace.BOOKMARK.equals(node) && account.getJid().asBareJid().equals(from)) {
+ } else if (Namespace.BOOKMARKS2.equals(node) && account.getJid().asBareJid().equals(from)) {
account.setBookmarks(Collections.emptyMap());
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": deleted bookmarks node");
}
@@ -362,7 +362,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
private void parsePurgeEvent(final Element event, final Jid from, final Account account) {
final Element purge = event.findChild("purge");
final String node = purge == null ? null : purge.getAttribute("node");
- if (Namespace.BOOKMARK.equals(node) && account.getJid().asBareJid().equals(from)) {
+ if (Namespace.BOOKMARKS2.equals(node) && account.getJid().asBareJid().equals(from)) {
account.setBookmarks(Collections.emptyMap());
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": purged bookmarks");
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 35ed69c60..c93a22719 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1879,7 +1879,7 @@ public class XmppConnectionService extends Service {
final XmppConnection connection = account.getXmppConnection();
if (connection.getFeatures().bookmarks2()) {
final Element item = mIqGenerator.publishBookmarkItem(bookmark);
- pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARK, item, bookmark.getJid().asBareJid().toEscapedString(), PublishOptions.persistentWhitelistAccessMaxItems());
+ pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARKS2, item, bookmark.getJid().asBareJid().toEscapedString(), PublishOptions.persistentWhitelistAccessMaxItems());
} else if (connection.getFeatures().bookmarksConversion()) {
pushBookmarksPep(account);
} else {
@@ -1891,7 +1891,7 @@ public class XmppConnectionService extends Service {
account.removeBookmark(bookmark);
final XmppConnection connection = account.getXmppConnection();
if (connection.getFeatures().bookmarksConversion()) {
- IqPacket request = mIqGenerator.deleteItem(Namespace.BOOKMARK, bookmark.getJid().asBareJid().toEscapedString());
+ IqPacket request = mIqGenerator.deleteItem(Namespace.BOOKMARKS2, bookmark.getJid().asBareJid().toEscapedString());
sendIqPacket(account, request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
diff --git a/src/main/java/de/pixart/messenger/utils/Namespace.java b/src/main/java/de/pixart/messenger/utils/Namespace.java
index 8e9bf1ed6..f8635f21d 100644
--- a/src/main/java/de/pixart/messenger/utils/Namespace.java
+++ b/src/main/java/de/pixart/messenger/utils/Namespace.java
@@ -33,5 +33,6 @@ public final class Namespace {
public static final String JINGLE_ENCRYPTED_TRANSPORT = "urn:xmpp:jingle:jet:0";
public static final String JINGLE_ENCRYPTED_TRANSPORT_OMEMO = "urn:xmpp:jingle:jet-omemo:0";
public static final String MUC_USER = "http://jabber.org/protocol/muc#user";
- public static final String BOOKMARK = "urn:xmpp:bookmarks:0";
+ public static final String BOOKMARKS2 = "urn:xmpp:bookmarks:0";
+ public static final String BOOKMARKS2_COMPAT = BOOKMARKS2 + "#compat";
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 32a1fe377..b4e41ca22 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -2001,7 +2001,7 @@ public class XmppConnection implements Runnable {
}
public boolean bookmarks2() {
- return hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARK);
+ return Config.USE_BOOKMARKS2 || hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS2_COMPAT);
}
}
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java b/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java
index af22cfd87..f32ea8ab1 100644
--- a/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java
+++ b/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java
@@ -31,6 +31,8 @@ public class PublishOptions {
options.putString("pubsub#access_model", "whitelist");
options.putString("pubsub#send_last_published_item", "never");
options.putString("pubsub#max_items", "128"); //YOLO!
+ options.putString("pubsub#notify_delete", "true");
+ options.putString("pubsub#notify_retract", "true"); //one could also set notify=true on the retract
return options;
}