leave/join on bookmark modifactions

This commit is contained in:
Daniel Gultsch 2019-09-28 10:16:29 +02:00
parent f26e0720c6
commit 94c592f213
2 changed files with 35 additions and 22 deletions

View File

@ -239,9 +239,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (item != null) { if (item != null) {
final Bookmark bookmark = Bookmark.parseFromItem(item, account); final Bookmark bookmark = Bookmark.parseFromItem(item, account);
if (bookmark != null) { if (bookmark != null) {
//TODO find conversation mXmppConnectionService.processModifiedBookmark(bookmark);
account.putBookmark(bookmark);
//TODO handle autojoin
} }
} }
if (retract != null) { if (retract != null) {
@ -249,6 +247,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (id != null) { if (id != null) {
account.removeBookmark(id); account.removeBookmark(id);
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmark for "+id); Log.d(Config.LOGTAG,account.getJid().asBareJid()+": deleted bookmark for "+id);
mXmppConnectionService.processDeletedBookmark(account, id);
} }
} }
} else { } else {

View File

@ -1592,10 +1592,31 @@ public class XmppConnectionService extends Service {
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
for (Bookmark bookmark : bookmarks.values()) { for (Bookmark bookmark : bookmarks.values()) {
previousBookmarks.remove(bookmark.getJid().asBareJid()); previousBookmarks.remove(bookmark.getJid().asBareJid());
processModifiedBookmark(bookmark, pep, synchronizeWithBookmarks);
}
if (pep && synchronizeWithBookmarks) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed");
for (Jid jid : previousBookmarks) {
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); Conversation conversation = find(bookmark);
if (conversation != null) { if (conversation != null) {
if (conversation.getMode() != Conversation.MODE_MULTI) { if (conversation.getMode() != Conversation.MODE_MULTI) {
continue; return;
} }
bookmark.setConversation(conversation); bookmark.setConversation(conversation);
if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) { if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) {
@ -1607,17 +1628,10 @@ public class XmppConnectionService extends Service {
bookmark.setConversation(conversation); bookmark.setConversation(conversation);
} }
} }
if (pep && synchronizeWithBookmarks) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed"); public void processModifiedBookmark(Bookmark bookmark) {
for (Jid jid : previousBookmarks) { final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
final Conversation conversation = find(account, jid); processModifiedBookmark(bookmark, true, synchronizeWithBookmarks);
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(bookmarks);
} }
public void createBookmark(final Account account, final Bookmark bookmark) { public void createBookmark(final Account account, final Bookmark bookmark) {