00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef DISCO_H__
00016 #define DISCO_H__
00017
00018 #include "gloox.h"
00019
00020 #include "iqhandler.h"
00021 #include "disconodehandler.h"
00022
00023 #include <string>
00024 #include <list>
00025 #include <map>
00026
00027 namespace gloox
00028 {
00029
00030 class ClientBase;
00031 class DiscoHandler;
00032 class DiscoItem;
00033 class Stanza;
00034
00043 class GLOOX_API Disco : public IqHandler
00044 {
00045 friend class Client;
00046 friend class Component;
00047
00048 public:
00062 void addFeature( const std::string& feature );
00063
00068 const StringList& features() const { return m_features; };
00069
00079 void getDiscoInfo( const std::string& to, const std::string& node, DiscoHandler *dh, int context );
00080
00090 void getDiscoItems( const std::string& to, const std::string& node, DiscoHandler *dh, int context );
00091
00100 void setVersion( const std::string& name, const std::string& version, const std::string& os = "" );
00101
00111 void setIdentity( const std::string& category, const std::string& type );
00112
00119 void registerDiscoHandler( DiscoHandler *dh );
00120
00125 void removeDiscoHandler( DiscoHandler *dh );
00126
00135 void registerNodeHandler( DiscoNodeHandler *nh, const std::string& node );
00136
00141 void removeNodeHandler( const std::string& node );
00142
00143
00144 virtual bool handleIq( Stanza *stanza );
00145
00146
00147 virtual bool handleIqID( Stanza *stanza, int context );
00148
00149 private:
00150 Disco( ClientBase *parent );
00151 virtual ~Disco();
00152
00153 enum IdType
00154 {
00155 GET_DISCO_INFO,
00156 GET_DISCO_ITEMS
00157 };
00158
00159 struct DiscoHandlerContext
00160 {
00161 DiscoHandler *dh;
00162 int context;
00163 };
00164
00165 ClientBase *m_parent;
00166
00167 typedef std::list<DiscoHandler*> DiscoHandlerList;
00168 typedef std::map<std::string, DiscoNodeHandler*> DiscoNodeHandlerMap;
00169 typedef std::map<std::string, DiscoHandlerContext> DiscoHandlerMap;
00170 typedef std::list<DiscoItem*> ItemList;
00171
00172 DiscoHandlerList m_discoHandlers;
00173 DiscoNodeHandlerMap m_nodeHandlers;
00174 DiscoHandlerMap m_track;
00175 ItemList m_items;
00176 StringList m_features;
00177 StringMap m_queryIDs;
00178
00179 std::string m_versionName;
00180 std::string m_versionVersion;
00181 std::string m_versionOs;
00182 std::string m_identityCategory;
00183 std::string m_identityType;
00184
00185 };
00186
00187 }
00188
00189 #endif // DISCO_H__