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 );
126 const std::string unsubscribe(
const JID& service,
127 const std::string& node,
128 const std::string& subid,
141 const std::string getSubscriptions(
const JID& service,
144 return getSubscriptionsOrAffiliations( service,
146 GetSubscriptionList );
158 const std::string getAffiliations(
const JID& service,
161 return getSubscriptionsOrAffiliations( service,
163 GetAffiliationList );
177 const std::string getSubscriptionOptions(
const JID& service,
179 const std::string& node,
181 {
return subscriptionOptions( GetSubscriptionOptions, service, jid, node, handler, 0 ); }
195 const std::string setSubscriptionOptions(
const JID& service,
197 const std::string& node,
200 {
return subscriptionOptions( SetSubscriptionOptions, service, jid, node, handler, df ); }
211 void getAffiliations(
const JID& service,
212 const std::string& node,
224 const std::string requestItems(
const JID& service,
225 const std::string& node,
226 const std::string& subid,
239 const std::string requestItems(
const JID& service,
240 const std::string& node,
241 const std::string& subid,
242 const ItemList& items,
259 const std::string publishItem(
const JID& service,
260 const std::string& node,
277 const std::string deleteItem(
const JID& service,
278 const std::string& node,
279 const ItemList& items,
295 const std::string createNode(
const JID& service,
296 const std::string& node,
310 const std::string deleteNode(
const JID& service,
311 const std::string& node,
324 const std::string getDefaultNodeConfig(
const JID& service,
338 const std::string purgeNode(
const JID& service,
339 const std::string& node,
352 const std::string getSubscribers(
const JID& service,
353 const std::string& node,
355 {
return subscriberList( GetSubscriberList, service,
356 node, SubscriberList(),
371 const std::string setSubscribers(
const JID& service,
372 const std::string& node,
373 const SubscriberList& list,
375 {
return subscriberList( SetSubscriberList, service,
376 node, list, handler ); }
388 const std::string getAffiliates(
const JID& service,
389 const std::string& node,
391 {
return affiliateList( GetAffiliateList, service,
392 node, AffiliateList(),
406 const std::string setAffiliates(
const JID& service,
407 const std::string& node,
408 const AffiliateList& list,
410 {
return affiliateList( SetAffiliateList, service,
411 node, list, handler ); }
423 const std::string getNodeConfig(
const JID& service,
424 const std::string& node,
426 {
return nodeConfig( service, node, 0, handler ); }
439 const std::string setNodeConfig(
const JID& service,
440 const std::string& node,
443 {
return nodeConfig( service, node, config, handler ); }
450 bool removeID(
const std::string&
id );
453 void handleDiscoInfoResult(
IQ* iq,
int context );
456 void handleDiscoItemsResult(
IQ* iq,
int context );
459 void handleDiscoError(
IQ* iq,
int context );
462 bool handleDiscoSet(
IQ* ) {
return 0; }
465 virtual bool handleIq(
const IQ& iq ) { (void)iq;
return false; }
468 virtual void handleIqID(
const IQ& iq,
int context );
471 #ifdef PUBSUBMANAGER_TEST
479 GetSubscriptionOptions,
480 SetSubscriptionOptions,
513 PubSubOwner( TrackContext context = InvalidContext );
519 PubSubOwner(
const Tag* tag );
524 virtual ~PubSubOwner();
530 void setNode(
const std::string& node ) { m_node = node; }
536 const std::string& node()
const {
return m_node; }
542 void setConfig( DataForm* config )
549 const DataForm* config()
const {
return m_form; }
555 void setSubscriberList(
const SubscriberList& subList )
556 { m_subList = subList; }
562 void setAffiliateList(
const AffiliateList& affList )
563 { m_affList = affList; }
566 virtual const std::string& filterString()
const;
569 virtual StanzaExtension* newInstance(
const Tag* tag )
const
571 return new PubSubOwner( tag );
575 virtual Tag* tag()
const;
578 virtual StanzaExtension* clone()
const
580 PubSubOwner* p =
new PubSubOwner();
583 p->m_form = m_form ?
new DataForm( *m_form ) : 0;
584 p->m_subList = m_subList;
585 p->m_affList = m_affList;
593 SubscriberList m_subList;
594 AffiliateList m_affList;
597 class PubSub :
public StanzaExtension
604 PubSub( TrackContext context = InvalidContext );
610 PubSub(
const Tag* tag );
621 void setJID(
const JID& jid ) { m_jid = jid; }
627 const JID& jid()
const {
return m_jid; }
633 void setNode(
const std::string& node ) { m_node = node; }
639 const std::string& node()
const {
return m_node; }
645 void setSubscriptionID(
const std::string& subid )
652 const std::string& subscriptionID()
const {
return m_subid; }
660 void setOptions(
const std::string& node, DataForm* df )
662 m_options.node = node;
670 const DataForm* options()
const
671 {
return m_options.df; }
677 const ItemList& items()
const {
return m_items; }
683 void setItems(
const ItemList& items )
690 void setMaxItems(
int maxItems )
691 { m_maxItems = maxItems; }
697 const SubscriptionMap& subscriptions()
const
698 {
return m_subscriptionMap; }
704 const AffiliationMap& affiliations()
const
705 {
return m_affiliationMap; }
711 void setNotify(
bool notify ) { m_notify = notify; }
714 virtual const std::string& filterString()
const;
717 virtual StanzaExtension* newInstance(
const Tag* tag )
const
719 return new PubSub( tag );
723 virtual Tag* tag()
const;
726 virtual StanzaExtension* clone()
const;
729 AffiliationMap m_affiliationMap;
730 SubscriptionMap m_subscriptionMap;
758 const std::string nodeConfig(
const JID& service,
759 const std::string& node,
761 ResultHandler* handler );
776 const std::string subscriberList( TrackContext ctx,
778 const std::string& node,
779 const SubscriberList& config,
780 ResultHandler* handler );
795 const std::string affiliateList( TrackContext ctx,
797 const std::string& node,
798 const AffiliateList& config,
799 ResultHandler* handler );
801 const std::string subscriptionOptions( TrackContext context,
804 const std::string& node,
805 ResultHandler* handler,
808 const std::string getSubscriptionsOrAffiliations(
const JID& service,
809 ResultHandler* handler,
810 TrackContext context );
812 typedef std::map < std::string, std::string > NodeOperationTrackMap;
813 typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap;
815 ClientBase* m_parent;
817 NodeOperationTrackMap m_nopTrackMap;
818 ResultHandlerTrackMap m_resultHandlerTrackMap;
820 util::Mutex m_trackMapMutex;
828 #endif // PUBSUBMANAGER_H__