disco.h

00001 /*
00002   Copyright (c) 2004-2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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 
00044   class GLOOX_API Disco : public IqHandler
00045   {
00046     friend class ClientBase;
00047 
00048     public:
00061       void addFeature( const std::string& feature );
00062 
00068       void removeFeature( const std::string& feature );
00069 
00074       const StringList& features() const { return m_features; }
00075 
00087       void getDiscoInfo( const JID& to, const std::string& node, DiscoHandler *dh, int context,
00088                          const std::string& tid = "" );
00089 
00101       void getDiscoItems( const JID& to, const std::string& node, DiscoHandler *dh, int context,
00102                           const std::string& tid = "" );
00103 
00112       void setVersion( const std::string& name, const std::string& version, const std::string& os = "" );
00113 
00123       void setIdentity( const std::string& category, const std::string& type );
00124 
00131       void registerDiscoHandler( DiscoHandler *dh );
00132 
00137       void removeDiscoHandler( DiscoHandler *dh );
00138 
00147       void registerNodeHandler( DiscoNodeHandler *nh, const std::string& node );
00148 
00155       void removeNodeHandler( DiscoNodeHandler *nh, const std::string& node );
00156 
00157       // reimplemented from IqHandler.
00158       virtual bool handleIq( Stanza *stanza );
00159 
00160       // reimplemented from IqHandler.
00161       virtual bool handleIqID( Stanza *stanza, int context );
00162 
00163     private:
00164       Disco( ClientBase *parent );
00165       virtual ~Disco();
00166 
00167       enum IdType
00168       {
00169         GET_DISCO_INFO,
00170         GET_DISCO_ITEMS
00171       };
00172 
00173       struct DiscoHandlerContext
00174       {
00175         DiscoHandler *dh;
00176         int context;
00177       };
00178 
00179       ClientBase *m_parent;
00180 
00181       typedef std::list<DiscoHandler*> DiscoHandlerList;
00182       typedef std::list<DiscoNodeHandler*> DiscoNodeHandlerList;
00183       typedef std::map<std::string, DiscoNodeHandlerList> DiscoNodeHandlerMap;
00184       typedef std::map<std::string, DiscoHandlerContext> DiscoHandlerMap;
00185       typedef std::list<DiscoItem*> ItemList;
00186 
00187       DiscoHandlerList m_discoHandlers;
00188       DiscoNodeHandlerMap m_nodeHandlers;
00189       DiscoHandlerMap m_track;
00190       ItemList m_items;
00191       StringList m_features;
00192       StringMap  m_queryIDs;
00193 
00194       std::string m_versionName;
00195       std::string m_versionVersion;
00196       std::string m_versionOs;
00197       std::string m_identityCategory;
00198       std::string m_identityType;
00199 
00200   };
00201 
00202 }
00203 
00204 #endif // DISCO_H__

Generated on Mon Dec 7 13:28:19 2009 for gloox by  doxygen 1.6.1