summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-27 19:40:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-27 19:40:47 +0000
commita1f073f66f4b985bf776b9be2015136209c0c311 (patch)
tree1413b1367e52ece46803c5d8fb57325c5ebbfd22
parent98a92e20f1fa4a9c7e5749e063414483d4615c2e (diff)
Change std::pair<bool,std::string> to neater typedef "ModePair"
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4557 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/mode.h12
-rw-r--r--include/modes/cmode_b.h1
-rw-r--r--include/modes/cmode_h.h2
-rw-r--r--include/modes/cmode_k.h2
-rw-r--r--include/modes/cmode_l.h2
-rw-r--r--include/modes/cmode_o.h2
-rw-r--r--include/modes/cmode_v.h2
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modes/cmode_b.cpp12
-rw-r--r--src/modes/cmode_h.cpp2
-rw-r--r--src/modes/cmode_k.cpp2
-rw-r--r--src/modes/cmode_l.cpp2
-rw-r--r--src/modes/cmode_o.cpp2
-rw-r--r--src/modes/cmode_v.cpp2
-rw-r--r--src/modules/m_chanprotect.cpp4
-rw-r--r--src/modules/m_joinflood.cpp8
-rw-r--r--src/modules/m_kicknorejoin.cpp8
-rw-r--r--src/modules/m_messageflood.cpp8
-rw-r--r--src/modules/m_redirect.cpp8
-rw-r--r--src/modules/m_spanningtree.cpp4
20 files changed, 66 insertions, 21 deletions
diff --git a/include/mode.h b/include/mode.h
index 6e2f03788..58586a001 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -55,6 +55,13 @@ enum ModeMasks {
MASK_CHANNEL = 0 /* A channel mode */
};
+/**
+ * Used by ModeHandler::ModeSet() to return the state of a mode upon a channel or user.
+ * The pair contains an activity flag, true if the mode is set with the given parameter,
+ * and the parameter of the mode (or the parameter provided) in the std::string.
+ */
+typedef std::pair<bool,std::string> ModePair;
+
/** Each mode is implemented by ONE ModeHandler class.
* You must derive ModeHandler and add the child class to
* the list of modes handled by the ircd, using
@@ -172,7 +179,8 @@ class ModeHandler : public Extensible
/**
* If your mode needs special action during a server sync to determine which side wins when comparing timestamps,
* override this function and use it to return true or false. The default implementation just returns true if
- * theirs < ours.
+ * theirs < ours. This will only be called for non-listmodes with parameters, when adding the mode and where
+ * theirs == ours (therefore the default implementation will always return false).
* @param theirs The timestamp of the remote side
* @param ours The timestamp of the local side
* @param their_param Their parameter if the mode has a parameter
@@ -195,7 +203,7 @@ class ModeHandler : public Extensible
* the current setting for this mode set locally, when the bool is true, or, the parameter given.
* This allows the local server to enforce our locally set parameters back to a remote server.
*/
- virtual std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ virtual ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
};
/**
diff --git a/include/modes/cmode_b.h b/include/modes/cmode_b.h
index df638005e..34b90c9b9 100644
--- a/include/modes/cmode_b.h
+++ b/include/modes/cmode_b.h
@@ -11,5 +11,6 @@ class ModeChannelBan : public ModeHandler
std::string& AddBan(userrec *user,std::string& dest,chanrec *chan,int status);
std::string& DelBan(userrec *user,std::string& dest,chanrec *chan,int status);
void DisplayList(userrec* user, chanrec* channel);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
};
diff --git a/include/modes/cmode_h.h b/include/modes/cmode_h.h
index 963052180..eaf2149af 100644
--- a/include/modes/cmode_h.h
+++ b/include/modes/cmode_h.h
@@ -9,6 +9,6 @@ class ModeChannelHalfOp : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
std::string AddHalfOp(userrec *user,const char *dest,chanrec *chan,int status);
std::string DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status);
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
};
diff --git a/include/modes/cmode_k.h b/include/modes/cmode_k.h
index 94a317df0..8434fc5c4 100644
--- a/include/modes/cmode_k.h
+++ b/include/modes/cmode_k.h
@@ -5,6 +5,6 @@ class ModeChannelKey : public ModeHandler
public:
ModeChannelKey();
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel);
};
diff --git a/include/modes/cmode_l.h b/include/modes/cmode_l.h
index 886ece324..69c132e56 100644
--- a/include/modes/cmode_l.h
+++ b/include/modes/cmode_l.h
@@ -5,6 +5,6 @@ class ModeChannelLimit : public ModeHandler
public:
ModeChannelLimit();
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel);
};
diff --git a/include/modes/cmode_o.h b/include/modes/cmode_o.h
index ad34f501c..ff166b5e2 100644
--- a/include/modes/cmode_o.h
+++ b/include/modes/cmode_o.h
@@ -9,6 +9,6 @@ class ModeChannelOp : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
std::string AddOp(userrec *user,const char *dest,chanrec *chan,int status);
std::string DelOp(userrec *user,const char *dest,chanrec *chan,int status);
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
};
diff --git a/include/modes/cmode_v.h b/include/modes/cmode_v.h
index f61f183c5..3e747ca9d 100644
--- a/include/modes/cmode_v.h
+++ b/include/modes/cmode_v.h
@@ -9,6 +9,6 @@ class ModeChannelVoice : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding);
std::string AddVoice(userrec *user,const char *dest,chanrec *chan,int status);
std::string DelVoice(userrec *user,const char *dest,chanrec *chan,int status);
- std::pair<bool,std::string> ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter);
};
diff --git a/src/mode.cpp b/src/mode.cpp
index 5b32c707a..6507c6d26 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -113,7 +113,7 @@ 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)
+ModePair ModeHandler::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
if (dest)
{
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp
index ccc6bdfcf..569fb6772 100644
--- a/src/modes/cmode_b.cpp
+++ b/src/modes/cmode_b.cpp
@@ -111,6 +111,18 @@ std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *cha
return dest;
}
+ModePair ModeChannelBan::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
+{
+ for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
+ {
+ if (!strcasecmp(i->data,parameter.c_str()))
+ {
+ return std::make_pair(true, i->data);
+ }
+ }
+ return std::make_pair(false, parameter);
+}
+
std::string& ModeChannelBan::DelBan(userrec *user,std::string& dest,chanrec *chan,int status)
{
if ((!user) || (!chan))
diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp
index 4a2c5fa69..e9a74fc3e 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modes/cmode_h.cpp
@@ -26,7 +26,7 @@ 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)
+ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
userrec* x = Find(parameter);
if (x)
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index e54aa688a..e509447f3 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -8,7 +8,7 @@ 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)
+ModePair ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
if (channel->modes[CM_KEY])
{
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index 89d67026c..cdbf0f58f 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -8,7 +8,7 @@ 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)
+ModePair ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
if (channel->limit)
{
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
index 853bb86e5..a24cc2af9 100644
--- a/src/modes/cmode_o.cpp
+++ b/src/modes/cmode_o.cpp
@@ -26,7 +26,7 @@ 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)
+ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
userrec* x = Find(parameter);
if (x)
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
index a72e6bf18..76978d346 100644
--- a/src/modes/cmode_v.cpp
+++ b/src/modes/cmode_v.cpp
@@ -26,7 +26,7 @@ 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)
+ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
userrec* x = Find(parameter);
if (x)
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 675e95e96..95bb06a13 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -31,7 +31,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
userrec* x = Find(parameter);
if (x)
@@ -135,7 +135,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
userrec* x = Find(parameter);
if (x)
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 0d038b48d..3068c5209 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -99,7 +99,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
joinfloodsettings* x;
if (channel->GetExt("joinflood",x))
@@ -108,6 +108,12 @@ class JoinFlood : public ModeHandler
return std::make_pair(false, parameter);
}
+ bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
+ {
+ /* When TS is equal, the alphabetically later one wins */
+ return (their_param < our_param);
+ }
+
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 97b766e36..4f415b8a9 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -25,7 +25,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
if (channel->IsModeSet('J'))
return std::make_pair(true, channel->GetModeParameter('J'));
@@ -33,6 +33,12 @@ class KickRejoin : public ModeHandler
return std::make_pair(false, parameter);
}
+ bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
+ {
+ /* When TS is equal, the alphabetically later one wins */
+ return (their_param < our_param);
+ }
+
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 7efe8e8ec..f322a63e6 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -88,7 +88,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
floodsettings* x;
if (channel->GetExt("flood",x))
@@ -97,6 +97,12 @@ class MsgFlood : public ModeHandler
return std::make_pair(false, parameter);
}
+ bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
+ {
+ /* When TS is equal, the alphabetically later one wins */
+ return (their_param < our_param);
+ }
+
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 b289c1a0e..7493b5c65 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -30,7 +30,7 @@ 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)
+ ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
if (channel->IsModeSet('L'))
return std::make_pair(true, channel->GetModeParameter('L'));
@@ -38,6 +38,12 @@ class Redirect : public ModeHandler
return std::make_pair(false, parameter);
}
+ bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
+ {
+ /* When TS is equal, the alphabetically later one wins */
+ return (their_param < our_param);
+ }
+
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 77929b382..59b82fb5a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -980,7 +980,7 @@ class TreeSocket : public InspSocket
* modes with parameters, we are going to rewrite
* those parameters
*/
- std::pair<bool, std::string> ret;
+ ModePair ret;
adding ? cur_change = '+' : cur_change = '-';
ret = mh->ModeSet(smode ? NULL : who, dst, chan, params[paramptr]);
@@ -1167,7 +1167,7 @@ class TreeSocket : public InspSocket
*/
if (mh)
{
- std::pair<bool, std::string> ret;
+ ModePair ret;
std::string p = "";
/* Does the mode require a parameter right now?