bookmarks2. introduce #compat namespace
This commit is contained in:
parent
94c592f213
commit
f530e395ca
|
@ -99,6 +99,7 @@ public final class Config {
|
||||||
public static final boolean OMEMO_PADDING = false;
|
public static final boolean OMEMO_PADDING = false;
|
||||||
public static final boolean PUT_AUTH_TAG_INTO_KEY = true;
|
public static final boolean PUT_AUTH_TAG_INTO_KEY = true;
|
||||||
|
|
||||||
|
public static final boolean USE_BOOKMARKS2 = false;
|
||||||
|
|
||||||
public static final boolean DISABLE_PROXY_LOOKUP = false; //useful to debug ibb
|
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 USE_DIRECT_JINGLE_CANDIDATES = true;
|
||||||
|
|
|
@ -3,19 +3,15 @@ package eu.siacs.conversations.entities;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
|
||||||
import eu.siacs.conversations.utils.StringUtils;
|
import eu.siacs.conversations.utils.StringUtils;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
@ -65,7 +61,7 @@ public class Bookmark extends Element implements ListItem {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
final Element items = pubsub.findChild("items");
|
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<>();
|
final Map<Jid, Bookmark> bookmarks = new HashMap<>();
|
||||||
for(Element item : items.getChildren()) {
|
for(Element item : items.getChildren()) {
|
||||||
if (item.getName().equals("item")) {
|
if (item.getName().equals("item")) {
|
||||||
|
@ -92,7 +88,7 @@ public class Bookmark extends Element implements ListItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bookmark parseFromItem(Element item, Account account) {
|
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) {
|
if (conference == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public abstract class AbstractGenerator {
|
||||||
features.add(Namespace.IDLE);
|
features.add(Namespace.IDLE);
|
||||||
}
|
}
|
||||||
if (connection != null && connection.getFeatures().bookmarks2()) {
|
if (connection != null && connection.getFeatures().bookmarks2()) {
|
||||||
features.add(Namespace.BOOKMARK+"+notify");
|
features.add(Namespace.BOOKMARKS2 +"+notify");
|
||||||
} else {
|
} else {
|
||||||
features.add(Namespace.BOOKMARKS+"+notify");
|
features.add(Namespace.BOOKMARKS+"+notify");
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IqPacket retrieveBookmarks() {
|
public IqPacket retrieveBookmarks() {
|
||||||
return retrieve(Namespace.BOOKMARK, null);
|
return retrieve(Namespace.BOOKMARKS2, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IqPacket publishNick(String nick) {
|
public IqPacket publishNick(String nick) {
|
||||||
|
@ -243,13 +243,15 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
public Element publishBookmarkItem(final Bookmark bookmark) {
|
public Element publishBookmarkItem(final Bookmark bookmark) {
|
||||||
final String name = bookmark.getBookmarkName();
|
final String name = bookmark.getBookmarkName();
|
||||||
final String nick = bookmark.getNick();
|
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) {
|
if (name != null) {
|
||||||
conference.setAttribute("name", name);
|
conference.setAttribute("name", name);
|
||||||
}
|
}
|
||||||
if (nick != null) {
|
if (nick != null) {
|
||||||
conference.addChild("nick").setContent(nick);
|
conference.addChild("nick").setContent(nick);
|
||||||
}
|
}
|
||||||
|
conference.setAttribute("autojoin",String.valueOf(autojoin));
|
||||||
return conference;
|
return conference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.util.Pair;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -233,7 +232,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring bookmark PEP event because bookmark conversion was not detected");
|
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 item = items.findChild("item");
|
||||||
final Element retract = items.findChild("retract");
|
final Element retract = items.findChild("retract");
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
@ -261,7 +260,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
if (Namespace.NICK.equals(node)) {
|
if (Namespace.NICK.equals(node)) {
|
||||||
Log.d(Config.LOGTAG, "parsing nick delete event from " + from);
|
Log.d(Config.LOGTAG, "parsing nick delete event from " + from);
|
||||||
setNick(account, from, null);
|
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());
|
account.setBookmarks(Collections.emptyMap());
|
||||||
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmarks node");
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmarks node");
|
||||||
}
|
}
|
||||||
|
@ -270,7 +269,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
private void parsePurgeEvent(final Element event, final Jid from, final Account account) {
|
private void parsePurgeEvent(final Element event, final Jid from, final Account account) {
|
||||||
final Element purge = event.findChild("purge");
|
final Element purge = event.findChild("purge");
|
||||||
final String node = purge == null ? null : purge.getAttribute("node");
|
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());
|
account.setBookmarks(Collections.emptyMap());
|
||||||
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": purged bookmarks");
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": purged bookmarks");
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -1639,7 +1638,7 @@ public class XmppConnectionService extends Service {
|
||||||
final XmppConnection connection = account.getXmppConnection();
|
final XmppConnection connection = account.getXmppConnection();
|
||||||
if (connection.getFeatures().bookmarks2()) {
|
if (connection.getFeatures().bookmarks2()) {
|
||||||
final Element item = mIqGenerator.publishBookmarkItem(bookmark);
|
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()) {
|
} else if (connection.getFeatures().bookmarksConversion()) {
|
||||||
pushBookmarksPep(account);
|
pushBookmarksPep(account);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1651,7 +1650,7 @@ public class XmppConnectionService extends Service {
|
||||||
account.removeBookmark(bookmark);
|
account.removeBookmark(bookmark);
|
||||||
final XmppConnection connection = account.getXmppConnection();
|
final XmppConnection connection = account.getXmppConnection();
|
||||||
if (connection.getFeatures().bookmarksConversion()) {
|
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() {
|
sendIqPacket(account, request, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
|
|
|
@ -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 = "urn:xmpp:jingle:jet:0";
|
||||||
public static final String JINGLE_ENCRYPTED_TRANSPORT_OMEMO = "urn:xmpp:jingle:jet-omemo: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 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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1880,7 +1880,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bookmarks2() {
|
public boolean bookmarks2() {
|
||||||
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARK);
|
return Config.USE_BOOKMARKS2 || hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS2_COMPAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,27 @@ public class PublishOptions {
|
||||||
|
|
||||||
public static Bundle openAccess() {
|
public static Bundle openAccess() {
|
||||||
final Bundle options = new Bundle();
|
final Bundle options = new Bundle();
|
||||||
options.putString("pubsub#access_model","open");
|
options.putString("pubsub#access_model", "open");
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bundle persistentWhitelistAccess() {
|
public static Bundle persistentWhitelistAccess() {
|
||||||
final Bundle options = new Bundle();
|
final Bundle options = new Bundle();
|
||||||
options.putString("pubsub#persist_items","true");
|
options.putString("pubsub#persist_items", "true");
|
||||||
options.putString("pubsub#access_model","whitelist");
|
options.putString("pubsub#access_model", "whitelist");
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bundle persistentWhitelistAccessMaxItems() {
|
public static Bundle persistentWhitelistAccessMaxItems() {
|
||||||
final Bundle options = new Bundle();
|
final Bundle options = new Bundle();
|
||||||
options.putString("pubsub#persist_items","true");
|
options.putString("pubsub#persist_items", "true");
|
||||||
options.putString("pubsub#access_model", "whitelist");
|
options.putString("pubsub#access_model", "whitelist");
|
||||||
options.putString("pubsub#send_last_published_item","never");
|
options.putString("pubsub#send_last_published_item", "never");
|
||||||
options.putString("pubsub#max_items","128"); //YOLO!
|
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;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue