summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-26 17:13:11 -0400
committerAdam <Adam@anope.org>2013-05-26 17:13:11 -0400
commit22658d63bdb1e52a66f4514af45fa55ca5891345 (patch)
tree673304ab19f7e077b489354248247867518331f8 /src
parentf2dee1e1d642b07947f59f91dfba9af34ef84685 (diff)
Get rid of the remaining references in the core to specific services. Move more stuff out of the core to the proper modules.
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp2
-rw-r--r--src/channels.cpp73
-rw-r--r--src/config.cpp12
-rw-r--r--src/init.cpp2
-rw-r--r--src/logger.cpp10
-rw-r--r--src/main.cpp19
-rw-r--r--src/memos.cpp2
-rw-r--r--src/messages.cpp15
-rw-r--r--src/misc.cpp1
-rw-r--r--src/modes.cpp33
-rw-r--r--src/nickalias.cpp109
-rw-r--r--src/nickcore.cpp3
-rw-r--r--src/protocol.cpp2
-rw-r--r--src/regchannel.cpp43
-rw-r--r--src/servers.cpp29
-rw-r--r--src/tools/anopesmtp.cpp26
-rw-r--r--src/users.cpp89
-rw-r--r--src/xline.cpp2
18 files changed, 102 insertions, 370 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 05dfdbe43..3ea2ef485 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -21,8 +21,6 @@
Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
-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"), channels("ChannelInfo"), botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
diff --git a/src/channels.cpp b/src/channels.cpp
index bc32781de..d774b8c8d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -34,6 +34,7 @@ Channel::Channel(const Anope::string &nname, time_t ts)
this->name = nname;
this->creation_time = ts;
+ this->syncing = false;
this->server_modetime = this->chanserv_modetime = 0;
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_ts = this->topic_time = 0;
@@ -79,7 +80,7 @@ void Channel::Reset()
}
for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
- this->SetCorrectModes(it->second->user, true, false);
+ this->SetCorrectModes(it->second->user, true);
this->Sync();
}
@@ -152,21 +153,20 @@ void Channel::CheckModes()
bool Channel::CheckDelete()
{
- /* Channel is persistent, it shouldn't be deleted and the service bot should stay */
- if (this->HasExt("PERSIST") || (this->ci && this->ci->HasExt("PERSIST")))
- return false;
-
/* 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->HasExt("SYNCING"))
+ if (this->syncing)
return false;
-
- /* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
- if (this->HasExt("INHABIT"))
+
+ /* Permanent channels never get deleted */
+ if (this->HasMode("PERM"))
return false;
- return this->users.empty();
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnCheckDelete, OnCheckDelete(this));
+
+ return MOD_RESULT != EVENT_STOP && this->users.empty();
}
ChanUserContainer* Channel::JoinUser(User *user)
@@ -180,14 +180,6 @@ ChanUserContainer* Channel::JoinUser(User *user)
user->chans[this] = cuc;
this->users[user] = cuc;
- 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;
- IRCD->SendChannel(this);
- this->Reset();
- }
-
return cuc;
}
@@ -323,7 +315,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
/* Enforce secureops, etc */
if (enforce_mlock && MOD_RESULT != EVENT_STOP)
- this->SetCorrectModes(u, false, false);
+ this->SetCorrectModes(u, false);
return;
}
@@ -343,14 +335,6 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop
cml->OnAdd(this, param);
}
- /* Channel mode +P or so was set, mark this channel as persistent */
- if (cm->name == "PERM")
- {
- this->Extend("PERSIST");
- if (this->ci)
- this->ci->ExtendMetadata("PERSIST");
- }
-
FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, setter, cm->name, param));
/* Check if we should enforce mlock */
@@ -395,7 +379,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param));
if (enforce_mlock && MOD_RESULT != EVENT_STOP)
- this->SetCorrectModes(u, false, false);
+ this->SetCorrectModes(u, false);
return;
}
@@ -419,20 +403,6 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
cml->OnDel(this, param);
}
- if (cm->name == "PERM")
- {
- this->Shrink("PERSIST");
-
- if (this->ci)
- this->ci->Shrink("PERSIST");
-
- if (this->users.empty() && !this->HasExt("SYNCING") && !this->HasExt("INHABIT"))
- {
- delete this;
- return;
- }
- }
-
FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param));
/* Check for mlock */
@@ -828,9 +798,6 @@ void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string
Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << (u ? u->nick : user) << " to " << newtopic;
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic));
-
- if (this->ci)
- this->ci->CheckTopic();
}
void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts)
@@ -847,12 +814,9 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
this->topic_time = Anope::CurTime;
FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic));
-
- if (this->ci)
- this->ci->CheckTopic();
}
-void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
+void Channel::SetCorrectModes(User *user, bool give_modes)
{
if (user == NULL)
return;
@@ -865,14 +829,17 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
AccessGroup u_access = ci->AccessFor(user);
ChannelMode *registered = ModeManager::FindChannelModeByName("REGISTERED");
- /* Only give modes if autoop isn't set */
- give_modes &= (!user->Account() || user->Account()->HasExt("AUTOOP")) && (!check_noop || !ci->HasExt("NOAUTOOP"));
/* If this channel has secureops, or the registered channel mode exists and the channel does not have +r set (aka the channel
* was created just now or while we were off), or the registered channel mode does not exist and channel is syncing (aka just
* created *to us*) and the user's server is synced (aka this isn't us doing our initial uplink - without this we would be deopping all
* users with no access on a non-secureops channel on startup), and the user's server isn't ulined, then set negative modes.
*/
- bool take_modes = (ci->HasExt("SECUREOPS") || (registered && !this->HasMode("REGISTERED")) || (!registered && this->HasExt("SYNCING") && user->server->IsSynced())) && !user->server->IsULined();
+ bool take_modes = (registered && !this->HasMode("REGISTERED")) || (!registered && this->syncing && user->server->IsSynced());
+
+ FOREACH_MOD(I_OnSetCorrectModes, OnSetCorrectModes(user, this, u_access, give_modes, take_modes));
+
+ /* Never take modes from ulines */
+ take_modes &= !user->server->IsULined();
bool given = false;
for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
@@ -911,8 +878,6 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
}
}
}
-
- FOREACH_MOD(I_OnSetCorrectModes, OnSetCorrectModes(user, this, u_access, give_modes));
}
bool Channel::Unban(User *u, bool full)
diff --git a/src/config.cpp b/src/config.cpp
index 52469c75a..d90c9728c 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -589,6 +589,18 @@ Block *Conf::GetModule(const Anope::string &mname)
return GetModule(mname);
}
+BotInfo *Conf::GetClient(const Anope::string &cname)
+{
+ Anope::map<Anope::string>::iterator it = bots.find(cname);
+ if (it != bots.end())
+ return BotInfo::Find(!it->second.empty() ? it->second : cname, true);
+
+ Block *block = GetModule(cname.lower());
+ const Anope::string &client = block->Get<const Anope::string>("client");
+ bots[cname] = client;
+ return GetClient(cname);
+}
+
File::File(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL)
{
}
diff --git a/src/init.cpp b/src/init.cpp
index 205fb2501..0a93c07f5 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -464,9 +464,9 @@ void Anope::Init(int ac, char **av)
Log() << "Loading databases...";
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase());
+ static_cast<void>(MOD_RESULT);
Log() << "Databases loaded";
Serialize::CheckTypes();
}
-/*************************************************************************/
diff --git a/src/logger.cpp b/src/logger.cpp
index 380e94b14..3873c1dee 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -98,9 +98,6 @@ Log::Log(const User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u
{
if (!chan)
throw CoreException("Invalid pointers passed to Log::Log");
-
- if (Config)
- this->bi = ChanServ;
}
Log::Log(const User *_u, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat)
@@ -113,9 +110,6 @@ Log::Log(Server *serv, const Anope::string &cat, const BotInfo *_bi) : bi(_bi),
{
if (!s)
throw CoreException("Invalid pointer passed to Log::Log");
-
- if (!this->bi)
- this->bi = OperServ;
}
Log::Log(const BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat)
@@ -134,13 +128,13 @@ Log::~Log()
std::cout << GetTimeStamp() << " " << this->BuildPrefix() << this->buf.str() << std::endl;
else if (this->type == LOG_TERMINAL)
std::cout << this->BuildPrefix() << this->buf.str() << std::endl;
+
+ FOREACH_MOD(I_OnLog, OnLog(this));
if (Config)
for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
if (Config->LogInfos[i].HasType(this->type, this->category))
Config->LogInfos[i].ProcessMessage(this);
-
- FOREACH_MOD(I_OnLog, OnLog(this));
}
Anope::string Log::BuildPrefix() const
diff --git a/src/main.cpp b/src/main.cpp
index 99174279b..576df28a6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,20 +47,30 @@ class UpdateTimer : public Timer
public:
UpdateTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
- void Tick(time_t)
+ void Tick(time_t) anope_override
{
Anope::SaveDatabases();
}
};
+class ExpireTimer : public Timer
+{
+ public:
+ ExpireTimer(time_t timeout) : Timer(timeout, Anope::CurTime, true) { }
+
+ void Tick(time_t) anope_override
+ {
+ FOREACH_MOD(I_OnExpireTick, OnExpireTick());
+ }
+};
+
void Anope::SaveDatabases()
{
if (Anope::ReadOnly)
return;
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnSaveDatabase, OnSaveDatabase());
Log(LOG_DEBUG) << "Saving databases";
+ FOREACH_MOD(I_OnSaveDatabase, OnSaveDatabase());
}
/** The following comes from InspIRCd to get the full path of the Anope executable
@@ -100,8 +110,6 @@ static Anope::string GetFullProgDir(const Anope::string &argv0)
return "/";
}
-/*************************************************************************/
-
/* Main routine. (What does it look like? :-) ) */
int main(int ac, char **av, char **envp)
@@ -150,6 +158,7 @@ int main(int ac, char **av, char **envp)
/* Set up timers */
time_t last_check = Anope::CurTime;
UpdateTimer updateTimer(Config->GetBlock("options")->Get<time_t>("updatetimeout"));
+ ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout"));
/*** Main loop. ***/
while (!Anope::Quitting)
diff --git a/src/memos.cpp b/src/memos.cpp
index b3f044e1e..a6cd6031a 100644
--- a/src/memos.cpp
+++ b/src/memos.cpp
@@ -75,7 +75,7 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data)
return m;
}
-MemoInfo::MemoInfo() : memos("Memo")
+MemoInfo::MemoInfo() : memomax(0), memos("Memo")
{
}
diff --git a/src/messages.cpp b/src/messages.cpp
index 5a688a89c..d9a89ef46 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -49,7 +49,7 @@ void Error::Run(MessageSource &source, const std::vector<Anope::string> &params)
Anope::Quitting = true;
}
-void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
User *targ = User::Find(params[0]);
Channel *c = Channel::Find(params[1]);
@@ -101,7 +101,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
bool keep_their_modes = true;
if (created)
- c->Extend("SYNCING");
+ c->syncing = true;
/* Some IRCds do not include a TS */
else if (!ts)
;
@@ -120,7 +120,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
/* If we are syncing, mlock is checked later in Channel::Sync. It is important to not check it here
* so that Channel::SetCorrectModes can correctly detect the presence of channel mode +r.
*/
- c->SetModesInternal(source, modes, ts, !c->HasExt("SYNCING"));
+ c->SetModesInternal(source, modes, ts, !c->syncing);
for (std::list<SJoinUser>::const_iterator it = users.begin(), it_end = users.end(); it != it_end; ++it)
{
@@ -137,16 +137,16 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
/* Set whatever modes the user should have, and remove any that
* they aren't allowed to have (secureops etc).
*/
- c->SetCorrectModes(u, true, true);
+ c->SetCorrectModes(u, true);
if (c->ci)
c->ci->CheckKick(u);
}
/* Channel is done syncing */
- if (c->HasExt("SYNCING"))
+ if (c->syncing)
{
- c->Shrink("SYNCING");
+ c->syncing = false;
/* Sync the channel (mode lock, topic, etc) */
/* the channel is synced when the netmerge is complete */
if (Me && Me->IsSynced())
@@ -444,7 +444,6 @@ void Version::Run(MessageSource &source, const std::vector<Anope::string> &param
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
- return;
}
void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -464,7 +463,5 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
}
else
IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str());
-
- return;
}
diff --git a/src/misc.cpp b/src/misc.cpp
index b446ea711..6fb9e8c91 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -478,6 +478,7 @@ void Anope::Encrypt(const Anope::string &src, Anope::string &dest)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest));
+ static_cast<void>(MOD_RESULT);
}
bool Anope::Decrypt(const Anope::string &src, Anope::string &dest)
diff --git a/src/modes.cpp b/src/modes.cpp
index 651fbafd9..2e9a49f09 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -14,9 +14,11 @@
#include "protocol.h"
#include "channels.h"
+struct StackerInfo;
+
/* List of pairs of user/channels and their stacker info */
-std::map<User *, StackerInfo *> ModeManager::UserStackerObjects;
-std::map<Channel *, StackerInfo *> ModeManager::ChannelStackerObjects;
+static std::map<User *, StackerInfo *> UserStackerObjects;
+static std::map<Channel *, StackerInfo *> ChannelStackerObjects;
/* List of all modes Anope knows about */
std::vector<ChannelMode *> ModeManager::ChannelModes;
@@ -31,6 +33,25 @@ static std::vector<ChannelModeStatus *> ChannelModesByStatus;
/* Number of generic modes we support */
unsigned ModeManager::GenericChannelModes = 0, ModeManager::GenericUserModes = 0;
+struct StackerInfo
+{
+ /* Modes to be added */
+ std::list<std::pair<Mode *, Anope::string> > AddModes;
+ /* Modes to be deleted */
+ std::list<std::pair<Mode *, Anope::string> > DelModes;
+ /* Bot this is sent from */
+ const BotInfo *bi;
+
+ StackerInfo() : bi(NULL) { }
+
+ /** Add a mode to this object
+ * @param mode The mode
+ * @param set true if setting, false if unsetting
+ * @param param The param for the mode
+ */
+ void AddMode(Mode *mode, bool set, const Anope::string &param);
+};
+
ChannelStatus::ChannelStatus()
{
}
@@ -255,7 +276,11 @@ static StackerInfo *GetInfo(List &l, Object *o)
return s;
}
-std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info)
+/** Build a list of mode strings to send to the IRCd from the mode stacker
+ * @param info The stacker info for a channel or user
+ * @return a list of strings
+ */
+static std::list<Anope::string> BuildModeStrings(StackerInfo *info)
{
std::list<Anope::string> ret;
std::list<std::pair<Mode *, Anope::string> >::iterator it, it_end;
@@ -521,8 +546,6 @@ void ModeManager::StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set,
s->AddMode(um, Set, Param);
if (bi)
s->bi = bi;
- else
- s->bi = NULL;
if (!modePipe)
modePipe = new ModePipe();
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index 4e7d5b46a..327340a1d 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -77,115 +77,6 @@ NickAlias::~NickAlias()
NickAliasList->erase(this->nick);
}
-void NickAlias::Release()
-{
- if (this->HasExt("HELD"))
- {
- if (IRCD->CanSVSHold)
- IRCD->SendSVSHoldDel(this->nick);
- else
- {
- User *u = User::Find(this->nick);
- if (u && u->server == Me)
- {
- u->Quit();
- }
- }
-
- this->Shrink("HELD");
- }
-}
-
-/** Timers for removing HELD status from nicks.
- */
-class NickServHeld : public Timer
-{
- static std::map<Anope::string, NickServHeld *> NickServHelds;
-
- Reference<NickAlias> na;
- Anope::string nick;
- public:
- NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick)
- {
- std::map<Anope::string, NickServHeld *>::iterator nit = NickServHelds.find(na->nick);
- if (nit != NickServHelds.end())
- delete nit->second;
-
- NickServHelds[na->nick] = this;
- }
-
- ~NickServHeld()
- {
- NickServHelds.erase(this->nick);
- }
-
- void Tick(time_t)
- {
- if (na)
- na->Shrink("HELD");
- }
-};
-std::map<Anope::string, NickServHeld *> NickServHeld::NickServHelds;
-
-/** Timers for releasing nicks to be available for use
- */
-class CoreExport NickServRelease : public User, public Timer
-{
- static std::map<Anope::string, NickServRelease *> NickServReleases;
- Anope::string nick;
-
- public:
- /** Constructor
- * @param na The nick
- * @param delay The delay before the nick is released
- */
- NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetBlock("options")->Get<const Anope::string>("enforceruser"),
- Config->GetBlock("options")->Get<const Anope::string>("enforcerhost"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Timer(delay), nick(na->nick)
- {
- /* Erase the current release timer and use the new one */
- std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick);
- if (nit != NickServReleases.end())
- {
- IRCD->SendQuit(nit->second, "");
- delete nit->second;
- }
-
- NickServReleases.insert(std::make_pair(this->nick, this));
-
- IRCD->SendClientIntroduction(this);
- }
-
- virtual ~NickServRelease()
- {
- NickServReleases.erase(this->nick);
- }
-
- /** Called when the delay is up
- * @param t The current time
- */
- void Tick(time_t t)
- {
- IRCD->SendQuit(this, "");
- }
-};
-std::map<Anope::string, NickServRelease *> NickServRelease::NickServReleases;
-
-void NickAlias::OnCancel(User *)
-{
- if (this->HasExt("COLLIDED"))
- {
- this->Extend("HELD");
- this->Shrink("COLLIDED");
-
- new NickServHeld(this, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
-
- if (IRCD->CanSVSHold)
- IRCD->SendSVSHold(this->nick, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
- else
- new NickServRelease(this, Config->GetBlock("options")->Get<time_t>("releasetimeout"));
- }
-}
-
void NickAlias::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created)
{
this->vhost_ident = ident;
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index e2b47e953..9e2ff8dbb 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -25,7 +25,6 @@ NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"),
this->o = NULL;
this->channelcount = 0;
this->lastmail = 0;
- this->memos.memomax = 0;
this->display = coredisplay;
@@ -51,10 +50,8 @@ NickCore::~NickCore()
}
this->users.clear();
- /* Remove the core from the list */
NickCoreList->erase(this->display);
- /* Clear access before deleting display name, we want to be able to use the display name in the clear access event */
this->ClearAccess();
if (!this->memos.memos->empty())
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 052ebd8fc..ccd58c95f 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -372,7 +372,7 @@ bool IRCDProto::IsHostValid(const Anope::string &host)
void IRCDProto::SendOper(User *u)
{
SendNumericInternal(381, u->GetUID(), ":You are now an IRC operator (set by services)");
- u->SetMode(OperServ, "OPER");
+ u->SetMode(NULL, "OPER");
}
unsigned IRCDProto::GetMaxListFor(Channel *c)
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 4ed7b4d86..2fcb3ca14 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -359,8 +359,6 @@ ChannelInfo::~ChannelInfo()
if (this->c)
{
- this->Shrink("PERSIST");
-
if (this->bi && this->c->FindUser(this->bi))
this->bi->Part(this->c);
@@ -565,10 +563,14 @@ BotInfo *ChannelInfo::WhoSends() const
{
if (this && this->bi)
return this->bi;
- else if (ChanServ)
+
+ BotInfo *ChanServ = Config->GetClient("ChanServ");
+ if (ChanServ)
return ChanServ;
- else if (!BotListByNick->empty())
+
+ if (!BotListByNick->empty())
return BotListByNick->begin()->second;
+
return NULL;
}
@@ -1041,39 +1043,6 @@ bool ChannelInfo::CheckKick(User *user)
return true;
}
-void ChannelInfo::CheckTopic()
-{
- if (!this->c)
- return;
-
- /* We only compare the topics here, not the time or setter. This is because some (old) IRCds do not
- * allow us to set the topic as someone else, meaning we have to bump the TS and change the setter to us.
- * This desyncs what is really set with what we have stored, and we end up resetting the topic often when
- * it is not required
- */
- if (this->HasExt("TOPICLOCK") && this->last_topic != this->c->topic)
- {
- this->c->ChangeTopic(this->last_topic_setter, this->last_topic, this->last_topic_time);
- }
- else
- {
- this->last_topic = this->c->topic;
- this->last_topic_setter = this->c->topic_setter;
- this->last_topic_time = this->c->topic_ts;
- }
-}
-
-void ChannelInfo::RestoreTopic()
-{
- if (!this->c)
- return;
-
- if ((this->HasExt("KEEPTOPIC") || this->HasExt("TOPICLOCK")) && this->last_topic != this->c->topic)
- {
- this->c->ChangeTopic(!this->last_topic_setter.empty() ? this->last_topic_setter : this->WhoSends()->nick, this->last_topic, this->last_topic_time ? this->last_topic_time : Anope::CurTime);
- }
-}
-
int16_t ChannelInfo::GetLevel(const Anope::string &priv) const
{
if (PrivilegeManager::FindPrivilege(priv) == NULL)
diff --git a/src/servers.cpp b/src/servers.cpp
index 0c1019216..d8fc84a81 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -247,33 +247,6 @@ void Server::Sync(bool sync_links)
if (this->GetUplink() && this->GetUplink() == Me)
{
- for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
- {
- ChannelInfo *ci = it->second;
- if (ci->HasExt("PERSIST"))
- {
- bool created;
- ci->c = Channel::FindOrCreate(ci->name, created, ci->time_registered);
-
- if (ModeManager::FindChannelModeByName("PERM") != NULL)
- {
- if (created)
- IRCD->SendChannel(ci->c);
- ci->c->SetMode(NULL, "PERM");
- }
- else
- {
- if (!ci->bi)
- ci->WhoSends()->Assign(NULL, ci);
- if (ci->c->FindUser(ci->bi) == NULL)
- {
- ChannelStatus status(Config->GetModule("botserv")->Get<const Anope::string>("botmodes"));
- ci->bi->Join(ci->c, &status);
- }
- }
- }
- }
-
FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this));
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
@@ -347,8 +320,6 @@ Server *Server::Find(const Anope::string &name, bool name_only)
return NULL;
}
-/*************************************************************************/
-
static inline char& nextID(char &c)
{
if (c == 'Z')
diff --git a/src/tools/anopesmtp.cpp b/src/tools/anopesmtp.cpp
index 9d94564a9..c14f2ca23 100644
--- a/src/tools/anopesmtp.cpp
+++ b/src/tools/anopesmtp.cpp
@@ -65,8 +65,6 @@ extern int connect(int, struct sockaddr *, int);
# endif
#endif
-/*************************************************************************/
-
#ifdef _WIN32
typedef SOCKET ano_socket_t;
#define ano_sockclose(fd) closesocket(fd)
@@ -141,8 +139,6 @@ void alog(const char *fmt, ...)
file.close();
}
-/*************************************************************************/
-
/* Remove a trailing \r\n */
std::string strip(const std::string &buf)
{
@@ -156,8 +152,6 @@ std::string strip(const std::string &buf)
return newbuf;
}
-/*************************************************************************/
-
/* Is the buffer a header? */
bool smtp_is_header(const std::string &buf)
{
@@ -171,8 +165,6 @@ bool smtp_is_header(const std::string &buf)
return false;
}
-/*************************************************************************/
-
/* Parse a header into a name and value */
void smtp_parse_header(const std::string &buf, std::string &header, std::string &value)
{
@@ -191,8 +183,6 @@ void smtp_parse_header(const std::string &buf, std::string &header, std::string
}
}
-/*************************************************************************/
-
/* Have we reached the end of input? */
bool smtp_is_end(const std::string &buf)
{
@@ -203,8 +193,6 @@ bool smtp_is_end(const std::string &buf)
return false;
}
-/*************************************************************************/
-
/* Set who the email is to */
void smtp_set_to(const std::string &to)
{
@@ -217,8 +205,6 @@ void smtp_set_to(const std::string &to)
}
}
-/*************************************************************************/
-
/* Establish a connection to the SMTP server */
int smtp_connect(const char *host, unsigned short port)
{
@@ -245,8 +231,6 @@ int smtp_connect(const char *host, unsigned short port)
return 1;
}
-/*************************************************************************/
-
/* Send a line of text */
int smtp_send(const char *text)
{
@@ -260,8 +244,6 @@ int smtp_send(const char *text)
return result;
}
-/*************************************************************************/
-
/* Read a line of text */
int smtp_read(char *buf, int len)
{
@@ -276,8 +258,6 @@ int smtp_read(char *buf, int len)
return result;
}
-/*************************************************************************/
-
/* Retrieve a response code */
int smtp_get_code(const std::string &text)
{
@@ -289,8 +269,6 @@ int smtp_get_code(const std::string &text)
return atol(text.substr(0, tmp).c_str());
}
-/*************************************************************************/
-
/* Send the email */
int smtp_send_email()
{
@@ -424,16 +402,12 @@ int smtp_send_email()
return 1;
}
-/*************************************************************************/
-
void smtp_disconnect()
{
smtp_send("QUIT\r\n");
ano_sockclose(smail.sock);
}
-/*************************************************************************/
-
int main(int argc, char *argv[])
{
/* Win32 stuff */
diff --git a/src/users.cpp b/src/users.cpp
index 8d0606ab1..cba624104 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -150,7 +150,7 @@ const Anope::string &User::GetDisplayedHost() const
void User::SetCloakedHost(const Anope::string &newhost)
{
if (newhost.empty())
- throw "empty host in User::SetCloakedHost";
+ throw CoreException("empty host in User::SetCloakedHost");
chost = newhost;
@@ -278,88 +278,23 @@ void User::SendMessage(const BotInfo *source, const Anope::string &msg)
* - The user is not registered and NSDefMsg is enabled
* - The user is registered and has set /ns set msg on
*/
+ bool send_privmsg = Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->HasExt("MSG")));
sepstream sep(translated_message, '\n', true);
for (Anope::string tok; sep.GetToken(tok);)
{
- if (Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->HasExt("MSG"))))
+ if (send_privmsg)
IRCD->SendPrivmsg(source, this->GetUID(), "%s", tok.c_str());
else
IRCD->SendNotice(source, this->GetUID(), "%s", tok.c_str());
}
}
-/** Collides a nick.
- *
- * First, it marks the nick as COLLIDED, this is checked in NickAlias::OnCancel.
- *
- * Then it does one of two things.
- *
- * 1. This will force change the users nick to the guest nick. This gets processed by the IRCd and comes
- * back as a nick change, which calls NickAlias::OnCancel
- * with the users old nick's nickalias (if there is one).
- *
- * 2. Calls User::Kill, which kills the user and deletes the user at the end of the I/O loop.
- * Users destructor then calls NickAlias::OnCancel
- *
- * NickAlias::OnCancel checks for NS_COLLIDED, it then does one of two things.
- *
- * 1. If supported, we send a SVSHold for the user. We are done here, the IRCds expires this at the time we give it.
- *
- * 2. We create a new client with SendClientIntroduction(). Note that is it important that this is called either after the
- * user has been removed from our internal list of user or after the users nick has been updated completely internally.
- * We then create a release timer for this new client that waits and later on sends a QUIT for the client. Release timers
- * are never used for SVSHolds. Ever.
- *
- *
- * Note that now for the timers we only store the users name, not the NickAlias* pointer. We never remove timers when
- * a user changes nick or a nick is deleted, the timers must assume that either of these may have happend.
- *
- * Adam
- */
-void User::Collide(NickAlias *na)
-{
- if (na)
- na->Extend("COLLIDED");
-
- if (IRCD->CanSVSNick)
- {
- const Anope::string &guestprefix = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix");
-
- Anope::string guestnick;
-
- int i = 0;
- do
- {
- guestnick = guestprefix + stringify(static_cast<uint16_t>(rand()));
- } while (User::Find(guestnick) && i++ < 10);
-
- if (i == 11)
- this->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
- else
- {
- if (NickServ)
- this->SendMessage(NickServ, _("Your nickname is now being changed to \002%s\002"), guestnick.c_str());
- IRCD->SendForceNickChange(this, guestnick, Anope::CurTime);
- }
- }
- else
- this->Kill(NickServ ? NickServ->nick : "", "Services nickname-enforcer kill");
-}
-
void User::Identify(NickAlias *na)
{
- if (!na)
- {
- Log() << "User::Identify() called with NULL pointer";
- return;
- }
-
if (this->nick.equals_ci(na->nick))
{
- Anope::string last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
- Anope::string last_realhost = this->GetIdent() + "@" + this->host;
- na->last_usermask = last_usermask;
- na->last_realhost = last_realhost;
+ na->last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
+ na->last_realhost = this->GetIdent() + "@" + this->host;
na->last_realname = this->realname;
na->last_seen = Anope::CurTime;
}
@@ -367,27 +302,21 @@ void User::Identify(NickAlias *na)
this->Login(na->nc);
IRCD->SendLogin(this);
- const NickAlias *this_na = NickAlias::Find(this->nick);
- if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && this_na && this_na->nc == *na->nc && na->nc->HasExt("UNCONFIRMED") == false)
- this->SetMode(NickServ, "REGISTERED");
-
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
if (this->IsServicesOper())
{
if (!this->nc->o->ot->modes.empty())
{
- this->SetModes(OperServ, "%s", this->nc->o->ot->modes.c_str());
- if (OperServ)
- this->SendMessage(OperServ, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
+ this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str());
+ this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
UserMode *um = ModeManager::FindUserModeByName("OPER");
if (um && !this->HasMode("OPER") && this->nc->o->ot->modes.find(um->mchar) != Anope::string::npos)
IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !this->nc->o->vhost.empty())
{
- if (OperServ)
- this->SendMessage(OperServ, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
+ this->SendMessage(NULL, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
this->SetDisplayedHost(this->nc->o->vhost);
IRCD->SendVhost(this, "", this->nc->o->vhost);
}
@@ -408,6 +337,8 @@ void User::Login(NickCore *core)
if (this->server->IsSynced())
Log(this, "account") << "is now identified as " << this->nc->display;
+
+ FOREACH_MOD(I_OnUserLogin, OnUserLogin(this));
}
void User::Logout()
diff --git a/src/xline.cpp b/src/xline.cpp
index efe19411f..66bb6d308 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -44,7 +44,7 @@ void XLine::InitRegex()
}
}
-XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), by(OperServ ? OperServ->nick : ""), created(0), expires(0), reason(r), id(uid)
+XLine::XLine(const Anope::string &ma, const Anope::string &r, const Anope::string &uid) : Serializable("XLine"), mask(ma), created(0), expires(0), reason(r), id(uid)
{
regex = NULL;
manager = NULL;