aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-11 19:28:44 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-11 19:28:44 +0100
commitb2c278c91bc2a733dcb807d7eb7f0d3e7145d9c2 (patch)
treed37d2a45c8e0318984f3015c993bf3c2c9914b02
parent293e820a5857ffff5301babc43fc08120a35385c (diff)
set bookmark name to room subject if no subject has been set before
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Bookmark.java10
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java12
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java1
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 0210da24..acb4bf1a 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 49c3134c..d8190b70 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 cb193167..3be56b04 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 adae7916..b3de28b3 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);