pubsubevent.h

00001 /*
00002   Copyright (c) 2004-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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 
00059           ItemOperation( const ItemOperation& right );
00060 
00061           bool retract;
00062           std::string item;
00063           const Tag* payload;
00064         };
00065 
00069         typedef std::list<ItemOperation*> ItemOperationList;
00070 
00075         Event( const Tag* event );
00076 
00082         Event( const std::string& node, PubSub::EventType type );
00083 
00087         virtual ~Event();
00088 
00093         PubSub::EventType type() const { return m_type; }
00094 
00100         const StringList& subscriptions() const
00101           { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; }
00102 
00107         const ItemOperationList& items() const
00108           { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; }
00109 
00115         void addItem( ItemOperation* op );
00116 
00121         const std::string& node() const { return m_node; }
00122 
00128         const JID& jid() { return m_jid; }
00129 
00135         bool subscription() { return m_subscription; }
00136 
00137         // reimplemented from StanzaExtension
00138         const std::string& filterString() const;
00139 
00140         // reimplemented from StanzaExtension
00141         StanzaExtension* newInstance( const Tag* tag ) const
00142         {
00143           return new Event( tag );
00144         }
00145 
00146         // reimplemented from StanzaExtension
00147         Tag* tag() const;
00148 
00149         // reimplemented from StanzaExtension
00150         virtual StanzaExtension* clone() const;
00151 
00152       private:
00153         Event& operator=( const Event& );
00154 
00155         PubSub::EventType m_type;
00156         std::string m_node;
00157         StringList* m_subscriptionIDs;
00158         JID m_jid;
00159         Tag* m_config;
00160         ItemOperationList* m_itemOperations;
00161         std::string m_collection;
00162         bool m_subscription;
00163 
00164         const ItemOperationList m_emptyOperationList;
00165         const StringList m_emptyStringList;
00166 
00167     };
00168 
00169   }
00170 
00171 }
00172 
00173 #endif // PUBSUBEVENT_H__
Generated on Tue Jun 8 23:37:54 2010 for gloox by  doxygen 1.6.3