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,
162 const std::string getSubscriptions(
const JID& service,
165 return getSubscriptionsOrAffiliations( service,
167 GetSubscriptionList );
179 const std::string getAffiliations(
const JID& service,
182 return getSubscriptionsOrAffiliations( service,
184 GetAffiliationList );
199 const std::string getSubscriptionOptions(
const JID& service,
201 const std::string& node,
204 {
return subscriptionOptions( GetSubscriptionOptions, service, jid, node, handler, 0, subid ); }
219 const std::string setSubscriptionOptions(
const JID& service,
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,
377 const std::string getSubscribers(
const JID& service,
378 const std::string& node,
380 {
return subscriberList( GetSubscriberList, service,
381 node, SubscriberList(),
396 const std::string setSubscribers(
const JID& service,
397 const std::string& node,
398 const SubscriberList& list,
400 {
return subscriberList( SetSubscriberList, service,
401 node, list, handler ); }
413 const std::string getAffiliates(
const JID& service,
414 const std::string& node,
416 {
return affiliateList( GetAffiliateList, service,
417 node, AffiliateList(),
431 const std::string setAffiliates(
const JID& service,
432 const std::string& node,
433 const AffiliateList& list,
435 {
return affiliateList( SetAffiliateList, service,
436 node, list, handler ); }
448 const std::string getNodeConfig(
const JID& service,
449 const std::string& node,
451 {
return nodeConfig( service, node, 0, handler ); }
464 const std::string setNodeConfig(
const JID& service,
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; }
591 virtual const std::string& filterString()
const;
594 virtual StanzaExtension* newInstance(
const Tag* tag )
const
596 return new PubSubOwner( tag );
600 virtual Tag* tag()
const;
603 virtual StanzaExtension* clone()
const
605 PubSubOwner* p =
new PubSubOwner();
608 p->m_form = m_form ?
new DataForm( *m_form ) : 0;
609 p->m_subList = m_subList;
610 p->m_affList = m_affList;
618 SubscriberList m_subList;
619 AffiliateList m_affList;
622 class PubSub :
public StanzaExtension
629 PubSub( TrackContext context = InvalidContext );
635 PubSub(
const Tag* tag );
646 void setJID(
const JID& jid ) { m_jid = jid; }
652 const JID& jid()
const {
return m_jid; }
658 void setNode(
const std::string& node ) { m_node = node; }
664 const std::string& node()
const {
return m_node; }
670 void setSubscriptionID(
const std::string& subid )
677 const std::string& subscriptionID()
const {
return m_subid; }
685 void setOptions(
const std::string& node, DataForm* df )
687 m_options.node = node;
688 if( m_options.df != 0 )
697 const DataForm* options()
const
698 {
return m_options.df; }
704 const ItemList& items()
const {
return m_items; }
710 void setItems(
const ItemList& items )
717 void setMaxItems(
int maxItems )
718 { m_maxItems = maxItems; }
724 const SubscriptionMap& subscriptions()
const
725 {
return m_subscriptionMap; }
731 const AffiliationMap& affiliations()
const
732 {
return m_affiliationMap; }
738 void setNotify(
bool notify ) { m_notify = notify; }
741 virtual const std::string& filterString()
const;
744 virtual StanzaExtension* newInstance(
const Tag* tag )
const
746 return new PubSub( tag );
750 virtual Tag* tag()
const;
753 virtual StanzaExtension* clone()
const;
756 AffiliationMap m_affiliationMap;
757 SubscriptionMap m_subscriptionMap;
785 const std::string nodeConfig(
const JID& service,
786 const std::string& node,
788 ResultHandler* handler );
803 const std::string subscriberList( TrackContext ctx,
805 const std::string& node,
806 const SubscriberList& config,
807 ResultHandler* handler );
822 const std::string affiliateList( TrackContext ctx,
824 const std::string& node,
825 const AffiliateList& config,
826 ResultHandler* handler );
828 const std::string subscriptionOptions( TrackContext context,
831 const std::string& node,
832 ResultHandler* handler,
836 const std::string getSubscriptionsOrAffiliations(
const JID& service,
837 ResultHandler* handler,
838 TrackContext context );
840 typedef std::map < std::string, std::string > NodeOperationTrackMap;
841 typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap;
843 ClientBase* m_parent;
845 NodeOperationTrackMap m_nopTrackMap;
846 ResultHandlerTrackMap m_resultHandlerTrackMap;
848 util::Mutex m_trackMapMutex;
856 #endif // PUBSUBMANAGER_H__