gloox  1.0.20
pubsubevent.h
1 /*
2  Copyright (c) 2004-2017 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 #ifndef PUBSUBEVENT_H__
14 #define PUBSUBEVENT_H__
15 
16 #include "stanzaextension.h"
17 #include "pubsub.h"
18 #include "gloox.h"
19 
20 namespace gloox
21 {
22 
23  class Tag;
24 
25  namespace PubSub
26  {
27 
34  class GLOOX_API Event : public StanzaExtension
35  {
36  public:
37 
42  {
51  ItemOperation( bool remove, const std::string& itemid, const Tag* pld = 0 )
52  : retract( remove ), item( itemid ), payload( pld )
53  {}
54 
59  ItemOperation( const ItemOperation& right );
60 
61  bool retract;
62  std::string item;
63  const Tag* payload;
64  };
65 
69  typedef std::list<ItemOperation*> ItemOperationList;
70 
75  Event( const Tag* event );
76 
82  Event( const std::string& node, PubSub::EventType type );
83 
87  virtual ~Event();
88 
93  PubSub::EventType type() const { return m_type; }
94 
100  const StringList& subscriptions() const
101  { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; }
102 
107  const ItemOperationList& items() const
108  { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; }
109 
115  void addItem( ItemOperation* op );
116 
121  const std::string& node() const { return m_node; }
122 
128  const JID& jid() { return m_jid; }
129 
135  bool subscription() { return m_subscription; }
136 
137  // reimplemented from StanzaExtension
138  const std::string& filterString() const;
139 
140  // reimplemented from StanzaExtension
141  StanzaExtension* newInstance( const Tag* tag ) const
142  {
143  return new Event( tag );
144  }
145 
146  // reimplemented from StanzaExtension
147  Tag* tag() const;
148 
149  // reimplemented from StanzaExtension
150  virtual StanzaExtension* clone() const;
151 
152  private:
153  Event& operator=( const Event& );
154 
155  PubSub::EventType m_type;
156  std::string m_node;
157  StringList* m_subscriptionIDs;
158  JID m_jid;
159  Tag* m_config;
160  ItemOperationList* m_itemOperations;
161  std::string m_collection;
162  bool m_subscription;
163 
164  const ItemOperationList m_emptyOperationList;
165  const StringList m_emptyStringList;
166 
167  };
168 
169  }
170 
171 }
172 
173 #endif // PUBSUBEVENT_H__
const ItemOperationList & items() const
Definition: pubsubevent.h:107
const JID & jid()
Definition: pubsubevent.h:128
This is an implementation of a PubSub Notification as a StanzaExtension.
Definition: pubsubevent.h:34
std::list< std::string > StringList
Definition: gloox.h:1251
const StringList & subscriptions() const
Definition: pubsubevent.h:100
PubSub::EventType type() const
Definition: pubsubevent.h:93
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
StanzaExtension * newInstance(const Tag *tag) const
Definition: pubsubevent.h:141
An abstraction of a JID.
Definition: jid.h:30
ItemOperation(bool remove, const std::string &itemid, const Tag *pld=0)
Definition: pubsubevent.h:51
std::list< ItemOperation * > ItemOperationList
Definition: pubsubevent.h:69
const std::string & node() const
Definition: pubsubevent.h:121
This is an abstraction of an XML element.
Definition: tag.h:46