/* * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include #include #include namespace Swift { WhiteboardResponder::WhiteboardResponder(WhiteboardSessionManager* sessionManager, IQRouter* router) : SetResponder(router), sessionManager_(sessionManager), router_(router) { } bool WhiteboardResponder::handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr payload) { if (payload->getType() == WhiteboardPayload::SessionRequest) { sessionManager_->onRequestReceived(from); sessionRequests_[from] = id; } else { sendResponse(from, id, boost::shared_ptr()); WhiteboardSession* session = sessionManager_->getSession(from.toBare()); if (session != NULL) { session->handleIncomingAction(payload); } } return true; } void WhiteboardResponder::sendRequestResponse(const JID& contact, bool accepted) { if (sessionRequests_.find(contact) == sessionRequests_.end()) { return; } if (accepted ) { sendResponse(contact, sessionRequests_[contact], boost::shared_ptr()); } else { sendError(contact, sessionRequests_[contact], ErrorPayload::Conflict, ErrorPayload::Cancel); } sessionRequests_.erase(contact); } }