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 ); }
236 void getAffiliations(
const JID& service,
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 void setSubscriptionID(
const std::string& subid )
683 const std::string& subscriptionID()
const {
return m_subid; }
691 void setOptions(
const std::string& node, DataForm* df )
693 m_options.node = node;
694 if( m_options.df != 0 )
703 const DataForm* options()
const
704 {
return m_options.df; }
710 const ItemList& items()
const {
return m_items; }
716 void setItems(
const ItemList& items )
723 void setMaxItems(
int maxItems )
724 { m_maxItems = maxItems; }
730 const SubscriptionMap& subscriptions()
const
731 {
return m_subscriptionMap; }
737 const AffiliationMap& affiliations()
const
738 {
return m_affiliationMap; }
744 void setNotify(
bool notify ) { m_notify = notify; }
747 virtual const std::string& filterString()
const;
750 virtual StanzaExtension* newInstance(
const Tag* tag )
const
752 return new PubSub( tag );
756 virtual Tag* tag()
const;
759 virtual StanzaExtension* clone()
const;
762 AffiliationMap m_affiliationMap;
763 SubscriptionMap m_subscriptionMap;
791 const std::string nodeConfig(
const JID& service,
792 const std::string& node,
794 ResultHandler* handler );
809 const std::string subscriberList( TrackContext ctx,
811 const std::string& node,
812 const SubscriberList& config,
813 ResultHandler* handler );
828 const std::string affiliateList( TrackContext ctx,
830 const std::string& node,
831 const AffiliateList& config,
832 ResultHandler* handler );
834 const std::string subscriptionOptions( TrackContext context,
837 const std::string& node,
838 ResultHandler* handler,
842 const std::string getSubscriptionsOrAffiliations(
const JID& service,
843 ResultHandler* handler,
844 TrackContext context );
846 typedef std::map < std::string, std::string > NodeOperationTrackMap;
847 typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap;
849 ClientBase* m_parent;
851 NodeOperationTrackMap m_nopTrackMap;
852 ResultHandlerTrackMap m_resultHandlerTrackMap;
854 util::Mutex m_trackMapMutex;
862 #endif // PUBSUBMANAGER_H__
const std::string getSubscriptions(const JID &service, ResultHandler *handler)
An abstraction of an IQ stanza.
const std::string getSubscribers(const JID &service, const std::string &node, ResultHandler *handler)
This manager is used to interact with PubSub services (XEP-0060).
const std::string getAffiliates(const JID &service, const std::string &node, ResultHandler *handler)
The namespace for the gloox library.
This class abstracts a stanza extension, which is usually an element in a specific namespace...
const std::string setAffiliates(const JID &service, const std::string &node, const AffiliateList &list, ResultHandler *handler)
const std::string getAffiliations(const JID &service, ResultHandler *handler)
A virtual interface to receive item related requests results.
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 getSubscriptionOptions(const JID &service, const JID &jid, const std::string &node, ResultHandler *handler, const std::string &subid=EmptyString)
A virtual interface which can be reimplemented to receive IQ stanzas.
const std::string setNodeConfig(const JID &service, const std::string &node, DataForm *config, ResultHandler *handler)
An abstraction of a subscription stanza.
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 getNodeConfig(const JID &service, const std::string &node, ResultHandler *handler)
const std::string EmptyString
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
This is an abstraction of an XML element.