1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 // include the common header files
44 MODEACTION_DENY = 0, /* Drop the mode change, AND a parameter if its a parameterized mode */
45 MODEACTION_ALLOW = 1 /* Allow the mode */
58 ModeHandler(char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly);
59 virtual ~ModeHandler();
62 ModeType GetModeType();
64 int GetNumParams(bool adding);
67 virtual ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); /* Can change the mode parameter as its a ref */
68 virtual void DisplayList(userrec* user, chanrec* channel);
69 virtual bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel);
78 ModeWatcher(char modeletter, ModeType type);
79 virtual ~ModeWatcher();
82 ModeType GetModeType();
84 virtual bool BeforeMode(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding, ModeType type); /* Can change the mode parameter */
85 virtual void AfterMode(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter, bool adding, ModeType type);
88 typedef std::vector<ModeWatcher*>::iterator ModeWatchIter;
94 * Mode handlers for each mode, to access a handler subtract
95 * 65 from the ascii value of the mode letter.
97 ModeHandler* modehandlers[64];
99 * Mode watcher classes
101 std::vector<ModeWatcher*> modewatchers[64];
103 char* GiveOps(userrec *user,char *dest,chanrec *chan,int status);
104 char* GiveHops(userrec *user,char *dest,chanrec *chan,int status);
105 char* GiveVoice(userrec *user,char *dest,chanrec *chan,int status);
106 char* TakeOps(userrec *user,char *dest,chanrec *chan,int status);
107 char* TakeHops(userrec *user,char *dest,chanrec *chan,int status);
108 char* TakeVoice(userrec *user,char *dest,chanrec *chan,int status);
109 char* AddBan(userrec *user,char *dest,chanrec *chan,int status);
110 char* TakeBan(userrec *user,char *dest,chanrec *chan,int status);
111 userrec* SanityChecks(userrec *user,char *dest,chanrec *chan,int status);
112 char* Grant(userrec *d,chanrec *chan,int MASK);
113 char* Revoke(userrec *d,chanrec *chan,int MASK);
115 void Process(char **parameters, int pcnt, userrec *user, bool servermode);
117 std::string CompressModes(std::string modes,bool channelmodes);
118 void ProcessModes(char **parameters,userrec* user,chanrec *chan,int status, int pcnt, bool servermode, bool silent, bool local);
119 bool AllowedUmode(char umode, char* sourcemodes,bool adding,bool serveroverride);
120 bool ProcessModuleUmode(char umode, userrec* source, void* dest, bool adding);
121 void ServerMode(char **parameters, int pcnt, userrec *user);
124 class cmd_mode : public command_t
127 cmd_mode () : command_t("MODE",0,1) { }
128 void Handle(char **parameters, int pcnt, userrec *user);