summaryrefslogtreecommitdiff
path: root/modules/extra/sql_oper.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-10-01 09:42:51 -0400
committerAdam <Adam@anope.org>2016-10-01 09:43:04 -0400
commitddfe45c4d9cad8999b7f11ea623149aa441e1b58 (patch)
tree0426fcca19570d3504efd8137f5c8e2d7fba9ad7 /modules/extra/sql_oper.cpp
parent80018f8a23b88337c478de2f23f5d6f97a3f152d (diff)
sql_oper: various fixups to compile on 2.1
Diffstat (limited to 'modules/extra/sql_oper.cpp')
-rw-r--r--modules/extra/sql_oper.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/modules/extra/sql_oper.cpp b/modules/extra/sql_oper.cpp
index a12b5d7b0..a82d1f258 100644
--- a/modules/extra/sql_oper.cpp
+++ b/modules/extra/sql_oper.cpp
@@ -20,11 +20,6 @@
#include "module.h"
#include "modules/sql.h"
-struct SQLOper : Oper
-{
- SQLOper(const Anope::string &n, OperType *o) : Oper(n, o) { }
-};
-
class SQLOperResult : public SQL::Interface
{
Reference<User> user;
@@ -68,10 +63,10 @@ class SQLOperResult : public SQL::Interface
ServiceBot *OperServ = Config->GetClient("OperServ");
if (opertype.empty())
{
- if (user->Account() && user->Account()->o && dynamic_cast<SQLOper *>(user->Account()->o))
+ if (user->Account()->o && user->Account()->o->owner == this->owner)
{
- delete user->Account()->o;
- user->Account()->o = NULL;
+ user->Account()->o->Delete();
+ user->Account()->o = nullptr;
Log(this->owner) << "m_sql_oper: Removed services operator from " << user->nick << " (" << user->Account()->GetDisplay() << ")";
user->RemoveMode(OperServ, "OPER"); // Probably not set, just incase
@@ -86,10 +81,16 @@ class SQLOperResult : public SQL::Interface
return;
}
- if (!user->Account()->o || user->Account()->o->ot != ot)
+ if (!user->Account()->o || user->Account()->o->GetType() != ot)
{
Log(this->owner) << "m_sql_oper: Tieing oper " << user->nick << " to type " << opertype;
- user->Account()->o = new SQLOper(user->Account()->GetDisplay(), ot);
+
+ Oper *o = Serialize::New<Oper *>();
+ o->owner = this->owner;
+ o->SetName(user->Account()->GetDisplay());
+ o->SetType(ot);
+
+ user->Account()->o = o;
}
if (!user->HasMode("OPER"))
@@ -118,20 +119,24 @@ class ModuleSQLOper : public Module
public:
ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR),
- EventHook<Event::NickIdentify>()
+ EventHook<Event::NickIdentify>(this)
{
}
~ModuleSQLOper()
{
- for (nickcore_map::const_iterator it = NickServ::AccountList->begin(), it_end = NickServ::AccountList->end(); it != it_end; ++it)
+ if (NickServ::service == nullptr)
+ return;
+
+ NickServ::nickcore_map& map = NickServ::service->GetAccountMap();
+ for (NickServ::nickcore_map::const_iterator it = map.begin(); it != map.end(); ++it)
{
NickServ::Account *nc = it->second;
- if (nc->o && dynamic_cast<SQLOper *>(nc->o))
+ if (nc->o && nc->o->owner == this)
{
- delete nc->o;
- nc->o = NULL;
+ nc->o->Delete();
+ nc->o = nullptr;
}
}
}
@@ -143,14 +148,14 @@ class ModuleSQLOper : public Module
this->engine = config->Get<Anope::string>("engine");
this->query = config->Get<Anope::string>("query");
- this->SQL = ServiceReference<SQL::Provider>("SQL::Provider", this->engine);
+ this->SQL = ServiceReference<SQL::Provider>(engine);
}
void OnNickIdentify(User *u) override
{
if (!this->SQL)
{
- Log() << "Unable to find SQL engine";
+ Log() << "Unable to find SQL engine: " << engine;
return;
}