summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-08 21:12:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-08 21:12:22 +0000
commit5e5162341d0ce830ba66c1965c800cecaa6b02cd (patch)
treee7349f989463d86ec03eaf3b85c286269a803b4e
parentf74b9b3debdf67e4f35483b3617515e43b686ccf (diff)
Port m_blockcaps to new api, remove OnExtendedMode and OnDisplayList events entirely
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4191 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/modules.h37
-rw-r--r--include/u_listmode.h2
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_blockcaps.cpp47
4 files changed, 34 insertions, 54 deletions
diff --git a/include/modules.h b/include/modules.h
index 4ba987fd3..786275c0e 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -22,10 +22,6 @@
*/
enum DebugLevels { DEBUG, VERBOSE, DEFAULT, SPARSE, NONE };
-/** Used with OnExtendedMode() method of modules
- */
-enum ModeTargetType { MT_CHANNEL, MT_CLIENT, MT_SERVER };
-
/** Used with OnAccessCheck() method of modules
*/
enum AccessControlType {
@@ -305,13 +301,13 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR
/** Implementation-specific flags which may be set in Module::Implements()
*/
enum Implementation { I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash, I_OnServerRaw,
- I_OnExtendedMode, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite,
+ I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite,
I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick, I_OnUserMessage, I_OnUserNotice, I_OnMode,
I_OnGetServerDescription, I_OnSyncUser, I_OnSyncChannel, I_OnSyncChannelMetaData, I_OnSyncUserMetaData,
I_OnDecodeMetaData, I_ProtoSendMode, I_ProtoSendMetaData, I_OnWallops, I_OnChangeHost, I_OnChangeName, I_OnAddGLine,
I_OnAddZLine, I_OnAddQLine, I_OnAddKLine, I_OnAddELine, I_OnDelGLine, I_OnDelZLine, I_OnDelKLine, I_OnDelELine, I_OnDelQLine,
I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule,
- I_OnBackgroundTimer, I_OnSendList, I_OnPreCommand, I_OnCheckReady, I_OnUserRrgister, I_OnRawMode, I_OnCheckInvite,
+ I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnUserRrgister, I_OnRawMode, I_OnCheckInvite,
I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange,
I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnOperCompre, I_OnGlobalOper, I_OnGlobalConnect, I_OnAddBan, I_OnDelBan,
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
@@ -446,23 +442,6 @@ class Module : public classbase
*/
virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user);
- /** Called whenever an extended mode is to be processed.
- * The type parameter is MT_SERVER, MT_CLIENT or MT_CHANNEL, dependent on where the mode is being
- * changed. mode_on is set when the mode is being set, in which case params contains a list of
- * parameters for the mode as strings. If mode_on is false, the mode is being removed, and parameters
- * may contain the parameters for the mode, dependent on wether they were defined when a mode handler
- * was set up with Server::AddExtendedMode
- * If the mode is a channel mode, target is a chanrec*, and if it is a user mode, target is a userrec*.
- * You must cast this value yourself to make use of it.
- * @param user The user issuing the mode
- * @param target The user or channel having the mode set on them
- * @param modechar The mode character being set
- * @param type The type of 4mode (user or channel) being set
- * @param mode_on True if the mode is being set, false if it is being unset
- * @param params A list of parameters for any channel mode (currently supports either 0 or 1 parameters)
- */
- virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params);
-
/** Called whenever a user is about to join a channel, before any processing is done.
* Returning a value of 1 from this function stops the process immediately, causing no
* output to be sent to the user by the core. If you do this you must produce your own numerics,
@@ -971,18 +950,6 @@ class Module : public classbase
*/
virtual void OnBackgroundTimer(time_t curtime);
- /** Called whenever a list is needed for a listmode.
- * For example, when a /MODE #channel +b (without any other parameters) is called,
- * if a module was handling +b this function would be called. The function can then
- * output any lists it wishes to. Please note that all modules will see all mode
- * characters to provide the ability to extend each other, so please only output
- * a list if the mode character given matches the one(s) you want to handle.
- * @param user The user requesting the list
- * @param channel The channel the list is for
- * @param mode The listmode which a list is being requested on
- */
- virtual void OnSendList(userrec* user, chanrec* channel, char mode);
-
/** Called whenever any command is about to be executed.
* This event occurs for all registered commands, wether they are registered in the core,
* or another module, but it will not occur for invalid commands (e.g. ones which do not
diff --git a/include/u_listmode.h b/include/u_listmode.h
index f016253f9..322061991 100644
--- a/include/u_listmode.h
+++ b/include/u_listmode.h
@@ -116,7 +116,7 @@ class ListModeBase : public ModeHandler
virtual void DoImplements(char* List)
{
- List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnChannelDelete] = List[I_OnSyncChannel] = List[I_OnCleanup] = List[I_OnRehash] = 1;
+ List[I_OnChannelDelete] = List[I_OnSyncChannel] = List[I_OnCleanup] = List[I_OnRehash] = 1;
}
virtual ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
diff --git a/src/modules.cpp b/src/modules.cpp
index e53f0c775..2c72943ec 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -134,7 +134,6 @@ void Module::OnUserPart(userrec* user, chanrec* channel, const std::string &par
void Module::OnRehash(const std::string &parameter) { }
void Module::OnServerRaw(std::string &raw, bool inbound, userrec* user) { }
int Module::OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { return 0; }
-int Module::OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params) { return false; }
void Module::OnMode(userrec* user, void* dest, int target_type, const std::string &text) { };
Version Module::GetVersion() { return Version(1,0,0,0,VF_VENDOR); }
void Module::OnOper(userrec* user, const std::string &opertype) { };
@@ -152,7 +151,6 @@ int Module::OnKill(userrec* source, userrec* dest, const std::string &reason) {
void Module::OnLoadModule(Module* mod,const std::string &name) { };
void Module::OnUnloadModule(Module* mod,const std::string &name) { };
void Module::OnBackgroundTimer(time_t curtime) { };
-void Module::OnSendList(userrec* user, chanrec* channel, char mode) { };
int Module::OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated) { return 0; };
bool Module::OnCheckReady(userrec* user) { return true; };
void Module::OnUserRegister(userrec* user) { };
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index f23726c58..8e5685398 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -22,20 +22,49 @@
/* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
+class BlockCaps : public ModeHandler
+{
+ BlockCaps() : ModeHandler('P', 0, 0, false, MODETYPE_CHANNEL, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+ {
+ if (adding)
+ {
+ if (!channel->IsModeSet('P'))
+ {
+ channel->SetCustomMode('P',true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (channel->IsModeSet('P'))
+ {
+ channel->SetCustomMode('P',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+ }
+};
+
class ModuleBlockCAPS : public Module
{
Server *Srv;
+ BlockCaps* bc;
public:
ModuleBlockCAPS(Server* Me) : Module::Module(Me)
{
Srv = Me;
- Srv->AddExtendedMode('P', MT_CHANNEL, false, 0, 0);
+ bc = new BlockCaps;
+ Srv->AddMode(bc, 'P');
}
void Implements(char* List)
{
- List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
+ List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
}
virtual void On005Numeric(std::string &output)
@@ -72,20 +101,6 @@ public:
return OnUserPreMessage(user,dest,target_type,text,status);
}
- virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
- {
- // check if this is our mode character...
- if ((modechar == 'P') && (type == MT_CHANNEL))
- {
- log(DEBUG,"Allowing P change");
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
virtual ~ModuleBlockCAPS()
{
}