gloox  0.9.9.12
disco.h
1 /*
2  Copyright (c) 2004-2008 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 
15 #ifndef DISCO_H__
16 #define DISCO_H__
17 
18 #include "gloox.h"
19 
20 #include "iqhandler.h"
21 #include "disconodehandler.h"
22 
23 #include <string>
24 #include <list>
25 #include <map>
26 
27 namespace gloox
28 {
29 
30  class ClientBase;
31  class DiscoHandler;
32  class DiscoItem;
33  class Stanza;
34 
44  class GLOOX_API Disco : public IqHandler
45  {
46  friend class ClientBase;
47 
48  public:
61  void addFeature( const std::string& feature );
62 
68  void removeFeature( const std::string& feature );
69 
74  const StringList& features() const { return m_features; }
75 
87  void getDiscoInfo( const JID& to, const std::string& node, DiscoHandler *dh, int context,
88  const std::string& tid = "" );
89 
101  void getDiscoItems( const JID& to, const std::string& node, DiscoHandler *dh, int context,
102  const std::string& tid = "" );
103 
112  void setVersion( const std::string& name, const std::string& version, const std::string& os = "" );
113 
123  void setIdentity( const std::string& category, const std::string& type );
124 
131  void registerDiscoHandler( DiscoHandler *dh );
132 
137  void removeDiscoHandler( DiscoHandler *dh );
138 
147  void registerNodeHandler( DiscoNodeHandler *nh, const std::string& node );
148 
155  void removeNodeHandler( DiscoNodeHandler *nh, const std::string& node );
156 
157  // reimplemented from IqHandler.
158  virtual bool handleIq( Stanza *stanza );
159 
160  // reimplemented from IqHandler.
161  virtual bool handleIqID( Stanza *stanza, int context );
162 
163  private:
164  Disco( ClientBase *parent );
165  virtual ~Disco();
166 
167  enum IdType
168  {
169  GET_DISCO_INFO,
170  GET_DISCO_ITEMS
171  };
172 
173  struct DiscoHandlerContext
174  {
175  DiscoHandler *dh;
176  int context;
177  };
178 
179  ClientBase *m_parent;
180 
181  typedef std::list<DiscoHandler*> DiscoHandlerList;
182  typedef std::list<DiscoNodeHandler*> DiscoNodeHandlerList;
183  typedef std::map<std::string, DiscoNodeHandlerList> DiscoNodeHandlerMap;
184  typedef std::map<std::string, DiscoHandlerContext> DiscoHandlerMap;
185  typedef std::list<DiscoItem*> ItemList;
186 
187  DiscoHandlerList m_discoHandlers;
188  DiscoNodeHandlerMap m_nodeHandlers;
189  DiscoHandlerMap m_track;
190  ItemList m_items;
191  StringList m_features;
192  StringMap m_queryIDs;
193 
194  std::string m_versionName;
195  std::string m_versionVersion;
196  std::string m_versionOs;
197  std::string m_identityCategory;
198  std::string m_identityType;
199 
200  };
201 
202 }
203 
204 #endif // DISCO_H__