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_MUMBLE_CLIENTUSER_H_
7 #define MUMBLE_MUMBLE_CLIENTUSER_H_
8 
9 #include <QtCore/QReadWriteLock>
10 
11 #include "User.h"
12 #include "Timer.h"
13 #include "Settings.h"
14 
15 class ClientUser : public QObject, public User {
16 	private:
17 		Q_OBJECT
18 		Q_DISABLE_COPY(ClientUser)
19 	public:
20 		Settings::TalkState tsState;
21 		Timer tLastTalkStateChange;
22 		bool bLocalIgnore;
23 		bool bLocalMute;
24 
25 		float fPowerMin, fPowerMax;
26 		float fAverageAvailable;
27 		float fLocalVolume;
28 
29 		int iFrames;
30 		int iSequence;
31 
32 		QByteArray qbaTextureFormat;
33 		QString qsFriendName;
34 
35 		QString getFlagsString() const;
36 		ClientUser(QObject *p = NULL);
37 
38 		/**
39 		 * Determines whether a user is active or not
40 		 * A user is active when it is currently speaking or when the user has
41 		 * spoken within Settings::uiActiveTime amount of seconds.
42 		 */
43 		bool isActive();
44 
45 		static QHash<unsigned int, ClientUser *> c_qmUsers;
46 		static QReadWriteLock c_qrwlUsers;
47 
48 		static QList<ClientUser *> c_qlTalking;
49 		static QReadWriteLock c_qrwlTalking;
50 		static QList<ClientUser *> getTalking();
51 		static QList<ClientUser *> getActive();
52 
53 		static void sortUsersOverlay(QList<ClientUser *> &list);
54 
55 		static ClientUser *get(unsigned int);
56 		static bool isValid(unsigned int);
57 		static ClientUser *add(unsigned int, QObject *p = NULL);
58 		static ClientUser *match(const ClientUser *p, bool matchname = false);
59 		static void remove(unsigned int);
60 		static void remove(ClientUser *);
61 	protected:
62 		static bool lessThanOverlay(const ClientUser *, const ClientUser *);
63 	public slots:
64 		void setTalking(Settings::TalkState ts);
65 		void setMute(bool mute);
66 		void setDeaf(bool deaf);
67 		void setSuppress(bool suppress);
68 		void setLocalIgnore(bool ignore);
69 		void setLocalMute(bool mute);
70 		void setSelfMute(bool mute);
71 		void setSelfDeaf(bool deaf);
72 		void setPrioritySpeaker(bool priority);
73 		void setRecording(bool recording);
74 	signals:
75 		void talkingStateChanged();
76 		void muteDeafStateChanged();
77 		void prioritySpeakerStateChanged();
78 		void recordingStateChanged();
79 };
80 
81 #endif
82