summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-26 21:54:36 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-26 21:54:36 +0000
commitf4d202cdbbcaa9e17c21e3f74d7816f58b2ffc6a (patch)
tree82709f66aa42e3ffcd96cd261a368d66f65a186c /src
parentdeb290af0f0200d530ba10e4c6c3f6a45b4971c5 (diff)
Add extra method to mode handler, ModeHandler::ModeSet().
Returns a std::pair<bool,string>. if the bool is true, the mode is set, and the second item in the pair is the parameter set on it, if any If the bool is false, the mode is not set, and the parameter given is returned as the second item of the pair To be used in mode bouncing, to build a safe set of bounced modes (dont ask yet) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4549 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp12
-rw-r--r--src/modes/cmode_h.cpp17
-rw-r--r--src/modes/cmode_k.cpp13
-rw-r--r--src/modes/cmode_l.cpp12
-rw-r--r--src/modes/cmode_o.cpp17
-rw-r--r--src/modes/cmode_v.cpp17
-rw-r--r--src/modules/m_chanprotect.cpp51
-rw-r--r--src/modules/m_joinflood.cpp9
-rw-r--r--src/modules/m_kicknorejoin.cpp8
-rw-r--r--src/modules/m_messageflood.cpp9
-rw-r--r--src/modules/m_redirect.cpp8
-rw-r--r--src/modules/m_spanningtree.cpp5
12 files changed, 178 insertions, 0 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 86b0024c0..56d1f398f 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -113,6 +113,18 @@ ModeAction ModeHandler::OnModeChange(userrec* source, userrec* dest, chanrec* ch
return MODEACTION_DENY;
}
+std::pair<bool,std::string> ModeHandler::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ if (dest)
+ {
+ return std::make_pair(dest->IsModeSet(this->mode), "");
+ }
+ else
+ {
+ return std::make_pair(channel->IsModeSet(this->mode), "");
+ }
+}
+
void ModeHandler::DisplayList(userrec* user, chanrec* channel)
{
}
diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp
index 2c96b4224..4a2c5fa69 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modes/cmode_h.cpp
@@ -26,6 +26,23 @@ ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_C
{
}
+std::pair<bool,std::string> ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ userrec* x = Find(parameter);
+ if (x)
+ {
+ if (cstatus(x, channel) == STATUS_HOP)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
+ return std::make_pair(false, parameter);
+}
+
ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
/* If halfops are not enabled in the conf, we don't execute
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index 9e69ed13b..2f06ba55c 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -8,6 +8,19 @@ ModeChannelKey::ModeChannelKey() : ModeHandler('k', 1, 1, false, MODETYPE_CHANNE
{
}
+std::pair<bool,std::string> ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ if (channel->modes[CM_KEY])
+ {
+ return std::make_pair(true, channel->key);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+}
+
+
ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
if (channel->modes[CM_KEY] != adding)
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index 10ff3135a..a5fa5329b 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -8,6 +8,18 @@ ModeChannelLimit::ModeChannelLimit() : ModeHandler('l', 1, 0, false, MODETYPE_CH
{
}
+std::pair<bool,std::string> ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ if (channel->limit)
+ {
+ return std::make_pair(true, ConvToStr(channel->limit));
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+}
+
ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
if (adding)
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
index dfa3a1a10..853bb86e5 100644
--- a/src/modes/cmode_o.cpp
+++ b/src/modes/cmode_o.cpp
@@ -26,6 +26,23 @@ ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL,
{
}
+std::pair<bool,std::string> ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ userrec* x = Find(parameter);
+ if (x)
+ {
+ if (cstatus(x, channel) == STATUS_OP)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
+ return std::make_pair(false, parameter);
+}
+
ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
int status = cstatus(source, channel);
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
index 87d391109..a72e6bf18 100644
--- a/src/modes/cmode_v.cpp
+++ b/src/modes/cmode_v.cpp
@@ -26,6 +26,23 @@ ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHA
{
}
+std::pair<bool,std::string> ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ userrec* x = Find(parameter);
+ if (x)
+ {
+ if (cstatus(x, channel) == STATUS_VOICE)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
+ return std::make_pair(false, parameter);
+}
+
ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
int status = cstatus(source, channel);
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 208dc8362..675e95e96 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -31,6 +31,32 @@ class ChanFounder : public ModeHandler
public:
ChanFounder(Server* s) : ModeHandler('q', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ userrec* x = Find(parameter);
+ if (x)
+ {
+ if (!channel->HasUser(x))
+ {
+ return std::make_pair(false, parameter);
+ }
+ else
+ {
+ std::string founder = "cm_founder_"+std::string(channel->name);
+ if (x->GetExt(founder,dummyptr))
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
+ }
+ return std::make_pair(false, parameter);
+ }
+
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
userrec* theuser = Srv->FindNick(parameter);
@@ -109,6 +135,31 @@ class ChanProtect : public ModeHandler
public:
ChanProtect(Server* s) : ModeHandler('a', 1, 1, true, MODETYPE_CHANNEL, false), Srv(s) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ userrec* x = Find(parameter);
+ if (x)
+ {
+ if (!channel->HasUser(x))
+ {
+ return std::make_pair(false, parameter);
+ }
+ else
+ {
+ std::string founder = "cm_protect_"+std::string(channel->name);
+ if (x->GetExt(founder,dummyptr))
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
+ }
+ return std::make_pair(false, parameter);
+ }
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
userrec* theuser = Srv->FindNick(parameter);
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 33b6b8b61..0d038b48d 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -99,6 +99,15 @@ class JoinFlood : public ModeHandler
public:
JoinFlood() : ModeHandler('j', 1, 0, false, MODETYPE_CHANNEL, false) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ joinfloodsettings* x;
+ if (channel->GetExt("joinflood",x))
+ return std::make_pair(true, ConvToStr(x->joins)+":"+ConvToStr(x->secs));
+ else
+ return std::make_pair(false, parameter);
+ }
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
joinfloodsettings* dummy;
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index 80e1fb8d0..97b766e36 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -25,6 +25,14 @@ class KickRejoin : public ModeHandler
public:
KickRejoin() : ModeHandler('J', 1, 0, false, MODETYPE_CHANNEL, false) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ if (channel->IsModeSet('J'))
+ return std::make_pair(true, channel->GetModeParameter('J'));
+ else
+ return std::make_pair(false, parameter);
+ }
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
if (!adding)
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 52fed00f0..7efe8e8ec 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -88,6 +88,15 @@ class MsgFlood : public ModeHandler
public:
MsgFlood() : ModeHandler('f', 1, 0, false, MODETYPE_CHANNEL, false) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ floodsettings* x;
+ if (channel->GetExt("flood",x))
+ return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs));
+ else
+ return std::make_pair(false, parameter);
+ }
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
floodsettings *f;
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index 6e239cb08..b289c1a0e 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -30,6 +30,14 @@ class Redirect : public ModeHandler
public:
Redirect(Server* s) : ModeHandler('L', 1, 0, false, MODETYPE_CHANNEL, false), Srv(s) { }
+ std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+ {
+ if (channel->IsModeSet('L'))
+ return std::make_pair(true, channel->GetModeParameter('L'));
+ else
+ return std::make_pair(false, parameter);
+ }
+
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
if (adding)
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index f14cc69de..e1834721d 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -945,6 +945,11 @@ class TreeSocket : public InspSocket
}
}
DoOneToOne(source,"FMODE",params,source);
+ /* XXX: We should check that we arent bouncing anything thats already set at this end.
+ * If we are, bounce +ourmode.
+ *
+ * E.G. They send +l 50, we have +l 10 set. rather than bounce -l 50, we bounce +l 10.
+ */
log(DEBUG,"Mode bounced, our TS less than theirs");
}
else