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 */
49 MASK_USER = 128, /* A user mode */
50 MASK_CHANNEL = 0 /* A channel mode */
63 ModeHandler(char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly);
64 virtual ~ModeHandler();
67 ModeType GetModeType();
69 int GetNumParams(bool adding);
72 virtual ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); /* Can change the mode parameter as its a ref */
73 virtual void DisplayList(userrec* user, chanrec* channel);
74 virtual bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel);
83 ModeWatcher(char modeletter, ModeType type);
84 virtual ~ModeWatcher();
87 ModeType GetModeType();
89 virtual bool BeforeMode(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding, ModeType type); /* Can change the mode parameter */
90 virtual void AfterMode(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter, bool adding, ModeType type);
93 typedef std::vector<ModeWatcher*>::iterator ModeWatchIter;
99 * Mode handlers for each mode, to access a handler subtract
100 * 65 from the ascii value of the mode letter.
101 * The upper bit of the value indicates if its a usermode
102 * or a channel mode, so we have 255 of them not 64.
104 ModeHandler* modehandlers[256];
106 * Mode watcher classes
108 std::vector<ModeWatcher*> modewatchers[256];
110 char* GiveOps(userrec *user,char *dest,chanrec *chan,int status);
111 char* GiveHops(userrec *user,char *dest,chanrec *chan,int status);
112 char* GiveVoice(userrec *user,char *dest,chanrec *chan,int status);
113 char* TakeOps(userrec *user,char *dest,chanrec *chan,int status);
114 char* TakeHops(userrec *user,char *dest,chanrec *chan,int status);
115 char* TakeVoice(userrec *user,char *dest,chanrec *chan,int status);
116 char* AddBan(userrec *user,char *dest,chanrec *chan,int status);
117 char* TakeBan(userrec *user,char *dest,chanrec *chan,int status);
118 userrec* SanityChecks(userrec *user,char *dest,chanrec *chan,int status);
119 char* Grant(userrec *d,chanrec *chan,int MASK);
120 char* Revoke(userrec *d,chanrec *chan,int MASK);
124 void Process(char **parameters, int pcnt, userrec *user, bool servermode);
126 //void ServerMode(char **parameters, int pcnt, userrec *user);
129 class cmd_mode : public command_t
132 cmd_mode () : command_t("MODE",0,1) { }
133 void Handle(char **parameters, int pcnt, userrec *user);