forked from mirror/monocles_chat
copy bookmarks before passing them to other parts of the app for read
closes #4381
(cherry picked from commit c1abca35da2fd8887fe0dd85935a63a930accba0)
(cherry picked from commit 7da24ab57b
)
This commit is contained in:
parent
862455d8b2
commit
d6f5b49736
4 changed files with 13 additions and 10 deletions
|
@ -91,7 +91,7 @@ public final class Config {
|
|||
public static final boolean FORCE_ORBOT = false; // always use TOR
|
||||
|
||||
|
||||
public static final boolean SASL_2_ENABLED = false;
|
||||
public static final boolean SASL_2_ENABLED = true;
|
||||
|
||||
//Notification settings
|
||||
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.os.SystemClock;
|
|||
import android.util.Log;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
|
||||
import net.java.otr4j.crypto.OtrCryptoException;
|
||||
|
@ -522,17 +523,19 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
|||
}
|
||||
|
||||
public Collection<Bookmark> getBookmarks() {
|
||||
return this.bookmarks.values();
|
||||
synchronized (this.bookmarks) {
|
||||
return ImmutableList.copyOf(this.bookmarks.values());
|
||||
}
|
||||
}
|
||||
|
||||
public void setBookmarks(Map<Jid, Bookmark> bookmarks) {
|
||||
public void setBookmarks(final Map<Jid, Bookmark> bookmarks) {
|
||||
synchronized (this.bookmarks) {
|
||||
this.bookmarks.clear();
|
||||
this.bookmarks.putAll(bookmarks);
|
||||
}
|
||||
}
|
||||
|
||||
public void putBookmark(Bookmark bookmark) {
|
||||
public void putBookmark(final Bookmark bookmark) {
|
||||
synchronized (this.bookmarks) {
|
||||
this.bookmarks.put(bookmark.getJid(), bookmark);
|
||||
}
|
||||
|
|
|
@ -2227,7 +2227,7 @@ public class XmppConnectionService extends Service {
|
|||
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
|
||||
Element query = iqPacket.query("jabber:iq:private");
|
||||
Element storage = query.addChild("storage", "storage:bookmarks");
|
||||
for (Bookmark bookmark : account.getBookmarks()) {
|
||||
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||
storage.addChild(bookmark);
|
||||
}
|
||||
sendIqPacket(account, iqPacket, mDefaultIqHandler);
|
||||
|
@ -2235,8 +2235,8 @@ public class XmppConnectionService extends Service {
|
|||
|
||||
private void pushBookmarksPep(Account account) {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": pushing bookmarks via pep");
|
||||
Element storage = new Element("storage", "storage:bookmarks");
|
||||
for (Bookmark bookmark : account.getBookmarks()) {
|
||||
final Element storage = new Element("storage", "storage:bookmarks");
|
||||
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||
storage.addChild(bookmark);
|
||||
}
|
||||
pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARKS, storage, "current", PublishOptions.persistentWhitelistAccess());
|
||||
|
@ -5009,7 +5009,7 @@ public class XmppConnectionService extends Service {
|
|||
for (final Account account : accounts) {
|
||||
if (account.getXmppConnection() != null) {
|
||||
mucServers.addAll(account.getXmppConnection().getMucServers());
|
||||
for (Bookmark bookmark : account.getBookmarks()) {
|
||||
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||
final Jid jid = bookmark.getJid();
|
||||
final String s = jid == null ? null : jid.getDomain().toEscapedString();
|
||||
if (s != null) {
|
||||
|
|
|
@ -994,9 +994,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
|
||||
protected void filterConferences(String needle) {
|
||||
this.conferences.clear();
|
||||
for (Account account : xmppConnectionService.getAccounts()) {
|
||||
for (final Account account : xmppConnectionService.getAccounts()) {
|
||||
if (account.getStatus() != Account.State.DISABLED) {
|
||||
for (Bookmark bookmark : account.getBookmarks()) {
|
||||
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||
if (bookmark.match(this, needle)) {
|
||||
this.conferences.add(bookmark);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue