00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __CHANNELS_H__
00015 #define __CHANNELS_H__
00016
00017 #include "inspircd_config.h"
00018 #include "base.h"
00019 #include <time.h>
00020 #include <vector>
00021 #include <string>
00022 #include <map>
00023
00026 enum ChannelModes {
00027 CM_TOPICLOCK = 't'-65,
00028 CM_NOEXTERNAL = 'n'-65,
00029 CM_INVITEONLY = 'i'-65,
00030 CM_MODERATED = 'm'-65,
00031 CM_SECRET = 's'-65,
00032 CM_PRIVATE = 'p'-65,
00033 CM_KEY = 'k'-65,
00034 CM_LIMIT = 'l'-65
00035 };
00036
00037
00038 class userrec;
00039 class chanrec;
00040
00044 class HostItem : public classbase
00045 {
00046 public:
00049 time_t set_time;
00052 char set_by[NICKMAX];
00055 char data[MAXBUF];
00056
00057 HostItem() { }
00058 virtual ~HostItem() { }
00059 };
00060
00063 class BanItem : public HostItem
00064 {
00065 };
00066
00069 typedef std::vector<BanItem> BanList;
00070
00073 typedef std::map<userrec*,std::string> CUList;
00074
00077 typedef CUList::iterator CUListIter;
00078
00081 typedef CUList::const_iterator CUListConstIter;
00082
00085 typedef std::map<char,char*> CustomModeList;
00086
00087
00090 enum UserChannelModes {
00091 UCMODE_OP = 1,
00092 UCMODE_VOICE = 2,
00093 UCMODE_HOP = 4
00094 };
00095
00096
00097 class InspIRCd;
00098
00101 typedef std::pair<char, unsigned int> prefixtype;
00102
00105 typedef std::vector<prefixtype> pfxcontainer;
00106
00109 typedef std::map<userrec*, std::vector<prefixtype> > prefixlist;
00110
00115 class CoreExport chanrec : public Extensible
00116 {
00117 private:
00118
00121 InspIRCd* ServerInstance;
00122
00125 static chanrec* ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, const std::string &privs);
00126
00129 void SetDefaultModes();
00130
00134 prefixlist prefixes;
00135
00138 int maxbans;
00139
00140 public:
00143 char name[CHANMAX];
00144
00151 char modes[64];
00152
00158 CUList internal_userlist;
00159
00165 CUList internal_op_userlist;
00166
00172 CUList internal_halfop_userlist;
00173
00179 CUList internal_voice_userlist;
00180
00184 CustomModeList custom_mode_params;
00185
00189 char topic[MAXTOPIC];
00190
00194 time_t created;
00195
00199 time_t topicset;
00200
00204 char setby[128];
00205
00209 short int limit;
00210
00214 char key[32];
00215
00218 BanList bans;
00219
00224 void SetMode(char mode,bool mode_on);
00225
00231 void SetModeParam(char mode,const char* parameter,bool mode_on);
00232
00237 bool IsModeSet(char mode);
00238
00249 std::string GetModeParameter(char mode);
00250
00258 long GetUserCounter();
00259
00267 void AddUser(userrec* user);
00268
00272 void AddOppedUser(userrec* user);
00273
00277 void AddHalfoppedUser(userrec* user);
00278
00282 void AddVoicedUser(userrec* user);
00283
00288 unsigned long DelUser(userrec* user);
00289
00293 void DelOppedUser(userrec* user);
00294
00298 void DelHalfoppedUser(userrec* user);
00299
00303 void DelVoicedUser(userrec* user);
00304
00314 CUList* GetUsers();
00315
00319 CUList* GetOppedUsers();
00320
00324 CUList* GetHalfoppedUsers();
00325
00329 CUList* GetVoicedUsers();
00330
00335 bool HasUser(userrec* user);
00336
00340 chanrec(InspIRCd* Instance);
00341
00349 long KickUser(userrec *src, userrec *user, const char* reason);
00350
00358 long ServerKickUser(userrec* user, const char* reason, bool triggerevents);
00359
00367 long PartUser(userrec *user, const char* reason = NULL);
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378 static chanrec* JoinUser(InspIRCd* ServerInstance, userrec *user, const char* cn, bool override, const char* key, time_t TS = 0);
00379
00385 void WriteChannel(userrec* user, char* text, ...);
00386
00391 void WriteChannel(userrec* user, const std::string &text);
00392
00398 void WriteChannelWithServ(const char* ServName, const char* text, ...);
00399
00404 void WriteChannelWithServ(const char* ServName, const std::string &text);
00405
00415 void WriteAllExceptSender(userrec* user, bool serversource, char status, char* text, ...);
00416
00426 void WriteAllExcept(userrec* user, bool serversource, char status, CUList &except_list, char* text, ...);
00427
00436 void WriteAllExceptSender(userrec* user, bool serversource, char status, const std::string& text);
00437
00446 void WriteAllExcept(userrec* user, bool serversource, char status, CUList &except_list, const std::string& text);
00447
00451 long GetMaxBans();
00452
00458 char* ChanModes(bool showkey);
00459
00465 void UserList(userrec *user, CUList* ulist = NULL);
00466
00470 int CountInvisible();
00471
00476 int GetStatus(userrec *user);
00477
00482 int GetStatusFlags(userrec *user);
00483
00495 const char* GetPrefixChar(userrec *user);
00496
00503 const char* GetAllPrefixChars(userrec* user);
00504
00516 unsigned int GetPrefixValue(userrec* user);
00517
00523 void RemoveAllPrefixes(userrec* user);
00524
00534 void SetPrefix(userrec* user, char prefix, unsigned int prefix_rank, bool adding);
00535
00540 bool IsBanned(userrec* user);
00541
00544 void ResetMaxBans();
00545
00548 virtual ~chanrec() { }
00549 };
00550
00551 #endif