/** * XMPP - libpurple transport * * Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */#pragma once#include<string>#include<algorithm>#include<map>#include"Swiften/Swiften.h"namespaceTransport{classConversation;classUser;classComponent;classDiscoItemsResponder;classAdHocCommandFactory;classAdHocCommand;classUserManager;classStorageBackend;/// Listens for AdHoc commands and manages all AdHoc commands sessionsclassAdHocManager:publicSwift::Responder<Swift::Command>{public:typedefstd::map<std::string,AdHocCommand*>CommandsMap;typedefstd::map<Swift::JID,CommandsMap>SessionsMap;/// Creates new AdHocManager./// \param component Transport instance associated with this AdHocManager.AdHocManager(Component*component,DiscoItemsResponder*discoItemsResponder,UserManager*userManager,StorageBackend*storageBackend=NULL);/// Destructor.virtual~AdHocManager();/// Starts handling AdHoc commands payloads.voidstart();/// Stops handling AdHoc commands payloads and destroys all existing/// AdHoc commands sessions.voidstop();/// Adds factory to create new AdHoc commands sessions of particular type.voidaddAdHocCommand(AdHocCommandFactory*factory);/// Remove sessions older than N seconds.voidremoveOldSessions();private:virtualboolhandleGetRequest(constSwift::JID&from,constSwift::JID&to,conststd::string&id,boost::shared_ptr<Swift::Command>payload);virtualboolhandleSetRequest(constSwift::JID&from,constSwift::JID&to,conststd::string&id,boost::shared_ptr<Swift::Command>payload);Component*m_component;DiscoItemsResponder*m_discoItemsResponder;std::map<std::string,AdHocCommandFactory*>m_factories;SessionsMapm_sessions;Swift::Timer::refm_collectTimer;UserManager*m_userManager;StorageBackend*m_storageBackend;};}