*/
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 */ }
};
* 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);
};
* 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);
[Project]
FileName=InspIRCd.dev
Name=InspIRCd
-UnitCount=25
+UnitCount=26
Type=1
Ver=1
ObjFiles=
OverrideBuildCmd=0
BuildCmd=
+[Unit26]
+FileName=channels.cpp
+Folder=Source
+Compile=1
+CompileCpp=1
+OverrideBuildCmd=0
+BuildCmd=
+
[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
[Editor_1]
Open=1
-Top=1
-CursorCol=1
-CursorRow=3902
-TopLine=3851
+Top=0
+CursorCol=11
+CursorRow=1918
+TopLine=1871
LeftChar=1
[Editor_2]
[Editor_4]
Open=1
Top=0
-CursorCol=51
-CursorRow=36
+CursorCol=19
+CursorRow=59
TopLine=1
LeftChar=1
Open=1
Top=0
CursorCol=1
-CursorRow=1
+CursorRow=9
TopLine=1
LeftChar=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]
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]
[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
LeftChar=1
[Editor_22]
-Open=0
+Open=1
Top=0
CursorCol=1
CursorRow=1
-TopLine=1
+TopLine=35
LeftChar=1
[Editor_23]
CursorRow=1
TopLine=1
LeftChar=1
+[Editor_25]
+Open=1
+Top=1
+CursorCol=1
+CursorRow=26
+TopLine=1
+LeftChar=1
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)
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)
--- /dev/null
+#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)
+{
+}
+
+
+
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;
+
}
}
}
#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) { };
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
}
-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)