gloox  1.1-svn
capabilities.h
1 /*
2  Copyright (c) 2007-2009 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 #ifndef CAPABILITIES_H__
15 #define CAPABILITIES_H__
16 
17 #include "disconodehandler.h"
18 #include "stanzaextension.h"
19 #include "tag.h"
20 
21 #include <string>
22 
23 namespace gloox
24 {
25 
26  class Disco;
27  class Tag;
28 
36  class GLOOX_API Capabilities : public StanzaExtension, public DiscoNodeHandler
37  {
38 
39  public:
44  Capabilities( Disco* disco );
45 
50  Capabilities( const Tag* tag = 0 );
51 
55  virtual ~Capabilities();
56 
61  const std::string& node() const { return m_node; }
62 
67  void setNode( const std::string& node ) { m_node = node; }
68 
73  const std::string ver() const;
74 
75  // reimplemented from StanzaExtension
76  virtual const std::string& filterString() const;
77 
78  // reimplemented from StanzaExtension
79  virtual StanzaExtension* newInstance( const Tag* tag ) const
80  {
81  return new Capabilities( tag );
82  }
83 
84  // reimplemented from StanzaExtension
85  virtual Tag* tag() const;
86 
87  // reimplemented from StanzaExtension
88  virtual StanzaExtension* clone() const
89  {
90  return new Capabilities( *this );
91  }
92 
93  // reimplemented from DiscoNodeHandler
94  virtual StringList handleDiscoNodeFeatures( const JID& from, const std::string& node );
95 
96  // reimplemented from DiscoNodeHandler
97  virtual Disco::IdentityList handleDiscoNodeIdentities( const JID& from,
98  const std::string& node );
99 
100  // reimplemented from DiscoNodeHandler
101  virtual Disco::ItemList handleDiscoNodeItems( const JID& from, const JID& to,
102  const std::string& node = EmptyString );
103 
104  private:
109  const std::string& hash() const { return m_hash; }
110 
116  void setHash( const std::string& hash ) { m_hash = hash; }
117 
118  static std::string generate( const Disco::IdentityList& identities,
119  const StringList& features, const DataForm* form = 0 );
120  static std::string generate( const Disco::Info* info );
121  static std::string generate( const Disco* disco );
122 
123  Disco* m_disco;
124  std::string m_node;
125  std::string m_hash;
126  std::string m_ver;
127  bool m_valid;
128  };
129 
130 }
131 
132 #endif // CAPABILITIES_H__