summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-04-19 12:41:44 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2003-04-19 12:41:44 +0000
commite1cc6b33f4e5510f65d8cfeb62b0f31d567e1bbf (patch)
tree26e091df454f728198dc58b3bd1aef39ff64148f /src
parent7493cbb6b96253da72eae375acc7b4d0d309122c (diff)
Added more code for custom channel/user modes via modules
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@175 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/InspIRCd.dev10
-rw-r--r--src/InspIRCd.layout51
-rw-r--r--src/Makefile.FreeBSD2
-rw-r--r--src/Makefile.Linux2
-rw-r--r--src/channels.cpp26
-rw-r--r--src/inspircd.cpp31
-rw-r--r--src/modules.cpp80
7 files changed, 171 insertions, 31 deletions
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 &params) { }
+bool Module::OnExtendedMode(userrec* user, chanrec* chan, char modechar, int type, bool mode_on, string_list &params) { }
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)