summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-07-31 11:46:01 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-07-31 11:46:01 (GMT)
commit6f300f03ed9a61b56dc69dab327869dd7ba4ff10 (patch)
tree430c4e43b8477d54a7b7a362f8ec3bb5343f03d9 /Swiften/Whiteboard
parent10c32b6e6ae334b5ad5280da6e526609e0e9370a (diff)
downloadswift-contrib-6f300f03ed9a61b56dc69dab327869dd7ba4ff10.zip
swift-contrib-6f300f03ed9a61b56dc69dab327869dd7ba4ff10.tar.bz2
Improved resource with whiteboard capabilities finding
Diffstat (limited to 'Swiften/Whiteboard')
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.cpp23
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.h4
2 files changed, 24 insertions, 3 deletions
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;
};
}