aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Bookmark.java77
-rw-r--r--src/main/java/de/pixart/messenger/generator/AbstractGenerator.java2
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java24
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java7
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java136
-rw-r--r--src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java11
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/utils/Namespace.java1
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java9
9 files changed, 195 insertions, 78 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java
index f57d1aacb..c7f33af3e 100644
--- a/src/main/java/de/pixart/messenger/entities/Bookmark.java
+++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java
@@ -1,14 +1,19 @@
package de.pixart.messenger.entities;
import android.content.Context;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.utils.StringUtils;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xml.Element;
@@ -33,20 +38,70 @@ public class Bookmark extends Element implements ListItem {
this.account = account;
}
+ public static Collection<Bookmark> parseFromStorage(Element storage, Account account) {
+ if (storage == null) {
+ return Collections.emptyList();
+ }
+ final HashMap<Jid, Bookmark> bookmarks = new HashMap<>();
+ for (final Element item : storage.getChildren()) {
+ if (item.getName().equals("conference")) {
+ final Bookmark bookmark = Bookmark.parse(item, account);
+ if (bookmark != null) {
+ final Bookmark old = bookmarks.put(bookmark.getJid(), bookmark);
+ if (old != null && old.getBookmarkName() != null && bookmark.getBookmarkName() == null) {
+ bookmark.setBookmarkName(old.getBookmarkName());
+ }
+ }
+ }
+ }
+ return bookmarks.values();
+ }
+
+ public static Collection<Bookmark> parseFromPubsub(Element pubsub, Account account) {
+ if (pubsub == null) {
+ return Collections.emptyList();
+ }
+ final Element items = pubsub.findChild("items");
+ if (items != null && Namespace.BOOKMARK.equals(items.getAttribute("node"))) {
+ final List<Bookmark> bookmarks = new ArrayList<>();
+ for (Element item : items.getChildren()) {
+ if (item.getName().equals("item")) {
+ final Bookmark bookmark = Bookmark.parseFromItem(item, account);
+ if (bookmark != null) {
+ bookmarks.add(bookmark);
+ }
+ }
+ }
+ return bookmarks;
+ }
+ return Collections.emptyList();
+ }
+
public static Bookmark parse(Element element, Account account) {
Bookmark bookmark = new Bookmark(account);
bookmark.setAttributes(element.getAttributes());
bookmark.setChildren(element.getChildren());
bookmark.jid = InvalidJid.getNullForInvalid(bookmark.getAttributeAsJid("jid"));
+ if (bookmark.jid == null) {
+ return null;
+ }
return bookmark;
}
- public static boolean printableValue(@Nullable String value, boolean permitNone) {
- return value != null && !value.trim().isEmpty() && (permitNone || !"None".equals(value));
- }
-
- public static boolean printableValue(@Nullable String value) {
- return printableValue(value, true);
+ public static Bookmark parseFromItem(Element item, Account account) {
+ final Element conference = item.findChild("conference", Namespace.BOOKMARK);
+ if (conference == null) {
+ return null;
+ }
+ final Bookmark bookmark = new Bookmark(account);
+ bookmark.jid = InvalidJid.getNullForInvalid(item.getAttributeAsJid("id"));
+ if (bookmark.jid == null) {
+ return null;
+ }
+ bookmark.setBookmarkName(conference.getAttribute("name"));
+ bookmark.setAutojoin(conference.getAttributeAsBoolean("autojoin"));
+ bookmark.setNick(conference.findChildContent("nick"));
+ return bookmark;
}
public void setAutojoin(boolean autojoin) {
@@ -82,6 +137,14 @@ public class Bookmark extends Element implements ListItem {
return 0;
}
+ public static boolean printableValue(@Nullable String value, boolean permitNone) {
+ return value != null && !value.trim().isEmpty() && (permitNone || !"None".equals(value));
+ }
+
+ public static boolean printableValue(@Nullable String value) {
+ return printableValue(value, true);
+ }
+
@Override
public Jid getJid() {
return this.jid;
@@ -191,4 +254,4 @@ public class Bookmark extends Element implements ListItem {
public int getAvatarBackgroundColor() {
return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
index 134ed69c7..68a9ea213 100644
--- a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
@@ -38,7 +38,7 @@ public abstract class AbstractGenerator {
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
Namespace.NICK + "+notify",
- Namespace.BOOKMARKS + "+notify",
+ Namespace.BOOKMARK + "+notify",
"urn:xmpp:ping",
"jabber:iq:version",
"http://jabber.org/protocol/chatstates"
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index e533dd723..812ffcb9e 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -24,6 +24,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.entities.Account;
+import de.pixart.messenger.entities.Bookmark;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.DownloadableFile;
import de.pixart.messenger.services.MessageArchiveService;
@@ -124,6 +125,10 @@ public class IqGenerator extends AbstractGenerator {
return packet;
}
+ public IqPacket retrieveBookmarks() {
+ return retrieve(Namespace.BOOKMARK, null);
+ }
+
public IqPacket publishNick(String nick) {
final Element item = new Element("item");
item.addChild("nick", Namespace.NICK).setContent(nick);
@@ -146,8 +151,12 @@ public class IqGenerator extends AbstractGenerator {
}
public IqPacket publishElement(final String namespace, final Element element, final Bundle options) {
+ return publishElement(namespace, element, "curent", options);
+ }
+
+ public IqPacket publishElement(final String namespace, final Element element, String id, final Bundle options) {
final Element item = new Element("item");
- item.setAttribute("id", "current");
+ item.setAttribute("id", id);
item.addChild(element);
return publish(namespace, item, options);
}
@@ -221,6 +230,19 @@ public class IqGenerator extends AbstractGenerator {
return publish(AxolotlService.PEP_DEVICE_LIST, item, publishOptions);
}
+ public Element publishBookmarkItem(final Bookmark bookmark) {
+ final String name = bookmark.getBookmarkName();
+ final String nick = bookmark.getNick();
+ final Element conference = new Element("conference", Namespace.BOOKMARK);
+ if (name != null) {
+ conference.setAttribute("name", name);
+ }
+ if (nick != null) {
+ conference.addChild("nick").setContent(nick);
+ }
+ return conference;
+ }
+
public IqPacket publishBundles(final SignedPreKeyRecord signedPreKeyRecord, final IdentityKey identityKey,
final Set<PreKeyRecord> preKeyRecords, final int deviceId, Bundle publishOptions) {
final Element item = new Element("item");
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 23cf142a9..0fc7e8bac 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -12,6 +12,7 @@ import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -27,6 +28,7 @@ import de.pixart.messenger.crypto.axolotl.BrokenSessionException;
import de.pixart.messenger.crypto.axolotl.NotEncryptedForThisDeviceException;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
+import de.pixart.messenger.entities.Bookmark;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Conversational;
@@ -318,12 +320,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final Element i = items.findChild("item");
final Element storage = i == null ? null : i.findChild("storage", Namespace.BOOKMARKS);
new Thread(() -> {
- mXmppConnectionService.processBookmarks(account, storage, true);
+ Collection<Bookmark> bookmarks = Bookmark.parseFromStorage(storage, account);
+ mXmppConnectionService.processBookmarksInitial(account, bookmarks, true);
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": processing bookmark PEP event");
}).start();
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring bookmark PEP event because bookmark conversion was not detected");
}
+ } else {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + " received pubsub notification for node=" + node);
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 432ad0fdf..b2ae329c8 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -68,7 +68,6 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
@@ -339,9 +338,10 @@ public class XmppConnectionService extends Service {
mJingleConnectionManager.cancelInTransmission();
mQuickConversationsService.considerSyncBackground(false);
fetchRosterFromServer(account);
- if (!account.getXmppConnection().getFeatures().bookmarksConversion()) {
+ fetchBookmarks2(account);
+ /*if (!account.getXmppConnection().getFeatures().bookmarksConversion()) {
fetchBookmarks(account);
- }
+ }*/
final boolean flexible = account.getXmppConnection().getFeatures().flexibleOfflineMessageRetrieval();
final boolean catchup = getMessageArchiveService().inCatchup(account);
if (flexible && catchup && account.getXmppConnection().isMamPreferenceAlways()) {
@@ -1802,7 +1802,8 @@ public class XmppConnectionService extends Service {
if (response.getType() == IqPacket.TYPE.RESULT) {
final Element query1 = response.query();
final Element storage = query1.findChild("storage", "storage:bookmarks");
- processBookmarks(a, storage, false);
+ Collection<Bookmark> bookmarks = Bookmark.parseFromStorage(storage, account);
+ processBookmarksInitial(a, bookmarks, false);
} else {
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": could not fetch bookmarks");
}
@@ -1810,59 +1811,62 @@ public class XmppConnectionService extends Service {
sendIqPacket(account, iqPacket, callback);
}
- public void processBookmarks(Account account, Element storage, final boolean pep) {
+ public void fetchBookmarks2(final Account account) {
+ final IqPacket retrieve = mIqGenerator.retrieveBookmarks();
+ sendIqPacket(account, retrieve, new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(final Account account, final IqPacket response) {
+ if (response.getType() == IqPacket.TYPE.RESULT) {
+ final Element pubsub = response.findChild("pubsub", Namespace.PUBSUB);
+ final Collection<Bookmark> bookmarks = Bookmark.parseFromPubsub(pubsub, account);
+ Log.d(Config.LOGTAG, "bookmarks2 " + pubsub);
+ Log.d(Config.LOGTAG, "bookmarks2" + bookmarks);
+ processBookmarksInitial(account, bookmarks, true);
+ }
+ }
+ });
+ }
+
+ public void processBookmarksInitial(Account account, Collection<Bookmark> bookmarks, final boolean pep) {
final Set<Jid> previousBookmarks = account.getBookmarkedJids();
- final HashMap<Jid, Bookmark> bookmarks = new HashMap<>();
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
- if (storage != null) {
- for (final Element item : storage.getChildren()) {
- if (item.getName().equals("conference")) {
- final Bookmark bookmark = Bookmark.parse(item, account);
- Bookmark old = bookmarks.put(bookmark.getJid(), bookmark);
- if (old != null && old.getBookmarkName() != null && bookmark.getBookmarkName() == null) {
- bookmark.setBookmarkName(old.getBookmarkName());
- }
- if (bookmark.getJid() == null) {
- continue;
- }
- previousBookmarks.remove(bookmark.getJid().asBareJid());
- Conversation conversation = find(bookmark);
- if (conversation != null) {
- if (conversation.getMode() != Conversation.MODE_MULTI) {
- continue;
- }
- bookmark.setConversation(conversation);
- if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) {
- Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conference (" + conversation.getJid() + ") after receiving pep");
- archiveConversation(conversation, false);
- }
- } else if (synchronizeWithBookmarks && bookmark.autojoin()) {
- conversation = findOrCreateConversation(account, bookmark.getFullJid(), true, true, false);
- bookmark.setConversation(conversation);
- }
+ for (Bookmark bookmark : bookmarks) {
+ previousBookmarks.remove(bookmark.getJid().asBareJid());
+ Conversation conversation = find(bookmark);
+ if (conversation != null) {
+ if (conversation.getMode() != Conversation.MODE_MULTI) {
+ continue;
}
+ bookmark.setConversation(conversation);
+ if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conference (" + conversation.getJid() + ") after receiving pep");
+ archiveConversation(conversation, false);
+ }
+ } else if (synchronizeWithBookmarks && bookmark.autojoin()) {
+ conversation = findOrCreateConversation(account, bookmark.getFullJid(), true, true, false);
+ bookmark.setConversation(conversation);
}
- if (pep && synchronizeWithBookmarks) {
- Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed");
- for (Jid jid : previousBookmarks) {
- final Conversation conversation = find(account, jid);
- if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) {
- Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving destroyed conference (" + conversation.getJid() + ") after receiving pep");
- archiveConversation(conversation, false);
- }
+ }
+ if (pep && synchronizeWithBookmarks) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed");
+ for (Jid jid : previousBookmarks) {
+ final Conversation conversation = find(account, jid);
+ if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving destroyed conference (" + conversation.getJid() + ") after receiving pep");
+ archiveConversation(conversation, false);
}
}
}
- account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks.values()));
+ account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks));
}
- public void pushBookmarks(Account account) {
+ public void createBookmark(final Account account, final Bookmark bookmark) {
+ final Element item = mIqGenerator.publishBookmarkItem(bookmark);
+ pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARK, item, bookmark.getJid().asBareJid().toEscapedString(), PublishOptions.persistentWhitelistAccessMaxItems());
+ }
+
+ public void deleteBookmark(final Account account, final Bookmark bookmark) {
final XmppConnection connection = account.getXmppConnection();
- if (connection != null && connection.getFeatures().bookmarksConversion()) {
- new Thread(() -> pushBookmarksPep(account)).start();
- } else {
- new Thread(() -> pushBookmarksPrivateXml(account)).start();
- }
}
private void pushBookmarksPrivateXml(Account account) {
@@ -1886,11 +1890,16 @@ public class XmppConnectionService extends Service {
}
private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final Bundle options) {
- pushNodeAndEnforcePublishOptions(account, node, element, options, true);
+ pushNodeAndEnforcePublishOptions(account, node, element, null, options, true);
+
+ }
+
+ private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final String id, final Bundle options) {
+ pushNodeAndEnforcePublishOptions(account, node, element, id, options, true);
}
- private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final Bundle options, final boolean retry) {
- final IqPacket packet = mIqGenerator.publishElement(node, element, options);
+ private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final String id, final Bundle options, final boolean retry) {
+ final IqPacket packet = mIqGenerator.publishElement(node, element, id, options);
sendIqPacket(account, packet, (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) {
return;
@@ -1899,7 +1908,7 @@ public class XmppConnectionService extends Service {
pushNodeConfiguration(account, node, options, new OnConfigurationPushed() {
@Override
public void onPushSucceeded() {
- pushNodeAndEnforcePublishOptions(account, node, element, options, false);
+ pushNodeAndEnforcePublishOptions(account, node, element, id, options, false);
}
@Override
@@ -2331,8 +2340,15 @@ public class XmppConnectionService extends Service {
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
Bookmark bookmark = conversation.getBookmark();
if (maySynchronizeWithBookmarks && bookmark != null && synchronizeWithBookmarks()) {
- bookmark.setAutojoin(false);
- pushBookmarks(bookmark.getAccount());
+ if (conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) {
+ Account account = bookmark.getAccount();
+ bookmark.setConversation(null);
+ account.getBookmarks().remove(bookmark);
+ deleteBookmark(account, bookmark);
+ } else if (bookmark.autojoin()) {
+ bookmark.setAutojoin(false);
+ createBookmark(bookmark.getAccount(), bookmark);
+ }
}
}
if (conversation.getMucOptions().push()) {
@@ -2341,7 +2357,6 @@ public class XmppConnectionService extends Service {
}
leaveMuc(conversation);
} else {
- conversation.endOtrIfNeeded();
if (conversation.getContact().getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
stopPresenceUpdatesTo(conversation.getContact());
}
@@ -3059,10 +3074,11 @@ public class XmppConnectionService extends Service {
if (conversation.getMode() == Conversation.MODE_MULTI) {
conversation.getMucOptions().setPassword(password);
if (conversation.getBookmark() != null) {
+ final Bookmark bookmark = conversation.getBookmark();
if (synchronizeWithBookmarks()) {
- conversation.getBookmark().setAutojoin(true);
+ bookmark.setAutojoin(true);
}
- pushBookmarks(conversation.getAccount());
+ createBookmark(conversation.getAccount(), bookmark);
}
updateConversation(conversation);
joinMuc(conversation);
@@ -3113,7 +3129,7 @@ public class XmppConnectionService extends Service {
}
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": persist nick '" + full.getResource() + "' into bookmark for " + conversation.getJid().asBareJid());
bookmark.setNick(full.getResource());
- pushBookmarks(bookmark.getAccount());
+ createBookmark(bookmark.getAccount(), bookmark);
}
}
@@ -3147,7 +3163,7 @@ public class XmppConnectionService extends Service {
Bookmark bookmark = conversation.getBookmark();
if (bookmark != null) {
bookmark.setNick(nick);
- pushBookmarks(bookmark.getAccount());
+ createBookmark(bookmark.getAccount(), bookmark);
}
joinMuc(conversation);
}
@@ -3314,7 +3330,7 @@ public class XmppConnectionService extends Service {
if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) {
if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) {
- pushBookmarks(account);
+ createBookmark(account, bookmark);
}
}
@@ -4825,7 +4841,7 @@ public class XmppConnectionService extends Service {
}
bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin)));
account.getBookmarks().add(bookmark);
- pushBookmarks(account);
+ createBookmark(account, bookmark);
bookmark.setConversation(conversation);
}
diff --git a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
index 25d0669ed..9e4cdc680 100644
--- a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java
@@ -226,16 +226,17 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
final boolean syncAutoJoin = getBooleanPreference("autojoin", R.bool.autojoin);
final Account account = xmppConnectionService.findAccountByJid(jid);
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, result.getRoom(), true, true, true);
- if (conversation.getBookmark() != null) {
- if (!conversation.getBookmark().autojoin() && syncAutoJoin) {
+ Bookmark bookmark = conversation.getBookmark();
+ if (bookmark != null) {
+ if (!bookmark.autojoin() && syncAutoJoin) {
conversation.getBookmark().setAutojoin(true);
- xmppConnectionService.pushBookmarks(account);
+ xmppConnectionService.createBookmark(account, bookmark);
}
} else {
- final Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
+ bookmark = new Bookmark(account, conversation.getJid().asBareJid());
bookmark.setAutojoin(syncAutoJoin);
account.getBookmarks().add(bookmark);
- xmppConnectionService.pushBookmarks(account);
+ xmppConnectionService.createBookmark(account, bookmark);
}
switchToConversation(conversation);
}
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index d94ebfb28..e34dacb2a 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -424,7 +424,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
bookmark.setConversation(conversation);
if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin))) {
bookmark.setAutojoin(true);
- xmppConnectionService.pushBookmarks(bookmark.getAccount());
+ xmppConnectionService.createBookmark(bookmark.getAccount(), bookmark);
}
SoftKeyboardUtils.hideSoftKeyboard(this);
switchToConversation(conversation);
@@ -473,7 +473,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
bookmark.setConversation(null);
Account account = bookmark.getAccount();
account.getBookmarks().remove(bookmark);
- xmppConnectionService.pushBookmarks(account);
+ xmppConnectionService.deleteBookmark(account, bookmark);
filter(mSearchEditText.getText().toString());
});
builder.create().show();
@@ -1024,7 +1024,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
bookmark.setNick(nick);
}
account.getBookmarks().add(bookmark);
- xmppConnectionService.pushBookmarks(account);
+ xmppConnectionService.createBookmark(account, bookmark);
final Conversation conversation = xmppConnectionService
.findOrCreateConversation(account, conferenceJid, true, true, true);
bookmark.setConversation(conversation);
diff --git a/src/main/java/de/pixart/messenger/utils/Namespace.java b/src/main/java/de/pixart/messenger/utils/Namespace.java
index a7bf70f54..8e9bf1ed6 100644
--- a/src/main/java/de/pixart/messenger/utils/Namespace.java
+++ b/src/main/java/de/pixart/messenger/utils/Namespace.java
@@ -33,4 +33,5 @@ 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";
}
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 53b12d239..af22cfd87 100644
--- a/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java
+++ b/src/main/java/de/pixart/messenger/xmpp/pep/PublishOptions.java
@@ -25,6 +25,15 @@ public class PublishOptions {
return options;
}
+ public static Bundle persistentWhitelistAccessMaxItems() {
+ final Bundle options = new Bundle();
+ options.putString("pubsub#persist_items", "true");
+ options.putString("pubsub#access_model", "whitelist");
+ options.putString("pubsub#send_last_published_item", "never");
+ options.putString("pubsub#max_items", "128"); //YOLO!
+ return options;
+ }
+
public static boolean preconditionNotMet(IqPacket response) {
final Element error = response.getType() == IqPacket.TYPE.ERROR ? response.findChild("error") : null;
return error != null && error.hasChild("precondition-not-met", Namespace.PUBSUB_ERROR);