diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-22 17:38:29 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-22 17:39:06 (GMT) |
commit | e8360f0dd62ea651e94f681499faef58747f2ece (patch) | |
tree | 5eeb231a12a44c65baf648b0350387a6f25986af /Swift | |
parent | 86e892137d512a11edde0aa7760fc1c15e598dad (diff) | |
download | swift-e8360f0dd62ea651e94f681499faef58747f2ece.zip swift-e8360f0dd62ea651e94f681499faef58747f2ece.tar.bz2 |
Support vCard-based avatars in MUCs.
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/ChatController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/ChatController.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/ChatControllerBase.cpp | 7 | ||||
-rw-r--r-- | Swift/Controllers/ChatControllerBase.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/MUCController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/MUCController.h | 5 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 7 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 17 |
8 files changed, 25 insertions, 20 deletions
diff --git a/Swift/Controllers/ChatController.cpp b/Swift/Controllers/ChatController.cpp index 39e9144..5fee3d2 100644 --- a/Swift/Controllers/ChatController.cpp +++ b/Swift/Controllers/ChatController.cpp @@ -31,7 +31,7 @@ void ChatController::postSendMessage(const String& body) { chatWindow_->addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), ""); } -String ChatController::senderDisplayNameFromMessage(JID from) { +String ChatController::senderDisplayNameFromMessage(const JID& from) { return nickResolver_->jidToNick(from); } diff --git a/Swift/Controllers/ChatController.h b/Swift/Controllers/ChatController.h index 265bc91..8168510 100644 --- a/Swift/Controllers/ChatController.h +++ b/Swift/Controllers/ChatController.h @@ -16,7 +16,7 @@ namespace Swift { bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); void postSendMessage(const String &body); void preHandleIncomingMessage(boost::shared_ptr<Message> message); - String senderDisplayNameFromMessage(JID from); + String senderDisplayNameFromMessage(const JID& from); private: NickResolver* nickResolver_; diff --git a/Swift/Controllers/ChatControllerBase.cpp b/Swift/Controllers/ChatControllerBase.cpp index e84ee04..91d088e 100644 --- a/Swift/Controllers/ChatControllerBase.cpp +++ b/Swift/Controllers/ChatControllerBase.cpp @@ -3,12 +3,12 @@ #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Avatars/AvatarManager.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Base/foreach.h" #include "Swift/Controllers/ChatWindow.h" #include "Swift/Controllers/ChatWindowFactory.h" #include "Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h" +#include "Swiften/Avatars/AvatarManager.h" namespace Swift { @@ -109,11 +109,6 @@ void ChatControllerBase::showChatWindow() { chatWindow_->show(); } -String ChatControllerBase::senderDisplayNameFromMessage(JID from) { - return from; -} - - void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent) { unreadMessages_.push_back(messageEvent); diff --git a/Swift/Controllers/ChatControllerBase.h b/Swift/Controllers/ChatControllerBase.h index 58d3a1d..5a322d2 100644 --- a/Swift/Controllers/ChatControllerBase.h +++ b/Swift/Controllers/ChatControllerBase.h @@ -5,6 +5,7 @@ #include <vector> #include <boost/shared_ptr.hpp> #include <boost/signals.hpp> +#include <boost/filesystem.hpp> #include "Swiften/Base/String.h" #include "Swiften/Elements/DiscoInfo.h" @@ -32,7 +33,7 @@ namespace Swift { ChatControllerBase(StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &toJID, PresenceOracle* presenceOracle, AvatarManager* avatarManager); virtual void postSendMessage(const String&) {}; - virtual String senderDisplayNameFromMessage(JID from); + virtual String senderDisplayNameFromMessage(const JID& from) = 0; void handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> previousPresence); virtual bool isIncomingMessageFromMe(boost::shared_ptr<Message>) = 0; virtual void preHandleIncomingMessage(boost::shared_ptr<Message>) {}; diff --git a/Swift/Controllers/MUCController.cpp b/Swift/Controllers/MUCController.cpp index 27ddcb8..e3615d9 100644 --- a/Swift/Controllers/MUCController.cpp +++ b/Swift/Controllers/MUCController.cpp @@ -66,7 +66,7 @@ bool MUCController::isIncomingMessageFromMe(boost::shared_ptr<Message> message) return nick_ == from.getResource(); } -String MUCController::senderDisplayNameFromMessage(JID from) { +String MUCController::senderDisplayNameFromMessage(const JID& from) { return from.getResource(); } diff --git a/Swift/Controllers/MUCController.h b/Swift/Controllers/MUCController.h index b2f396c..77335da 100644 --- a/Swift/Controllers/MUCController.h +++ b/Swift/Controllers/MUCController.h @@ -28,12 +28,15 @@ namespace Swift { protected: void preSendMessageRequest(boost::shared_ptr<Message> message); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - String senderDisplayNameFromMessage(JID from); + String senderDisplayNameFromMessage(const JID& from); + private: void handleWindowClosed(); void handleOccupantJoined(const MUCOccupant& occupant); void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const String& reason); void handleOccupantPresenceChange(boost::shared_ptr<Presence> presence); + + private: MUC *muc_; String nick_; TreeWidgetFactory *treeWidgetFactory_; diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 20dfaa1..93b7c2a 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -105,7 +105,7 @@ void MainController::handleConnected() { loginWindow_->morphInto(rosterController_->getWindow()); delete avatarManager_; - avatarManager_ = new AvatarManager(client_, client_, avatarStorage_); + avatarManager_ = new AvatarManager(client_, client_, avatarStorage_, this); DiscoInfo discoInfo; discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc")); @@ -271,4 +271,9 @@ void MainController::handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> } } +bool MainController::isMUC(const JID& jid) const { + return mucControllers_.find(jid.toBare()) != mucControllers_.end(); +} + + } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index aa6a85b..650afd1 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -1,6 +1,9 @@ #ifndef SWIFTEN_MainController_H #define SWIFTEN_MainController_H +#include <boost/signals.hpp> +#include <boost/shared_ptr.hpp> +#include <vector> #include "Swiften/Base/String.h" #include "Swiften/Client/ClientError.h" @@ -11,12 +14,7 @@ #include "Swiften/Elements/Message.h" #include "Swiften/Settings/SettingsProvider.h" #include "Swiften/Elements/CapsInfo.h" - - -#include <boost/signals.hpp> -#include <boost/shared_ptr.hpp> - -#include <vector> +#include "Swiften/MUC/MUCRegistry.h" namespace Swift { class AvatarStorage; @@ -42,7 +40,7 @@ namespace Swift { class SystemTray; class SystemTrayController; - class MainController { + class MainController : public MUCRegistry { public: MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray); ~MainController(); @@ -62,7 +60,10 @@ namespace Swift { void handleEventQueueLengthChange(int count); ChatController* getChatController(const JID &contact); void logout(); - + + virtual bool isMUC(const JID& muc) const; + + private: Client* client_; ChatWindowFactory* chatWindowFactory_; MainWindowFactory* mainWindowFactory_; |