diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Whiteboard/WhiteboardResponder.cpp | 4 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSessionManager.cpp | 42 | ||||
-rw-r--r-- | Swiften/Whiteboard/WhiteboardSessionManager.h | 11 |
3 files changed, 19 insertions, 38 deletions
diff --git a/Swiften/Whiteboard/WhiteboardResponder.cpp b/Swiften/Whiteboard/WhiteboardResponder.cpp index 4074f26..f72861f 100644 --- a/Swiften/Whiteboard/WhiteboardResponder.cpp +++ b/Swiften/Whiteboard/WhiteboardResponder.cpp @@ -18,7 +18,7 @@ namespace Swift { bool WhiteboardResponder::handleSetRequest(const JID& from, const JID& /*to*/, const std::string& id, boost::shared_ptr<WhiteboardPayload> payload) { if (payload->getType() == WhiteboardPayload::SessionRequest) { - if (sessionManager_->getSession(from.toBare())) { + if (sessionManager_->getSession(from)) { sendError(from, id, ErrorPayload::Conflict, ErrorPayload::Cancel); } else { sendResponse(from, id, boost::shared_ptr<WhiteboardPayload>()); @@ -27,7 +27,7 @@ namespace Swift { } } else { sendResponse(from, id, boost::shared_ptr<WhiteboardPayload>()); - WhiteboardSession::ref session = sessionManager_->getSession(from.toBare()); + WhiteboardSession::ref session = sessionManager_->getSession(from); if (session != NULL) { session->handleIncomingAction(payload); } diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp index effdc4b..88771e7 100644 --- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp +++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp @@ -27,10 +27,10 @@ namespace Swift { } WhiteboardSession::ref WhiteboardSessionManager::getSession(const JID& to) { - if (sessions_.find(to.toBare()) == sessions_.end()) { + if (sessions_.find(to) == sessions_.end()) { return boost::shared_ptr<WhiteboardSession>(); } - return sessions_[to.toBare()]; + return sessions_[to]; } OutgoingWhiteboardSession::ref WhiteboardSessionManager::createOutgoingSession(const JID& to) { @@ -39,11 +39,10 @@ namespace Swift { fullJID = getFullJID(fullJID); } OutgoingWhiteboardSession::ref session = boost::make_shared<OutgoingWhiteboardSession>(fullJID, router_); - sessions_[to.toBare()] = session; - session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::handleSessionTerminate, this, _1)); - session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancel, this, _1)); - session->onRequestAccepted.connect(boost::bind(&WhiteboardSessionManager::handleSessionAccept, this, _1)); - session->onRequestRejected.connect(boost::bind(&WhiteboardSessionManager::handleRequestReject, this, _1)); + sessions_[fullJID] = session; + session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::deleteSessionEntry, this, _1)); + session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::deleteSessionEntry, this, _1)); + session->onRequestRejected.connect(boost::bind(&WhiteboardSessionManager::deleteSessionEntry, this, _1)); return session; } @@ -51,7 +50,6 @@ namespace Swift { WhiteboardSession::ref session = getSession(to); if (!session) { OutgoingWhiteboardSession::ref outgoingSession = createOutgoingSession(to); - onSessionRequest(to, true); outgoingSession->startSession(); return outgoingSession; } else { @@ -60,11 +58,10 @@ namespace Swift { } void WhiteboardSessionManager::handleIncomingSession(IncomingWhiteboardSession::ref session) { - sessions_[session->getTo().toBare()] = session; - session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::handleSessionTerminate, this, _1)); - session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancel, this, _1)); - session->onRequestAccepted.connect(boost::bind(&WhiteboardSessionManager::handleSessionAccept, this, _1)); - onSessionRequest(session->getTo(), false); + sessions_[session->getTo()] = session; + session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::deleteSessionEntry, this, _1)); + session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::deleteSessionEntry, this, _1)); + onSessionRequest(session); } JID WhiteboardSessionManager::getFullJID(const JID& bareJID) { @@ -89,22 +86,7 @@ namespace Swift { return fullReceipientJID; } - void WhiteboardSessionManager::handleSessionTerminate(const JID& contact) { - sessions_.erase(contact.toBare()); - onSessionTerminate(contact); - } - - void WhiteboardSessionManager::handleSessionCancel(const JID& contact) { - sessions_.erase(contact.toBare()); - onSessionTerminate(contact); - } - - void WhiteboardSessionManager::handleSessionAccept(const JID& contact) { - onRequestAccepted(contact); - } - - void WhiteboardSessionManager::handleRequestReject(const JID& contact) { - sessions_.erase(contact.toBare()); - onRequestRejected(contact); + void WhiteboardSessionManager::deleteSessionEntry(const JID& contact) { + sessions_.erase(contact); } } diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.h b/Swiften/Whiteboard/WhiteboardSessionManager.h index b63066e..faccb97 100644 --- a/Swiften/Whiteboard/WhiteboardSessionManager.h +++ b/Swiften/Whiteboard/WhiteboardSessionManager.h @@ -26,23 +26,22 @@ namespace Swift { public: WhiteboardSessionManager(IQRouter* router, PresenceOracle* presenceOracle, EntityCapsProvider* capsProvider); ~WhiteboardSessionManager(); + WhiteboardSession::ref getSession(const JID& to); WhiteboardSession::ref requestSession(const JID& to); public: - boost::signal< void (const JID&, bool senderIsSelf)> onSessionRequest; + /*boost::signal< void (const JID&, bool senderIsSelf)> onSessionRequest; boost::signal< void (const JID&)> onSessionTerminate; boost::signal< void (const JID&)> onRequestAccepted; - boost::signal< void (const JID&)> onRequestRejected; + boost::signal< void (const JID&)> onRequestRejected;*/ + boost::signal< void (IncomingWhiteboardSession::ref)> onSessionRequest; private: JID getFullJID(const JID& bareJID); OutgoingWhiteboardSession::ref createOutgoingSession(const JID& to); void handleIncomingSession(IncomingWhiteboardSession::ref session); - void handleSessionTerminate(const JID& contact); - void handleSessionCancel(const JID& contact); - void handleSessionAccept(const JID& contact); - void handleRequestReject(const JID& contact); + void deleteSessionEntry(const JID& contact); private: std::map<JID, boost::shared_ptr<WhiteboardSession> > sessions_; |