/* * Copyright (c) 2010 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include #include #include #include #include #include #include #include namespace Swift { class IQRouter; /** * Recursively walk service discovery trees to find all services offered. * This stops on any disco item that's not reporting itself as a server. */ class DiscoServiceWalker : public boost::signals::trackable { public: DiscoServiceWalker(const JID& service, IQRouter* iqRouter, size_t maxSteps = 200); /** Start the walk. Call this exactly once.*/ void beginWalk(); /** Emitted for each service found. */ boost::signal)> onServiceFound; /** Emitted when walking is complete.*/ boost::signal onWalkComplete; private: void handleReceivedDiscoItem(const JID& item); void walkNode(const JID& jid); void markNodeCompleted(const JID& jid); void handleDiscoInfoResponse(boost::shared_ptr info, ErrorPayload::ref error, const JID& jid); void handleDiscoItemsResponse(boost::shared_ptr items, ErrorPayload::ref error, const JID& jid); void handleDiscoError(const JID& jid, ErrorPayload::ref error); JID service_; IQRouter* iqRouter_; size_t maxSteps_; std::vector servicesBeingSearched_; std::vector searchedServices_; }; }