copy bookmarks before passing them to other parts of the app for read
closes #4381
This commit is contained in:
parent
d0efe6eae2
commit
c1abca35da
|
@ -57,7 +57,7 @@ public final class Config {
|
||||||
public static final long CONTACT_SYNC_RETRY_INTERVAL = 1000L * 60 * 5;
|
public static final long CONTACT_SYNC_RETRY_INTERVAL = 1000L * 60 * 5;
|
||||||
|
|
||||||
|
|
||||||
public static final boolean SASL_2_ENABLED = false;
|
public static final boolean SASL_2_ENABLED = true;
|
||||||
|
|
||||||
//Notification settings
|
//Notification settings
|
||||||
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
|
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -488,17 +489,19 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Bookmark> getBookmarks() {
|
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) {
|
synchronized (this.bookmarks) {
|
||||||
this.bookmarks.clear();
|
this.bookmarks.clear();
|
||||||
this.bookmarks.putAll(bookmarks);
|
this.bookmarks.putAll(bookmarks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putBookmark(Bookmark bookmark) {
|
public void putBookmark(final Bookmark bookmark) {
|
||||||
synchronized (this.bookmarks) {
|
synchronized (this.bookmarks) {
|
||||||
this.bookmarks.put(bookmark.getJid(), bookmark);
|
this.bookmarks.put(bookmark.getJid(), bookmark);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1862,7 +1862,7 @@ public class XmppConnectionService extends Service {
|
||||||
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
|
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
|
||||||
Element query = iqPacket.query("jabber:iq:private");
|
Element query = iqPacket.query("jabber:iq:private");
|
||||||
Element storage = query.addChild("storage", "storage:bookmarks");
|
Element storage = query.addChild("storage", "storage:bookmarks");
|
||||||
for (Bookmark bookmark : account.getBookmarks()) {
|
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||||
storage.addChild(bookmark);
|
storage.addChild(bookmark);
|
||||||
}
|
}
|
||||||
sendIqPacket(account, iqPacket, mDefaultIqHandler);
|
sendIqPacket(account, iqPacket, mDefaultIqHandler);
|
||||||
|
@ -1870,8 +1870,8 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
private void pushBookmarksPep(Account account) {
|
private void pushBookmarksPep(Account account) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": pushing bookmarks via pep");
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": pushing bookmarks via pep");
|
||||||
Element storage = new Element("storage", "storage:bookmarks");
|
final Element storage = new Element("storage", "storage:bookmarks");
|
||||||
for (Bookmark bookmark : account.getBookmarks()) {
|
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||||
storage.addChild(bookmark);
|
storage.addChild(bookmark);
|
||||||
}
|
}
|
||||||
pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARKS, storage, "current", PublishOptions.persistentWhitelistAccess());
|
pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARKS, storage, "current", PublishOptions.persistentWhitelistAccess());
|
||||||
|
@ -4418,7 +4418,7 @@ public class XmppConnectionService extends Service {
|
||||||
for (final Account account : accounts) {
|
for (final Account account : accounts) {
|
||||||
if (account.getXmppConnection() != null) {
|
if (account.getXmppConnection() != null) {
|
||||||
mucServers.addAll(account.getXmppConnection().getMucServers());
|
mucServers.addAll(account.getXmppConnection().getMucServers());
|
||||||
for (Bookmark bookmark : account.getBookmarks()) {
|
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||||
final Jid jid = bookmark.getJid();
|
final Jid jid = bookmark.getJid();
|
||||||
final String s = jid == null ? null : jid.getDomain().toEscapedString();
|
final String s = jid == null ? null : jid.getDomain().toEscapedString();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
|
|
|
@ -980,9 +980,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
|
|
||||||
protected void filterConferences(String needle) {
|
protected void filterConferences(String needle) {
|
||||||
this.conferences.clear();
|
this.conferences.clear();
|
||||||
for (Account account : xmppConnectionService.getAccounts()) {
|
for (final Account account : xmppConnectionService.getAccounts()) {
|
||||||
if (account.getStatus() != Account.State.DISABLED) {
|
if (account.getStatus() != Account.State.DISABLED) {
|
||||||
for (Bookmark bookmark : account.getBookmarks()) {
|
for (final Bookmark bookmark : account.getBookmarks()) {
|
||||||
if (bookmark.match(this, needle)) {
|
if (bookmark.match(this, needle)) {
|
||||||
this.conferences.add(bookmark);
|
this.conferences.add(bookmark);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue