13 #ifndef PUBSUBMANAGER_H__
14 #define PUBSUBMANAGER_H__
18 #include "iqhandler.h"
108 const std::string subscribe(
const JID& service,
const std::string& node,
111 int depth = 1,
const std::string& expire =
EmptyString );
130 const std::string subscribe(
const JID& service,
const std::string& node,
147 const std::string unsubscribe(
const JID& service,
148 const std::string& node,
149 const std::string& subid,
165 return getSubscriptionsOrAffiliations( service,
167 GetSubscriptionList );
182 return getSubscriptionsOrAffiliations( service,
184 GetAffiliationList );
201 const std::string& node,
204 {
return subscriptionOptions( GetSubscriptionOptions, service, jid, node, handler, 0, subid ); }
221 const std::string& node,
225 {
return subscriptionOptions( SetSubscriptionOptions, service, jid, node, handler, df, subid ); }
237 const std::string& node,
249 const std::string requestItems(
const JID& service,
250 const std::string& node,
251 const std::string& subid,
264 const std::string requestItems(
const JID& service,
265 const std::string& node,
266 const std::string& subid,
267 const ItemList& items,
284 const std::string publishItem(
const JID& service,
285 const std::string& node,
302 const std::string deleteItem(
const JID& service,
303 const std::string& node,
304 const ItemList& items,
320 const std::string createNode(
const JID& service,
321 const std::string& node,
335 const std::string deleteNode(
const JID& service,
336 const std::string& node,
349 const std::string getDefaultNodeConfig(
const JID& service,
363 const std::string purgeNode(
const JID& service,
364 const std::string& node,
378 const std::string& node,
380 {
return subscriberList( GetSubscriberList, service,
381 node, SubscriberList(),
397 const std::string& node,
398 const SubscriberList& list,
400 {
return subscriberList( SetSubscriberList, service,
401 node, list, handler ); }
414 const std::string& node,
416 {
return affiliateList( GetAffiliateList, service,
417 node, AffiliateList(),
432 const std::string& node,
433 const AffiliateList& list,
435 {
return affiliateList( SetAffiliateList, service,
436 node, list, handler ); }
449 const std::string& node,
451 {
return nodeConfig( service, node, 0, handler ); }
465 const std::string& node,
468 {
return nodeConfig( service, node, config, handler ); }
475 bool removeID(
const std::string&
id );
478 void handleDiscoInfoResult(
IQ* iq,
int context );
481 void handleDiscoItemsResult(
IQ* iq,
int context );
484 void handleDiscoError(
IQ* iq,
int context );
487 bool handleDiscoSet(
IQ* ) {
return 0; }
490 virtual bool handleIq(
const IQ& iq ) { (void)iq;
return false; }
493 virtual void handleIqID(
const IQ& iq,
int context );
496 #ifdef PUBSUBMANAGER_TEST
504 GetSubscriptionOptions,
505 SetSubscriptionOptions,
538 PubSubOwner( TrackContext context = InvalidContext );
544 PubSubOwner(
const Tag* tag );
549 virtual ~PubSubOwner();
555 void setNode(
const std::string& node ) { m_node = node; }
561 const std::string& node()
const {
return m_node; }
567 void setConfig( DataForm* config )
574 const DataForm* config()
const {
return m_form; }
580 void setSubscriberList(
const SubscriberList& subList )
581 { m_subList = subList; }
587 void setAffiliateList(
const AffiliateList& affList )
588 { m_affList = affList; }
594 const AffiliateList* affiliateList()
const {
return &m_affList; }
597 virtual const std::string& filterString()
const;
600 virtual StanzaExtension* newInstance(
const Tag* tag )
const
602 return new PubSubOwner( tag );
606 virtual Tag* tag()
const;
609 virtual StanzaExtension* clone()
const
611 PubSubOwner* p =
new PubSubOwner();
614 p->m_form = m_form ?
new DataForm( *m_form ) : 0;
615 p->m_subList = m_subList;
616 p->m_affList = m_affList;
624 SubscriberList m_subList;
625 AffiliateList m_affList;
628 class PubSub :
public StanzaExtension
635 PubSub( TrackContext context = InvalidContext );
641 PubSub(
const Tag* tag );
652 void setJID(
const JID& jid ) { m_jid = jid; }
658 const JID& jid()
const {
return m_jid; }
664 void setNode(
const std::string& node ) { m_node = node; }
670 const std::string& node()
const {
return m_node; }
676 TrackContext context()
const {
return m_ctx; }
682 void setSubscriptionID(
const std::string& subid )
689 const std::string& subscriptionID()
const {
return m_subid; }
697 void setOptions(
const std::string& node, DataForm* df )
699 m_options.node = node;
700 if( m_options.df != 0 )
709 const DataForm* options()
const
710 {
return m_options.df; }
716 const ItemList& items()
const {
return m_items; }
722 void setItems(
const ItemList& items )
729 void setMaxItems(
int maxItems )
730 { m_maxItems = maxItems; }
736 const SubscriptionMap& subscriptions()
const
737 {
return m_subscriptionMap; }
743 const AffiliationMap& affiliations()
const
744 {
return m_affiliationMap; }
750 void setNotify(
bool notify ) { m_notify = notify; }
753 virtual const std::string& filterString()
const;
756 virtual StanzaExtension* newInstance(
const Tag* tag )
const
758 return new PubSub( tag );
762 virtual Tag* tag()
const;
765 virtual StanzaExtension* clone()
const;
768 AffiliationMap m_affiliationMap;
769 SubscriptionMap m_subscriptionMap;
797 const std::string nodeConfig(
const JID& service,
798 const std::string& node,
800 ResultHandler* handler );
815 const std::string subscriberList( TrackContext ctx,
817 const std::string& node,
818 const SubscriberList& config,
819 ResultHandler* handler );
834 const std::string affiliateList( TrackContext ctx,
836 const std::string& node,
837 const AffiliateList& config,
838 ResultHandler* handler );
840 const std::string subscriptionOptions( TrackContext context,
843 const std::string& node,
844 ResultHandler* handler,
848 const std::string getSubscriptionsOrAffiliations(
const JID& service,
849 ResultHandler* handler,
850 TrackContext context );
852 typedef std::map < std::string, std::string > NodeOperationTrackMap;
853 typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap;
855 ClientBase* m_parent;
857 NodeOperationTrackMap m_nopTrackMap;
858 ResultHandlerTrackMap m_resultHandlerTrackMap;
860 util::Mutex m_trackMapMutex;
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
An abstraction of an IQ stanza.
A virtual interface which can be reimplemented to receive IQ stanzas.
This manager is used to interact with PubSub services (XEP-0060).
const std::string setSubscribers(const JID &service, const std::string &node, const SubscriberList &list, ResultHandler *handler)
virtual bool handleIq(const IQ &iq)
const std::string getSubscriptionOptions(const JID &service, const JID &jid, const std::string &node, ResultHandler *handler, const std::string &subid=EmptyString)
const std::string getAffiliates(const JID &service, const std::string &node, ResultHandler *handler)
const std::string getSubscriptions(const JID &service, ResultHandler *handler)
const std::string getSubscribers(const JID &service, const std::string &node, ResultHandler *handler)
const std::string setSubscriptionOptions(const JID &service, const JID &jid, const std::string &node, DataForm *df, ResultHandler *handler, const std::string &subid=EmptyString)
const std::string setNodeConfig(const JID &service, const std::string &node, DataForm *config, ResultHandler *handler)
const std::string getAffiliations(const JID &service, ResultHandler *handler)
void getAffiliations(const JID &service, const std::string &node, ResultHandler *handler)
const std::string setAffiliates(const JID &service, const std::string &node, const AffiliateList &list, ResultHandler *handler)
const std::string getNodeConfig(const JID &service, const std::string &node, ResultHandler *handler)
A virtual interface to receive item related requests results.
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
An abstraction of a subscription stanza.
This is an abstraction of an XML element.
The namespace for the gloox library.
const std::string EmptyString