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
00041 class GLOOX_EXPORT Disco : public IqHandler
00042 {
00043 public:
00050 Disco( ClientBase *parent );
00051
00055 virtual ~Disco();
00056
00070 void addFeature( const std::string& feature );
00071
00081 void getDiscoInfo( const std::string& to, const std::string& node, DiscoHandler *dh, int context );
00082
00092 void getDiscoItems( const std::string& to, const std::string& node, DiscoHandler *dh, int context );
00093
00102 void setVersion( const std::string& name, const std::string& version, const std::string& os = "" );
00103
00113 void setIdentity( const std::string& category, const std::string& type );
00114
00121 void registerDiscoHandler( DiscoHandler *dh );
00122
00127 void removeDiscoHandler( DiscoHandler *dh );
00128
00137 void registerNodeHandler( DiscoNodeHandler *nh, const std::string& node );
00138
00143 void removeNodeHandler( const std::string& node );
00144
00145
00146 virtual bool handleIq( Stanza *stanza );
00147
00148
00149 virtual bool handleIqID( Stanza *stanza, int context );
00150
00151 private:
00152 enum IdType
00153 {
00154 GET_DISCO_INFO,
00155 GET_DISCO_ITEMS
00156 };
00157
00158 struct DiscoHandlerContext
00159 {
00160 DiscoHandler *dh;
00161 int context;
00162 };
00163
00164 ClientBase *m_parent;
00165
00166 typedef std::list<DiscoHandler*> DiscoHandlerList;
00167 typedef std::map<std::string, DiscoNodeHandler*> DiscoNodeHandlerMap;
00168 typedef std::map<std::string, DiscoHandlerContext> DiscoHandlerMap;
00169 typedef std::list<DiscoItem*> ItemList;
00170
00171 DiscoHandlerList m_discoHandlers;
00172 DiscoNodeHandlerMap m_nodeHandlers;
00173 DiscoHandlerMap m_track;
00174 ItemList m_items;
00175 StringList m_features;
00176 StringMap m_queryIDs;
00177
00178 std::string m_versionName;
00179 std::string m_versionVersion;
00180 std::string m_versionOs;
00181 std::string m_identityCategory;
00182 std::string m_identityType;
00183
00184 };
00185
00186 }
00187
00188 #endif // DISCO_H__