diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-08 13:37:12 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-08 13:37:12 (GMT) |
commit | 6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad (patch) | |
tree | fd2c0a48c6f5d033fe742790fb2e640d7e13ba91 /Swiften/Whiteboard/WhiteboardSessionManager.cpp | |
parent | 13ededd86bfb5dc5115af69d79810122313273b5 (diff) | |
download | swift-contrib-6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad.zip swift-contrib-6e9fb4e4a3aeee8c40617a4dda6e5e0892ceebad.tar.bz2 |
Added handling of whiteboard session requests
Diffstat (limited to 'Swiften/Whiteboard/WhiteboardSessionManager.cpp')
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSessionManager.cpp | 36 |
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(); |