aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java36
2 files changed, 30 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 4df9f955d..d8461d940 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -311,7 +311,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (account.getXmppConnection().getFeatures().bookmarksConversion()) {
final Element i = items.findChild("item");
final Element storage = i == null ? null : i.findChild("storage", Namespace.BOOKMARKS);
- mXmppConnectionService.processBookmarks(account, storage);
+ mXmppConnectionService.processBookmarks(account, storage, true);
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": processing bookmark PEP event");
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring bookmark PEP event because bookmark conversion was not detected");
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 205f4db48..644325e2c 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1598,7 +1598,7 @@ 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);
+ processBookmarks(a, storage, false);
} else {
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": could not fetch bookmarks");
}
@@ -1606,9 +1606,9 @@ public class XmppConnectionService extends Service {
sendIqPacket(account, iqPacket, callback);
}
- public void processBookmarks(Account account, Element storage) {
+ public void processBookmarks(Account account, Element storage, final boolean pep) {
final HashMap<Jid, Bookmark> bookmarks = new HashMap<>();
- final boolean autojoin = respectAutojoin();
+ final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
if (storage != null) {
for (final Element item : storage.getChildren()) {
if (item.getName().equals("conference")) {
@@ -1617,10 +1617,20 @@ public class XmppConnectionService extends Service {
if (old != null && old.getBookmarkName() != null && bookmark.getBookmarkName() == null) {
bookmark.setBookmarkName(old.getBookmarkName());
}
+ if (bookmark.getJid() == null) {
+ continue;
+ }
Conversation conversation = find(bookmark);
if (conversation != null) {
+ if (conversation.getMode() != Conversation.MODE_MULTI) {
+ continue;
+ }
bookmark.setConversation(conversation);
- } else if (bookmark.autojoin() && bookmark.getJid() != null && autojoin) {
+ 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);
}
@@ -2078,6 +2088,10 @@ public class XmppConnectionService extends Service {
}
public void archiveConversation(Conversation conversation) {
+ archiveConversation(conversation, true);
+ }
+
+ private void archiveConversation(Conversation conversation, final boolean maySyncronizeWithBookmarks) {
getNotificationService().clear(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED);
conversation.setNextMessage(null);
@@ -2086,7 +2100,7 @@ public class XmppConnectionService extends Service {
if (conversation.getMode() == Conversation.MODE_MULTI) {
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
Bookmark bookmark = conversation.getBookmark();
- if (bookmark != null && bookmark.autojoin() && respectAutojoin()) {
+ if (maySyncronizeWithBookmarks && bookmark != null && bookmark.autojoin() && synchronizeWithBookmarks()) {
bookmark.setAutojoin(false);
pushBookmarks(bookmark.getAccount());
}
@@ -2593,11 +2607,19 @@ public class XmppConnectionService extends Service {
@Override
public void onConferenceConfigurationFetched(Conversation conversation) {
+ if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": conversation (" + conversation.getJid() + ") got archived before IQ result");
+ return;
+ }
join(conversation);
}
@Override
public void onFetchFailed(final Conversation conversation, Element error) {
+ if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": conversation (" + conversation.getJid() + ") got archived before IQ result");
+ return;
+ }
if (error != null && "remote-server-not-found".equals(error.getName())) {
conversation.getMucOptions().setError(MucOptions.Error.SERVER_NOT_FOUND);
updateConversationUi();
@@ -2689,7 +2711,7 @@ public class XmppConnectionService extends Service {
if (conversation.getMode() == Conversation.MODE_MULTI) {
conversation.getMucOptions().setPassword(password);
if (conversation.getBookmark() != null) {
- if (respectAutojoin()) {
+ if (synchronizeWithBookmarks()) {
conversation.getBookmark().setAutojoin(true);
}
pushBookmarks(conversation.getAccount());
@@ -3749,7 +3771,7 @@ public class XmppConnectionService extends Service {
return getBooleanPreference("chat_states", R.bool.chat_states);
}
- private boolean respectAutojoin() {
+ private boolean synchronizeWithBookmarks() {
return getBooleanPreference("autojoin", R.bool.autojoin);
}