aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java5
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java52
2 files changed, 35 insertions, 22 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index b3e6bc396..1b9fb2f58 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -331,9 +331,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (item != null) {
final Bookmark bookmark = Bookmark.parseFromItem(item, account);
if (bookmark != null) {
- //TODO find conversation
- account.putBookmark(bookmark);
- //TODO handle autojoin
+ mXmppConnectionService.processModifiedBookmark(bookmark);
}
}
if (retract != null) {
@@ -341,6 +339,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (id != null) {
account.removeBookmark(id);
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": deleted bookmark for " + id);
+ mXmppConnectionService.processDeletedBookmark(account, id);
}
}
} else {
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index b47fbdf1b..35ed69c60 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1832,34 +1832,48 @@ public class XmppConnectionService extends Service {
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
for (Bookmark bookmark : bookmarks.values()) {
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);
- }
+ processModifiedBookmark(bookmark, pep, synchronizeWithBookmarks);
}
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);
- }
+ processDeletedBookmark(account, jid);
}
}
account.setBookmarks(bookmarks);
}
+ public void processDeletedBookmark(Account account, Jid jid) {
+ 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);
+ }
+ }
+
+ private void processModifiedBookmark(Bookmark bookmark, final boolean pep, final boolean synchronizeWithBookmarks) {
+ final Account account = bookmark.getAccount();
+ Conversation conversation = find(bookmark);
+ if (conversation != null) {
+ if (conversation.getMode() != Conversation.MODE_MULTI) {
+ return;
+ }
+ 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);
+ }
+ }
+
+ public void processModifiedBookmark(Bookmark bookmark) {
+ final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
+ processModifiedBookmark(bookmark, true, synchronizeWithBookmarks);
+ }
+
public void createBookmark(final Account account, final Bookmark bookmark) {
account.putBookmark(bookmark);
final XmppConnection connection = account.getXmppConnection();