diff options
| author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
| commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
| tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/extra/stats | |
| parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) | |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'modules/extra/stats')
| -rw-r--r-- | modules/extra/stats/cs_fantasy_stats.cpp | 4 | ||||
| -rw-r--r-- | modules/extra/stats/cs_fantasy_top.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/stats/irc2sql/irc2sql.cpp | 8 | ||||
| -rw-r--r-- | modules/extra/stats/irc2sql/irc2sql.h | 4 | ||||
| -rw-r--r-- | modules/extra/stats/m_chanstats.cpp | 30 |
5 files changed, 24 insertions, 24 deletions
diff --git a/modules/extra/stats/cs_fantasy_stats.cpp b/modules/extra/stats/cs_fantasy_stats.cpp index 4674e0892..a5ce54d33 100644 --- a/modules/extra/stats/cs_fantasy_stats.cpp +++ b/modules/extra/stats/cs_fantasy_stats.cpp @@ -114,7 +114,7 @@ class CSStats : public Module else { if (NickServ::Nick *na = NickServ::FindNick(params[0])) - display = na->nc->display; + display = na->GetAccount()->GetDisplay(); else { source.Reply(_("%s not found."), params[0].c_str()); @@ -125,7 +125,7 @@ class CSStats : public Module } if (display.empty()) - display = source.nc->display; + display = source.nc->GetDisplay(); try { diff --git a/modules/extra/stats/cs_fantasy_top.cpp b/modules/extra/stats/cs_fantasy_top.cpp index 540a4f3d9..94197a0e5 100644 --- a/modules/extra/stats/cs_fantasy_top.cpp +++ b/modules/extra/stats/cs_fantasy_top.cpp @@ -122,7 +122,7 @@ class CSTop : public Module if (!params.empty()) channel = params[0]; else if (source.c && source.c->ci) - channel = source.c->ci->name; + channel = source.c->ci->GetName(); if (!is_global && channel.empty()) is_global = true; diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp index 8c0aa83ab..bc302c575 100644 --- a/modules/extra/stats/irc2sql/irc2sql.cpp +++ b/modules/extra/stats/irc2sql/irc2sql.cpp @@ -25,7 +25,7 @@ void IRC2SQL::OnReload(Configuration::Conf *conf) const Anope::string &snick = block->Get<const Anope::string>("client"); if (snick.empty()) throw ConfigException(Module::name + ": <client> must be defined"); - StatServ = BotInfo::Find(snick, true); + StatServ = ServiceBot::Find(snick, true); if (!StatServ) throw ConfigException(Module::name + ": no bot named " + snick); @@ -99,7 +99,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt) query.SetValue("ident", u->GetIdent()); query.SetValue("vident", u->GetVIdent()); query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N"); - query.SetValue("account", u->Account() ? u->Account()->display : ""); + query.SetValue("account", u->Account() ? u->Account()->GetDisplay() : ""); query.SetValue("fingerprint", u->fingerprint); query.SetValue("signon", u->signon); query.SetValue("server", u->server->GetName()); @@ -158,7 +158,7 @@ void IRC2SQL::OnUserLogin(User *u) { query = "UPDATE `" + prefix + "user` SET account=@account@ WHERE nick=@nick@"; query.SetValue("nick", u->nick); - query.SetValue("account", u->Account() ? u->Account()->display : ""); + query.SetValue("account", u->Account() ? u->Account()->GetDisplay() : ""); this->RunQuery(query); } @@ -255,7 +255,7 @@ void IRC2SQL::OnTopicUpdated(Channel *c, const Anope::string &user, const Anope: this->RunQuery(query); } -void IRC2SQL::OnBotNotice(User *u, BotInfo *bi, Anope::string &message) +void IRC2SQL::OnBotNotice(User *u, ServiceBot *bi, Anope::string &message) { Anope::string versionstr; if (bi != StatServ) diff --git a/modules/extra/stats/irc2sql/irc2sql.h b/modules/extra/stats/irc2sql/irc2sql.h index 1ce118f38..175e37681 100644 --- a/modules/extra/stats/irc2sql/irc2sql.h +++ b/modules/extra/stats/irc2sql/irc2sql.h @@ -27,7 +27,7 @@ class IRC2SQL : public Module std::vector<Anope::string> TableList, ProcedureList, EventList; Anope::string prefix, GeoIPDB; bool quitting, introduced_myself, ctcpuser, ctcpeob, firstrun; - BotInfo *StatServ; + ServiceBot *StatServ; PrimitiveExtensibleItem<bool> versionreply; void RunQuery(const SQL::Query &q); @@ -71,7 +71,7 @@ class IRC2SQL : public Module void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) override; - void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) override; + void OnBotNotice(User *u, ServiceBot *bi, Anope::string &message) override; }; diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp index 6238b749c..1d299ce7a 100644 --- a/modules/extra/stats/m_chanstats.cpp +++ b/modules/extra/stats/m_chanstats.cpp @@ -73,25 +73,25 @@ class CommandNSSetChanstats : public Command } EventReturn MOD_RESULT; - MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, na->nc, param); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, na->GetAccount(), param); if (MOD_RESULT == EVENT_STOP) return; if (param.equals_ci("ON")) { - Log(na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable chanstats for " << na->nc->display; - na->nc->Extend<bool>("NS_STATS"); + Log(na->GetAccount() == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable chanstats for " << na->GetAccount()->GetDisplay(); + na->GetAccount()->Extend<bool>("NS_STATS"); if (saset) - source.Reply(_("Chanstats statistics are now enabled for %s"), na->nc->display.c_str()); + source.Reply(_("Chanstats statistics are now enabled for %s"), na->GetAccount()->GetDisplay().c_str()); else source.Reply(_("Chanstats statistics are now enabled for your nick.")); } else if (param.equals_ci("OFF")) { - Log(na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable chanstats for " << na->nc->display; - na->nc->Shrink<bool>("NS_STATS"); + Log(na->GetAccount() == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable chanstats for " << na->GetAccount()->GetDisplay(); + na->GetAccount()->Shrink<bool>("NS_STATS"); if (saset) - source.Reply(_("Chanstats statistics are now disabled for %s"), na->nc->display.c_str()); + source.Reply(_("Chanstats statistics are now disabled for %s"), na->GetAccount()->GetDisplay().c_str()); else source.Reply(_("Chanstats statistics are now disabled for your nick.")); } @@ -101,7 +101,7 @@ class CommandNSSetChanstats : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - this->Run(source, source.nc->display, params[0]); + this->Run(source, source.nc->GetDisplay(), params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -156,7 +156,7 @@ class MySQLInterface : public SQL::Interface class MChanstats : public Module { - SerializableExtensibleItem<bool> cs_stats, ns_stats; + Serialize::Field<bool> cs_stats, ns_stats; CommandCSSetChanstats commandcssetchanstats; @@ -200,7 +200,7 @@ class MChanstats : public Module const Anope::string GetDisplay(User *u) { if (u && u->Account() && ns_stats.HasExt(u->Account())) - return u->Account()->display; + return u->Account()->GetDisplay(); else return ""; } @@ -513,7 +513,7 @@ class MChanstats : public Module { if (!show_hidden) return; - if (ns_stats.HasExt(na->nc)) + if (ns_stats.HasExt(na->GetAccount())) info.AddOption(_("Chanstats")); } @@ -613,14 +613,14 @@ class MChanstats : public Module void OnDelCore(NickServ::Account *nc) override { query = "DELETE FROM `" + prefix + "chanstats` WHERE `nick` = @nick@;"; - query.SetValue("nick", nc->display); + query.SetValue("nick", nc->GetDisplay()); this->RunQuery(query); } void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) override { query = "CALL " + prefix + "chanstats_proc_chgdisplay(@old_display@, @new_display@);"; - query.SetValue("old_display", nc->display); + query.SetValue("old_display", nc->GetDisplay()); query.SetValue("new_display", newdisplay); this->RunQuery(query); } @@ -628,7 +628,7 @@ class MChanstats : public Module void OnDelChan(ChanServ::Channel *ci) override { query = "DELETE FROM `" + prefix + "chanstats` WHERE `chan` = @channel@;"; - query.SetValue("channel", ci->name); + query.SetValue("channel", ci->GetName()); this->RunQuery(query); } @@ -641,7 +641,7 @@ class MChanstats : public Module void OnNickRegister(User *user, NickAlias *na, const Anope::string &) { if (NSDefChanstats) - na->nc->Extend<bool>("NS_STATS"); + na->GetAccount()->Extend<bool>("NS_STATS"); } }; |
