summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Whiteboard/WhiteboardSessionManager.cpp')
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
index 3b82cda..ccbc4d7 100644
--- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp
+++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
@@ -7,6 +7,7 @@
#include <Swiften/Whiteboard/WhiteboardSessionManager.h>
+#include <boost/bind.hpp>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Whiteboard/WhiteboardSession.h>
#include <Swiften/Whiteboard/WhiteboardResponder.h>
@@ -24,18 +25,45 @@ namespace Swift {
}
WhiteboardSession* WhiteboardSessionManager::getSession(const JID& to) {
- if (sessions_.find(to) == sessions_.end()) {
+ if (sessions_.find(to.toBare()) == sessions_.end()) {
return NULL;
}
- return sessions_[to];
+ return sessions_[to.toBare()];
}
WhiteboardSession* WhiteboardSessionManager::createSession(const JID& to) {
- WhiteboardSession* session = new WhiteboardSession(getFullJID(to), router_);
- sessions_[to] = session;
+ JID fullJID = to;
+ if (fullJID.isBare()) {
+ fullJID = getFullJID(fullJID);
+ }
+ WhiteboardSession* session = new WhiteboardSession(fullJID, router_);
+ sessions_[to.toBare()] = session;
+ return session;
+ }
+
+ WhiteboardSession* WhiteboardSessionManager::acceptSession(const JID& to) {
+ responder->sendRequestResponse(to, true);
+ WhiteboardSession* session = getSession(to);
+ if (session == NULL) {
+ return createSession(to);
+ }
return session;
}
+ void WhiteboardSessionManager::requestSession(const JID& to) {
+ WhiteboardSession* session = createSession(to);
+ session->onRequestAccepted.connect(boost::bind(&WhiteboardSessionManager::handleRequestAccepted, this, _1, _2));
+ session->sendSessionRequest();
+ }
+
+ void WhiteboardSessionManager::cancelSession(const JID& to) {
+ responder->sendRequestResponse(to, false);
+ }
+
+ void WhiteboardSessionManager::handleRequestAccepted(const JID& contact, WhiteboardSession* session) {
+ onRequestAccepted(contact, session);
+ }
+
JID WhiteboardSessionManager::getFullJID(const JID& bareJID) {
std::vector<Presence::ref> presences = presenceOracle_->getAllPresence(bareJID);
return presences[0]->getFrom();