summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp29
-rw-r--r--src/channels.cpp127
-rw-r--r--src/command.cpp30
-rw-r--r--src/config.cpp82
-rw-r--r--src/extensible.cpp99
-rw-r--r--src/memos.cpp18
-rw-r--r--src/messages.cpp12
-rw-r--r--src/modes.cpp165
-rw-r--r--src/nickalias.cpp29
-rw-r--r--src/nickcore.cpp33
-rw-r--r--src/pipeengine.cpp14
-rw-r--r--src/protocol.cpp4
-rw-r--r--src/regchannel.cpp126
-rw-r--r--src/servers.cpp39
-rw-r--r--src/socket_clients.cpp16
-rw-r--r--src/socketengines/socketengine_epoll.cpp21
-rw-r--r--src/sockets.cpp28
-rw-r--r--src/threadengine.cpp4
-rw-r--r--src/uplink.cpp8
-rw-r--r--src/users.cpp94
20 files changed, 460 insertions, 518 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index ef8514c87..a81332ad6 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -21,23 +21,13 @@
Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
-static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF", "" };
-template<> const Anope::string* Flags<BotFlag>::flags_strings = BotFlagString;
-
-static const Anope::string BotServFlagStrings[] = {
- "BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
- "KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
- "KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
- "MSG_NOTICEOPS", ""
-};
-template<> const Anope::string* Flags<BotServFlag>::flags_strings = BotServFlagStrings;
-
BotInfo *BotServ = NULL, *ChanServ = NULL, *Global = NULL, *HostServ = NULL, *MemoServ = NULL, *NickServ = NULL, *OperServ = NULL;
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
+ this->oper_only = this->conf = false;
(*BotListByNick)[this->nick] = this;
if (!this->uid.empty())
@@ -91,7 +81,7 @@ void BotInfo::Serialize(Serialize::Data &data) const
data["host"] << this->host;
data["realname"] << this->realname;
data["created"] << this->created;
- data["flags"] << this->ToString();
+ data["oper_only"] << this->oper_only;
}
Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
@@ -102,15 +92,16 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
data["user"] >> user;
data["host"] >> host;
data["realname"] >> realname;
- data["flags"] >> flags;
BotInfo *bi;
if (obj)
bi = anope_dynamic_static_cast<BotInfo *>(obj);
else if (!(bi = BotInfo::Find(nick)))
bi = new BotInfo(nick, user, host, realname);
+
data["created"] >> bi->created;
- bi->FromString(flags);
+ data["oper_only"] >> bi->oper_only;
+
return bi;
}
@@ -198,23 +189,23 @@ void BotInfo::Join(Channel *c, ChannelStatus *status)
if (Config && IRCD && Config->BSSmartJoin)
{
- std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = c->GetModeList(CMODE_BAN);
+ std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = c->GetModeList("BAN");
/* We check for bans */
for (; bans.first != bans.second; ++bans.first)
{
- Entry ban(CMODE_BAN, bans.first->second);
+ Entry ban("BAN", bans.first->second);
if (ban.Matches(this))
- c->RemoveMode(NULL, CMODE_BAN, ban.GetMask());
+ c->RemoveMode(NULL, "BAN", ban.GetMask());
}
Anope::string Limit;
unsigned limit = 0;
- if (c->GetParam(CMODE_LIMIT, Limit) && Limit.is_pos_number_only())
+ if (c->GetParam("LIMIT", Limit) && Limit.is_pos_number_only())
limit = convertTo<unsigned>(Limit);
/* Should we be invited? */
- if (c->HasMode(CMODE_INVITE) || (limit && c->users.size() >= limit))
+ if (c->HasMode("INVITE") || (limit && c->users.size() >= limit))
IRCD->SendNotice(this, "@" + c->name, "%s invited %s into the channel.", this->nick.c_str(), this->nick.c_str());
ModeManager::ProcessModes();
diff --git a/src/channels.cpp b/src/channels.cpp
index 43c4283c1..32fb5aea7 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -26,9 +26,6 @@
channel_map ChannelList;
-static const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" };
-template<> const Anope::string* Flags<ChannelFlag>::flags_strings = ChannelFlagString;
-
Channel::Channel(const Anope::string &nname, time_t ts)
{
if (nname.empty())
@@ -76,8 +73,8 @@ void Channel::Reset()
{
ChanUserContainer *uc = *it;
- ChannelStatus flags = uc->status;
- uc->status.ClearFlags();
+ ChannelStatus f = uc->status;
+ uc->status.modes.clear();
if (BotInfo::Find(uc->user->nick))
{
@@ -85,7 +82,7 @@ void Channel::Reset()
{
ChannelMode *cm = ModeManager::ChannelModes[i];
- if (flags.HasFlag(cm->name))
+ if (f.modes.count(cm->name))
this->SetMode(NULL, cm, uc->user->GetUID(), false);
}
}
@@ -102,7 +99,7 @@ void Channel::Reset()
void Channel::Sync()
{
- if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi && *this->ci->bi == this->users.front()->user)))
+ if (!this->HasMode("PERM") && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi && *this->ci->bi == this->users.front()->user)))
{
this->Hold();
}
@@ -191,7 +188,7 @@ ChanUserContainer* Channel::JoinUser(User *user)
user->chans.push_back(cuc);
this->users.push_back(cuc);
- if (this->ci && this->ci->HasFlag(CI_PERSIST) && this->creation_time > this->ci->time_registered)
+ if (this->ci && this->ci->HasExt("PERSIST") && this->creation_time > this->ci->time_registered)
{
Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered;
this->creation_time = this->ci->time_registered;
@@ -231,17 +228,17 @@ void Channel::DeleteUser(User *user)
delete cul;
/* Channel is persistent, it shouldn't be deleted and the service bot should stay */
- if (this->HasFlag(CH_PERSIST) || (this->ci && this->ci->HasFlag(CI_PERSIST)))
+ if (this->HasExt("PERSIST") || (this->ci && this->ci->HasExt("PERSIST")))
return;
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly
* We also don't part the bot here either, if necessary we will part it after the sync
*/
- if (this->HasFlag(CH_SYNCING))
+ if (this->HasExt("SYNCING"))
return;
/* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
- if (this->HasFlag(CH_INHABIT))
+ if (this->HasExt("INHABIT"))
return;
if (this->users.empty())
@@ -258,39 +255,39 @@ ChanUserContainer *Channel::FindUser(const User *u) const
bool Channel::HasUserStatus(const User *u, ChannelModeStatus *cms) const
{
- if (!u || (cms && cms->type != MODE_STATUS))
- throw CoreException("Channel::HasUserStatus got bad mode");
+ if (!cms)
+ return false;
/* Usually its more efficient to search the users channels than the channels users */
ChanUserContainer *cc = u->FindChannel(this);
if (cc)
{
if (cms)
- return cc->status.HasFlag(cms->name);
+ return cc->status.modes.count(cms->name);
else
- return !cc->status.FlagCount();
+ return cc->status.modes.empty();
}
return false;
}
-bool Channel::HasUserStatus(const User *u, ChannelModeName Name) const
+bool Channel::HasUserStatus(const User *u, const Anope::string &mname) const
{
- return HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name)));
+ return HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(mname)));
}
-size_t Channel::HasMode(ChannelModeName Name, const Anope::string &param)
+size_t Channel::HasMode(const Anope::string &mname, const Anope::string &param)
{
if (param.empty())
- return modes.count(Name);
- std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = this->GetModeList(Name);
+ return modes.count(mname);
+ std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = this->GetModeList(mname);
for (; its.first != its.second; ++its.first)
if (its.first->second == param)
return 1;
return 0;
}
-std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> Channel::GetModeList(ChannelModeName mname)
+std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> Channel::GetModeList(const Anope::string &mname)
{
Channel::ModeList::iterator it = this->modes.find(mname), it_end = it;
if (it != this->modes.end())
@@ -328,7 +325,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
/* Set the status on the user */
ChanUserContainer *cc = u->FindChannel(this);
if (cc)
- cc->status.SetFlag(cm->name);
+ cc->status.modes.insert(cm->name);
/* Enforce secureops, etc */
if (enforce_mlock)
@@ -353,11 +350,11 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
}
/* Channel mode +P or so was set, mark this channel as persistent */
- if (cm->name == CMODE_PERM)
+ if (cm->name == "PERM")
{
- this->SetFlag(CH_PERSIST);
+ this->Extend("PERSIST");
if (this->ci)
- this->ci->SetFlag(CI_PERSIST);
+ this->ci->ExtendMetadata("PERSIST");
}
/* Check if we should enforce mlock */
@@ -398,14 +395,14 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
/* Remove the status on the user */
ChanUserContainer *cc = u->FindChannel(this);
if (cc)
- cc->status.UnsetFlag(cm->name);
+ cc->status.modes.erase(cm->name);
if (enforce_mlock)
{
/* Reset modes on bots if we're supposed to */
if (this->ci && this->ci->bi && this->ci->bi == bi)
{
- if (ModeManager::DefaultBotModes.HasFlag(cm->name))
+ if (ModeManager::DefaultBotModes.modes.count(cm->name))
this->SetMode(bi, cm, bi->GetUID());
}
@@ -433,12 +430,12 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
cml->OnDel(this, param);
}
- if (cm->name == CMODE_PERM)
+ if (cm->name == "PERM")
{
- this->UnsetFlag(CH_PERSIST);
+ this->Shrink("PERSIST");
if (this->ci)
- this->ci->UnsetFlag(CI_PERSIST);
+ this->ci->Shrink("PERSIST");
if (this->users.empty())
{
@@ -490,9 +487,9 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param,
SetModeInternal(ms, cm, param, enforce_mlock);
}
-void Channel::SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param, bool enforce_mlock)
+void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
{
- SetMode(bi, ModeManager::FindChannelModeByName(Name), param, enforce_mlock);
+ SetMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock);
}
void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
@@ -530,20 +527,20 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &para
RemoveModeInternal(ms, cm, realparam, enforce_mlock);
}
-void Channel::RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param, bool enforce_mlock)
+void Channel::RemoveMode(BotInfo *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
{
- RemoveMode(bi, ModeManager::FindChannelModeByName(Name), param, enforce_mlock);
+ RemoveMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock);
}
-bool Channel::GetParam(ChannelModeName Name, Anope::string &Target) const
+bool Channel::GetParam(const Anope::string &mname, Anope::string &target) const
{
- std::multimap<ChannelModeName, Anope::string>::const_iterator it = this->modes.find(Name);
+ std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.find(mname);
- Target.clear();
+ target.clear();
if (it != this->modes.end())
{
- Target = it->second;
+ target = it->second;
return true;
}
@@ -728,7 +725,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
this->CheckModes();
}
-bool Channel::MatchesList(User *u, ChannelModeName mode)
+bool Channel::MatchesList(User *u, const Anope::string &mode)
{
if (!this->HasMode(mode))
return false;
@@ -770,7 +767,7 @@ void Channel::KickInternal(MessageSource &source, const Anope::string &nick, con
{
FOREACH_MOD(I_OnUserKicked, OnUserKicked(this, target, source, reason));
if (bi)
- this->SetFlag(CH_INHABIT);
+ this->Extend("INHABIT");
this->DeleteUser(target);
}
else
@@ -780,7 +777,7 @@ void Channel::KickInternal(MessageSource &source, const Anope::string &nick, con
if (bi)
{
bi->Join(this, &ModeManager::DefaultBotModes);
- this->UnsetFlag(CH_INHABIT);
+ this->Shrink("INHABIT");
}
}
@@ -817,7 +814,7 @@ Anope::string Channel::GetModes(bool complete, bool plus)
{
Anope::string res, params;
- for (std::multimap<ChannelModeName, Anope::string>::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
+ for (std::multimap<Anope::string, Anope::string>::const_iterator it = this->modes.begin(), it_end = this->modes.end(); it != it_end; ++it)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(it->first);
if (!cm || cm->type == MODE_LIST)
@@ -893,7 +890,7 @@ void Channel::Hold()
{
if (!ChanServ || !c)
return;
- c->SetFlag(CH_INHABIT);
+ c->Extend("INHABIT");
if (!c->ci || !c->ci->bi)
ChanServ->Join(c);
else if (!c->FindUser(c->ci->bi))
@@ -908,7 +905,7 @@ void Channel::Hold()
if (!c)
return;
- c->UnsetFlag(CH_INHABIT);
+ c->Shrink("INHABIT");
if (!c->ci || !c->ci->bi)
{
@@ -925,11 +922,11 @@ void Channel::Hold()
void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
{
- ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER),
- *admin = ModeManager::FindChannelModeByName(CMODE_PROTECT),
- *op = ModeManager::FindChannelModeByName(CMODE_OP),
- *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP),
- *voice = ModeManager::FindChannelModeByName(CMODE_VOICE);
+ ChannelMode *owner = ModeManager::FindChannelModeByName("OWNER"),
+ *admin = ModeManager::FindChannelModeByName("PROTECT"),
+ *op = ModeManager::FindChannelModeByName("OP"),
+ *halfop = ModeManager::FindChannelModeByName("HALFOP"),
+ *voice = ModeManager::FindChannelModeByName("VOICE");
if (user == NULL)
return;
@@ -941,34 +938,34 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
AccessGroup u_access = ci->AccessFor(user);
- if (give_modes && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP)) && (!check_noop || !ci->HasFlag(CI_NOAUTOOP)))
+ if (give_modes && (!user->Account() || user->Account()->HasExt("AUTOOP")) && (!check_noop || !ci->HasExt("NOAUTOOP")))
{
if (owner && u_access.HasPriv("AUTOOWNER"))
- this->SetMode(NULL, CMODE_OWNER, user->GetUID());
+ this->SetMode(NULL, "OWNER", user->GetUID());
else if (admin && u_access.HasPriv("AUTOPROTECT"))
- this->SetMode(NULL, CMODE_PROTECT, user->GetUID());
+ this->SetMode(NULL, "PROTECT", user->GetUID());
if (op && u_access.HasPriv("AUTOOP"))
- this->SetMode(NULL, CMODE_OP, user->GetUID());
+ this->SetMode(NULL, "OP", user->GetUID());
else if (halfop && u_access.HasPriv("AUTOHALFOP"))
- this->SetMode(NULL, CMODE_HALFOP, user->GetUID());
+ this->SetMode(NULL, "HALFOP", user->GetUID());
else if (voice && u_access.HasPriv("AUTOVOICE"))
- this->SetMode(NULL, CMODE_VOICE, user->GetUID());
+ this->SetMode(NULL, "VOICE", user->GetUID());
}
/* If this channel has secureops or the channel is syncing and they are not ulined, check to remove modes */
- if ((ci->HasFlag(CI_SECUREOPS) || (this->HasFlag(CH_SYNCING) && user->server->IsSynced())) && !user->server->IsULined())
+ if ((ci->HasExt("SECUREOPS") || (this->HasExt("SYNCING") && user->server->IsSynced())) && !user->server->IsULined())
{
if (owner && !u_access.HasPriv("AUTOOWNER") && !u_access.HasPriv("OWNERME"))
- this->RemoveMode(NULL, CMODE_OWNER, user->GetUID());
+ this->RemoveMode(NULL, "OWNER", user->GetUID());
if (admin && !u_access.HasPriv("AUTOPROTECT") && !u_access.HasPriv("PROTECTME"))
- this->RemoveMode(NULL, CMODE_PROTECT, user->GetUID());
+ this->RemoveMode(NULL, "PROTECT", user->GetUID());
- if (op && this->HasUserStatus(user, CMODE_OP) && !u_access.HasPriv("AUTOOP") && !u_access.HasPriv("OPDEOPME"))
- this->RemoveMode(NULL, CMODE_OP, user->GetUID());
+ if (op && this->HasUserStatus(user, "OP") && !u_access.HasPriv("AUTOOP") && !u_access.HasPriv("OPDEOPME"))
+ this->RemoveMode(NULL, "OP", user->GetUID());
if (halfop && !u_access.HasPriv("AUTOHALFOP") && !u_access.HasPriv("HALFOPME"))
- this->RemoveMode(NULL, CMODE_HALFOP, user->GetUID());
+ this->RemoveMode(NULL, "HALFOP", user->GetUID());
}
// Check mlock
@@ -994,16 +991,16 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
void Channel::Unban(const User *u, bool full)
{
- if (!this->HasMode(CMODE_BAN))
+ if (!this->HasMode("BAN"))
return;
- std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = this->GetModeList(CMODE_BAN);
+ std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = this->GetModeList("BAN");
for (; bans.first != bans.second;)
{
- Entry ban(CMODE_BAN, bans.first->second);
+ Entry ban("BAN", bans.first->second);
++bans.first;
if (ban.Matches(u, full))
- this->RemoveMode(NULL, CMODE_BAN, ban.GetMask());
+ this->RemoveMode(NULL, "BAN", ban.GetMask());
}
}
diff --git a/src/command.cpp b/src/command.cpp
index 11913ffd2..36bab658f 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -18,9 +18,6 @@
#include "regchannel.h"
#include "channels.h"
-static const Anope::string CommandFlagString[] = { "CFLAG_ALLOW_UNREGISTERED", "CFLAG_STRIP_CHANNEL", "CFLAG_REQUIRE_USER", "" };
-template<> const Anope::string* Flags<CommandFlag>::flags_strings = CommandFlagString;
-
CommandSource::CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *r, BotInfo *bi) : nick(n), u(user), nc(core), reply(r),
c(NULL), service(bi)
{
@@ -90,7 +87,7 @@ bool CommandSource::IsServicesOper()
bool CommandSource::IsOper()
{
if (this->u)
- return this->u->HasMode(UMODE_OPER);
+ return this->u->HasMode("OPER");
else if (this->nc)
return this->nc->IsServicesOper();
return false;
@@ -123,6 +120,7 @@ void CommandSource::Reply(const Anope::string &message)
Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, "Command", sname), max_params(maxparams), min_params(minparams), module(owner)
{
+ allow_unregistered = require_user = false;
}
Command::~Command()
@@ -160,6 +158,26 @@ void Command::SendSyntax(CommandSource &source, const Anope::string &syn)
source.Reply(MORE_INFO, Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), source.command.c_str());
}
+bool Command::AllowUnregistered() const
+{
+ return this->allow_unregistered;
+}
+
+void Command::AllowUnregistered(bool b)
+{
+ this->allow_unregistered = b;
+}
+
+bool Command::RequireUser() const
+{
+ return this->require_user;
+}
+
+void Command::RequireUser(bool b)
+{
+ this->require_user = b;
+}
+
const Anope::string &Command::GetDesc() const
{
return this->desc;
@@ -218,11 +236,11 @@ void RunCommand(CommandSource &source, const Anope::string &message)
return;
}
- if (c->HasFlag(CFLAG_REQUIRE_USER) && !source.GetUser())
+ if (c->RequireUser() && !source.GetUser())
return;
// Command requires registered users only
- if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !source.nc)
+ if (!c->AllowUnregistered() && !source.nc)
{
source.Reply(NICK_IDENTIFY_REQUIRED);
if (source.GetUser())
diff --git a/src/config.cpp b/src/config.cpp
index bdd7180da..968d6fd73 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -43,9 +43,9 @@ ServerConfig::ServerConfig()
if (NSDefaults.empty())
{
- this->NSDefFlags.SetFlag(NI_SECURE);
- this->NSDefFlags.SetFlag(NI_MEMO_SIGNON);
- this->NSDefFlags.SetFlag(NI_MEMO_RECEIVE);
+ this->NSDefFlags.insert("SECURE");
+ this->NSDefFlags.insert("MEMOSIGNON");
+ this->NSDefFlags.insert("MEMORECEIVE");
}
else if (!NSDefaults.equals_ci("none"))
{
@@ -53,33 +53,15 @@ ServerConfig::ServerConfig()
Anope::string option;
while (options.GetToken(option))
{
- if (option.equals_ci("kill"))
- this->NSDefFlags.SetFlag(NI_KILLPROTECT);
- else if (option.equals_ci("killquick"))
- this->NSDefFlags.SetFlag(NI_KILL_QUICK);
- else if (option.equals_ci("secure"))
- this->NSDefFlags.SetFlag(NI_SECURE);
- else if (option.equals_ci("private"))
- this->NSDefFlags.SetFlag(NI_PRIVATE);
- else if (option.equals_ci("msg"))
+ if (option.equals_ci("msg"))
{
if (!this->UsePrivmsg)
Log() << "msg in <nickserv:defaults> can only be used when UsePrivmsg is set";
else
- this->NSDefFlags.SetFlag(NI_MSG);
+ this->NSDefFlags.insert(option.upper());
}
- else if (option.equals_ci("hideemail"))
- this->NSDefFlags.SetFlag(NI_HIDE_EMAIL);
- else if (option.equals_ci("hideusermask"))
- this->NSDefFlags.SetFlag(NI_HIDE_MASK);
- else if (option.equals_ci("hidequit"))
- this->NSDefFlags.SetFlag(NI_HIDE_QUIT);
- else if (option.equals_ci("memosignon"))
- this->NSDefFlags.SetFlag(NI_MEMO_SIGNON);
- else if (option.equals_ci("memoreceive"))
- this->NSDefFlags.SetFlag(NI_MEMO_RECEIVE);
- else if (option.equals_ci("autoop"))
- this->NSDefFlags.SetFlag(NI_AUTOOP);
+ else
+ this->NSDefFlags.insert(option.upper());
}
}
@@ -90,42 +72,17 @@ ServerConfig::ServerConfig()
if (CSDefaults.empty())
{
- this->CSDefFlags.SetFlag(CI_KEEPTOPIC);
- this->CSDefFlags.SetFlag(CI_SECURE);
- this->CSDefFlags.SetFlag(CI_SECUREFOUNDER);
- this->CSDefFlags.SetFlag(CI_SIGNKICK);
+ this->CSDefFlags.insert("KEEPTOPIC");
+ this->CSDefFlags.insert("SECURE");
+ this->CSDefFlags.insert("SECUREFOUNDER");
+ this->CSDefFlags.insert("SIGNKICK");
}
else if (!CSDefaults.equals_ci("none"))
{
spacesepstream options(CSDefaults);
Anope::string option;
while (options.GetToken(option))
- {
- if (option.equals_ci("keeptopic"))
- this->CSDefFlags.SetFlag(CI_KEEPTOPIC);
- else if (option.equals_ci("topiclock"))
- this->CSDefFlags.SetFlag(CI_TOPICLOCK);
- else if (option.equals_ci("private"))
- this->CSDefFlags.SetFlag(CI_PRIVATE);
- else if (option.equals_ci("restricted"))
- this->CSDefFlags.SetFlag(CI_RESTRICTED);
- else if (option.equals_ci("secure"))
- this->CSDefFlags.SetFlag(CI_SECURE);
- else if (option.equals_ci("secureops"))
- this->CSDefFlags.SetFlag(CI_SECUREOPS);
- else if (option.equals_ci("securefounder"))
- this->CSDefFlags.SetFlag(CI_SECUREFOUNDER);
- else if (option.equals_ci("signkick"))
- this->CSDefFlags.SetFlag(CI_SIGNKICK);
- else if (option.equals_ci("signkicklevel"))
- this->CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL);
- else if (option.equals_ci("peace"))
- this->CSDefFlags.SetFlag(CI_PEACE);
- else if (option.equals_ci("persist"))
- this->CSDefFlags.SetFlag(CI_PERSIST);
- else if (option.equals_ci("noautoop"))
- this->CSDefFlags.SetFlag(CI_NOAUTOOP);
- }
+ this->CSDefFlags.insert(option.upper());
}
if (UseStrictPrivMsg)
@@ -139,16 +96,7 @@ ServerConfig::ServerConfig()
spacesepstream options(BSDefaults);
Anope::string option;
while (options.GetToken(option))
- {
- if (option.equals_ci("dontkickops"))
- this->BSDefFlags.SetFlag(BS_DONTKICKOPS);
- else if (option.equals_ci("dontkickvoices"))
- this->BSDefFlags.SetFlag(BS_DONTKICKVOICES);
- else if (option.equals_ci("greet"))
- this->BSDefFlags.SetFlag(BS_GREET);
- else if (option.equals_ci("fantasy"))
- this->BSDefFlags.SetFlag(BS_FANTASY);
- }
+ this->BSDefFlags.insert(option.upper());
}
/* Ulines */
@@ -922,7 +870,7 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope:
BotInfo* bi = BotInfo::Find(nick);
if (!bi)
bi = new BotInfo(nick, user, host, gecos, modes);
- bi->SetFlag(BI_CONF);
+ bi->conf = true;
Anope::string token;
commasepstream sep(channels);
@@ -995,7 +943,7 @@ static bool DoneServices(ServerConfig *config, const Anope::string &)
BotInfo *bi = it->second;
++it;
- if (bi->HasFlag(BI_CONF) && services.count(bi->nick) == 0)
+ if (bi->conf && services.count(bi->nick) == 0)
bi->Destroy();
}
services.clear();
diff --git a/src/extensible.cpp b/src/extensible.cpp
new file mode 100644
index 000000000..66f603e21
--- /dev/null
+++ b/src/extensible.cpp
@@ -0,0 +1,99 @@
+/*
+ *
+ * (C) 2003-2013 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ *
+ */
+
+#include "extensible.h"
+
+Extensible::Extensible() : extension_items(NULL)
+{
+}
+
+Extensible::~Extensible()
+{
+ if (extension_items)
+ {
+ for (extensible_map::iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it)
+ delete it->second;
+ delete extension_items;
+ }
+}
+
+void Extensible::Extend(const Anope::string &key, ExtensibleItem *p)
+{
+ this->Shrink(key);
+ if (!extension_items)
+ extension_items = new extensible_map();
+ (*this->extension_items)[key] = p;
+}
+
+void Extensible::ExtendMetadata(const Anope::string &key, const Anope::string &value)
+{
+ this->Extend(key, new ExtensibleMetadata(value));
+}
+
+bool Extensible::Shrink(const Anope::string &key)
+{
+ if (!extension_items)
+ return false;
+
+ extensible_map::iterator it = this->extension_items->find(key);
+ if (it != this->extension_items->end())
+ {
+ delete it->second;
+ /* map::size_type map::erase( const key_type& key );
+ * returns the number of elements removed, std::map
+ * is single-associative so this should only be 0 or 1
+ */
+ return this->extension_items->erase(key) > 0;
+ }
+
+ return false;
+}
+
+bool Extensible::HasExt(const Anope::string &key) const
+{
+ return this->extension_items != NULL && this->extension_items->count(key) > 0;
+}
+
+void Extensible::GetExtList(std::deque<Anope::string> &list) const
+{
+ if (extension_items)
+ for (extensible_map::const_iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it)
+ list.push_back(it->first);
+}
+
+void Extensible::ExtensibleSerialize(Serialize::Data &data) const
+{
+ if (extension_items)
+ for (extensible_map::const_iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it)
+ if (it->second && it->second->Serialize())
+ data["extensible:" + it->first] << *it->second->Serialize();
+}
+
+void Extensible::ExtensibleUnserialize(Serialize::Data &data)
+{
+ /* Shrink existing extensible items */
+ if (extension_items)
+ for (extensible_map::iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it)
+ this->Shrink(it->first);
+
+ std::set<Anope::string> keys = data.KeySet();
+ for (std::set<Anope::string>::iterator it = keys.begin(), it_end = keys.end(); it != it_end; ++it)
+ if (it->find("extensible:") == 0)
+ {
+ if (!extension_items)
+ extension_items = new extensible_map();
+
+ Anope::string str;
+ data[*it] >> str;
+
+ this->ExtendMetadata(it->substr(11), str);
+ }
+}
+
diff --git a/src/memos.cpp b/src/memos.cpp
index d3bb7afce..eb4d22107 100644
--- a/src/memos.cpp
+++ b/src/memos.cpp
@@ -19,10 +19,10 @@
#include "account.h"
#include "regchannel.h"
-static const Anope::string MemoFlagString[] = { "MF_UNREAD", "MF_RECEIPT", "" };
-template<> const Anope::string* Flags<MemoFlag>::flags_strings = MemoFlagString;
-
-Memo::Memo() : Serializable("Memo") { }
+Memo::Memo() : Serializable("Memo")
+{
+ unread = receipt = false;
+}
void Memo::Serialize(Serialize::Data &data) const
{
@@ -30,7 +30,8 @@ void Memo::Serialize(Serialize::Data &data) const
data.SetType("time", Serialize::Data::DT_INT); data["time"] << this->time;
data["sender"] << this->sender;
data["text"] << this->text;
- data["flags"] << this->ToString();
+ data["unread"] << this->unread;
+ data["receipt"] << this->receipt;
}
Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
@@ -39,10 +40,9 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
if (!MemoServService)
return NULL;
- Anope::string owner, flags;
+ Anope::string owner;
data["owner"] >> owner;
- data["flags"] >> flags;
bool ischan;
MemoInfo *mi = MemoServService->GetMemoInfo(owner, ischan);
@@ -54,11 +54,13 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
m = anope_dynamic_static_cast<Memo *>(obj);
else
m = new Memo();
+
data["owner"] >> m->owner;
data["time"] >> m->time;
data["sender"] >> m->sender;
data["text"] >> m->text;
- m->FromString(flags);
+ data["unread"] >> m->unread;
+ data["receipt"] >> m->receipt;
if (obj == NULL)
mi->memos->push_back(m);
diff --git a/src/messages.cpp b/src/messages.cpp
index 1317b5e46..6a60d9cd9 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -90,7 +90,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
if (!c)
{
c = new Channel(chan, ts ? ts : Anope::CurTime);
- c->SetFlag(CH_SYNCING);
+ c->Extend("SYNCING");
}
/* Some IRCds do not include a TS */
else if (!ts)
@@ -139,9 +139,9 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
}
/* Channel is done syncing */
- if (c->HasFlag(CH_SYNCING))
+ if (c->HasExt("SYNCING"))
{
- c->UnsetFlag(CH_SYNCING);
+ c->Shrink("SYNCING");
/* Sync the channel (mode lock, topic, etc) */
c->Sync();
}
@@ -345,7 +345,7 @@ void Quit::Run(MessageSource &source, const std::vector<Anope::string> &params)
Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")";
NickAlias *na = NickAlias::Find(user->nick);
- if (na && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true)))
+ if (na && !na->nc->HasExt("SUSPENDED") && (user->IsRecognized() || user->IsIdentified(true)))
{
na->last_seen = Anope::CurTime;
na->last_quit = reason;
@@ -380,7 +380,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
switch (params[0][0])
{
case 'l':
- if (u->HasMode(UMODE_OPER))
+ if (u->HasMode("OPER"))
{
IRCD->SendNumeric(211, source.GetSource(), "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
IRCD->SendNumeric(211, source.GetSource(), "%s %d %d %d %d %d %d %ld", Config->Uplinks[Anope::CurrentUplink]->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - Anope::StartTime));
@@ -391,7 +391,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
case 'o':