diff options
-rw-r--r-- | include/channels.h | 19 | ||||
-rw-r--r-- | include/modules.h | 7 | ||||
-rw-r--r-- | src/InspIRCd.dev | 10 | ||||
-rw-r--r-- | src/InspIRCd.layout | 51 | ||||
-rw-r--r-- | src/Makefile.FreeBSD | 2 | ||||
-rw-r--r-- | src/Makefile.Linux | 2 | ||||
-rw-r--r-- | src/channels.cpp | 26 | ||||
-rw-r--r-- | src/inspircd.cpp | 31 | ||||
-rw-r--r-- | src/modules.cpp | 80 |
9 files changed, 185 insertions, 43 deletions
diff --git a/include/channels.h b/include/channels.h index ffa984033..a800c73a9 100644 --- a/include/channels.h +++ b/include/channels.h @@ -133,18 +133,17 @@ class chanrec : public classbase */ BanList bans; + /** Sets or unsets a custom mode in the channels info + */ + SetCustomMode(char mode,bool mode_on); + + /** Sets or unsets the parameterrs for a custom mode in a channels info + */ + SetCustomModeParam(char mode,char* parameter,bool mode_on); + /** Creates a channel record and initialises it with default values */ - chanrec() - { - strcpy(name,""); - strcpy(custom_modes,""); - strcpy(topic,""); - strcpy(setby,""); - strcpy(key,""); - created = topicset = limit = 0; - topiclock = noexternal = inviteonly = moderated = secret = c_private = false; - } + chanrec(); virtual ~chanrec() { /* stub */ } }; diff --git a/include/modules.h b/include/modules.h index 378c7ba31..9a1c4cfef 100644 --- a/include/modules.h +++ b/include/modules.h @@ -145,8 +145,9 @@ class Module : public classbase * 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 not a channel mode, chanrec* chan is null, and should not be read from or written to. */ - virtual bool OnExtendedMode(char modechar, int type, bool mode_on, string_list ¶ms); + virtual bool OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms); }; @@ -265,7 +266,9 @@ class Server : public classbase * use this parameter. The function returns false if the mode is unavailable, and will not * attempt to allocate another character, as this will confuse users. This also means that * as only one module can claim a specific mode character, the core does not need to keep track - * of which modules own which modes, which speeds up operation of the server. + * of which modules own which modes, which speeds up operation of the server. In this version, + * a mode can have at most one parameter, attempting to use more parameters will have undefined + * effects. */ virtual bool AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off); diff --git a/src/InspIRCd.dev b/src/InspIRCd.dev index 158897e8b..df23f865d 100644 --- a/src/InspIRCd.dev +++ b/src/InspIRCd.dev @@ -1,7 +1,7 @@ [Project] FileName=InspIRCd.dev Name=InspIRCd -UnitCount=25 +UnitCount=26 Type=1 Ver=1 ObjFiles= @@ -244,3 +244,11 @@ CompileCpp=1 OverrideBuildCmd=0 BuildCmd= +[Unit26] +FileName=channels.cpp +Folder=Source +Compile=1 +CompileCpp=1 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index d220c38d2..4f5a21d68 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,6 +1,6 @@ [Editors] -Focused=1 -Order=1,7,3,2,0,6,5,4,-1 +Focused=25 +Order=1,7,3,2,0,6,5,4,-1,25 [Editor_0] Open=1 @@ -12,10 +12,10 @@ LeftChar=1 [Editor_1] Open=1 -Top=1 -CursorCol=1 -CursorRow=3902 -TopLine=3851 +Top=0 +CursorCol=11 +CursorRow=1918 +TopLine=1871 LeftChar=1 [Editor_2] @@ -37,8 +37,8 @@ LeftChar=1 [Editor_4] Open=1 Top=0 -CursorCol=51 -CursorRow=36 +CursorCol=19 +CursorRow=59 TopLine=1 LeftChar=1 @@ -54,7 +54,7 @@ LeftChar=1 Open=1 Top=0 CursorCol=1 -CursorRow=1 +CursorRow=9 TopLine=1 LeftChar=1 @@ -99,11 +99,11 @@ TopLine=1 LeftChar=1 [Editor_12] -Open=0 +Open=1 Top=0 CursorCol=1 -CursorRow=1 -TopLine=1 +CursorRow=142 +TopLine=120 LeftChar=1 [Editor_13] @@ -139,11 +139,11 @@ TopLine=1 LeftChar=1 [Editor_17] -Open=0 +Open=1 Top=0 -CursorCol=9 -CursorRow=60 -TopLine=30 +CursorCol=1 +CursorRow=1 +TopLine=1 LeftChar=1 [Editor_18] @@ -165,10 +165,10 @@ LeftChar=1 [Editor_20] Open=1 Top=0 -CursorCol=68 -CursorRow=135 -TopLine=94 -LeftChar=3 +CursorCol=13 +CursorRow=271 +TopLine=232 +LeftChar=1 [Editor_21] Open=0 @@ -179,11 +179,11 @@ TopLine=1 LeftChar=1 [Editor_22] -Open=0 +Open=1 Top=0 CursorCol=1 CursorRow=1 -TopLine=1 +TopLine=35 LeftChar=1 [Editor_23] @@ -201,3 +201,10 @@ CursorCol=1 CursorRow=1 TopLine=1 LeftChar=1 +[Editor_25] +Open=1 +Top=1 +CursorCol=1 +CursorRow=26 +TopLine=1 +LeftChar=1 diff --git a/src/Makefile.FreeBSD b/src/Makefile.FreeBSD index 8e8bdce4d..981b075f7 100644 --- a/src/Makefile.FreeBSD +++ b/src/Makefile.FreeBSD @@ -8,7 +8,7 @@ CC = im a cheezeball SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp connection.cpp -SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp +SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp channels.cpp SRC = $(SRC_1) $(SRC_2) OBJS = $(SRC:.cpp=.o) diff --git a/src/Makefile.Linux b/src/Makefile.Linux index 8e8bdce4d..981b075f7 100644 --- a/src/Makefile.Linux +++ b/src/Makefile.Linux @@ -8,7 +8,7 @@ CC = im a cheezeball SRC_1 = inspircd.cpp inspircd_util.cpp inspircd_io.cpp connection.cpp -SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp +SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp channels.cpp SRC = $(SRC_1) $(SRC_2) OBJS = $(SRC:.cpp=.o) diff --git a/src/channels.cpp b/src/channels.cpp new file mode 100644 index 000000000..2a9a354a1 --- /dev/null +++ b/src/channels.cpp @@ -0,0 +1,26 @@ +#include "inspircd_config.h" +#include "channels.h" +#include "inspircd.h" +#include <stdio.h> + +chanrec::chanrec() +{ + strcpy(name,""); + strcpy(custom_modes,""); + strcpy(topic,""); + strcpy(setby,""); + strcpy(key,""); + created = topicset = limit = 0; + topiclock = noexternal = inviteonly = moderated = secret = c_private = false; +} + +chanrec::SetCustomMode(char mode,bool mode_on) +{ +} + +chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on) +{ +} + + + diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 621ca21c5..79e3c8b73 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1892,6 +1892,37 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int chan->c_private = mdir; break; + default: + string_list p; + p.clear(); + if (ModeDefined(modelist[ptr],MT_CHANNEL)) + { + if ((ModeDefinedOn(modelist[ptr],MT_CHANNEL)>0) && (mdir)) + { + p.push_back(parameters[param]); + } + if ((ModeDefinedOff(modelist[ptr],MT_CHANNEL)>0) && (!mdir)) + { + p.push_back(parameters[param]); + } + for (int i = 0; i <= MODCOUNT; i++) + { + if (modules[i]->OnExtendedMode(user,chan,modechar,MT_CHANNEL,mdir,p)) + { + strcat(outlist,modelist[ptr]); + chan->SetCustomMode(modelist[ptr],mdir); + // include parameters in output if mode has them + if ((ModeDefinedOn(modelist[ptr],MT_CHANNEL)>0) || + (ModeDefinedOff(modelist[ptr],MT_CHANNEL)>0)) + { + chan->SetCustomModeParam(modelist[ptr],parameters[param],mdir); + strcpy(outpars[pc++],parameters[param++]); + } + } + } + } + break; + } } } diff --git a/src/modules.cpp b/src/modules.cpp index 4452f0423..34c9bf125 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -11,6 +11,73 @@ #include "modules.h" #include "inspircd_io.h" +// class type for holding an extended mode character - internal to core + +class ExtMode +{ +public: + char modechar; + int type; + bool default_on; + int params_when_on; + int params_when_off; + void SetInfo(char mc, int ty, bool d_on, int p_on, int p_off) : modechar(mc), type(ty), default_on(d_on), params_when_on(p_on), params_when_off(p_off) { }; +}; + +typedef vector<ExtMode> ExtModeList; +typedef ExtModeList::iterator ExtModeListIter; + +ExtModeList EMode; + +// returns true if an extended mode character is in use +bool ModeDefined(char modechar, int type) +{ + for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) + { + if ((i->modechar == modechar) && (i->type == type)) + { + return true; + } + } + return false; +} + +// returns number of parameters for a custom mode when it is switched on +int ModeDefinedOn(char modechar, int type) +{ + for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) + { + if ((i->modechar == modechar) && (i->type == type)) + { + return i->params_when_on; + } + } + return 0; +} + +// returns number of parameters for a custom mode when it is switched on +int ModeDefinedOff(char modechar, int type) +{ + for (ExtModeListIter i = EMode.begin(); i < EMode.end(); i++) + { + if ((i->modechar == modechar) && (i->type == type)) + { + return i->params_when_off; + } + } + return 0; +} + +// returns true if an extended mode character is in use +bool AddExtendedMode(char modechar, int type, bool default_on, int params_on, int params_off) +{ + ExtMode Mode; + Mode.SetInfo(modechar,type,default_on,params_on,params_off); + EMode.push_back(Mode); + return true; +} + + // version is a simple class for holding a modules version number Version::Version(int major, int minor, int revision, int build) : Major(major), Minor(minor), Revision(revision), Build(build) { }; @@ -34,7 +101,7 @@ void Module::OnPacketTransmit(char *p) { } void Module::OnPacketReceive(char *p) { } void Module::OnRehash() { } void Module::OnServerRaw(string &raw, bool inbound) { } -bool Module::OnExtendedMode(char modechar, int type, bool mode_on, string_list ¶ms) { } +bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list ¶ms) { } Version Module::GetVersion() { return Version(1,0,0,0); } // server is a wrapper class that provides methods to all of the C-style @@ -150,22 +217,23 @@ Admin Server::GetAdmin() } -ConfigReader::ConfigReader() + +bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off) { - fname = CONFIG_FILE; } -ConfigReader::~ConfigReader() +ConfigReader::ConfigReader() { + fname = CONFIG_FILE; } -bool Server::AddExtendedMode(char modechar, int type, bool default_on, int params_when_on, int params_when_off) +ConfigReader::~ConfigReader() { } - + ConfigReader::ConfigReader(string filename) : fname(filename) { }; string ConfigReader::ReadValue(string tag, string name, int index) |