diff options
Diffstat (limited to 'modules/commands')
-rw-r--r-- | modules/commands/cs_entrymsg.cpp | 18 | ||||
-rw-r--r-- | modules/commands/cs_fantasy_stats.cpp | 32 | ||||
-rw-r--r-- | modules/commands/cs_fantasy_top.cpp | 32 | ||||
-rw-r--r-- | modules/commands/cs_seen.cpp | 14 | ||||
-rw-r--r-- | modules/commands/cs_set_misc.cpp | 18 | ||||
-rw-r--r-- | modules/commands/cs_suspend.cpp | 12 | ||||
-rw-r--r-- | modules/commands/hs_request.cpp | 13 | ||||
-rw-r--r-- | modules/commands/ns_ajoin.cpp | 14 | ||||
-rw-r--r-- | modules/commands/ns_set_misc.cpp | 18 | ||||
-rw-r--r-- | modules/commands/ns_suspend.cpp | 12 | ||||
-rw-r--r-- | modules/commands/os_dns.cpp | 12 | ||||
-rw-r--r-- | modules/commands/os_forbid.h | 8 | ||||
-rw-r--r-- | modules/commands/os_ignore.h | 15 | ||||
-rw-r--r-- | modules/commands/os_news.h | 8 | ||||
-rw-r--r-- | modules/commands/os_oper.cpp | 15 | ||||
-rw-r--r-- | modules/commands/os_session.h | 8 | ||||
-rw-r--r-- | modules/commands/os_stats.cpp | 6 |
17 files changed, 123 insertions, 132 deletions
diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 85e428cc1..ab9c4d0c4 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -28,16 +28,12 @@ struct EntryMsg : Serializable this->when = ct; } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["ci"] << this->ci->name; data["creator"] << this->creator; data["message"] << this->message; - data["when"].SetType(Serialize::DT_INT) << this->when; - - return data; + data.SetType("when", Serialize::Data::DT_INT); data["when"] << this->when; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); @@ -52,7 +48,13 @@ struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >, Extensib Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data) { - ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr()); + Anope::string sci, screator, smessage; + + data["ci"] >> sci; + data["creator"] >> screator; + data["message"] >> smessage; + + ChannelInfo *ci = ChannelInfo::Find(sci); if (!ci) return NULL; @@ -73,7 +75,7 @@ Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data) ci->Extend("cs_entrymsg", messages); } - EntryMsg *m = new EntryMsg(ci, data["creator"].astr(), data["message"].astr()); + EntryMsg *m = new EntryMsg(ci, screator, smessage); (*messages)->push_back(m); return m; } diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index bbe135298..5b25cccce 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -14,16 +14,16 @@ #include "module.h" #include "../extra/sql.h" -class MySQLInterface : public SQLInterface +class MySQLInterface : public SQL::Interface { public: - MySQLInterface(Module *o) : SQLInterface(o) { } + MySQLInterface(Module *o) : SQL::Interface(o) { } - void OnResult(const SQLResult &r) anope_override + void OnResult(const SQL::Result &r) anope_override { } - void OnError(const SQLResult &r) anope_override + void OnError(const SQL::Result &r) anope_override { if (!r.GetQuery().query.empty()) Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); @@ -66,7 +66,7 @@ class CSStats : public Module { CommandCSStats commandcsstats; CommandCSGStats commandcsgstats; - ServiceReference<SQLProvider> sql; + ServiceReference<SQL::Provider> sql; MySQLInterface sqlinterface; Anope::string prefix; public: @@ -86,17 +86,17 @@ class CSStats : public Module ConfigReader config; prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); - this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine); } - SQLResult RunQuery(const SQLQuery &query) + SQL::Result RunQuery(const SQL::Query &query) { if (!this->sql) - throw SQLException("Unable to locate SQL reference, is m_mysql loaded and configured correctly?"); + throw SQL::Exception("Unable to locate SQL reference, is m_mysql loaded and configured correctly?"); - SQLResult res = this->sql->RunQuery(query); + SQL::Result res = this->sql->RunQuery(query); if (!res.GetError().empty()) - throw SQLException(res.GetError()); + throw SQL::Exception(res.GetError()); return res; } @@ -118,16 +118,16 @@ class CSStats : public Module try { - SQLQuery query; + SQL::Query query; query = "SELECT letters, words, line, smileys_happy+smileys_sad+smileys_other as smileys," "actions FROM `" + prefix + "chanstats` " "WHERE `nick` = @nick@ AND `chan` = @channel@ AND `type` = 'total';"; if (is_global) - query.setValue("channel", ""); + query.SetValue("channel", ""); else - query.setValue("channel", source.c->ci->name); - query.setValue("nick", display); - SQLResult res = this->RunQuery(query); + query.SetValue("channel", source.c->ci->name); + query.SetValue("nick", display); + SQL::Result res = this->RunQuery(query); if (res.Rows() > 0) { @@ -144,7 +144,7 @@ class CSStats : public Module else source.Reply(_("No stats for %s"), display.c_str()); } - catch (const SQLException &ex) + catch (const SQL::Exception &ex) { Log(LOG_DEBUG) << ex.GetReason(); } diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 86e25f122..ca9572039 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -14,16 +14,16 @@ #include "module.h" #include "../extra/sql.h" -class MySQLInterface : public SQLInterface +class MySQLInterface : public SQL::Interface { public: - MySQLInterface(Module *o) : SQLInterface(o) { } + MySQLInterface(Module *o) : SQL::Interface(o) { } - void OnResult(const SQLResult &r) anope_override + void OnResult(const SQL::Result &r) anope_override { } - void OnError(const SQLResult &r) anope_override + void OnError(const SQL::Result &r) anope_override { if (!r.GetQuery().query.empty()) Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); @@ -93,7 +93,7 @@ class CSTop : public Module CommandCSGTop commandcsgtop; CommandCSTop10 commandcstop10; CommandCSGTop10 commandcsgtop10; - ServiceReference<SQLProvider> sql; + ServiceReference<SQL::Provider> sql; MySQLInterface sqlinterface; Anope::string prefix; @@ -115,17 +115,17 @@ class CSTop : public Module ConfigReader config; prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); - this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine); } - SQLResult RunQuery(const SQLQuery &query) + SQL::Result RunQuery(const SQL::Query &query) { if (!this->sql) - throw SQLException("Unable to locate SQL reference, is m_mysql loaded and configured correctly?"); + throw SQL::Exception("Unable to locate SQL reference, is m_mysql loaded and configured correctly?"); - SQLResult res = sql->RunQuery(query); + SQL::Result res = sql->RunQuery(query); if (!res.GetError().empty()) - throw SQLException(res.GetError()); + throw SQL::Exception(res.GetError()); return res; } @@ -147,20 +147,20 @@ class CSTop : public Module try { - SQLQuery query; + SQL::Query query; query = "SELECT nick, letters, words, line, actions," "smileys_happy+smileys_sad+smileys_other as smileys " "FROM `" + prefix + "chanstats` " "WHERE `nick` != '' AND `chan` = @channel@ AND `type` = 'total' " "ORDER BY `letters` DESC LIMIT @limit@;"; - query.setValue("limit", limit, false); + query.SetValue("limit", limit, false); if (is_global) - query.setValue("channel", ""); + query.SetValue("channel", ""); else - query.setValue("channel", channel.c_str()); + query.SetValue("channel", channel.c_str()); - SQLResult res = this->RunQuery(query); + SQL::Result res = this->RunQuery(query); if (res.Rows() > 0) { @@ -176,7 +176,7 @@ class CSTop : public Module else source.Reply(_("No stats for %s"), is_global ? "Network" : channel.c_str()); } - catch (const SQLException &ex) + catch (const SQL::Exception &ex) { Log(LOG_DEBUG) << ex.GetReason(); } diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 18a21d35e..8f90e2f08 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -38,30 +38,30 @@ struct SeenInfo : Serializable { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["nick"] << nick; data["vhost"] << vhost; data["type"] << type; data["nick2"] << nick2; data["channel"] << channel; data["message"] << message; - data["last"].SetType(Serialize::DT_INT) << last; - - return data; + data.SetType("last", Serialize::Data::DT_INT); data["last"] << last; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { + Anope::string snick; + + data["nick"] >> snick; + SeenInfo *s; if (obj) s = anope_dynamic_static_cast<SeenInfo *>(obj); else { /* ignore duplicate entries in the db, created by an old bug */ - s = FindInfo(data["nick"].str()); + s = FindInfo(snick); if (!s) s = new SeenInfo(); } diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 3bf0e9bbd..1fb25c79a 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -22,20 +22,22 @@ struct CSMiscData : ExtensibleItem, Serializable { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &sdata) const anope_override { - Serialize::Data sdata; - sdata["ci"] << this->ci->name; sdata["name"] << this->name; sdata["data"] << this->data; - - return sdata; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr()); + Anope::string sci, sname, sdata; + + data["ci"] >> sci; + data["name"] >> sname; + data["data"] >> sdata; + + ChannelInfo *ci = ChannelInfo::Find(sci); if (ci == NULL) return NULL; @@ -49,8 +51,8 @@ struct CSMiscData : ExtensibleItem, Serializable } else { - d = new CSMiscData(ci, data["name"].astr(), data["data"].astr()); - ci->Extend(data["name"].astr(), d); + d = new CSMiscData(ci, sname, sdata); + ci->Extend(sname, d); } return d; diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index b380d4c97..097de1823 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -22,19 +22,19 @@ struct ChanSuspend : ExtensibleItem, Serializable { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &sd) const anope_override { - Serialize::Data sd; - sd["chan"] << this->chan; sd["when"] << this->when; - - return sd; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - ChannelInfo *ci = ChannelInfo::Find(sd["chan"].astr()); + Anope::string schan; + + sd["chan"] >> schan; + + ChannelInfo *ci = ChannelInfo::Find(schan); if (ci == NULL) return NULL; diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index c7cd75c11..6cd2e6811 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -32,21 +32,20 @@ struct HostRequest : ExtensibleItem, Serializable HostRequest() : Serializable("HostRequest") { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["nick"] << this->nick; data["ident"] << this->ident; data["host"] << this->host; - data["time"].SetType(Serialize::DT_INT) << this->time; - - return data; + data.SetType("time", Serialize::Data::DT_INT); data["time"] << this->time; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - NickAlias *na = NickAlias::Find(data["nick"].astr()); + Anope::string snick; + data["nick"] >> snick; + + NickAlias *na = NickAlias::Find(snick); if (na == NULL) return NULL; diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index ce92582f6..3a73772c1 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -28,23 +28,23 @@ struct AJoinEntry : Serializable AJoinEntry() : Serializable("AJoinEntry") { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &sd) const anope_override { - Serialize::Data sd; - if (!this->owner) - return sd; + return; sd["owner"] << this->owner->display; sd["channel"] << this->channel; sd["key"] << this->key; - - return sd; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - NickCore *nc = NickCore::Find(sd["owner"].astr()); + Anope::string sowner; + + sd["owner"] >> sowner; + + NickCore *nc = NickCore::Find(sowner); if (nc == NULL) return NULL; diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 1e088a425..b6dd672a3 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -23,20 +23,22 @@ struct NSMiscData : ExtensibleItem, Serializable { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &sdata) const anope_override { - Serialize::Data sdata; - sdata["nc"] << this->nc->display; sdata["name"] << this->name; sdata["data"] << this->data; - - return sdata; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - NickCore *nc = NickCore::Find(data["nc"].astr()); + Anope::string snc, sname, sdata; + + data["nc"] >> snc; + data["name"] >> sname; + data["data"] >> sdata; + + NickCore *nc = NickCore::Find(snc); if (nc == NULL) return NULL; @@ -50,8 +52,8 @@ struct NSMiscData : ExtensibleItem, Serializable } else { - d = new NSMiscData(nc, data["name"].astr(), data["data"].astr()); - nc->Extend(data["name"].astr(), d); + d = new NSMiscData(nc, sname, sdata); + nc->Extend(sname, d); } return d; diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 6ff355437..63710ccca 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -22,19 +22,19 @@ struct NickSuspend : ExtensibleItem, Serializable { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &sd) const anope_override { - Serialize::Data sd; - sd["nick"] << this->nick; sd["when"] << this->when; - - return sd; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - const NickAlias *na = NickAlias::Find(sd["nick"].astr()); + Anope::string snick; + + sd["nick"] >> snick; + + const NickAlias *na = NickAlias::Find(snick); if (na == NULL) return NULL; diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index 769a42f26..6e5689396 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -49,17 +49,13 @@ class DNSServer : public Serializable } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["server_name"] << server_name; for (unsigned i = 0; i < ips.size(); ++i) data["ip" + stringify(i)] << ips[i]; data["limit"] << limit; data["pooled"] << pooled; - - return data; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) @@ -72,12 +68,16 @@ class DNSServer : public Serializable req = new DNSServer(); data["server_name"] >> req->server_name; - for (unsigned i = 0; data.count("ip" + stringify(i)); ++i) + + for (unsigned i = 0; true; ++i) { Anope::string ip_str; data["ip" + stringify(i)] >> ip_str; + if (ip_str.empty()) + break; req->ips.push_back(ip_str); } + data["limit"] >> req->limit; data["pooled"] >> req->pooled; diff --git a/modules/commands/os_forbid.h b/modules/commands/os_forbid.h index 1fce928db..07619f65e 100644 --- a/modules/commands/os_forbid.h +++ b/modules/commands/os_forbid.h @@ -19,7 +19,7 @@ struct ForbidData : Serializable ForbidType type; ForbidData() : Serializable("ForbidData") { } - Serialize::Data Serialize() const anope_override; + void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -39,18 +39,14 @@ class ForbidService : public Service static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid"); -Serialize::Data ForbidData::Serialize() const +void ForbidData::Serialize(Serialize::Data &data) const { - Serialize::Data data; - data["mask"] << this->mask; data["creator"] << this->creator; data["reason"] << this->reason; data["created"] << this->created; data["expires"] << this->expires; data["type"] << this->type; - - return data; } Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/commands/os_ignore.h b/modules/commands/os_ignore.h index 003d88b5b..1990d95c4 100644 --- a/modules/commands/os_ignore.h +++ b/modules/commands/os_ignore.h @@ -18,7 +18,7 @@ struct IgnoreData : Serializable time_t time; /* When do we stop ignoring them? */ IgnoreData() : Serializable("IgnoreData") { } - Serialize::Data Serialize() const anope_override; + void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -43,16 +43,12 @@ class IgnoreService : public Service static ServiceReference<IgnoreService> ignore_service("IgnoreService", "ignore"); -Serialize::Data IgnoreData::Serialize() const +void IgnoreData::Serialize(Serialize::Data &data) const { - Serialize::Data data; - data["mask"] << this->mask; data["creator"] << this->creator; data["reason"] << this->reason; data["time"] << this->time; - - return data; } Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data) @@ -70,9 +66,14 @@ Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data) return ign; } + Anope::string smask, screator, sreason; time_t t; + + data["mask"] >> smask; + data["creator"] >> screator; + data["reason"] >> sreason; data["time"] >> t; - return ignore_service->AddIgnore(data["mask"].astr(), data["creator"].astr(), data["reason"].astr(), t); + return ignore_service->AddIgnore(smask, screator, sreason, t); } diff --git a/modules/commands/os_news.h b/modules/commands/os_news.h index 44525b963..b1e717455 100644 --- a/modules/commands/os_news.h +++ b/modules/commands/os_news.h @@ -23,7 +23,7 @@ struct NewsItem : Serializable time_t time; NewsItem() : Serializable("NewsItem") { } - Serialize::Data Serialize() const anope_override; + void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -41,16 +41,12 @@ class NewsService : public Service static ServiceReference<NewsService> news_service("NewsService", "news"); -Serialize::Data NewsItem::Serialize() const +void NewsItem::Serialize(Serialize::Data &data) const { - Serialize::Data data; - data["type"] << this->type; data["text"] << this->text; data["who"] << this->who; data["time"] << this->time; - - return data; } Serializable* NewsItem::Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index 882455898..b014a1271 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -17,22 +17,23 @@ struct MyOper : Oper, Serializable { MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["name"] << this->name; data["type"] << this->ot->GetName(); - - return data; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - OperType *ot = OperType::Find(data["type"].astr()); + Anope::string stype, sname; + + data["type"] >> stype; + data["name"] >> sname; + + OperType *ot = OperType::Find(stype); if (ot == NULL) return NULL; - NickCore *nc = NickCore::Find(data["name"].astr()); + NickCore *nc = NickCore::Find(sname); if (nc == NULL) return NULL; diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h index 7304b21ae..6d1dd917d 100644 --- a/modules/commands/os_session.h +++ b/modules/commands/os_session.h @@ -20,7 +20,7 @@ struct Exception : Serializable time_t expires; /* Time when it expires. 0 == no expiry */ Exception() : Serializable("Exception") { } - Serialize::Data Serialize() const anope_override; + void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; @@ -53,18 +53,14 @@ class SessionService : public Service static ServiceReference<SessionService> session_service("SessionService", "session"); -Serialize::Data Exception::Serialize() const +void Exception::Serialize(Serialize::Data &data) const { - Serialize::Data data; - data["mask"] << this->mask; data["limit"] << this->limit; data["who"] << this->who; data["reason"] << this->reason; data["time"] << this->time; data["expires"] << this->expires; - - return data; } Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index bb029eed9..18e2e89fd 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -18,14 +18,10 @@ struct Stats : Serializable { Stats() : Serializable("Stats") { } - Serialize::Data Serialize() const anope_override + void Serialize(Serialize::Data &data) const anope_override { - Serialize::Data data; - data["maxusercnt"] << MaxUserCount; data["maxusertime"] << MaxUserTime; - - return data; } static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) |