summaryrefslogtreecommitdiffstats
blob: ea4199dc683f1eef5f208f489488b06049c72b9b (plain)
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
/*
 * Copyright (c) 2011 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>
#include <map>

#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Jingle/IncomingJingleSession.h>

namespace Swift {
	class IQRouter;
	class JingleResponder;
	class IncomingJingleSessionHandler;

	class JingleSessionManager {
			friend class JingleResponder;
		public:
			JingleSessionManager(IQRouter* router);
			~JingleSessionManager();

			JingleSession::ref getSession(const JID& jid, const String& id) const;

			void addIncomingSessionHandler(IncomingJingleSessionHandler* handler);
			void removeIncomingSessionHandler(IncomingJingleSessionHandler* handler);

		protected:
			void handleIncomingSession(const JID& from, IncomingJingleSession::ref);

		private:
			IQRouter* router;
			JingleResponder* responder;
			std::vector<IncomingJingleSessionHandler*> incomingSessionHandlers;
			struct JIDSession {
				JIDSession(const JID& jid, const String& session) : jid(jid), session(session) {}
				bool operator<(const JIDSession& o) const {
					return jid == o.jid ? session < o.session : jid < o.jid;
				}
				JID jid;
				String session;
			};
			typedef std::map<JIDSession, JingleSession::ref> SessionMap;
			SessionMap incomingSessions;
	};
}