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 #ifndef MUMBLE_CHANNEL_H_
7 #define MUMBLE_CHANNEL_H_
8 
9 #include <QtCore/QHash>
10 #include <QtCore/QList>
11 #include <QtCore/QObject>
12 #include <QtCore/QReadWriteLock>
13 #include <QtCore/QSet>
14 #include <QtCore/QString>
15 
16 class User;
17 class Group;
18 class ChanACL;
19 
20 class ClientUser;
21 
22 class Channel : public QObject {
23 	private:
24 		Q_OBJECT
25 		Q_DISABLE_COPY(Channel)
26 	private:
27 		QSet<Channel *> qsUnseen;
28 	public:
29 		int iId;
30 		int iPosition;
31 		bool bTemporary;
32 		Channel *cParent;
33 		QString qsName;
34 		QString qsDesc;
35 		QByteArray qbaDescHash;
36 		QList<Channel *> qlChannels;
37 		QList<User *> qlUsers;
38 		QHash<QString, Group *> qhGroups;
39 		QList<ChanACL *> qlACL;
40 
41 		QSet<Channel *> qsPermLinks;
42 		QHash<Channel *, int> qhLinks;
43 
44 		bool bInheritACL;
45 
46 		/// Maximum number of users allowed in the channel. If this
47 		/// value is zero, the maximum number of users allowed in the
48 		/// channel is given by the server's "usersperchannel"
49 		/// setting.
50 		unsigned int uiMaxUsers;
51 
52 		Channel(int id, const QString &name, QObject *p = NULL);
53 		~Channel();
54 
55 #ifdef MUMBLE
56 		unsigned int uiPermissions;
57 		bool bFiltered;
58 
59 		static QHash<int, Channel *> c_qhChannels;
60 		static QReadWriteLock c_qrwlChannels;
61 
62 		static Channel *get(int);
63 		static Channel *add(int, const QString &);
64 		static void remove(Channel *);
65 
66 		void addClientUser(ClientUser *p);
67 #endif
68 		static bool lessThan(const Channel *, const Channel *);
69 
70 		size_t getLevel() const;
71 		size_t getDepth() const;
72 		QString getPath() const;
73 
74 		void addChannel(Channel *c);
75 		void removeChannel(Channel *c);
76 		void addUser(User *p);
77 		void removeUser(User *p);
78 
79 		bool isLinked(Channel *c) const;
80 		void link(Channel *c);
81 		void unlink(Channel *c = NULL);
82 
83 		QSet<Channel *> allLinks();
84 		QSet<Channel *> allChildren();
85 
86 		operator QString() const;
87 };
88 
89 #endif
90