1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 03:05:42 +02:00

Made mlock_on, mlock_off, access, and akick private in ChannelInfo

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2630 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Adam-
2009-11-07 21:46:58 +00:00
parent 029f39964b
commit 9047b0347d
8 changed files with 150 additions and 90 deletions
+27 -7
View File
@@ -12,7 +12,11 @@
class CoreExport ChannelInfo : public Extensible
{
private:
std::map<ChannelModeName, std::string> Params;
std::map<ChannelModeName, std::string> Params; /* Map of parameters by mode name */
std::vector<ChanAccess *> access; /* List of authorized users */
std::vector<AutoKick *> akick; /* List of users to kickban */
std::bitset<128> mlock_on; /* Modes mlocked on */
std::bitset<128> mlock_off; /* Modes mlocked off */
public:
ChannelInfo();
@@ -39,12 +43,6 @@ class CoreExport ChannelInfo : public Extensible
int16 bantype;
int16 *levels; /* Access levels for commands */
std::vector<ChanAccess *> access; /* List of authorized users */
std::vector<AutoKick *> akick; /* List of users to kickban */
std::bitset<128> mlock_on;
std::bitset<128> mlock_off;
char *entry_message; /* Notice sent on entering channel */
MemoInfo memos;
@@ -94,6 +92,11 @@ class CoreExport ChannelInfo : public Extensible
*/
ChanAccess *GetAccess(NickCore *nc, int16 level = 0);
/** Get the size of the accss vector for this channel
* @return The access vector size
*/
const unsigned GetAccessCount() const;
/** Erase an entry from the channel access list
*
* @param index The index in the access list vector
@@ -130,6 +133,17 @@ class CoreExport ChannelInfo : public Extensible
*/
AutoKick *AddAkick(const std::string &user, const std::string &mask, const std::string &reason, time_t t = time(NULL));
/** Get an entry from the channel akick list
* @param index The index in the akick vector
* @return The akick structure, or NULL if not found
*/
AutoKick *GetAkick(unsigned index);
/** Get the size of the akick vector for this channel
* @return The akick vector size
*/
const unsigned GetAkickCount() const;
/** Erase an entry from the channel akick list
* @param akick The akick
*/
@@ -162,6 +176,12 @@ class CoreExport ChannelInfo : public Extensible
*/
void ClearMLock();
/** Get the number of mlocked modes for this channel
* @param status true for mlock on, false for mlock off
* @return The number of mlocked modes
*/
const size_t GetMLockCount(bool status) const;
/** Set a channel mode param on the channel
* @param Name The mode
* @param param The param
+27 -28
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -40,7 +40,7 @@ static int access_del_callback(User * u, int num, va_list args)
int *last = va_arg(args, int *);
int *perm = va_arg(args, int *);
int uacc = va_arg(args, int);
if (num < 1 || num > ci->access.size())
if (num < 1 || num > ci->GetAccessCount())
return 0;
*last = num;
return access_del(u, ci, ci->GetAccess(num - 1), perm, uacc);
@@ -75,7 +75,7 @@ static int access_list_callback(User * u, int num, va_list args)
{
ChannelInfo *ci = va_arg(args, ChannelInfo *);
int *sent_header = va_arg(args, int *);
if (num < 1 || num > ci->access.size())
if (num < 1 || num > ci->GetAccessCount())
return 0;
return access_list(u, num - 1, ci, sent_header);
}
@@ -232,7 +232,7 @@ class CommandCSAccess : public Command
return MOD_CONT;
}
if (ci->access.size() >= CSAccessMax)
if (ci->GetAccessCount() >= CSAccessMax)
{
notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, CSAccessMax);
return MOD_CONT;
@@ -255,7 +255,7 @@ class CommandCSAccess : public Command
return MOD_CONT;
}
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
return MOD_CONT;
@@ -331,7 +331,7 @@ class CommandCSAccess : public Command
{
int sent_header = 0;
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
return MOD_CONT;
@@ -340,7 +340,7 @@ class CommandCSAccess : public Command
process_numlist(nick, NULL, access_list_callback, u, ci, &sent_header);
else
{
for (i = 0; i < ci->access.size(); i++)
for (i = 0; i < ci->GetAccessCount(); i++)
{
access = ci->GetAccess(i);
if (nick && access->nc && !Anope::Match(access->nc->display, nick, false))
@@ -357,7 +357,7 @@ class CommandCSAccess : public Command
{
int sent_header = 0;
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan);
return MOD_CONT;
@@ -366,7 +366,7 @@ class CommandCSAccess : public Command
process_numlist(nick, NULL, access_view_callback, u, ci, &sent_header);
else
{
for (i = 0; i < ci->access.size(); ++i)
for (i = 0; i < ci->GetAccessCount(); ++i)
{
access = ci->GetAccess(i);
if (nick && access->nc && !Anope::Match(access->nc->display, nick, false))
+28 -27
View File
File diff suppressed because it is too large Load Diff
+2 -7
View File
@@ -62,14 +62,9 @@ class CommandCSRegister : public Command
{
c->ci = ci;
ci->c = c;
ci->bantype = CSDefBantype;
ci->flags = CSDefFlags;
ci->mlock_on = ircd->DefMLock;
ci->memos.memomax = MSMaxMemos;
ci->last_used = ci->time_registered;
ci->founder = u->nc;
ci->desc = sstrdup(desc);
if (c->topic)
{
ci->last_topic = sstrdup(c->topic);
@@ -77,8 +72,8 @@ class CommandCSRegister : public Command
ci->last_topic_time = c->topic_time;
}
else strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX); /* Set this to something, otherwise it will maliform the topic */
ci->bi = NULL;
ci->botflags = BSDefFlags;
++ci->founder->channelcount;
alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan, u->nick, u->GetIdent().c_str(), u->host);
notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick);
+1 -1
View File
@@ -431,7 +431,7 @@ class CommandCSSet : public Command
if (!(ci->flags & CI_XOP)) {
ChanAccess *access;
for (unsigned i = 0; i < ci->access.size(); i++) {
for (unsigned i = 0; i < ci->GetAccessCount(); i++) {
access = ci->GetAccess(i);
if (!access->in_use)
continue;
+8 -8
View File
@@ -171,7 +171,7 @@ class XOPBase : public Command
++change;
}
if (!change && ci->access.size() >= CSAccessMax)
if (!change && ci->GetAccessCount() >= CSAccessMax)
{
notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, CSAccessMax);
return MOD_CONT;
@@ -224,7 +224,7 @@ class XOPBase : public Command
return MOD_CONT;
}
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, messages[XOP_LIST_EMPTY], ci->name);
return MOD_CONT;
@@ -315,7 +315,7 @@ class XOPBase : public Command
return MOD_CONT;
}
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, messages[XOP_LIST_EMPTY], ci->name);
return MOD_CONT;
@@ -325,7 +325,7 @@ class XOPBase : public Command
process_numlist(nick, NULL, xop_list_callback, u, ci, &sent_header, level, messages[XOP_LIST_HEADER]);
else
{
for (unsigned i = 0; i < ci->access.size(); ++i)
for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
{
ChanAccess *access = ci->GetAccess(i);
if (nick && access->nc && !Anope::Match(access->nc->display, nick, false))
@@ -347,7 +347,7 @@ class XOPBase : public Command
return MOD_CONT;
}
if (ci->access.empty())
if (!ci->GetAccessCount())
{
notice_lang(s_ChanServ, u, messages[XOP_LIST_EMPTY], ci->name);
return MOD_CONT;
@@ -359,7 +359,7 @@ class XOPBase : public Command
return MOD_CONT;
}
for (unsigned i = ci->access.size(); i > 0; --i)
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
{
ChanAccess *access = ci->GetAccess(i - 1);
if (access->in_use && access->level == level)
@@ -590,7 +590,7 @@ int xop_del_callback(User *u, int num, va_list args)
int uacc = va_arg(args, int);
int xlev = va_arg(args, int);
if (num < 1 || num > ci->access.size())
if (num < 1 || num > ci->GetAccessCount())
return 0;
*last = num;
@@ -622,7 +622,7 @@ int xop_list_callback(User *u, int num, va_list args)
int xlev = va_arg(args, int);
int xmsg = va_arg(args, int);
if (num < 1 || num > ci->access.size())
if (num < 1 || num > ci->GetAccessCount())
return 0;
return xop_list(u, num - 1, ci, sent_header, xlev, xmsg);
+49 -4
View File
@@ -20,20 +20,26 @@ ChannelInfo::ChannelInfo()
name[0] = last_topic_setter[0] = '\0';
founder = successor = NULL;
desc = url = email = last_topic = forbidby = forbidreason = NULL;
time_registered = last_used = last_topic_time = 0;
flags = 0;
bantype = 0;
last_topic_time = 0;
levels = NULL;
entry_message = NULL;
c = NULL;
bi = NULL;
botflags = 0;
ttb = NULL;
bwcount = 0;
badwords = NULL;
capsmin = capspercent = 0;
floodlines = floodsecs = 0;
repeattimes = 0;
/* If ircd doesn't exist, this is from DB load and mlock is set later */
if (ircd)
mlock_on = ircd->DefMLock;
flags = CSDefFlags;
bantype = CSDefBantype;
memos.memomax = MSMaxMemos;
botflags = BSDefFlags;
last_used = time_registered = time(NULL);
}
/** Add an entry to the channel access list
@@ -98,6 +104,14 @@ ChanAccess *ChannelInfo::GetAccess(NickCore *nc, int16 level)
return NULL;
}
/** Get the size of the accss vector for this channel
* @return The access vector size
*/
const unsigned ChannelInfo::GetAccessCount() const
{
return access.empty() ? 0 : access.size();
}
/** Erase an entry from the channel access list
*
@@ -177,6 +191,26 @@ AutoKick *ChannelInfo::AddAkick(const std::string &user, const std::string &mask
return autokick;
}
/** Get an entry from the channel akick list
* @param index The index in the akick vector
* @return The akick structure, or NULL if not found
*/
AutoKick *ChannelInfo::GetAkick(unsigned index)
{
if (akick.empty() || index >= akick.size())
return NULL;
return akick[index];
}
/** Get the size of the akick vector for this channel
* @return The akick vector size
*/
const unsigned ChannelInfo::GetAkickCount() const
{
return akick.empty() ? 0 : akick.size();
}
/** Erase an entry from the channel akick list
* @param akick The akick
*/
@@ -250,6 +284,17 @@ void ChannelInfo::ClearMLock()
mlock_off.reset();
}
/** Get the number of mlocked modes for this channel
* @param status true for mlock on, false for mlock off
* @return The number of mlocked modes
*/
const size_t ChannelInfo::GetMLockCount(bool status) const
{
if (status)
return mlock_on.count();
else
return mlock_off.count();
}
/** Set a channel mode param on the channel
* @param Name The mode