From 909ecaea63618e9b94c9063c94cd51aa69654b00 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Fri, 11 Sep 2015 00:39:47 +0200 Subject: Show potentially existing MUC bookmark in chat window bookmark dialog The MUC bookmark editor window opened from the chat window would always show a new bookmark. With this commit it will show the existing bookmark if it exists. Otherwise it will show a new bookmark. Test-Information: Tested this behavior by creating a bookmark, changing name and nickname to different values and verified that the bookmark dialog for this room, opened from its chat view, would show the existing bookmark. Change-Id: I6766253ce11be271016473dff1105369482e73df diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index c9936c0..35e79cc 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -928,10 +928,22 @@ void MUCController::handleChangeSubjectRequest(const std::string& subject) { void MUCController::handleBookmarkRequest() { const JID jid = muc_->getJID(); - MUCBookmark bookmark(jid, jid.toBare().toString()); - bookmark.setPassword(password_); - bookmark.setNick(nick_); - chatWindow_->showBookmarkWindow(bookmark); + + // Prepare new bookmark for this room. + MUCBookmark roomBookmark(jid, jid.toBare().toString()); + roomBookmark.setPassword(password_); + roomBookmark.setNick(nick_); + + // Check for existing bookmark for this room and, if it exists, use it instead. + std::vector bookmarks = mucBookmarkManager_->getBookmarks(); + foreach (const MUCBookmark& bookmark, bookmarks) { + if (bookmark.getRoom() == jid.toBare()) { + roomBookmark = bookmark; + break; + } + } + + chatWindow_->showBookmarkWindow(roomBookmark); } void MUCController::handleConfigureRequest(Form::ref form) { -- cgit v0.10.2-6-g49f6