gloox  1.0.9
pubsubevent.h
1 /*
2  Copyright (c) 2004-2013 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 #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__