leave/join on bookmark modifactions
This commit is contained in:
parent
f26e0720c6
commit
94c592f213
|
@ -239,9 +239,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) {
|
||||
|
@ -249,6 +247,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 {
|
||||
|
|
|
@ -1592,10 +1592,31 @@ public class XmppConnectionService extends Service {
|
|||
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
|
||||
for (Bookmark bookmark : bookmarks.values()) {
|
||||
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);
|
||||
if (conversation != null) {
|
||||
if (conversation.getMode() != Conversation.MODE_MULTI) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
bookmark.setConversation(conversation);
|
||||
if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) {
|
||||
|
@ -1607,17 +1628,10 @@ public class XmppConnectionService extends Service {
|
|||
bookmark.setConversation(conversation);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
account.setBookmarks(bookmarks);
|
||||
|
||||
public void processModifiedBookmark(Bookmark bookmark) {
|
||||
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
|
||||
processModifiedBookmark(bookmark, true, synchronizeWithBookmarks);
|
||||
}
|
||||
|
||||
public void createBookmark(final Account account, final Bookmark bookmark) {
|
||||
|
|
Loading…
Reference in a new issue