1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifdef USE_ICE
7 #ifndef MUMBLE_MURMUR_MURMURICE_H_
8 #define MUMBLE_MURMUR_MURMURICE_H_
9 
10 #include <QtCore/QList>
11 #include <QtCore/QMap>
12 #include <QtCore/QMutex>
13 #include <QtCore/QObject>
14 #include <QtCore/QWaitCondition>
15 #include <QtNetwork/QSslCertificate>
16 
17 #include "MurmurI.h"
18 
19 class Channel;
20 class Server;
21 class User;
22 struct TextMessage;
23 
24 class MurmurIce : public QObject {
25 		friend class MurmurLocker;
26 		Q_OBJECT;
27 	protected:
28 		int count;
29 		QMutex qmEvent;
30 		QWaitCondition qwcEvent;
31 		void customEvent(QEvent *evt);
32 		void badMetaProxy(const ::Murmur::MetaCallbackPrx &prx);
33 		void badServerProxy(const ::Murmur::ServerCallbackPrx &prx, const ::Server* server);
34 		void badAuthenticator(::Server *);
35 		QList< ::Murmur::MetaCallbackPrx> qlMetaCallbacks;
36 		QMap<int, QList< ::Murmur::ServerCallbackPrx> > qmServerCallbacks;
37 		QMap<int, QMap<int, QMap<QString, ::Murmur::ServerContextCallbackPrx> > > qmServerContextCallbacks;
38 		QMap<int, ::Murmur::ServerAuthenticatorPrx> qmServerAuthenticator;
39 		QMap<int, ::Murmur::ServerUpdatingAuthenticatorPrx> qmServerUpdatingAuthenticator;
40 	public:
41 		Ice::CommunicatorPtr communicator;
42 		Ice::ObjectAdapterPtr adapter;
43 		MurmurIce();
44 		~MurmurIce();
45 
46 		void addMetaCallback(const ::Murmur::MetaCallbackPrx& prx);
47 		void removeMetaCallback(const ::Murmur::MetaCallbackPrx& prx);
48 		void addServerCallback(const ::Server* server, const ::Murmur::ServerCallbackPrx& prx);
49 		void removeServerCallback(const ::Server* server, const ::Murmur::ServerCallbackPrx& prx);
50 		void removeServerCallbacks(const ::Server* server);
51 		void addServerContextCallback(const ::Server* server, int session_id, const QString& action, const ::Murmur::ServerContextCallbackPrx& prx);
52 		const QMap< int, QMap<QString, ::Murmur::ServerContextCallbackPrx> > getServerContextCallbacks(const ::Server* server) const;
53 		void removeServerContextCallback(const ::Server* server, int session_id, const QString& action);
54 		void setServerAuthenticator(const ::Server* server, const ::Murmur::ServerAuthenticatorPrx& prx);
55 		const ::Murmur::ServerAuthenticatorPrx getServerAuthenticator(const ::Server* server) const;
56 		void removeServerAuthenticator(const ::Server* server);
57 		void setServerUpdatingAuthenticator(const ::Server* server, const ::Murmur::ServerUpdatingAuthenticatorPrx& prx);
58 		const ::Murmur::ServerUpdatingAuthenticatorPrx getServerUpdatingAuthenticator(const ::Server* server) const;
59 		void removeServerUpdatingAuthenticator(const ::Server* server);
60 
61 	public slots:
62 		void started(Server *);
63 		void stopped(Server *);
64 
65 		void authenticateSlot(int &res, QString &uname, int sessionId, const QList<QSslCertificate> &certlist, const QString &certhash, bool certstrong, const QString &pw);
66 		void registerUserSlot(int &res, const QMap<int, QString> &);
67 		void unregisterUserSlot(int &res, int id);
68 		void getRegisteredUsersSlot(const QString &filter, QMap<int, QString> &res);
69 		void getRegistrationSlot(int &, int, QMap<int, QString> &);
70 		void setInfoSlot(int &, int, const QMap<int, QString> &);
71 		void setTextureSlot(int &res, int id, const QByteArray &texture);
72 		void nameToIdSlot(int &res, const QString &name);
73 		void idToNameSlot(QString &res, int id);
74 		void idToTextureSlot(QByteArray &res, int id);
75 
76 		void userStateChanged(const User *p);
77 		void userTextMessage(const User *p, const TextMessage &);
78 		void userConnected(const User *p);
79 		void userDisconnected(const User *p);
80 
81 		void channelStateChanged(const Channel *c);
82 		void channelCreated(const Channel *c);
83 		void channelRemoved(const Channel *c);
84 
85 		void contextAction(const User *, const QString &, unsigned int, int);
86 };
87 #endif
88 #endif
89