This file is indexed.

/usr/include/gloox/jinglesession.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
/*
  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 JINGLESESSION_H__
#define JINGLESESSION_H__

#include "stanzaextension.h"
#include "tag.h"
#include "iqhandler.h"
#include "jingleplugin.h"

#include <string>

namespace gloox
{

  class ClientBase;

  /**
   * @brief The namespace containing Jingle-related (@xep{0166} et. al.) classes.
   *
   * See @link gloox::Jingle::SessionManager SessionManager @endlink for more information
   * about Jingle in gloox.
   *
   * @author Jakob Schroeter <js@camaya.net>
   * @since 1.0.5
   */
  namespace Jingle
  {

    class Description;
    class Transport;
    class SessionHandler;
    class Content;

    /**
     * Jingle Session actions.
     */
    enum Action
    {
      ContentAccept,                /**< Accept a content-add action received from another party. */
      ContentAdd,                   /**< Add one or more new content definitions to the session. */
      ContentModify,                /**< Change the directionality of media sending. */
      ContentReject,                /**< Reject a content-add action received from another party. */
      ContentRemove,                /**< Remove one or more content definitions from the session. */
      DescriptionInfo,              /**< Exchange information about parameters for an application type. */
      SecurityInfo,                 /**< Send information related to establishment or maintenance of security preconditions. */
      SessionAccept,                /**< Definitively accept a session negotiation. */
      SessionInfo,                  /**< Send session-level information, such as a ping or a ringing message. */
      SessionInitiate,              /**< Request negotiation of a new Jingle session. */
      SessionTerminate,             /**< End an existing session. */
      TransportAccept,              /**< Accept a transport-replace action received from another party. */
      TransportInfo,                /**< Exchange transport candidates. */
      TransportReject,              /**< Reject a transport-replace action received from another party. */
      TransportReplace,             /**< Redefine a transport method or replace it with a different method. */
      InvalidAction                 /**< Invalid action. */
    };

    /**
     * @brief This is an implementation of a Jingle Session (@xep{0166}).
     *
     * See @link gloox::Jingle::SessionManager Jingle::SessionManager @endlink for info on how to use
     * Jingle in gloox.
     *
     * XEP Version: 1.1
     *
     * @author Jakob Schroeter <js@camaya.net>
     * @since 1.0.5
     */
    class GLOOX_API Session : public IqHandler
    {

      friend class SessionManager;

      public:
        /**
         * Session state.
         */
        enum State
        {
          Ended,                    /**< The session has ended or was not active yet. */
          Pending,                  /**< The session has been initiated but has not yet been accepted by the remote party. */
          Active                    /**< The session is active. */
        };

        /**
         * @brief An abstraction of a Jingle (@xep{0166}) session terminate reason.
         *
         * XEP Version: 1.1
         *
         * @author Jakob Schroeter <js@camaya.net>
         * @since 1.0.5
         */
        class GLOOX_API Reason : public Plugin
        {
          public:
            /**
             * Defined reasons for terminating a Jingle Session.
             */
            enum Reasons
            {
              AlternativeSession,           /**< An alternative session exists that should be used. */
              Busy,                         /**< The terminating party is busy. */
              Cancel,                       /**< The session has been canceled. */
              ConnectivityError,            /**< Connectivity error. */
              Decline,                      /**< The terminating party formally declines the request. */
              Expired,                      /**< The session has expired. */
              FailedApplication,            /**< Application type setup failed. */
              FailedTransport,              /**< Transport setup has failed. */
              GeneralError,                 /**< General error. */
              Gone,                         /**< Participant went away. */
              IncompatibleParameters,       /**< Offered or negotiated application type parameters not supported. */
              MediaError,                   /**< Media error. */
              SecurityError,                /**< Security error. */
              Success,                      /**< Session terminated after successful call. */
              Timeout,                      /**< A timeout occured. */
              UnsupportedApplications,      /**< The terminating party does not support any of the offered application formats. */
              UnsupportedTransports,        /**< The terminating party does not support any of the offered transport methods. */
              InvalidReason                 /**< Invalid reason. */
            };

            /**
             * Constructor.
             * @param reason The reason for the termination of the session.
             * @param sid An optional session ID (only used if reason is AlternativeSession).
             * @param text An optional human-readable text explaining the reason for the session termination.
             */
            Reason( Reasons reason, const std::string& sid = EmptyString,
                    const std::string& text = EmptyString );

            /**
             * Constructs a new element by parsing the given Tag.
             * @param tag A tag to parse.
             */
            Reason( const Tag* tag = 0 );

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

            /**
             * Returns the reason for the session termination.
             * @return The reason for the session termination.
             */
            Reasons reason() const { return m_reason; }

            /**
             * Returns the session ID of the alternate session, if given (only applicable
             * if reason() returns AlternativeSession).
             * @return The session ID of the alternative session, or an empty string.
             */
            const std::string& sid() const { return m_sid; }

            /**
             * Returns the content of an optional, human-readable
             * &lt;text&gt; element.
             * @return An optional text describing the reason for the terminate action.
             */
            const std::string& text() const { return m_text; }

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

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

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

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

          private:
            Reasons m_reason;
            std::string m_sid;
            std::string m_text;

        };

        /**
         * @brief This is an abstraction of Jingle's (@xep{0166}) &lt;jingle&gt; element as a StanzaExtension.
         *
         * XEP Version: 1.1
         * @author Jakob Schroeter <js@camaya.net>
         * @since 1.0.5
         */
        class Jingle : public StanzaExtension
        {

          friend class Session;

          public:
            /**
             * Constructs a new object from the given Tag.
             * @param tag The Tag to parse.
             */
            Jingle( const Tag* tag = 0 );

            /**
             * Virtual Destructor.
             */
            virtual ~Jingle();

            /**
             * Returns the session ID.
             * @return The session ID.
             */
            const std::string& sid() const { return m_sid; }

            /**
             * Returns the 'session initiator'. This will usually be empty for any action other than 'session-initiate'.
             * @return The 'session initiator'.
             */
            const JID& initiator() const { return m_initiator; }

            /**
             * Returns the 'session responder'. This will usually be empty for any action other than 'session-accept'.
             * @return The 'session responder'.
             */
            const JID& responder() const { return m_responder; }

            /**
             * Returns this Jingle's action.
             * @return The action.
             */
            Action action() const { return m_action; }

            /**
             * Adds a Plugin as child.
             * @param plugin A plugin to be embedded. Will be owned by this instance and deleted in the destructor.
             */
            void addPlugin( const Plugin* plugin ) { if( plugin ) m_plugins.push_back( plugin ); }

            /**
             * Returns a reference to a list of embedded plugins.
             * @return A reference to a list of embedded plugins.
             */
            const PluginList& plugins() const { return m_plugins; }

            /**
             * Returns the tag to build plugins from.
             * @return The tag to build plugins from.
             */
            Tag* embeddedTag() const { return m_tag; }

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

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

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

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

#ifdef JINGLE_TEST
          public:
#else
          private:
#endif
            /**
             * Constructs a new object and fills it according to the parameters.
             * @param action The Action to carry out.
             * @param initiator The full JID of the initiator of the session flow. Will only be used for the SessionInitiate action.
             * @param responder The full JID of the responder. Will only be used for the SessionAccept action.
             * @param plugins A list of contents (plugins) for the &lt;jingle&gt;
             * element. Usually, these will be Content objects, but can be any Plugin-derived objects.
             * These objects will be owned and deleted by this Jingle instance.
             * @param sid The session ID:
             */
            Jingle( Action action, const JID& initiator, const JID& responder,
                    const PluginList& plugins, const std::string& sid );

#ifdef JINGLE_TEST
            /**
             * Constructs a new object and fills it according to the parameters.
             * @param action The Action to carry out.
             * @param initiator The full JID of the initiator of the session flow. Will only be used for the SessionInitiate action.
             * @param responder The full JID of the responder. Will only be used for the SessionAccept action.
             * @param plugin A single content (plugin) for the &lt;jingle&gt;
             * element. Usually, this will be a Content object, but can be any Plugin-derived object.
             * This object will be owned and deleted by this Jingle instance.
             * @param sid The session ID:
             */
            Jingle( Action action, const JID& initiator, const JID& responder,
                    const Plugin* plugin, const std::string& sid );
            #endif

//             /**
//              * Copy constructor.
//              * @param right The instance to copy.
//              */
//             Jingle( const Jingle& right );

            Action m_action;
            std::string m_sid;
            JID m_initiator;
            JID m_responder;
            PluginList m_plugins;
            Tag* m_tag;

        };

        /**
         * Virtual Destructor.
         */
        virtual ~Session();

        /**
         * Explicitely sets a new session initiator. The initiator defaults to the initiating entity's JID.
         * Normally, you should not need to use this function.
         * @param initiator The new initiator.
         */
        void setInitiator( const JID& initiator ) { m_initiator = initiator; }

        /**
         * Returns the session's initiator.
         * @return The session's initiator.
         */
        const JID& initiator() const { return m_initiator; }

        /**
         * Returns the session's responder. This will only return something useful after the 'session-accept' action has been
         * sent/received.
         * @return The session's responder.
         */
        const JID& responder() const { return m_responder; }

        /**
         * Explicitely sets the 'session responder'. By default, the associated ClientBase's jid() will be used.
         * You can change this here.
         * @note Changing the session responder only affects the 'session-accept' action; it will have no effect after
         * that action has been executed or if the local entity is the session initiator.
         * @param jid The session responder's full JID.
         */
        void setResponder( const JID& jid ) { m_responder = jid; }

        /**
         * Explicitely sets a new handler for the session.
         * @param handler The new handler.
         */
        void setHandler( SessionHandler* handler ) { m_handler = handler; }

        /**
         * Sends a 'content-accept' notification.
         * @param content The accepted content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentAccept( const Content* content );

        /**
         * Sends a 'content-add' request.
         * @param content The proposed content to be added.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentAdd( const Content* content );

        /**
         * Sends a 'content-add' request.
         * @param contents A list of proposed content to be added.
         * These objects will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentAdd( const PluginList& contents );

        /**
         * Sends a 'content-modify' request.
         * @param content The proposed content type to be modified.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentModify( const Content* content );

        /**
         * Sends a 'content-reject' reply.
         * @param content The rejected content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentReject( const Content* content );

        /**
         * Sends a 'content-remove' request.
         * @param content The content type to be removed.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool contentRemove( const Content* content );

        /**
         * Sends a 'description-info' notice.
         * @param info The payload.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool descriptionInfo( const Plugin* info );

        /**
         * Sends a 'security-info' notice.
         * @param info A security pre-condition.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool securityInfo( const Plugin* info );

        /**
         * Accepts an incoming session with the given content.
         * @param content A pair of application description and transport method wrapped in a Content that describes
         * the accepted session parameters.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionAccept( const Content* content );

        /**
         * Accepts an incoming session with the given list of contents.
         * @param content A list of Content objects that describe the accepted session parameters.
         * These objects will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionAccept( const PluginList& plugins );

        /**
         * Sends a 'session-info' notice.
         * @param info The payload.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionInfo( const Plugin* info );

        /**
         * Initiates a session with a remote entity.
         * @param content A Content object. You may use initiate( const PluginList& contents ) for more than one Content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionInitiate( const Content* content );

        /**
         * Initiates a session with a remote entity.
         * @param plugins A list of Content objects. It is important to pass a (list of) Content objects here.
         * Even though e.g. Jingle::ICEUDP are Plugin-derived, too, using anything other than Content here will result
         * in erroneous behaviour at best. You may use sessionInitiate( const Content* content ) for just one Content.
         * These objects will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionInitiate( const PluginList& plugins );

        /**
         * Terminates the current session, if it is at least in Pending state, with the given reason. The sid parameter
         * is ignored unless the reason is AlternativeSession.
         * @param reason The reason for terminating the session.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool sessionTerminate( Session::Reason* reason );

        /**
         * Sends a 'transport-accept' reply.
         * @param content The accepted transport wrapped in a Content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool transportAccept( const Content* content );

        /**
         * Sends a 'transport-info' notice.
         * @param info The payload.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool transportInfo( const Plugin* info );

        /**
         * Sends a 'transport-reject' reply.
         * @param content The rejected transport wrapped in a Content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool transportReject( const Content* content );

        /**
         * Sends a 'transport-replace' request.
         * @param content The proposed transport to be replaced wrapped in a Content.
         * This object will be owned and deleted by this Session instance.
         * @return @b False if a prerequisite is not met, @b true otherwise.
         */
        bool transportReplace( const Content* content );

        /**
         * Returns the session's state.
         * @return The session's state.
         */
        State state() const { return m_state; }

        /**
         * Sets the session's ID. This will be initialized to a random value (or taken from an incoming session request)
         * by default. You should not need to set the session ID manually.
         * @param sid  The session's id.
         */
        void setSID( const std::string& sid ) { m_sid = sid; }

        /**
         * Returns the session's ID.
         * @return The session's ID.
         */
        const std::string& sid() const { return m_sid; }

        // reimplemented from IqHandler
        virtual bool handleIq( const IQ& iq );

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

#ifdef JINGLE_TEST
      public:
#else
      private:
#endif
        /**
         * Creates a new Jingle Session.
         * @param parent The ClientBase to use for communication.
         * @param callee The remote end of the session.
         * @param jsh The handler to receive events and results.
         */
        Session( ClientBase* parent, const JID& callee, SessionHandler* jsh );

        /**
         * Creates a new Session from the incoming Jingle object.
         * This is a NOOP for Jingles that have an action() different from SessionInitiate.
         * @param parent The ClientBase to use for communication.
         * @param callee The remote entity.
         * @param jingle The Jingle object to init the Session from.
         * @param jsh The handler to receive events and results.
         */
        Session( ClientBase* parent, const JID& callee, const Session::Jingle* jingle,
                 SessionHandler* jsh );

        bool doAction( Action action, const Plugin* plugin );
        bool doAction( Action action, const PluginList& plugin );

        ClientBase* m_parent;
        State m_state;
        JID m_remote;
        JID m_initiator;
        JID m_responder;
        SessionHandler* m_handler;
        std::string m_sid;
        bool m_valid;

    };

  }

}

#endif // JINGLESESSION_H__