summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp2
-rw-r--r--Swiften/Client/Client.cpp2
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.cpp23
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.h4
4 files changed, 26 insertions, 5 deletions
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index 798f8b3..fe57d95 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -101,7 +101,7 @@ public:
chatListWindow_ = new MockChatListWindow();
ftManager_ = new DummyFileTransferManager();
ftOverview_ = new FileTransferOverview(ftManager_);
- wbSessionManager_ = new WhiteboardSessionManager(iqRouter_, presenceOracle_);
+ wbSessionManager_ = new WhiteboardSessionManager(iqRouter_, presenceOracle_, entityCapsManager_);
mocks_->ExpectCall(chatListWindowFactory_, ChatListWindowFactory::createChatListWindow).With(uiEventStream_).Return(chatListWindow_);
manager_ = new ChatsManager(jid_, stanzaChannel_, iqRouter_, eventController_, chatWindowFactory_, joinMUCWindowFactory_, nickResolver_, presenceOracle_, directedPresenceSender_, uiEventStream_, chatListWindowFactory_, true, NULL, mucRegistry_, entityCapsManager_, mucManager_, mucSearchWindowFactory_, profileSettings_, ftOverview_, xmppRoster_, false, settings_, wbSessionManager_);
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index cc853b2..a631590 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -70,7 +70,7 @@ Client::Client(const JID& jid, const SafeString& password, NetworkFactories* net
jingleSessionManager = new JingleSessionManager(getIQRouter());
fileTransferManager = NULL;
- whiteboardSessionManager = new WhiteboardSessionManager(getIQRouter(), presenceOracle);
+ whiteboardSessionManager = new WhiteboardSessionManager(getIQRouter(), presenceOracle, getEntityCapsProvider());
}
Client::~Client() {
diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
index 253febe..038482b 100644
--- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp
+++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
@@ -7,13 +7,15 @@
#include <Swiften/Whiteboard/WhiteboardSessionManager.h>
+#include <Swiften/Base/foreach.h>
#include <boost/bind.hpp>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Whiteboard/WhiteboardResponder.h>
#include <Swiften/Presence/PresenceOracle.h>
+#include "Swiften/Disco/EntityCapsProvider.h"
namespace Swift {
- WhiteboardSessionManager::WhiteboardSessionManager(IQRouter* router, PresenceOracle* presenceOracle) : router_(router), presenceOracle_(presenceOracle) {
+ WhiteboardSessionManager::WhiteboardSessionManager(IQRouter* router, PresenceOracle* presenceOracle, EntityCapsProvider* capsProvider) : router_(router), presenceOracle_(presenceOracle), capsProvider_(capsProvider) {
responder = new WhiteboardResponder(this, router);
responder->start();
}
@@ -64,8 +66,25 @@ namespace Swift {
}
JID WhiteboardSessionManager::getFullJID(const JID& bareJID) {
+ JID fullReceipientJID;
+ int priority = INT_MIN;
+
+ //getAllPresence(bareJID) gives you all presences for the bare JID (i.e. all resources) Remko Tronçon @ 11:11
std::vector<Presence::ref> presences = presenceOracle_->getAllPresence(bareJID);
- return presences[0]->getFrom();
+
+ //iterate over them
+ foreach(Presence::ref pres, presences) {
+ if (pres->getPriority() > priority) {
+ // look up caps from the jid
+ DiscoInfo::ref info = capsProvider_->getCaps(pres->getFrom());
+ if (info && info->hasFeature(DiscoInfo::WhiteboardFeature)) {
+ priority = pres->getPriority();
+ fullReceipientJID = pres->getFrom();
+ }
+ }
+ }
+
+ return fullReceipientJID;
}
void WhiteboardSessionManager::handleSessionTerminate(const JID& contact) {
diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.h b/Swiften/Whiteboard/WhiteboardSessionManager.h
index 9711e5b..b63066e 100644
--- a/Swiften/Whiteboard/WhiteboardSessionManager.h
+++ b/Swiften/Whiteboard/WhiteboardSessionManager.h
@@ -19,11 +19,12 @@ namespace Swift {
class IQRouter;
class WhiteboardResponder;
class PresenceOracle;
+ class EntityCapsProvider;
class WhiteboardSessionManager {
friend class WhiteboardResponder;
public:
- WhiteboardSessionManager(IQRouter* router, PresenceOracle* presenceOracle);
+ WhiteboardSessionManager(IQRouter* router, PresenceOracle* presenceOracle, EntityCapsProvider* capsProvider);
~WhiteboardSessionManager();
WhiteboardSession::ref getSession(const JID& to);
WhiteboardSession::ref requestSession(const JID& to);
@@ -47,6 +48,7 @@ namespace Swift {
std::map<JID, boost::shared_ptr<WhiteboardSession> > sessions_;
IQRouter* router_;
PresenceOracle* presenceOracle_;
+ EntityCapsProvider* capsProvider_;
WhiteboardResponder* responder;
};
}