gloox  1.0.28
capabilities.h
1 /*
2  Copyright (c) 2007-2023 by Jakob Schröter <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__
This is an implementation of XEP-0115 (Entity Capabilities).
Definition: capabilities.h:37
const std::string & node() const
Definition: capabilities.h:61
void setNode(const std::string &node)
Definition: capabilities.h:67
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition: capabilities.h:79
virtual StanzaExtension * clone() const
Definition: capabilities.h:88
Derived classes can be registered as NodeHandlers for certain nodes with the Disco object.
This class implements XEP-0030 (Service Discovery) and XEP-0092 (Software Version).
Definition: disco.h:46
std::list< Identity * > IdentityList
Definition: disco.h:51
std::list< Item * > ItemList
Definition: disco.h:261
An abstraction of a JID.
Definition: jid.h:31
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
Definition: tag.h:47
The namespace for the gloox library.
Definition: adhoc.cpp:28
std::list< std::string > StringList
Definition: gloox.h:1251
const std::string EmptyString
Definition: gloox.cpp:124