InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
channels.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6  * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7  * Copyright (C) 2003-2007 Craig Edwards <craigedwards@brainbox.cc>
8  *
9  * This file is part of InspIRCd. InspIRCd is free software: you can
10  * redistribute it and/or modify it under the terms of the GNU General Public
11  * License as published by the Free Software Foundation, version 2.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #ifndef CHANNELS_H
24 #define CHANNELS_H
25 
26 #include "membership.h"
27 #include "mode.h"
28 
32 class HostItem
33 {
34  public:
37  time_t set_time;
40  std::string set_by;
43  std::string data;
44 
45  HostItem() { /* stub */ }
46  virtual ~HostItem() { /* stub */ }
47 };
48 
51 class BanItem : public HostItem
52 {
53 };
54 
59 class CoreExport Channel : public Extensible, public InviteBase
60 {
63  static Channel* ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created);
64 
67  void SetDefaultModes();
68 
71  int maxbans;
72 
79  std::bitset<64> modes;
80 
84  CustomModeList custom_mode_params;
85 
86  public:
90  Channel(const std::string &name, time_t ts);
91 
94  std::string name;
95 
98  time_t age;
99 
102  UserMembList userlist;
103 
107  std::string topic;
108 
112  time_t topicset;
113 
117  std::string setby; /* 128 */
118 
121  BanList bans;
122 
127  void SetMode(ModeHandler* mode, bool value);
128  void SetMode(char mode,bool mode_on);
129 
135  void SetModeParam(ModeHandler* mode, const std::string& parameter);
136  void SetModeParam(char mode, const std::string& parameter);
137 
142  inline bool IsModeSet(char mode) { return modes[mode-'A']; }
143  inline bool IsModeSet(ModeHandler* mode) { return modes[mode->GetModeChar()-'A']; }
144 
145 
156  std::string GetModeParameter(char mode);
157  std::string GetModeParameter(ModeHandler* mode);
158 
164  int SetTopic(User *u, std::string &t, bool forceset = false);
165 
173  long GetUserCounter();
174 
182  Membership* AddUser(User* user);
183 
188  void DelUser(User* user);
189 
199  const UserMembList* GetUsers();
200 
205  bool HasUser(User* user);
206 
207  Membership* GetUser(User* user);
208 
214  void KickUser(User *src, User *user, const char* reason);
215 
221  void PartUser(User *user, std::string &reason);
222 
223  /* Join a user to a channel. May be a channel that doesnt exist yet.
224  * @param user The user to join to the channel.
225  * @param cn The channel name to join to. Does not have to exist.
226  * @param key The key of the channel, if given
227  * @param override If true, override all join restrictions such as +bkil
228  * @return A pointer to the Channel the user was joined to. A new Channel may have
229  * been created if the channel did not exist before the user was joined to it.
230  * If the user could not be joined to a channel, the return value may be NULL.
231  */
232  static Channel* JoinUser(User *user, const char* cn, bool override, const char* key, bool bursting, time_t TS = 0);
233 
239  void WriteChannel(User* user, const char* text, ...) CUSTOM_PRINTF(3, 4);
240 
245  void WriteChannel(User* user, const std::string &text);
246 
252  void WriteChannelWithServ(const std::string& ServName, const char* text, ...) CUSTOM_PRINTF(3, 4);
253 
258  void WriteChannelWithServ(const std::string& ServName, const std::string &text);
259 
269  void WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...) CUSTOM_PRINTF(5, 6);
270 
280  void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...) CUSTOM_PRINTF(6, 7);
281 
290  void WriteAllExceptSender(User* user, bool serversource, char status, const std::string& text);
291 
300  void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string& text);
302  void RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string& text);
303 
307  long GetMaxBans();
308 
314  char* ChanModes(bool showkey);
315 
319  void UserList(User *user);
320 
324  int CountInvisible();
325 
337  const char* GetPrefixChar(User *user);
338 
345  const char* GetAllPrefixChars(User* user);
346 
358  unsigned int GetPrefixValue(User* user);
359 
365  void RemoveAllPrefixes(User* user);
366 
376  bool SetPrefix(User* user, char prefix, bool adding);
377 
382  bool IsBanned(User* user);
383 
386  bool CheckBan(User* user, const std::string& banmask);
387 
390  ModResult GetExtBanStatus(User *u, char type);
391 
394  void ResetMaxBans();
395 };
396 
397 #endif
std::string name
Definition: channels.h:94
Definition: mode.h:102
Definition: channels.h:51
std::string setby
Definition: channels.h:117
Definition: extensible.h:76
UserMembList userlist
Definition: channels.h:102
Definition: users.h:230
time_t age
Definition: channels.h:98
std::string set_by
Definition: channels.h:40
time_t set_time
Definition: channels.h:37
Definition: membership.h:23
std::string data
Definition: channels.h:43
bool IsModeSet(char mode)
Definition: channels.h:142
Definition: channels.h:32
Definition: modules.h:75
BanList bans
Definition: channels.h:121
std::string topic
Definition: channels.h:107
Definition: membership.h:38
time_t topicset
Definition: channels.h:112
char GetModeChar()
Definition: mode.h:207
Definition: channels.h:59