-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel.h
More file actions
74 lines (56 loc) · 2.4 KB
/
channel.h
File metadata and controls
74 lines (56 loc) · 2.4 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <list>
#include <string>
#include <mutex>
#include "ChannelManager.h"
namespace FTS {
class Packet;
}
namespace FTSSrv2 {
class Client;
class DataBase;
class Channel {
private:
int m_iID; ///< The MySQL ID of the row, needed when saving.
bool m_bPublic; ///< Whether this is publicly visible or not.
std::string m_sName; ///< The name of this channel.
std::string m_sMotto; ///< The motto of this channel.
std::string m_sAdmin; ///< The name of the admin of this channel.
std::list<std::string>m_lsOperators;///< The names of the operators of this channel.
std::list<Client *>m_lpUsers; ///< The users that are currently in this channel.
std::recursive_mutex m_mutex; ///< Mutex for accessing me.
DataBase* m_pDataBase = nullptr; ///< Access the database.
public:
struct channel_parameter_t
{
int id = -1;
bool isPublic = false;
std::string name;
std::string motto;
std::string admin;
};
Channel(const channel_parameter_t &in_param, DataBase* in_pDataBase);
virtual ~Channel();
int join(Client *in_pUser);
int quit(Client *in_pUser);
int save();
int destroyDB(const std::string &in_sWhoWantsIt);
int op(const std::string & in_sUser, bool in_bOninit = false);
int deop(const std::string & in_sUser);
bool isop(const std::string & in_sUser);
int messageToAll(const Client &in_From, const std::string &in_sMessage, uint8_t in_cFlags);
FTS::Packet makeSystemMessagePacket(const std::string &in_sMessageID);
int sendPacketToAll(FTS::Packet *in_pPacket);
int kick(const Client *in_pFrom, const std::string &in_sUser);
inline std::string getMotto() const { return m_sMotto; }
int setMotto(const std::string &in_sMotto, const std::string &in_sClient);
inline std::string getName() const { return m_sName; }
inline std::string getAdmin() const { return m_sAdmin; }
inline void setAdmin(const std::string &in_sNewAdmin) { m_sAdmin = in_sNewAdmin; }
inline std::list<Client *> getUsers() const { return m_lpUsers; }
inline int getNUsers() const { return (int)this->getUsers().size(); }
inline bool isPublic() const { return m_bPublic; }
Client *getUserIfPresent(const std::string &in_sUsername);
};
} // namespace FTSSrv2
/* EOF */