pubsubevent.h
/*
Copyright (c) 2004-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef PUBSUBEVENT_H__
#define PUBSUBEVENT_H__
#include "stanzaextension.h"
#include "pubsub.h"
#include "gloox.h"
namespace gloox
{
class Tag;
namespace PubSub
{
class GLOOX_API Event : public StanzaExtension
{
public:
struct ItemOperation
{
ItemOperation( bool remove, const std::string& itemid, const Tag* pld = 0 )
: retract( remove ), item( itemid ), payload( pld )
{}
ItemOperation( const ItemOperation& right );
bool retract;
std::string item;
const Tag* payload;
};
typedef std::list<ItemOperation*> ItemOperationList;
Event();
Event( const Tag* event );
Event( const std::string& node, PubSub::EventType type );
virtual ~Event();
PubSub::EventType type() const { return m_type; }
const StringList& subscriptions() const
{ return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; }
const ItemOperationList& items() const
{ return m_itemOperations ? *m_itemOperations : m_emptyOperationList; }
void addItem( ItemOperation* op );
const std::string& node() const { return m_node; }
const JID& jid() { return m_jid; }
bool subscription() { return m_subscription; }
// reimplemented from StanzaExtension
const std::string& filterString() const;
// reimplemented from StanzaExtension
StanzaExtension* newInstance( const Tag* tag ) const
{
return new Event( tag );
}
// reimplemented from StanzaExtension
Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const;
private:
Event& operator=( const Event& );
PubSub::EventType m_type;
std::string m_node;
StringList* m_subscriptionIDs;
JID m_jid;
Tag* m_config;
ItemOperationList* m_itemOperations;
std::string m_collection;
bool m_subscription;
const ItemOperationList m_emptyOperationList;
const StringList m_emptyStringList;
};
}
}
#endif // PUBSUBEVENT_H__
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::PubSub::Event
This is an implementation of a PubSub Notification as a StanzaExtension.
Definition pubsubevent.h:35
gloox::PubSub::Event::type
PubSub::EventType type() const
Definition pubsubevent.h:100
gloox::PubSub::Event::node
const std::string & node() const
Definition pubsubevent.h:128
gloox::PubSub::Event::ItemOperationList
std::list< ItemOperation * > ItemOperationList
Definition pubsubevent.h:69
gloox::PubSub::Event::items
const ItemOperationList & items() const
Definition pubsubevent.h:114
gloox::PubSub::Event::newInstance
StanzaExtension * newInstance(const Tag *tag) const
Definition pubsubevent.h:148
gloox::PubSub::Event::Event
Event()
Definition pubsubevent.cpp:39
gloox::PubSub::Event::jid
const JID & jid()
Definition pubsubevent.h:135
gloox::PubSub::Event::subscription
bool subscription()
Definition pubsubevent.h:142
gloox::PubSub::Event::subscriptions
const StringList & subscriptions() const
Definition pubsubevent.h:107
gloox::PubSub::Event::tag
Tag * tag() const
Definition pubsubevent.cpp:187
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::PubSub
Namespace holding all the Pubsub-related structures and definitions.
Definition pubsub.h:28
gloox::PubSub::EventType
EventType
Definition pubsub.h:82
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::PubSub::Event::ItemOperation
Definition pubsubevent.h:42
gloox::PubSub::Event::ItemOperation::ItemOperation
ItemOperation(bool remove, const std::string &itemid, const Tag *pld=0)
Definition pubsubevent.h:51