This file is indexed.

/usr/include/gloox/pubsubmanager.h is in libgloox-dev 1.0.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
/*
  Copyright (c) 2007-2014 by Jakob Schroeter <js@camaya.net>
  This file is part of the gloox library. http://camaya.net/gloox

  This software is distributed under a license. The full license
  agreement can be found in the file LICENSE in this distribution.
  This software may not be copied, modified, sold or distributed
  other than expressed in the named license agreement.

  This software is distributed without any warranty.
*/

#ifndef PUBSUBMANAGER_H__
#define PUBSUBMANAGER_H__

#include "pubsub.h"
#include "dataform.h"
#include "iqhandler.h"
#include "mutex.h"

#include <map>
#include <string>

namespace gloox
{

  class ClientBase;

  namespace PubSub
  {

    class ResultHandler;

    /**
     * @brief This manager is used to interact with PubSub services (@xep{0060}).
     *
     * @note PubSub support in gloox is still relatively young and you are most
     * welcome to ask questions, criticize the API and so on.
     *
     * A ResultHandler is used to receive a request's result. Depending on the
     * context, this can be a notification that an item has been succesfully
     * deleted (or not), or the default node configuration for a service.
     *
     * To receive PubSub events:
     * @li Tell ClientBase that you are interested in PubSub events by registering
     * an empty PubSub::Event StanzaExtension
     * @code
     * m_client->registerStanzaExtension( new PubSub::Event() );
     * @endcode
     * @li Implement a MessageHandler and register it with ClientBase, or use the MessageSession interface, at your choice,
     * @li When receiving a Message, check it for a PubSub::Event
     * @code
     * const PubSub::Event* pse = msg.findExtension<PubSub::Event>( ExtPubSubEvent );
     * if( pse )
     * {
     *   // use the Event
     * }
     * else
     * {
     *   // no Event
     * }
     * @endcode
     *
     * To interact with PubSub services, you will need to
     * instantiate a PubSub::Manager and
     * implement the ResultHandler virtual interfaces to be notified of the
     * result of requests.
     *
     * @note A null ResultHandler to a query is not allowed and is a no-op.
     *
     * XEP Version: 1.12
     *
     * @author Jakob Schroeter <js@camaya.net>
     * @author Vincent Thomasset <vthomasset@gmail.com>
     *
     * @since 1.0
     */
    class GLOOX_API Manager : public IqHandler
    {
      public:

        /**
         * Initialize the manager.
         * @param parent Client to which this manager belongs.
         */
        Manager( ClientBase* parent );

        /**
         * Default virtual destructor.
         */
        virtual ~Manager() {}

        /**
         * Subscribe to a node.
         *
         * @param service Service hosting the node.
         * @param node ID of the node to subscribe to.
         * @param handler The ResultHandler.
         * @param jid JID to subscribe. If empty, the client's JID will be used
         *        (ie. self subscription).
         * @param type SubscriptionType of the subscription (Collections only).
         * @param depth Subscription depth. For 'all', use 0 (Collections only).
         * @param expire Subscription expiry. Defaults to the empty string.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleSubscriptionResult
         */
        const std::string subscribe( const JID& service, const std::string& node,
                                     ResultHandler* handler, const JID& jid = JID(),
                                     SubscriptionObject type = SubscriptionNodes,
                                     int depth = 1, const std::string& expire = EmptyString );

        /**
         * Subscribe to a node and configure options.
         *
         * @param service Service hosting the node.
         * @param node ID of the node to subscribe to.
         * @param handler The ResultHandler.
         * @param jid JID to subscribe. If empty, the client's JID will be used
         *        (ie. self subscription).
         * @param options The options to configure while subscribing.
         *        Should be a TypeSubmit form, with a field named FORM_TYPE having the value
         *        http://jabber.org/protocol/pubsub#subscribe_options
         *        See @xep{0060}, "Subscribe and Configure".
         *        Will be owned and deleted by the PubSub object.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleSubscriptionResult
         */
        const std::string subscribe( const JID& service, const std::string& node,
                                     ResultHandler* handler, const JID& jid,
                                     DataForm* options );

        /**
         * Unsubscribe from a node.
         *
         * @param service Service hosting the node.
         * @param node ID of the node to unsubscribe from.
         * @param subid An optional, additional subscription ID.
         * @param handler ResultHandler receiving the result notification.
         * @param jid JID to unsubscribe. If empty, the client's JID will be
         * used (ie self unsubscription).
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleUnsubscriptionResult
         */
        const std::string unsubscribe( const JID& service,
                                       const std::string& node,
                                       const std::string& subid,
                                       ResultHandler* handler,
                                       const JID& jid = JID() );

        /**
         * Requests the subscription list from a service.
         *
         * @param service Service to query.
         * @param handler The ResultHandler to handle the result.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleSubscriptions
         */
        const std::string getSubscriptions( const JID& service,
                                            ResultHandler* handler )
        {
          return getSubscriptionsOrAffiliations( service,
                                                 handler,
                                                 GetSubscriptionList );
        }

        /**
         * Requests the affiliation list from a service.
         *
         * @param service Service to query.
         * @param handler The ResultHandler to handle the result.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleAffiliations
         */
        const std::string getAffiliations( const JID& service,
                                           ResultHandler* handler )
        {
          return getSubscriptionsOrAffiliations( service,
                                                 handler,
                                                 GetAffiliationList );
        }

        /**
         * Requests subscription options.
         *
         * @param service Service to query.
         * @param jid Subscribed entity.
         * @param node Node ID of the node.
         * @param handler The SubscriptionListHandler to handle the result.
         * @param subid An optional subscription ID.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleSubscriptionOptions
         */
        const std::string getSubscriptionOptions( const JID& service,
                                                  const JID& jid,
                                                  const std::string& node,
                                                  ResultHandler* handler,
                                                  const std::string& subid = EmptyString)
          { return subscriptionOptions( GetSubscriptionOptions, service, jid, node, handler, 0, subid ); }

        /**
         * Modifies subscription options.
         *
         * @param service Service to query.
         * @param jid Subscribed entity.
         * @param node Node ID of the node.
         * @param df New configuration. The DataForm will be owned and deleted by the Manager.
         * @param handler The handler to handle the result.
         * @param subid An optional subscription ID.
         * @return The IQ ID used in the request.
         *
         * @see ResultHandler::handleSubscriptionOptionsResult
         */
        const std::string setSubscriptionOptions( const JID& service,
                                                  const JID& jid,
                                                  const std::string& node,
                                                  DataForm* df,
                                                  ResultHandler* handler,
                                                  const std::string& subid = EmptyString )
          { return subscriptionOptions( SetSubscriptionOptions, service, jid, node, handler, df, subid ); }

        /**
         * Requests the affiliation list for a node.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param handler The AffiliationListHandler to handle the result.
         *
         * @see ResultHandler::handleAffiliations
         */
        void getAffiliations( const JID& service,
                              const std::string& node,
                              ResultHandler* handler );

        /**
         * Requests items from a node.
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param subid An optional subscription ID.
         * @param maxItems The optional maximum number of items to return.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         */
        const std::string requestItems( const JID& service,
                                        const std::string& node,
                                        const std::string& subid,
                                        int maxItems,
                                        ResultHandler* handler);

        /**
         * Requests specific items from a node.
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param subid An optional subscription ID.
         * @param items The list of item IDs to request.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         */
        const std::string requestItems( const JID& service,
                                        const std::string& node,
                                        const std::string& subid,
                                        const ItemList& items,
                                        ResultHandler* handler);

        /**
         * Publish an item to a node. The Tag to publish is destroyed
         * by the function before returning.
         *
         * @param service Service hosting the node.
         * @param node ID of the node to delete the item from.
         * @param items One or more items to publish. The items will be owned and deleted by the Manager,
         * even in the error case (empty string returned).
         * @param options An optional DataForm containing publish options. The DataForm will be owned and deleted by the Manager.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleItemPublication
         */
        const std::string publishItem( const JID& service,
                                       const std::string& node,
                                       ItemList& items,
                                       DataForm* options,
                                       ResultHandler* handler );

        /**
         * Delete an item from a node.
         *
         * @param service Service hosting the node.
         * @param node ID of the node to delete the item from.
         * @param items A list of items to delete (only ID filled in).
         * @param notify Whether or not to notify subscribers about the deletion.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleItemDeletation
         */
        const std::string deleteItem( const JID& service,
                                      const std::string& node,
                                      const ItemList& items,
                                      bool notify,
                                      ResultHandler* handler );

        /**
         * Creates a new node.
         *
         * @param service Service where to create the new node.
         * @param node The ID of the new node.
         * @param config An optional DataForm that holds the node configuration.
         * The DataForm will be owned and deleted by the Manager.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleNodeCreation
         */
        const std::string createNode( const JID& service,
                                      const std::string& node,
                                      DataForm* config,
                                      ResultHandler* handler );

        /**
         * Deletes a node.
         *
         * @param service Service where to create the new node.
         * @param node Node ID of the new node.
         * @param handler The handler to handle the result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleNodeDeletion
         */
        const std::string deleteNode( const JID& service,
                                      const std::string& node,
                                      ResultHandler* handler );

        /**
         * Retrieves the default configuration for a specific NodeType.
         *
         * @param service The queried service.
         * @param type NodeType to get default configuration for.
         * @param handler ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleDefaultNodeConfig
         */
        const std::string getDefaultNodeConfig( const JID& service,
                                                NodeType type,
                                                ResultHandler* handler );

        /**
         * Removes all the items from a node.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param handler ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleNodePurge
         */
        const std::string purgeNode( const JID& service,
                                     const std::string& node,
                                     ResultHandler* handler );

        /**
         * Requests the subscriber list for a node.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param handler ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleSubscribers
         */
        const std::string getSubscribers( const JID& service,
                                          const std::string& node,
                                          ResultHandler* handler )
          { return subscriberList( GetSubscriberList, service,
                                   node, SubscriberList(),
                                   handler ); }

        /**
         * Modifies the subscriber list for a node. This function SHOULD only set the
         * subscriber list to those which needs modification.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param list The subscriber list.
         * @param handler The ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleSubscribers
         */
        const std::string setSubscribers( const JID& service,
                                          const std::string& node,
                                          const SubscriberList& list,
                                          ResultHandler* handler )
          { return subscriberList( SetSubscriberList, service,
                                   node, list, handler ); }

        /**
         * Requests the affiliate list for a node.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param handler ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleAffiliates
         */
        const std::string getAffiliates( const JID& service,
                                         const std::string& node,
                                         ResultHandler* handler )
          { return affiliateList( GetAffiliateList, service,
                                  node, AffiliateList(),
                                  handler ); }

        /**
         * Modifies the affiliate list for a node.
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param list ResultHandler.
         * @param handler ResultHandler.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleAffiliatesResult
         */
        const std::string setAffiliates( const JID& service,
                                         const std::string& node,
                                         const AffiliateList& list,
                                         ResultHandler* handler )
          { return affiliateList( SetAffiliateList, service,
                                  node, list, handler ); }

        /**
         * Retrieve the configuration (options) of a node.
         *
         * @param service Service hosting the node.
         * @param node ID of the node.
         * @param handler ResultHandler responsible to handle the request result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleNodeConfig
         */
        const std::string getNodeConfig( const JID& service,
                                         const std::string& node,
                                         ResultHandler* handler )
          { return nodeConfig( service, node, 0, handler ); }

        /**
         * Changes a node's configuration (options).
         *
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param config The node's configuration DataForm.
         * @param handler ResultHandler responsible to handle the request result.
         * @return The ID used in the request.
         *
         * @see ResultHandler::handleNodeConfigResult
         */
        const std::string setNodeConfig( const JID& service,
                                         const std::string& node,
                                         DataForm* config,
                                         ResultHandler* handler  )
          { return nodeConfig( service, node, config, handler ); }

        /**
         * Removes an ID from our tracking lists.
         * @param id The ID to remove.
         * @return @b True if the ID was found and removed, @b false otherwise.
         */
        bool removeID( const std::string& id );

        // reimplemented from DiscoHandler
        void handleDiscoInfoResult( IQ* iq, int context );

        // reimplemented from DiscoHandler
        void handleDiscoItemsResult( IQ* iq, int context );

        // reimplemented from DiscoHandler
        void handleDiscoError( IQ* iq, int context );

        // reimplemented from DiscoHandler
        bool handleDiscoSet( IQ* ) { return 0; }

        // reimplemented from IqHandler.
        virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }

        // reimplemented from IqHandler.
        virtual void handleIqID( const IQ& iq, int context );

      private:
#ifdef PUBSUBMANAGER_TEST
      public:
#endif

        enum TrackContext
        {
          Subscription,
          Unsubscription,
          GetSubscriptionOptions,
          SetSubscriptionOptions,
          GetSubscriptionList,
          GetSubscriberList,
          SetSubscriberList,
          GetAffiliationList,
          GetAffiliateList,
          SetAffiliateList,
          GetNodeConfig,
          SetNodeConfig,
          DefaultNodeConfig,
          GetItemList,
          PublishItem,
          DeleteItem,
          CreateNode,
          DeleteNode,
          PurgeNodeItems,
          NodeAssociation,
          NodeDisassociation,
          GetFeatureList,
          DiscoServiceInfos,
          DiscoNodeInfos,
          DiscoNodeItems,
          RequestItems,
          InvalidContext
        };

        class PubSubOwner : public StanzaExtension
        {
          public:
            /**
             * Creates a new PubSubOwner object that can be used to request the given type.
             * @param context The requets type.
             */
            PubSubOwner( TrackContext context = InvalidContext );

            /**
             * Creates a new PubSubOwner object by parsing the given Tag.
             * @param tag The Tag to parse.
             */
            PubSubOwner( const Tag* tag );

            /**
             * Virtual destructor.
             */
            virtual ~PubSubOwner();

            /**
             * Sets the node to use in e.g. subscription requests.
             * @param node The node to use.
             */
            void setNode( const std::string& node ) { m_node = node; }

            /**
             * Returns the pubsub node.
             * @return The pubsub node.
             */
            const std::string& node() const { return m_node; }

            /**
             * Sets an options DataForm.
             * @param options The DataForm.
             */
            void setConfig( DataForm* config )
              { m_form = config; }

            /**
             * Returns the config DataForm.
             * @return The config DataForm.
             */
            const DataForm* config() const { return m_form; }

            /**
             * Sets the subscriber list.
             * @param subList The subscriber list.
             */
            void setSubscriberList( const SubscriberList& subList )
              { m_subList = subList; }

            /**
             * Sets the affiliate list.
             * @param affList The affiliate list.
             */
            void setAffiliateList( const AffiliateList& affList )
              { m_affList = affList; }

            // reimplemented from StanzaExtension
            virtual const std::string& filterString() const;

            // reimplemented from StanzaExtension
            virtual StanzaExtension* newInstance( const Tag* tag ) const
            {
              return new PubSubOwner( tag );
            }

            // reimplemented from StanzaExtension
            virtual Tag* tag() const;

            // reimplemented from StanzaExtension
            virtual StanzaExtension* clone() const
            {
              PubSubOwner* p = new PubSubOwner();
              p->m_node = m_node;
              p->m_ctx = m_ctx;
              p->m_form = m_form ? new DataForm( *m_form ) : 0;
              p->m_subList = m_subList;
              p->m_affList = m_affList;
              return p;
            }

          private:
            std::string m_node;
            TrackContext m_ctx;
            DataForm* m_form;
            SubscriberList m_subList;
            AffiliateList m_affList;
        };

        class PubSub : public StanzaExtension
        {
          public:
            /**
             * Creates a new PubSub object that can be used to request the given type.
             * @param context The requets type.
             */
            PubSub( TrackContext context = InvalidContext );

            /**
             * Creates a new PubSub object by parsing the given Tag.
             * @param tag The Tag to parse.
             */
            PubSub( const Tag* tag );

            /**
             * Virtual destructor.
             */
            virtual ~PubSub();

            /**
             * Sets the JID to use in e.g. subscription requests.
             * @param jid The JID to use.
             */
            void setJID( const JID& jid ) { m_jid = jid; }

            /**
             * Returns the pubsub JID (not the service JID).
             * @return The pubsub JID.
             */
            const JID& jid() const { return m_jid; }

            /**
             * Sets the node to use in e.g. subscription requests.
             * @param node The node to use.
             */
            void setNode( const std::string& node ) { m_node = node; }

            /**
             * Returns the pubsub node.
             * @return The pubsub node.
             */
            const std::string& node() const { return m_node; }

            /**
             * Sets the Subscription ID to use.
             * @param subid The Subscription ID to use.
             */
            void setSubscriptionID( const std::string& subid )
              { m_subid = subid; }

            /**
             * Gets the Subscription ID to use.
             * @return The Subscription ID to use.
             */
            const std::string& subscriptionID() const { return m_subid; }

            /**
             * Sets the subscription options.
             * @param node The node to set the options for.
             * @param df The DataForm holding the subscription options.
             * Will be owned and deleted by the PubSub object
             */
            void setOptions( const std::string& node, DataForm* df )
            {
              m_options.node = node;
              if( m_options.df != 0 )
                delete m_options.df;
              m_options.df = df;
            }

            /**
             * Returns the subscription options.
             * @return The subscription options.
             */
            const DataForm* options() const
              { return m_options.df; }

            /**
             * Returns the current Items.
             * @return The current items.
             */
            const ItemList& items() const { return m_items; }

            /**
             * Sets the subscription IDs.
             * @param ids Subscription IDs.
             */
            void setItems( const ItemList& items )
             { m_items = items; }

            /**
             * Sets the maximum number of items to request.
             * @param maxItems The maximum number of items to request.
             */
            void setMaxItems( int maxItems )
              { m_maxItems = maxItems; }

            /**
             * Returns the subscriptions.
             * @param The subscriptions.
             */
            const SubscriptionMap& subscriptions() const
              { return m_subscriptionMap; }

            /**
             * Returns the affiliations.
             * @param The affiliations.
             */
            const AffiliationMap& affiliations() const
              { return m_affiliationMap; }

            /**
             * Sets whether or not a notify element should be included in a 'retract'.
             * @param notify Indicates whether a notify attribute is included.
             */
            void setNotify( bool notify ) { m_notify = notify; }

            // reimplemented from StanzaExtension
            virtual const std::string& filterString() const;

            // reimplemented from StanzaExtension
            virtual StanzaExtension* newInstance( const Tag* tag ) const
            {
              return new PubSub( tag );
            }

            // reimplemented from StanzaExtension
            virtual Tag* tag() const;

            // reimplemented from StanzaExtension
            virtual StanzaExtension* clone() const;

          private:
            AffiliationMap m_affiliationMap;
            SubscriptionMap m_subscriptionMap;
            TrackContext m_ctx;

            struct Options
            {
              std::string node;
              DataForm* df;
            };
            Options m_options;
            JID m_jid;
            std::string m_node;
            std::string m_subid;
            ItemList m_items;
            int m_maxItems;
            bool m_notify;
        };

        /**
         * This function sets or requests a node's configuration form
         * (depending on arguments). Does the actual work for requestNodeConfig
         * and setNodeConfig.
         * Requests or changes a node's configuration.
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param config If not NULL, the function will request the node config.
         * Otherwise, it will set the config based on the form.
         * @param handler ResultHandler responsible to handle the request result.
         */
        const std::string nodeConfig( const JID& service,
                                      const std::string& node,
                                      DataForm* config,
                                      ResultHandler* handler );

        /**
         * This function sets or requests a node's subscribers list form
         * (depending on arguments). Does the actual work for
         * requestSubscriberList and setSubscriberList.
         * Requests or changes a node's configuration.
         * @param ctx The operation to be performed.
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param config If not NULL, the function will request the node config.
         * Otherwise, it will set the config based on the form.
         * @param handler ResultHandler responsible to handle the request result.
         * @return The ID used in the request.
         */
        const std::string subscriberList( TrackContext ctx,
                                          const JID& service,
                                          const std::string& node,
                                          const SubscriberList& config,
                                          ResultHandler* handler );

        /**
         * This function sets or requests a node's affiliates list
         * (depending on arguments). Does the actual work for
         * requestAffiliateList and setAffiliateList.
         * Requests or changes a node's configuration.
         * @param ctx The operation to be performed.
         * @param service Service to query.
         * @param node Node ID of the node.
         * @param config If not NULL, the function will request the node config.
         * Otherwise, it will set the config based on the form.
         * @param handler ResultHandler responsible to handle the request result.
         * @return The ID used in the request.
         */
        const std::string affiliateList( TrackContext ctx,
                                         const JID& service,
                                         const std::string& node,
                                         const AffiliateList& config,
                                         ResultHandler* handler );

        const std::string subscriptionOptions( TrackContext context,
                                               const JID& service,
                                               const JID& jid,
                                               const std::string& node,
                                               ResultHandler* handler,
                                               DataForm* df,
                                               const std::string& subid = EmptyString );

        const std::string getSubscriptionsOrAffiliations( const JID& service,
            ResultHandler* handler,
            TrackContext context );

        typedef std::map < std::string, std::string > NodeOperationTrackMap;
        typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap;

        ClientBase* m_parent;

        NodeOperationTrackMap  m_nopTrackMap;
        ResultHandlerTrackMap  m_resultHandlerTrackMap;

        util::Mutex m_trackMapMutex;

    };

  }

}

#endif // PUBSUBMANAGER_H__