set bookmark name to room subject if no subject has been set before
This commit is contained in:
parent
293e820a58
commit
b2c278c91b
|
@ -138,6 +138,16 @@ public class Bookmark extends Element implements ListItem {
|
||||||
return this.getAttribute("name");
|
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() {
|
public void unregisterConversation() {
|
||||||
if (this.mJoinedConversation != null) {
|
if (this.mJoinedConversation != null) {
|
||||||
this.mJoinedConversation.deregisterWithBookmark();
|
this.mJoinedConversation.deregisterWithBookmark();
|
||||||
|
|
|
@ -14,6 +14,7 @@ import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import eu.siacs.conversations.entities.Bookmark;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
|
@ -458,7 +459,14 @@ public class MessageParser extends AbstractParser implements
|
||||||
if (packet.hasChild("subject")) {
|
if (packet.hasChild("subject")) {
|
||||||
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
conversation.setHasMessagesLeftOnServer(conversation.countMessages() > 0);
|
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();
|
mXmppConnectionService.updateConversationUi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,9 +250,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
account.getRoster().clearPresences();
|
account.getRoster().clearPresences();
|
||||||
fetchRosterFromServer(account);
|
fetchRosterFromServer(account);
|
||||||
fetchBookmarks(account);
|
fetchBookmarks(account);
|
||||||
|
mMessageArchiveService.executePendingQueries(account);
|
||||||
sendPresence(account);
|
sendPresence(account);
|
||||||
connectMultiModeConversations(account);
|
connectMultiModeConversations(account);
|
||||||
mMessageArchiveService.executePendingQueries(account);
|
|
||||||
mJingleConnectionManager.cancelInTransmission();
|
mJingleConnectionManager.cancelInTransmission();
|
||||||
syncDirtyContacts(account);
|
syncDirtyContacts(account);
|
||||||
}
|
}
|
||||||
|
@ -1015,6 +1015,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushBookmarks(Account account) {
|
public void pushBookmarks(Account account) {
|
||||||
|
Log.d(Config.LOGTAG, account.getJid().toBareJid()+": pushing bookmarks");
|
||||||
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
|
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
|
||||||
Element query = iqPacket.query("jabber:iq:private");
|
Element query = iqPacket.query("jabber:iq:private");
|
||||||
Element storage = query.addChild("storage", "storage:bookmarks");
|
Element storage = query.addChild("storage", "storage:bookmarks");
|
||||||
|
|
|
@ -420,6 +420,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
if (!mConversation.getJid().isBareJid()) {
|
if (!mConversation.getJid().isBareJid()) {
|
||||||
bookmark.setNick(mConversation.getJid().getResourcepart());
|
bookmark.setNick(mConversation.getJid().getResourcepart());
|
||||||
}
|
}
|
||||||
|
bookmark.setBookmarkName(mConversation.getMucOptions().getSubject());
|
||||||
bookmark.setAutojoin(true);
|
bookmark.setAutojoin(true);
|
||||||
account.getBookmarks().add(bookmark);
|
account.getBookmarks().add(bookmark);
|
||||||
xmppConnectionService.pushBookmarks(account);
|
xmppConnectionService.pushBookmarks(account);
|
||||||
|
|
Loading…
Reference in New Issue