summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-05-28 12:07:29 -0400
committerAdam <Adam@anope.org>2014-05-28 12:07:54 -0400
commitf29e1cf383529a1a29f02b0669d973f5ee0b7a66 (patch)
tree3c33db276dc9328235bbd572641521ed44458176 /src
parent1253c70e0682fa1490c99c3d2869049a0e3fa2e0 (diff)
Move most of the core pseudoclient logic to modules
Diffstat (limited to 'src')
-rw-r--r--src/access.cpp441
-rw-r--r--src/account.cpp80
-rw-r--r--src/bots.cpp18
-rw-r--r--src/channels.cpp63
-rw-r--r--src/command.cpp23
-rw-r--r--src/config.cpp61
-rw-r--r--src/event.cpp1
-rw-r--r--src/hashcomp.cpp2
-rw-r--r--src/init.cpp2
-rw-r--r--src/language.cpp7
-rw-r--r--src/logger.cpp12
-rw-r--r--src/mail.cpp9
-rw-r--r--src/memos.cpp133
-rw-r--r--src/messages.cpp15
-rw-r--r--src/misc.cpp12
-rw-r--r--src/modes.cpp41
-rw-r--r--src/module.cpp4
-rw-r--r--src/modulemanager.cpp17
-rw-r--r--src/nickalias.cpp217
-rw-r--r--src/nickcore.cpp266
-rw-r--r--src/process.cpp5
-rw-r--r--src/protocol.cpp6
-rw-r--r--src/regchannel.cpp689
-rw-r--r--src/serialize.cpp8
-rw-r--r--src/servers.cpp12
-rw-r--r--src/socket_transport.cpp4
-rw-r--r--src/socketengines/socketengine_epoll.cpp6
-rw-r--r--src/socketengines/socketengine_kqueue.cpp4
-rw-r--r--src/socketengines/socketengine_poll.cpp2
-rw-r--r--src/socketengines/socketengine_select.cpp2
-rw-r--r--src/sockets.cpp2
-rw-r--r--src/tools/anopesmtp.cpp2
-rw-r--r--src/uplink.cpp1
-rw-r--r--src/users.cpp73
-rw-r--r--src/win32/anope_windows.h4
-rw-r--r--src/win32/dir/dir.cpp2
-rw-r--r--src/win32/dir/dir.h2
-rw-r--r--src/win32/pipe/pipe.cpp2
-rw-r--r--src/win32/resource.h2
-rw-r--r--src/win32/sigaction/sigaction.cpp5
-rw-r--r--src/win32/sigaction/sigaction.h10
-rw-r--r--src/win32/socket.cpp2
-rw-r--r--src/win32/windows.cpp6
43 files changed, 224 insertions, 2051 deletions
diff --git a/src/access.cpp b/src/access.cpp
deleted file mode 100644
index 26c8dee27..000000000
--- a/src/access.cpp
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- *
- * (C) 2003-2014 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- */
-
-#include "service.h"
-#include "access.h"
-#include "regchannel.h"
-#include "users.h"
-#include "account.h"
-#include "protocol.h"
-#include "event.h"
-
-static struct
-{
- Anope::string name;
- Anope::string desc;
-} descriptions[] = {
- {"ACCESS_CHANGE", _("Allowed to modify the access list")},
- {"ACCESS_LIST", _("Allowed to view the access list")},
- {"AKICK", _("Allowed to use the AKICK command")},
- {"ASSIGN", _("Allowed to assign/unassign a bot")},
- {"AUTOHALFOP", _("Automatic halfop upon join")},
- {"AUTOOP", _("Automatic channel operator status upon join")},
- {"AUTOOWNER", _("Automatic owner upon join")},
- {"AUTOPROTECT", _("Automatic protect upon join")},
- {"AUTOVOICE", _("Automatic voice on join")},
- {"BADWORDS", _("Allowed to modify channel badwords list")},
- {"BAN", _("Allowed to ban users")},
- {"FANTASIA", _("Allowed to use fantasy commands")},
- {"FOUNDER", _("Allowed to issue commands restricted to channel founders")},
- {"GETKEY", _("Allowed to use GETKEY command")},
- {"GREET", _("Greet message displayed on join")},
- {"HALFOP", _("Allowed to (de)halfop users")},
- {"HALFOPME", _("Allowed to (de)halfop him/herself")},
- {"INFO", _("Allowed to get full INFO output")},
- {"INVITE", _("Allowed to use the INVITE command")},
- {"KICK", _("Allowed to use the KICK command")},
- {"MEMO", _("Allowed to read channel memos")},
- {"MODE", _("Allowed to use the MODE command")},
- {"NOKICK", _("Prevents users being kicked by Services")},
- {"OP", _("Allowed to (de)op users")},
- {"OPME", _("Allowed to (de)op him/herself")},
- {"OWNER", _("Allowed to (de)owner users")},
- {"OWNERME", _("Allowed to (de)owner him/herself")},
- {"PROTECT", _("Allowed to (de)protect users")},
- {"PROTECTME", _("Allowed to (de)protect him/herself")},
- {"SAY", _("Allowed to use SAY and ACT commands")},
- {"SET", _("Allowed to set channel settings")},
- {"SIGNKICK", _("No signed kick when SIGNKICK LEVEL is used")},
- {"TOPIC", _("Allowed to change channel topics")},
- {"UNBAN", _("Allowed to unban users")},
- {"VOICE", _("Allowed to (de)voice users")},
- {"VOICEME", _("Allowed to (de)voice him/herself")}
-};
-
-Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r)
-{
- if (this->desc.empty())
- for (unsigned j = 0; j < sizeof(descriptions) / sizeof(*descriptions); ++j)
- if (descriptions[j].name.equals_ci(name))
- this->desc = descriptions[j].desc;
-}
-
-bool Privilege::operator==(const Privilege &other) const
-{
- return this->name.equals_ci(other.name);
-}
-
-std::vector<Privilege> PrivilegeManager::Privileges;
-
-void PrivilegeManager::AddPrivilege(Privilege p)
-{
- unsigned i;
- for (i = 0; i < Privileges.size(); ++i)
- {
- Privilege &priv = Privileges[i];
-
- if (priv.rank > p.rank)
- break;
- }
-
- Privileges.insert(Privileges.begin() + i, p);
-}
-
-void PrivilegeManager::RemovePrivilege(Privilege &p)
-{
- std::vector<Privilege>::iterator it = std::find(Privileges.begin(), Privileges.end(), p);
- if (it != Privileges.end())
- Privileges.erase(it);
-
- for (registered_channel_map::const_iterator cit = RegisteredChannelList->begin(), cit_end = RegisteredChannelList->end(); cit != cit_end; ++cit)
- {
- cit->second->QueueUpdate();
- cit->second->RemoveLevel(p.name);
- }
-}
-
-Privilege *PrivilegeManager::FindPrivilege(const Anope::string &name)
-{
- for (unsigned i = Privileges.size(); i > 0; --i)
- if (Privileges[i - 1].name.equals_ci(name))
- return &Privileges[i - 1];
- return NULL;
-}
-
-std::vector<Privilege> &PrivilegeManager::GetPrivileges()
-{
- return Privileges;
-}
-
-void PrivilegeManager::ClearPrivileges()
-{
- Privileges.clear();
-}
-
-AccessProvider::AccessProvider(Module *o, const Anope::string &n) : Service(o, "AccessProvider", n)
-{
- Providers.push_back(this);
-}
-
-AccessProvider::~AccessProvider()
-{
- std::list<AccessProvider *>::iterator it = std::find(Providers.begin(), Providers.end(), this);
- if (it != Providers.end())
- Providers.erase(it);
-}
-
-std::list<AccessProvider *> AccessProvider::Providers;
-
-const std::list<AccessProvider *>& AccessProvider::GetProviders()
-{
- return Providers;
-}
-
-ChanAccess::ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p)
-{
-}
-
-ChanAccess::~ChanAccess()
-{
- if (this->ci)
- {
- std::vector<ChanAccess *>::iterator it = std::find(this->ci->access->begin(), this->ci->access->end(), this);
- if (it != this->ci->access->end())
- this->ci->access->erase(it);
-
- const NickAlias *na = NickAlias::Find(this->mask);
- if (na != NULL)
- na->nc->RemoveChannelReference(this->ci);
- else
- {
- ChannelInfo *c = ChannelInfo::Find(this->mask);
- if (c)
- c->RemoveChannelReference(this->ci->name);
- }
- }
-}
-
-void ChanAccess::Serialize(Serialize::Data &data) const
-{
- data["provider"] << this->provider->name;
- data["ci"] << this->ci->name;
- data["mask"] << this->mask;
- data["creator"] << this->creator;
- data.SetType("last_seen", Serialize::Data::DT_INT); data["last_seen"] << this->last_seen;
- data.SetType("created", Serialize::Data::DT_INT); data["created"] << this->created;
- data["data"] << this->AccessSerialize();
-}
-
-Serializable* ChanAccess::Unserialize(Serializable *obj, Serialize::Data &data)
-{
- Anope::string provider, chan;
-
- data["provider"] >> provider;
- data["ci"] >> chan;
-
- ServiceReference<AccessProvider> aprovider("AccessProvider", provider);
- ChannelInfo *ci = ChannelInfo::Find(chan);
- if (!aprovider || !ci)
- return NULL;
-
- ChanAccess *access;
- if (obj)
- access = anope_dynamic_static_cast<ChanAccess *>(obj);
- else
- access = aprovider->Create();
- access->ci = ci;
- data["mask"] >> access->mask;
- data["creator"] >> access->creator;
- data["last_seen"] >> access->last_seen;
- data["created"] >> access->created;
-
- Anope::string adata;
- data["data"] >> adata;
- access->AccessUnserialize(adata);
-
- if (!obj)
- ci->AddAccess(access);
- return access;
-}
-
-bool ChanAccess::Matches(const User *u, const NickCore *acc, Path &p) const
-{
- if (this->nc)
- return this->nc == acc;
-
- if (u)
- {
- bool is_mask = this->mask.find_first_of("!@?*") != Anope::string::npos;
- if (is_mask && Anope::Match(u->nick, this->mask))
- return true;
- else if (Anope::Match(u->GetDisplayedMask(), this->mask))
- return true;
- }
-
- if (acc)
- {
- for (unsigned i = 0; i < acc->aliases->size(); ++i)
- {
- const NickAlias *na = acc->aliases->at(i);
- if (Anope::Match(na->nick, this->mask))
- return true;
- }
- }
-
- if (IRCD->IsChannelValid(this->mask))
- {
- ChannelInfo *tci = ChannelInfo::Find(this->mask);
- if (tci)
- {
- for (unsigned i = 0; i < tci->GetAccessCount(); ++i)
- {
- ChanAccess *a = tci->GetAccess(i);
- std::pair<const ChanAccess *, const ChanAccess *> pair = std::make_pair(this, a);
-
- std::pair<Set::iterator, Set::iterator> range = p.first.equal_range(this);
- for (; range.first != range.second; ++range.first)
- if (range.first->first == pair.first && range.first->second == pair.second)
- goto cont;
-
- p.first.insert(pair);
- if (a->Matches(u, acc, p))
- p.second.insert(pair);
-
- cont:;
- }
-
- return p.second.count(this) > 0;
- }
- }
-
- return false;
-}
-
-bool ChanAccess::operator>(const ChanAccess &other) const
-{
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return this_p && !other_p;
- }
-
- return false;
-}
-
-bool ChanAccess::operator<(const ChanAccess &other) const
-{
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return !this_p && other_p;
- }
-
- return false;
-}
-
-bool ChanAccess::operator>=(const ChanAccess &other) const
-{
- return !(*this < other);
-}
-
-bool ChanAccess::operator<=(const ChanAccess &other) const
-{
- return !(*this > other);
-}
-
-AccessGroup::AccessGroup() : std::vector<ChanAccess *>()
-{
- this->ci = NULL;
- this->nc = NULL;
- this->super_admin = this->founder = false;
-}
-
-static bool HasPriv(const AccessGroup &ag, const ChanAccess *access, const Anope::string &name)
-{
- EventReturn MOD_RESULT = Event::OnCheckPriv(&Event::CheckPriv::OnCheckPriv, access, name);
- if (MOD_RESULT == EVENT_ALLOW || access->HasPriv(name))
- {
- typedef std::multimap<const ChanAccess *, const ChanAccess *> path;
- std::pair<path::const_iterator, path::const_iterator> it = ag.path.second.equal_range(access);
- if (it.first != it.second)
- /* check all of the paths for this entry */
- for (; it.first != it.second; ++it.first)
- {
- const ChanAccess *a = it.first->second;
- /* if only one path fully matches then we are ok */
- if (HasPriv(ag, a, name))
- return true;
- }
- else
- /* entry is the end of a chain, all entries match, ok */
- return true;
- }
-
- /* entry does not match or none of the chains fully match */
- return false;
-}
-
-bool AccessGroup::HasPriv(const Anope::string &name) const
-{
- if (this->super_admin)
- return true;
- else if (!ci || ci->GetLevel(name) == ACCESS_INVALID)
- return false;
-
- /* Privileges prefixed with auto are understood to be given
- * automatically. Sometimes founders want to not automatically
- * obtain privileges, so we will let them */
- bool auto_mode = !name.find("AUTO");
-
- /* Only grant founder privilege if this isn't an auto mode or if they don't match any entries in this group */
- if ((!auto_mode || this->empty()) && this->founder)
- return true;
-
- EventReturn MOD_RESULT;
- MOD_RESULT = Event::OnGroupCheckPriv(&Event::GroupCheckPriv::OnGroupCheckPriv, this, name);
- if (MOD_RESULT != EVENT_CONTINUE)
- return MOD_RESULT == EVENT_ALLOW;
-
- for (unsigned i = this->size(); i > 0; --i)
- {
- ChanAccess *access = this->at(i - 1);
-
- if (::HasPriv(*this, access, name))
- return true;
- }
-
- return false;
-}
-
-const ChanAccess *AccessGroup::Highest() const
-{
- ChanAccess *highest = NULL;
- for (unsigned i = 0; i < this->size(); ++i)
- if (highest == NULL || *this->at(i) > *highest)
- highest = this->at(i);
- return highest;
-}
-
-bool AccessGroup::operator>(const AccessGroup &other) const
-{
- if (other.super_admin)
- return false;
- else if (this->super_admin)
- return true;
- else if (other.founder)
- return false;
- else if (this->founder)
- return true;
-
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return this_p && !other_p;
- }
-
- return false;
-}
-
-bool AccessGroup::operator<(const AccessGroup &other) const
-{
- if (this->super_admin)
- return false;
- else if (other.super_admin)
- return true;
- else if (this->founder)
- return false;
- else if (other.founder)
- return true;
-
- const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
- for (unsigned i = privs.size(); i > 0; --i)
- {
- bool this_p = this->HasPriv(privs[i - 1].name),
- other_p = other.HasPriv(privs[i - 1].name);
-
- if (!this_p && !other_p)
- continue;
-
- return !this_p && other_p;
- }
-
- return false;
-}
-
-bool AccessGroup::operator>=(const AccessGroup &other) const
-{
- return !(*this < other);
-}
-
-bool AccessGroup::operator<=(const AccessGroup &other) const
-{
- return !(*this > other);
-}
-
diff --git a/src/account.cpp b/src/account.cpp
deleted file mode 100644
index e58ee1646..000000000
--- a/src/account.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * (C) 2003-2014 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- */
-
-#include "services.h"
-#include "account.h"
-#include "modules.h"
-#include "users.h"
-#include "protocol.h"
-#include "regchannel.h"
-
-std::set<IdentifyRequest *> IdentifyRequest::Requests;
-
-IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false)
-{
- Requests.insert(this);
-}
-
-IdentifyRequest::~IdentifyRequest()
-{
- Requests.erase(this);
-}
-
-void IdentifyRequest::Hold(Module *m)
-{
- holds.insert(m);
-}
-
-void IdentifyRequest::Release(Module *m)
-{
- holds.erase(m);
- if (holds.empty() && dispatched)
- {
- if (!success)
- this->OnFail();
- delete this;
- }
-}
-
-void IdentifyRequest::Success(Module *m)
-{
- if (!success)
- {
- this->OnSuccess();
- success = true;
- }
-}
-
-void IdentifyRequest::Dispatch()
-{
- if (holds.empty())
- {
- if (!success)
- this->OnFail();
- delete this;
- }
- else
- dispatched = true;
-}
-
-void IdentifyRequest::ModuleUnload(Module *m)
-{
- for (std::set<IdentifyRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end;)
- {
- IdentifyRequest *ir = *it;
- ++it;
-
- ir->Release(m);
- if (ir->owner == m)
- delete ir;
- }
-}
diff --git a/src/bots.cpp b/src/bots.cpp
index b2feb9c4e..ea0bf4ec3 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -13,16 +13,16 @@
#include "servers.h"
#include "protocol.h"
#include "xline.h"
-#include "regchannel.h"
#include "channels.h"
#include "config.h"
#include "language.h"
#include "serialize.h"
#include "event.h"
+#include "modules/chanserv.h"
Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
-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(), NULL), Serializable("BotInfo"), channels("ChannelInfo"), botmodes(bmodes)
+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(), NULL), Serializable("BotInfo"), channels("ChanServ::Channel"), botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
@@ -31,7 +31,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
(*BotListByNick)[this->nick] = this;
if (!this->uid.empty())
(*BotListByUID)[this->uid] = this;
-
+
Event::OnCreateBot(&Event::CreateBot::OnCreateBot, this);
// If we're synchronised with the uplink already, send the bot.
@@ -61,9 +61,9 @@ BotInfo::~BotInfo()
IRCD->SendSQLineDel(&x);
}
- for (std::set<ChannelInfo *>::iterator it = this->channels->begin(), it_end = this->channels->end(); it != it_end; ++it)
+ for (std::set<ChanServ::Channel *>::iterator it = this->channels->begin(), it_end = this->channels->end(); it != it_end; ++it)
{
- ChannelInfo *ci = *it;
+ ChanServ::Channel *ci = *it;
this->UnAssign(NULL, ci);
}
@@ -145,12 +145,12 @@ void BotInfo::SetNewNick(const Anope::string &newnick)
(*BotListByNick)[this->nick] = this;
}
-const std::set<ChannelInfo *> &BotInfo::GetChannels() const
+const std::set<ChanServ::Channel *> &BotInfo::GetChannels() const
{
return this->channels;
}
-void BotInfo::Assign(User *u, ChannelInfo *ci)
+void BotInfo::Assign(User *u, ChanServ::Channel *ci)
{
EventReturn MOD_RESULT;
MOD_RESULT = Event::OnPreBotAssign(&Event::PreBotAssign::OnPreBotAssign, u, ci, this);
@@ -159,14 +159,14 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
if (ci->bi)
ci->bi->UnAssign(u, ci);
-
+
ci->bi = this;
this->channels->insert(ci);
Event::OnBotAssign(&Event::BotAssign::OnBotAssign, u, ci, this);
}
-void BotInfo::UnAssign(User *u, ChannelInfo *ci)
+void BotInfo::UnAssign(User *u, ChanServ::Channel *ci)
{
EventReturn MOD_RESULT;
MOD_RESULT = Event::OnBotUnAssign(&Event::BotUnAssign::OnBotUnAssign, u, ci);
diff --git a/src/channels.cpp b/src/channels.cpp
index 09b88a7e9..9ba886c30 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -12,20 +12,18 @@
#include "services.h"
#include "channels.h"
-#include "regchannel.h"
#include "logger.h"
#include "modules.h"
#include "users.h"
-#include "bots.h"
#include "servers.h"
#include "protocol.h"
#include "users.h"
#include "config.h"
-#include "access.h"
#include "sockets.h"
#include "language.h"
#include "uplink.h"
#include "event.h"
+#include "modules/chanserv.h"
channel_map ChannelList;
@@ -41,10 +39,6 @@ Channel::Channel(const Anope::string &nname, time_t ts)
this->server_modetime = this->chanserv_modetime = 0;
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_ts = this->topic_time = 0;
- this->ci = ChannelInfo::Find(this->name);
- if (this->ci)
- this->ci->c = this;
-
if (Me && Me->IsSynced())
Log(NULL, this, "create");
@@ -89,7 +83,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);
-
+
// If the channel is syncing now, do not force a sync due to Reset(), as we are probably iterating over users in Message::SJoin
// A sync will come soon
if (!syncing)
@@ -127,7 +121,7 @@ bool Channel::CheckDelete()
*/
if (this->syncing)
return false;
-
+
/* Permanent channels never get deleted */
if (this->HasMode("PERM"))
return false;
@@ -332,8 +326,7 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *cm, c
return;
}
- BotInfo *bi = BotInfo::Find(param);
- User *u = bi ? bi : User::Find(param);
+ User *u = User::Find(param);
if (!u)
{
@@ -368,7 +361,7 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *cm, c
}
else
this->modes.erase(cm->name);
-
+
if (cm->type == MODE_LIST)
{
ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm);
@@ -393,7 +386,7 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *cm, c
this->CheckModes();
}
-void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
+void Channel::SetMode(User *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
{
if (!cm)
return;
@@ -438,12 +431,12 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param,
SetModeInternal(bi, cm, param, enforce_mlock);
}
-void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
+void Channel::SetMode(User *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
{
SetMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock);
}
-void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
+void Channel::RemoveMode(User *bi, ChannelMode *cm, const Anope::string &param, bool enforce_mlock)
{
if (!cm)
return;
@@ -488,7 +481,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &para
RemoveModeInternal(bi, cm, realparam, enforce_mlock);
}
-void Channel::RemoveMode(BotInfo *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
+void Channel::RemoveMode(User *bi, const Anope::string &mname, const Anope::string &param, bool enforce_mlock)
{
RemoveMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock);
}
@@ -508,7 +501,7 @@ bool Channel::GetParam(const Anope::string &mname, Anope::string &target) const
return false;
}
-void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...)
+void Channel::SetModes(User *bi, bool enforce_mlock, const char *cmodes, ...)
{
char buf[BUFSIZE] = "";
va_list args;
@@ -688,7 +681,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
Log(setter, this, "mode") << modestring << paramstring;
else
Log(LOG_DEBUG) << source.GetName() << " is setting " << this->name << " to " << modestring << paramstring;
-
+
if (enforce_mlock)
this->CheckModes();
}
@@ -710,14 +703,14 @@ bool Channel::MatchesList(User *u, const Anope::string &mode)
return false;
}
-void Channel::KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason)
+bool Channel::KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason)
{
User *sender = source.GetUser();
User *target = User::Find(nick);
if (!target)
{
Log(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason;
- return;
+ return false;
}
if (sender)
@@ -731,18 +724,23 @@ void Channel::KickInternal(const MessageSource &source, const Anope::string &nic
if (cu == NULL)
{
Log(LOG_DEBUG) << "Channel::KickInternal got kick for user " << target->nick << " from " << source.GetSource() << " who isn't on channel " << this->name;
- return;
+ return false;
}
Anope::string this_name = this->name;
ChannelStatus status = cu->status;
- Event::OnPreUserKicked(&Event::PreUserKicked::OnPreUserKicked, source, cu, reason);
+ EventReturn MOD_RESULT = Event::OnPreUserKicked(&Event::PreUserKicked::OnPreUserKicked, source, cu, reason);
+ if ((sender && sender->server == Me) || source.GetServer() == Me)
+ if (MOD_RESULT == EVENT_STOP)
+ return false;
+
this->DeleteUser(target); /* This can delete this; */
Event::OnUserKicked(&Event::UserKicked::OnUserKicked, source, target, this_name, status, reason);
+ return true;
}
-bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...)
+bool Channel::Kick(User *source, User *u, const char *reason, ...)
{
va_list args;
char buf[BUFSIZE] = "";
@@ -753,16 +751,13 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...)
/* Do not kick protected clients or Ulines */
if (u->IsProtected())
return false;
-
- if (bi == NULL)
- bi = this->ci->WhoSends();
- EventReturn MOD_RESULT;
- MOD_RESULT = Event::OnBotKick(&Event::BotKick::OnBotKick, bi, this, u, buf);
- if