~ubuntu-branches/ubuntu/vivid/gloox/vivid-proposed

« back to all changes in this revision

Viewing changes to src/jinglesessionmanager.h

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2014-03-16 17:34:43 UTC
  • mfrom: (12.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20140316173443-4s177dovzaz5dm8o
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 2013 by Jakob Schroeter <js@camaya.net>
 
3
  This file is part of the gloox library. http://camaya.net/gloox
 
4
 
 
5
  This software is distributed under a license. The full license
 
6
  agreement can be found in the file LICENSE in this distribution.
 
7
  This software may not be copied, modified, sold or distributed
 
8
  other than expressed in the named license agreement.
 
9
 
 
10
  This software is distributed without any warranty.
 
11
*/
 
12
 
 
13
 
 
14
#ifndef JINGLESESSIONMANAGER_H__
 
15
#define JINGLESESSIONMANAGER_H__
 
16
 
 
17
#include "macros.h"
 
18
#include "iqhandler.h"
 
19
#include "jinglepluginfactory.h"
 
20
 
 
21
#include <list>
 
22
 
 
23
namespace gloox
 
24
{
 
25
 
 
26
  class ClientBase;
 
27
 
 
28
  namespace Jingle
 
29
  {
 
30
 
 
31
    class Session;
 
32
    class SessionHandler;
 
33
 
 
34
    /**
 
35
     * @brief The SessionManager is responsible for creating and destroying Jingle sessions, as well as for delegating incoming
 
36
     * IQs to their respective sessions. This is part of Jingle (@xep{0166}).
 
37
     *
 
38
     * @note The classes in the Jingle namespace implement the signaling part of Jingle only.
 
39
     * Establishing connections to a remote entity or transfering data outside the XMPP channel
 
40
     * is out of scope of gloox.
 
41
     *
 
42
     * To use Jingle with gloox you should first instantiate a Jingle::SessionManager. The SessionManager will
 
43
     * let you create new Jingle sessions and notify the respective handler about incoming Jingle session requests.
 
44
     * It will also announce generic Jingle support via Disco. You have to register any
 
45
     * @link gloox::Jingle::Plugin Jingle plugins @endlink you want to use using registerPlugin().
 
46
     * These will automatically announce any additional features via Disco.
 
47
     *
 
48
     * Use createSession() to create a new Session.
 
49
     *
 
50
     * Implement SessionHandler::handleIncomingSession() to receive incoming session requests.
 
51
     *
 
52
     * Use discardSession() to get rid of a session. Do not delete a session manually.
 
53
     *
 
54
     * There is no limit to the number of concurrent sessions.
 
55
     *
 
56
     * @author Jakob Schroeter <js@camaya.net>
 
57
     * @since 1.0.5
 
58
     */
 
59
    class GLOOX_API SessionManager : public IqHandler
 
60
    {
 
61
      public:
 
62
        /**
 
63
         * Creates new instance. There should be only one SessionManager per ClientBase.
 
64
         * @param parent A ClientBase instance used for sending and receiving.
 
65
         * @param sh A session handler that will be notified about incoming session requests.
 
66
         * Only handleIncomingSession() will be called in that handler.
 
67
         */
 
68
        SessionManager( ClientBase* parent, SessionHandler* sh );
 
69
 
 
70
        /**
 
71
         * Virtual destructor.
 
72
         */
 
73
        virtual ~SessionManager();
 
74
 
 
75
        /**
 
76
         * Registers an empty Plugin as a template with the manager.
 
77
         * @param plugin The plugin to register.
 
78
         */
 
79
        void registerPlugin( Plugin* plugin );
 
80
 
 
81
        /**
 
82
         * Lets you create a new Jingle session.
 
83
         * @param callee The remote entity's JID.
 
84
         * @param handler The handler responsible for handling events assicoated with the new session.
 
85
         * @return The new session.
 
86
         * @note You should not delete a session yourself. Instead, pass it to discardSession().
 
87
         */
 
88
        Session* createSession( const JID& callee, SessionHandler* handler );
 
89
 
 
90
        /**
 
91
         * Removes a given session from the nternal queue and deletes it.
 
92
         * @param session The session to delete.
 
93
         */
 
94
        void discardSession( Session* session );
 
95
 
 
96
 
 
97
        // reimplemented from IqHandler
 
98
        virtual bool handleIq( const IQ& iq );
 
99
 
 
100
        // reimplemented from IqHandler
 
101
        virtual void handleIqID( const IQ& /*iq*/, int /*context*/ ) {}
 
102
 
 
103
      private:
 
104
        typedef std::list<Jingle::Session*> SessionList;
 
105
 
 
106
        SessionList m_sessions;
 
107
        ClientBase* m_parent;
 
108
        SessionHandler* m_handler;
 
109
        PluginFactory m_factory;
 
110
 
 
111
    };
 
112
 
 
113
  }
 
114
 
 
115
}
 
116
 
 
117
#endif // JINGLESESSIONMANAGER_H__