diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-12-11 19:28:44 +0100 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-12-12 15:53:43 +0100 |
commit | 1f47a03294f6e59bfa9f0f79343736a1f726d1c8 (patch) | |
tree | 0d03380be8d520f19498f77b22ce7319dfdfd98a /src/main/java/eu/siacs/conversations | |
parent | 459984c47c064a6392132a4b50d129a5b9d0c4ff (diff) |
set bookmark name to room subject if no subject has been set before
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
4 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java index 0210da245..acb4bf1a3 100644 --- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java +++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java @@ -138,6 +138,16 @@ public class Bookmark extends Element implements ListItem { return this.getAttribute("name"); } + public boolean setBookmarkName(String name) { + String before = getBookmarkName(); + if (name != null && !name.equals(before)) { + this.setAttribute("name", name); + return true; + } else { + return false; + } + } + public void unregisterConversation() { if (this.mJoinedConversation != null) { this.mJoinedConversation.deregisterWithBookmark(); diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 49c3134cf..d8190b707 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -14,6 +14,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage; import eu.siacs.conversations.entities.Account; +import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; @@ -387,7 +388,7 @@ public class MessageParser extends AbstractParser implements message.setType(Message.TYPE_PRIVATE); } } - updateLastseen(packet,account,true); + updateLastseen(packet, account, true); boolean checkForDuplicates = query != null || (isTypeGroupChat && packet.hasChild("delay","urn:xmpp:delay")) || message.getType() == Message.TYPE_PRIVATE; @@ -458,7 +459,14 @@ public class MessageParser extends AbstractParser implements if (packet.hasChild("subject")) { if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { conversation.setHasMessagesLeftOnServer(conversation.countMessages() > 0); - conversation.getMucOptions().setSubject(packet.findChildContent("subject")); + String subject = packet.findChildContent("subject"); + conversation.getMucOptions().setSubject(subject); + final Bookmark bookmark = conversation.getBookmark(); + if (bookmark != null && bookmark.getBookmarkName() == null) { + if (bookmark.setBookmarkName(subject)) { + mXmppConnectionService.pushBookmarks(account); + } + } mXmppConnectionService.updateConversationUi(); return; } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index cb193167a..3be56b042 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -250,9 +250,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa account.getRoster().clearPresences(); fetchRosterFromServer(account); fetchBookmarks(account); + mMessageArchiveService.executePendingQueries(account); sendPresence(account); connectMultiModeConversations(account); - mMessageArchiveService.executePendingQueries(account); mJingleConnectionManager.cancelInTransmission(); syncDirtyContacts(account); } @@ -1015,6 +1015,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public void pushBookmarks(Account account) { + Log.d(Config.LOGTAG, account.getJid().toBareJid()+": pushing bookmarks"); IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET); Element query = iqPacket.query("jabber:iq:private"); Element storage = query.addChild("storage", "storage:bookmarks"); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index adae79168..b3de28b38 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -420,6 +420,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers if (!mConversation.getJid().isBareJid()) { bookmark.setNick(mConversation.getJid().getResourcepart()); } + bookmark.setBookmarkName(mConversation.getMucOptions().getSubject()); bookmark.setAutojoin(true); account.getBookmarks().add(bookmark); xmppConnectionService.pushBookmarks(account); |