gloox 1.0.27
pubsubevent.h
1/*
2 Copyright (c) 2004-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#ifndef PUBSUBEVENT_H__
14#define PUBSUBEVENT_H__
15
16#include "stanzaextension.h"
17#include "pubsub.h"
18#include "gloox.h"
19
20namespace 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
76 Event();
77
82 Event( const Tag* event );
83
89 Event( const std::string& node, PubSub::EventType type );
90
94 virtual ~Event();
95
100 PubSub::EventType type() const { return m_type; }
101
108 { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; }
109
115 { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; }
116
122 void addItem( ItemOperation* op );
123
128 const std::string& node() const { return m_node; }
129
135 const JID& jid() { return m_jid; }
136
142 bool subscription() { return m_subscription; }
143
144 // reimplemented from StanzaExtension
145 const std::string& filterString() const;
146
147 // reimplemented from StanzaExtension
148 StanzaExtension* newInstance( const Tag* tag ) const
149 {
150 return new Event( tag );
151 }
152
153 // reimplemented from StanzaExtension
154 Tag* tag() const;
155
156 // reimplemented from StanzaExtension
157 virtual StanzaExtension* clone() const;
158
159 private:
160 Event& operator=( const Event& );
161
162 PubSub::EventType m_type;
163 std::string m_node;
164 StringList* m_subscriptionIDs;
165 JID m_jid;
166 Tag* m_config;
167 ItemOperationList* m_itemOperations;
168 std::string m_collection;
169 bool m_subscription;
170
171 const ItemOperationList m_emptyOperationList;
172 const StringList m_emptyStringList;
173
174 };
175
176 }
177
178}
179
180#endif // PUBSUBEVENT_H__
An abstraction of a JID.
Definition jid.h:31
This is an implementation of a PubSub Notification as a StanzaExtension.
Definition pubsubevent.h:35
PubSub::EventType type() const
const std::string & node() const
std::list< ItemOperation * > ItemOperationList
Definition pubsubevent.h:69
const ItemOperationList & items() const
StanzaExtension * newInstance(const Tag *tag) const
const JID & jid()
const StringList & subscriptions() const
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
ItemOperation(bool remove, const std::string &itemid, const Tag *pld=0)
Definition pubsubevent.h:51