summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-26 11:22:06 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-26 11:22:06 (GMT)
commitfd6e929a54514d5c3f77956429d5ab5fb4271ff2 (patch)
tree59157c256de56e24f0aaf50efa50f2290afe4fee /Swift/Controllers/Chat
parent1e1e1f083b63769b019763c420ef8d556090459f (diff)
downloadswift-fd6e929a54514d5c3f77956429d5ab5fb4271ff2.zip
swift-fd6e929a54514d5c3f77956429d5ab5fb4271ff2.tar.bz2
Starting plumbing for MUC bookmarks
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp14
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 250f02d..ac03f8a 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -10,6 +10,7 @@
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
#include "Swiften/Presence/PresenceSender.h"
#include "Swiften/Elements/ChatState.h"
+#include "Swiften/MUC/MUCBookmarkManager.h"
namespace Swift {
@@ -28,6 +29,8 @@ ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRo
serverDiscoInfo_ = serverDiscoInfo;
presenceSender_ = presenceSender;
uiEventStream_ = uiEventStream;
+ mucBookmarkManager_ = new MUCBookmarkManager(iqRouter);
+ mucBookmarkManager_->onBookmarksChanged.connect(boost::bind(&ChatsManager::handleMUCBookmarksChanged, this));
presenceOracle_->onPresenceChange.connect(boost::bind(&ChatsManager::handlePresenceChange, this, _1, _2));
uiEventStream_->onUIEvent.connect(boost::bind(&ChatsManager::handleUIEvent, this, _1));
}
@@ -39,7 +42,18 @@ ChatsManager::~ChatsManager() {
foreach (JIDMUCControllerPair controllerPair, mucControllers_) {
delete controllerPair.second;
}
+ delete mucBookmarkManager_;
+}
+void ChatsManager::handleMUCBookmarksChanged() {
+ foreach (boost::shared_ptr<MUCBookmark> bookmark, mucBookmarkManager_->getBookmarks()) {
+ std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark->getRoom());
+ if (it == mucControllers_.end()) {
+ //FIXME: need vcard stuff here to get a nick
+ String nick = bookmark->getNick() ? bookmark->getNick().get() : "Swift user";
+ handleJoinMUCRequest(bookmark->getRoom(), nick);
+ }
+ }
}
void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> event) {
diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h
index 04d9330..bef766b 100644
--- a/Swift/Controllers/Chat/ChatsManager.h
+++ b/Swift/Controllers/Chat/ChatsManager.h
@@ -24,6 +24,7 @@ namespace Swift {
class StanzaChannel;
class IQRouter;
class PresenceSender;
+ class MUCBookmarkManager;
class ChatsManager : public MUCRegistry {
public:
@@ -39,6 +40,7 @@ namespace Swift {
void rebindControllerJID(const JID& from, const JID& to);
void handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> lastPresence);
void handleUIEvent(boost::shared_ptr<UIEvent> event);
+ void handleMUCBookmarksChanged();
ChatController* getChatController(const JID &contact);
virtual bool isMUC(const JID& muc) const;
@@ -55,6 +57,7 @@ namespace Swift {
AvatarManager* avatarManager_;
PresenceSender* presenceSender_;
UIEventStream* uiEventStream_;
+ MUCBookmarkManager* mucBookmarkManager_;
boost::shared_ptr<DiscoInfo> serverDiscoInfo_;
};
}