00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <set>
00010 #include <map>
00011
00012 #include <Swiften/Base/API.h>
00013 #include <Swiften/Base/boost_bsignals.h>
00014 #include <Swiften/Elements/Presence.h>
00015 #include <Swiften/Elements/DiscoInfo.h>
00016 #include <Swiften/Elements/CapsInfo.h>
00017 #include <Swiften/Elements/ErrorPayload.h>
00018 #include <Swiften/Disco/CapsProvider.h>
00019
00020 namespace Swift {
00021 class StanzaChannel;
00022 class IQRouter;
00023 class JID;
00024 class CapsStorage;
00025
00026 class SWIFTEN_API CapsManager : public CapsProvider, public boost::bsignals::trackable {
00027 public:
00028 CapsManager(CapsStorage*, StanzaChannel*, IQRouter*);
00029
00030 DiscoInfo::ref getCaps(const std::string&) const;
00031
00032
00033 void setWarnOnInvalidHash(bool b) {
00034 warnOnInvalidHash = b;
00035 }
00036
00037 private:
00038 void handlePresenceReceived(boost::shared_ptr<Presence>);
00039 void handleStanzaChannelAvailableChanged(bool);
00040 void handleDiscoInfoReceived(const JID&, const std::string& hash, DiscoInfo::ref, ErrorPayload::ref);
00041 void requestDiscoInfo(const JID& jid, const std::string& node, const std::string& hash);
00042
00043 private:
00044 IQRouter* iqRouter;
00045 CapsStorage* capsStorage;
00046 bool warnOnInvalidHash;
00047 std::set<std::string> requestedDiscoInfos;
00048 std::set< std::pair<JID, std::string> > failingCaps;
00049 std::map<std::string, std::set< std::pair<JID, std::string> > > fallbacks;
00050 };
00051 }