diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-05-06 13:08:57 (GMT) |
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-05-29 16:18:23 (GMT) |
| commit | b70a50f11da1ea57a0e89ff14882eed03944eb2a (patch) | |
| tree | bbe3d3f28104dcba7d276a7016da283665b8f326 /Swift/Controllers | |
| parent | ab612d0f18ff545b4ebcb2bf2bb400996e751181 (diff) | |
| download | swift-contrib-b70a50f11da1ea57a0e89ff14882eed03944eb2a.zip swift-contrib-b70a50f11da1ea57a0e89ff14882eed03944eb2a.tar.bz2 | |
Right-click MUC in Recents to bookmark.
Change-Id: Idfb5907adf9bf53f0ac1f417dd57d49ecc897bb0
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 17 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 4 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 1 | ||||
| -rw-r--r-- | Swift/Controllers/UIInterfaces/ChatListWindow.h | 7 |
4 files changed, 23 insertions, 6 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 654f735..1698b4a 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -5,18 +5,19 @@ */ #include <Swift/Controllers/Chat/ChatsManager.h> #include <boost/bind.hpp> #include <boost/algorithm/string.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/optional.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/split_free.hpp> #include <Swiften/Base/foreach.h> #include <Swiften/Presence/PresenceSender.h> #include <Swiften/Client/NickResolver.h> #include <Swiften/MUC/MUCManager.h> @@ -56,42 +57,47 @@ #include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/WhiteboardManager.h> #include <Swift/Controllers/Chat/ChatMessageParser.h> #include <Swift/Controllers/Chat/UserSearchController.h> #include <Swiften/Disco/DiscoServiceWalker.h> #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/StringCodecs/Base64.h> #include <Swiften/Base/Log.h> +BOOST_CLASS_VERSION(Swift::ChatListWindow::Chat, 1) + namespace boost { namespace serialization { template<class Archive> void save(Archive& ar, const Swift::JID& jid, const unsigned int /*version*/) { std::string jidStr = jid.toString(); ar << jidStr; } template<class Archive> void load(Archive& ar, Swift::JID& jid, const unsigned int /*version*/) { std::string stringJID; ar >> stringJID; jid = Swift::JID(stringJID); } template<class Archive> inline void serialize(Archive& ar, Swift::JID& t, const unsigned int file_version){ split_free(ar, t, file_version); } - template<class Archive> void serialize(Archive& ar, Swift::ChatListWindow::Chat& chat, const unsigned int /*version*/) { + template<class Archive> void serialize(Archive& ar, Swift::ChatListWindow::Chat& chat, const unsigned int version) { ar & chat.jid; ar & chat.chatName; ar & chat.activity; ar & chat.isMUC; ar & chat.nick; ar & chat.impromptuJIDs; + if (version > 0) { + ar & chat.password; + } } } } namespace Swift { typedef std::pair<JID, ChatController*> JIDChatControllerPair; typedef std::pair<JID, MUCController*> JIDMUCControllerPair; @@ -363,34 +369,39 @@ void ChatsManager::handleMUCBookmarkRemoved(const MUCBookmark& bookmark) { chatListWindow_->removeMUCBookmark(bookmark); } ChatListWindow::Chat ChatsManager::createChatListChatItem(const JID& jid, const std::string& activity) { int unreadCount = 0; if (mucRegistry_->isMUC(jid)) { MUCController* controller = mucControllers_[jid.toBare()]; StatusShow::Type type = StatusShow::None; std::string nick = ""; + std::string password = ""; if (controller) { unreadCount = controller->getUnreadCount(); if (controller->isJoined()) { type = StatusShow::Online; } nick = controller->getNick(); + if (controller->getPassword()) { + password = *controller->getPassword(); + } + if (controller->isImpromptu()) { - ChatListWindow::Chat chat = ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, boost::filesystem::path(), true, nick); + ChatListWindow::Chat chat = ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, boost::filesystem::path(), true, nick, password); typedef std::pair<std::string, JID> StringJIDPair; std::map<std::string, JID> participants = controller->getParticipantJIDs(); chat.impromptuJIDs = participants; return chat; } } - return ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, boost::filesystem::path(), true, nick); + return ChatListWindow::Chat(jid, jid.toString(), activity, unreadCount, type, boost::filesystem::path(), true, nick, password); } else { ChatController* controller = getChatControllerIfExists(jid, false); if (controller) { unreadCount = controller->getUnreadCount(); } JID bareishJID = mucRegistry_->isMUC(jid.toBare()) ? jid : jid.toBare(); Presence::ref presence = presenceOracle_->getHighestPriorityPresence(bareishJID); StatusShow::Type type = presence ? presence->getShow() : StatusShow::None; boost::filesystem::path avatarPath = avatarManager_ ? avatarManager_->getAvatarPath(bareishJID) : boost::filesystem::path(); diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 4860fc8..6bc7067 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -237,18 +237,22 @@ void MUCController::rejoin() { bool MUCController::isJoined() { return joined_; } const std::string& MUCController::getNick() { return nick_; } +const boost::optional<std::string> MUCController::getPassword() const { + return password_; +} + bool MUCController::isImpromptu() const { return isImpromptu_; } std::map<std::string, JID> MUCController::getParticipantJIDs() const { std::map<std::string, JID> participants; typedef std::pair<std::string, MUCOccupant> MUCOccupantPair; std::map<std::string, MUCOccupant> occupants = muc_->getOccupants(); foreach(const MUCOccupantPair& occupant, occupants) { diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index e78ff77..feffaba 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -56,18 +56,19 @@ namespace Swift { boost::signal<void ()> onUserJoined; boost::signal<void ()> onImpromptuConfigCompleted; virtual void setOnline(bool online); void rejoin(); static void appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent); static std::string generateJoinPartString(const std::vector<NickJoinPart>& joinParts, bool isImpromptu); static std::string concatenateListOfNames(const std::vector<NickJoinPart>& joinParts); bool isJoined(); const std::string& getNick(); + const boost::optional<std::string> getPassword() const; bool isImpromptu() const; std::map<std::string, JID> getParticipantJIDs() const; void sendInvites(const std::vector<JID>& jids, const std::string& reason) const; protected: void preSendMessageRequest(boost::shared_ptr<Message> message); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); std::string senderDisplayNameFromMessage(const JID& from); boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const; diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index 67cd0ff..38d8c3e 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2010-2011 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <list> #include <set> #include <map> @@ -16,20 +16,20 @@ #include <Swiften/Base/foreach.h> #include <Swiften/Base/boost_bsignals.h> namespace Swift { class ChatListWindow { public: class Chat { public: Chat() : statusType(StatusShow::None), isMUC(false), unreadCount(0) {} - Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, const std::string& nick = "") - : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), unreadCount(unreadCount), avatarPath(avatarPath) {} + Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, const std::string& nick = "", const boost::optional<std::string> password = boost::optional<std::string>()) + : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), password(password), unreadCount(unreadCount), avatarPath(avatarPath) {} /** Assume that nicks and other transient features aren't important for equality */ bool operator==(const Chat& other) const { if (impromptuJIDs.empty()) { return jid.toBare() == other.jid.toBare() && isMUC == other.isMUC; } else { /* compare the chat occupant lists */ typedef std::map<std::string, JID> JIDMap; foreach (const JIDMap::value_type& jid, impromptuJIDs) { bool found = false; @@ -67,18 +67,19 @@ namespace Swift { } return title; } JID jid; std::string chatName; std::string activity; StatusShow::Type statusType; bool isMUC; std::string nick; + boost::optional<std::string> password; int unreadCount; boost::filesystem::path avatarPath; std::map<std::string, JID> impromptuJIDs; }; virtual ~ChatListWindow(); virtual void setBookmarksEnabled(bool enabled) = 0; virtual void addMUCBookmark(const MUCBookmark& bookmark) = 0; virtual void addWhiteboardSession(const ChatListWindow::Chat& chat) = 0; |
Swift