00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef PUBSUBEVENT_H__
00014 #define PUBSUBEVENT_H__
00015
00016 #include "stanzaextension.h"
00017 #include "pubsub.h"
00018 #include "gloox.h"
00019
00020 namespace gloox
00021 {
00022
00023 class Tag;
00024
00025 namespace PubSub
00026 {
00027
00034 class GLOOX_API Event : public StanzaExtension
00035 {
00036 public:
00037
00041 struct ItemOperation
00042 {
00051 ItemOperation( bool remove, const std::string& itemid, const Tag* pld = 0)
00052 : retract( remove ), item( itemid ), payload( pld ) {}
00053
00054 bool retract;
00055 std::string item;
00056 const Tag* payload;
00057 };
00058
00062 typedef std::list<ItemOperation*> ItemOperationList;
00063
00068 Event( const Tag* event );
00069
00073 virtual ~Event();
00074
00079 PubSub::EventType type() const { return m_type; }
00080
00086 const StringList& subscriptions() const
00087 { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; }
00088
00093 const ItemOperationList& items() const
00094 { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; }
00095
00100 const std::string& node() { return m_node; }
00101
00102
00103 const std::string& filterString() const;
00104
00105
00106 StanzaExtension* newInstance( const Tag* tag ) const
00107 {
00108 return new Event( tag );
00109 }
00110
00111
00112 Tag* tag() const;
00113
00114 private:
00115
00116 PubSub::EventType m_type;
00117 std::string m_node;
00118 StringList* m_subscriptionIDs;
00119 Tag* m_config;
00120 ItemOperationList* m_itemOperations;
00121 std::string m_collection;
00122
00123 const ItemOperationList m_emptyOperationList;
00124 const StringList m_emptyStringList;
00125
00126 };
00127
00128 }
00129
00130 }
00131
00132 #endif // PUBSUBEVENT_H__