mirror of
https://github.com/anope/anope.git
synced 2026-07-07 20:43:14 +02:00
Move serialization from Serializable to a Serialize::Type child.
This commit is contained in:
@@ -18,15 +18,25 @@ struct BadWordImpl final
|
||||
{
|
||||
BadWordImpl() : Serializable("BadWord") { }
|
||||
~BadWordImpl() override;
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct BadWordTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
BadWordTypeImpl()
|
||||
: Serialize::Type("BadWord")
|
||||
{
|
||||
data.Store("ci", this->chan);
|
||||
data.Store("word", this->word);
|
||||
data.Store("type", this->type);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *bw = static_cast<const BadWordImpl *>(obj);
|
||||
data.Store("ci", bw->chan);
|
||||
data.Store("word", bw->word);
|
||||
data.Store("type", bw->type);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &) const override;
|
||||
};
|
||||
|
||||
struct BadWordsImpl final
|
||||
@@ -117,7 +127,7 @@ BadWordImpl::~BadWordImpl()
|
||||
}
|
||||
}
|
||||
|
||||
Serializable *BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *BadWordTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci, sword;
|
||||
|
||||
@@ -464,11 +474,13 @@ class BSBadwords final
|
||||
{
|
||||
CommandBSBadwords commandbsbadwords;
|
||||
ExtensibleItem<BadWordsImpl> badwords;
|
||||
Serialize::Type badword_type;
|
||||
BadWordTypeImpl badword_type;
|
||||
|
||||
public:
|
||||
BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandbsbadwords(this), badwords(this, "badwords"), badword_type("BadWord", BadWordImpl::Unserialize)
|
||||
BSBadwords(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandbsbadwords(this)
|
||||
, badwords(this, "badwords")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,16 +29,26 @@ struct EntryMsgImpl final
|
||||
}
|
||||
|
||||
~EntryMsgImpl() override;
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct EntryMsgTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
EntryMsgTypeImpl()
|
||||
: Serialize::Type("EntryMsg")
|
||||
{
|
||||
data.Store("ci", this->chan);
|
||||
data.Store("creator", this->creator);
|
||||
data.Store("message", this->message);
|
||||
data.Store("when", this->when);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *msg = static_cast<const EntryMsgImpl *>(obj);
|
||||
data.Store("ci", msg->chan);
|
||||
data.Store("creator", msg->creator);
|
||||
data.Store("message", msg->message);
|
||||
data.Store("when", msg->when);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
struct EntryMessageListImpl final
|
||||
@@ -68,7 +78,7 @@ EntryMsgImpl::~EntryMsgImpl()
|
||||
}
|
||||
|
||||
|
||||
Serializable *EntryMsgImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *EntryMsgTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci, screator, smessage;
|
||||
time_t swhen;
|
||||
@@ -264,12 +274,13 @@ class CSEntryMessage final
|
||||
{
|
||||
CommandEntryMessage commandentrymsg;
|
||||
ExtensibleItem<EntryMessageListImpl> eml;
|
||||
Serialize::Type entrymsg_type;
|
||||
EntryMsgTypeImpl entrymsg_type;
|
||||
|
||||
public:
|
||||
CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandentrymsg(this),
|
||||
eml(this, "entrymsg"), entrymsg_type("EntryMsg", EntryMsgImpl::Unserialize)
|
||||
CSEntryMessage(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandentrymsg(this)
|
||||
, eml(this, "entrymsg")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+26
-15
@@ -34,20 +34,30 @@ struct LogSettingImpl final
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct LogSettingTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
LogSettingTypeImpl()
|
||||
: Serialize::Type("LogSetting")
|
||||
{
|
||||
data.Store("ci", chan);
|
||||
data.Store("service_name", service_name);
|
||||
data.Store("command_service", command_service);
|
||||
data.Store("command_name", command_name);
|
||||
data.Store("method", method);
|
||||
data.Store("extra", extra);
|
||||
data.Store("creator", creator);
|
||||
data.Store("created", created);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *ls = static_cast<const LogSettingImpl *>(obj);
|
||||
data.Store("ci", ls->chan);
|
||||
data.Store("service_name", ls->service_name);
|
||||
data.Store("command_service", ls->command_service);
|
||||
data.Store("command_name", ls->command_name);
|
||||
data.Store("method", ls->method);
|
||||
data.Store("extra", ls->extra);
|
||||
data.Store("creator", ls->creator);
|
||||
data.Store("created", ls->created);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string sci;
|
||||
data["ci"] >> sci;
|
||||
@@ -291,7 +301,7 @@ class CSLog final
|
||||
ServiceReference<MemoServService> MSService;
|
||||
CommandCSLog commandcslog;
|
||||
ExtensibleItem<LogSettingsImpl> logsettings;
|
||||
Serialize::Type logsetting_type;
|
||||
LogSettingTypeImpl logsetting_type;
|
||||
|
||||
struct LogDefault final
|
||||
{
|
||||
@@ -301,11 +311,12 @@ class CSLog final
|
||||
std::vector<LogDefault> defaults;
|
||||
|
||||
public:
|
||||
CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
MSService("MemoServService", "MemoServ"), commandcslog(this),
|
||||
logsettings(this, "logsettings"), logsetting_type("LogSetting", LogSettingImpl::Unserialize)
|
||||
CSLog(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, MSService("MemoServService", "MemoServ")
|
||||
, commandcslog(this)
|
||||
, logsettings(this, "logsettings")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
|
||||
@@ -30,9 +30,17 @@ struct ModeLockImpl final
|
||||
ml->RemoveMLock(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
struct ModeLockTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
ModeLockTypeImpl()
|
||||
: Serialize::Type("ModeLock")
|
||||
{
|
||||
}
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
struct ModeLocksImpl final
|
||||
@@ -203,17 +211,18 @@ struct ModeLocksImpl final
|
||||
}
|
||||
};
|
||||
|
||||
void ModeLockImpl::Serialize(Serialize::Data &data) const
|
||||
void ModeLockTypeImpl::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
data.Store("ci", this->ci);
|
||||
data.Store("set", this->set);
|
||||
data.Store("name", this->name);
|
||||
data.Store("param", this->param);
|
||||
data.Store("setter", this->setter);
|
||||
data.Store("created", this->created);
|
||||
const auto *ml = static_cast<const ModeLockImpl *>(obj);
|
||||
data.Store("ci", ml->ci);
|
||||
data.Store("set", ml->set);
|
||||
data.Store("name", ml->name);
|
||||
data.Store("param", ml->param);
|
||||
data.Store("setter", ml->setter);
|
||||
data.Store("created", ml->created);
|
||||
}
|
||||
|
||||
Serializable *ModeLockImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *ModeLockTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci;
|
||||
|
||||
@@ -935,15 +944,15 @@ class CSMode final
|
||||
CommandCSMode commandcsmode;
|
||||
CommandCSModes commandcsmodes;
|
||||
ExtensibleItem<ModeLocksImpl> modelocks;
|
||||
Serialize::Type modelocks_type;
|
||||
ModeLockTypeImpl modelocks_type;
|
||||
|
||||
public:
|
||||
CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandcsmode(this), commandcsmodes(this),
|
||||
modelocks(this, "modelocks"),
|
||||
modelocks_type("ModeLock", ModeLockImpl::Unserialize)
|
||||
CSMode(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandcsmode(this)
|
||||
, commandcsmodes(this)
|
||||
, modelocks(this, "modelocks")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnReload(Configuration::Conf &conf) override
|
||||
|
||||
@@ -43,19 +43,29 @@ struct SeenInfo final
|
||||
if (iter != database.end() && iter->second == this)
|
||||
database.erase(iter);
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct SeenInfoType final
|
||||
: Serialize::Type
|
||||
{
|
||||
SeenInfoType()
|
||||
: Serialize::Type("SeenInfo")
|
||||
{
|
||||
data.Store("nick", nick);
|
||||
data.Store("vhost", vhost);
|
||||
data.Store("type", type);
|
||||
data.Store("nick2", nick2);
|
||||
data.Store("channel", channel);
|
||||
data.Store("message", message);
|
||||
data.Store("last", last);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *s = static_cast<const SeenInfo *>(obj);
|
||||
data.Store("nick", s->nick);
|
||||
data.Store("vhost", s->vhost);
|
||||
data.Store("type", s->type);
|
||||
data.Store("nick2", s->nick2);
|
||||
data.Store("channel", s->channel);
|
||||
data.Store("message", s->message);
|
||||
data.Store("last", s->last);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
|
||||
@@ -374,11 +384,14 @@ public:
|
||||
class CSSeen final
|
||||
: public Module
|
||||
{
|
||||
Serialize::Type seeninfo_type;
|
||||
SeenInfoType seeninfo_type;
|
||||
CommandSeen commandseen;
|
||||
CommandOSSeen commandosseen;
|
||||
public:
|
||||
CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this)
|
||||
CSSeen(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandseen(this)
|
||||
, commandosseen(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,25 @@ struct CSMiscData final
|
||||
name = n;
|
||||
data = d;
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &sdata) const override
|
||||
struct CSMiscDataType
|
||||
: Serialize::Type
|
||||
{
|
||||
CSMiscDataType()
|
||||
: Serialize::Type("CSMiscData")
|
||||
{
|
||||
sdata.Store("ci", this->object);
|
||||
sdata.Store("name", this->name);
|
||||
sdata.Store("data", this->data);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &sdata) const override
|
||||
{
|
||||
const auto *d = static_cast<const CSMiscData *>(obj);
|
||||
sdata.Store("ci", d->object);
|
||||
sdata.Store("name", d->name);
|
||||
sdata.Store("data", d->data);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string sci, sname, sdata;
|
||||
|
||||
@@ -172,11 +182,12 @@ class CSSetMisc final
|
||||
: public Module
|
||||
{
|
||||
CommandCSSetMisc commandcssetmisc;
|
||||
Serialize::Type csmiscdata_type;
|
||||
CSMiscDataType csmiscdata_type;
|
||||
|
||||
public:
|
||||
CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandcssetmisc(this), csmiscdata_type("CSMiscData", CSMiscData::Unserialize)
|
||||
CSSetMisc(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandcssetmisc(this)
|
||||
{
|
||||
me = this;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,27 @@ struct CSSuspendInfo final
|
||||
, Serializable
|
||||
{
|
||||
CSSuspendInfo(Extensible *) : Serializable("CSSuspendInfo") { }
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct CSSuspendInfoType final
|
||||
: Serialize::Type
|
||||
{
|
||||
CSSuspendInfoType()
|
||||
: Serialize::Type("CSSuspendInfo")
|
||||
{
|
||||
data.Store("chan", what);
|
||||
data.Store("by", by);
|
||||
data.Store("reason", reason);
|
||||
data.Store("time", when);
|
||||
data.Store("expires", expires);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *si = static_cast<const CSSuspendInfo *>(obj);
|
||||
data.Store("chan", si->what);
|
||||
data.Store("by", si->by);
|
||||
data.Store("reason", si->reason);
|
||||
data.Store("time", si->when);
|
||||
data.Store("expires", si->expires);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string schan;
|
||||
data["chan"] >> schan;
|
||||
@@ -203,7 +213,7 @@ class CSSuspend final
|
||||
CommandCSSuspend commandcssuspend;
|
||||
CommandCSUnSuspend commandcsunsuspend;
|
||||
ExtensibleItem<CSSuspendInfo> suspend;
|
||||
Serialize::Type suspend_type;
|
||||
CSSuspendInfoType suspend_type;
|
||||
std::vector<Anope::string> show;
|
||||
|
||||
struct trim final
|
||||
@@ -227,9 +237,11 @@ class CSSuspend final
|
||||
}
|
||||
|
||||
public:
|
||||
CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandcssuspend(this), commandcsunsuspend(this), suspend(this, "CS_SUSPENDED"),
|
||||
suspend_type("CSSuspendInfo", CSSuspendInfo::Unserialize)
|
||||
CSSuspend(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandcssuspend(this)
|
||||
, commandcsunsuspend(this)
|
||||
, suspend(this, "CS_SUSPENDED")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ public:
|
||||
*data.fs << "OBJECT " << s_type->GetName();
|
||||
if (base->id)
|
||||
*data.fs << "\nID " << base->id;
|
||||
base->Serialize(data);
|
||||
s_type->Serialize(base, data);
|
||||
*data.fs << "\nEND\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
else
|
||||
{
|
||||
Data data;
|
||||
obj->Serialize(data);
|
||||
t->Serialize(obj, data);
|
||||
|
||||
if (obj->IsCached(data))
|
||||
return;
|
||||
@@ -402,7 +402,7 @@ void Updater::OnResult(const Reply &r)
|
||||
}
|
||||
|
||||
Data data;
|
||||
obj->Serialize(data);
|
||||
st->Serialize(obj, data);
|
||||
|
||||
/* Transaction start */
|
||||
me->redis->StartTransaction();
|
||||
@@ -526,8 +526,7 @@ void SubscriptionListener::OnResult(const Reply &r)
|
||||
Log(LOG_DEBUG) << "redis: notify: deleting object id " << obj_id << " of type " << type;
|
||||
|
||||
Data data;
|
||||
|
||||
s->Serialize(data);
|
||||
s_type->Serialize(s, data);
|
||||
|
||||
/* Transaction start */
|
||||
me->redis->StartTransaction();
|
||||
@@ -578,8 +577,7 @@ void ModifiedObject::OnResult(const Reply &r)
|
||||
if (obj)
|
||||
{
|
||||
Data data;
|
||||
|
||||
obj->Serialize(data);
|
||||
st->Serialize(obj, data);
|
||||
|
||||
for (auto &[key, value] : data.data)
|
||||
{
|
||||
|
||||
@@ -113,8 +113,12 @@ public:
|
||||
{
|
||||
if (this->sql)
|
||||
{
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
Data data;
|
||||
obj->Serialize(data);
|
||||
s_type->Serialize(obj, data);
|
||||
|
||||
if (obj->IsCached(data))
|
||||
continue;
|
||||
@@ -125,10 +129,6 @@ public:
|
||||
if (!this->loaded && !this->imported && !this->import)
|
||||
continue;
|
||||
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
auto create = this->sql->CreateTable(GetTableName(s_type), data);
|
||||
auto insert = this->sql->BuildInsert(GetTableName(s_type), obj->id, data);
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
*/
|
||||
|
||||
Data data2;
|
||||
obj->Serialize(data2);
|
||||
sb->Serialize(obj, data2);
|
||||
obj->UpdateCache(data2); /* We know this is the most up to date copy */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,18 +93,18 @@ public:
|
||||
{
|
||||
if (obj && this->SQL)
|
||||
{
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
Data data;
|
||||
obj->Serialize(data);
|
||||
s_type->Serialize(obj, data);
|
||||
|
||||
if (obj->IsCached(data))
|
||||
continue;
|
||||
|
||||
obj->UpdateCache(data);
|
||||
|
||||
Serialize::Type *s_type = obj->GetSerializableType();
|
||||
if (!s_type)
|
||||
continue;
|
||||
|
||||
auto create = this->SQL->CreateTable(GetTableName(s_type), data);
|
||||
for (const auto &query : create)
|
||||
this->RunQuery(query);
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
*/
|
||||
|
||||
Data data2;
|
||||
new_s->Serialize(data2);
|
||||
obj->Serialize(new_s, data2);
|
||||
new_s->UpdateCache(data2); /* We know this is the most up to date copy */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,16 +29,26 @@ struct HostRequestImpl final
|
||||
: Serializable("HostRequest")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct HostRequestTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
HostRequestTypeImpl()
|
||||
: Serialize::Type("HostRequest")
|
||||
{
|
||||
data.Store("nick", this->nick);
|
||||
data.Store("ident", this->ident);
|
||||
data.Store("host", this->host);
|
||||
data.Store("time", this->time);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *req = static_cast<const HostRequestImpl *>(obj);
|
||||
data.Store("nick", req->nick);
|
||||
data.Store("ident", req->ident);
|
||||
data.Store("host", req->host);
|
||||
data.Store("time", req->time);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
data["nick"] >> snick;
|
||||
@@ -360,12 +370,16 @@ class HSRequest final
|
||||
CommandHSReject commandhsreject;
|
||||
CommandHSWaiting commandhswaiting;
|
||||
ExtensibleItem<HostRequestImpl> hostrequest;
|
||||
Serialize::Type request_type;
|
||||
HostRequestTypeImpl request_type;
|
||||
|
||||
public:
|
||||
HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandhsrequest(this), commandhsactive(this),
|
||||
commandhsreject(this), commandhswaiting(this), hostrequest(this, "hostrequest"), request_type("HostRequest", HostRequestImpl::Unserialize)
|
||||
HSRequest(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandhsrequest(this)
|
||||
, commandhsactive(this)
|
||||
, commandhsreject(this)
|
||||
, commandhswaiting(this)
|
||||
, hostrequest(this, "hostrequest")
|
||||
{
|
||||
if (!IRCD || !IRCD->CanSetVHost)
|
||||
throw ModuleException("Your IRCd does not support vhosts");
|
||||
|
||||
@@ -39,18 +39,28 @@ struct AJoinEntry final
|
||||
(*channels)->erase(it);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct AJoinEntryType final
|
||||
: public Serialize::Type
|
||||
{
|
||||
AJoinEntryType()
|
||||
: Serialize::Type("AJoinEntry")
|
||||
{
|
||||
if (!this->owner)
|
||||
return;
|
||||
|
||||
data.Store("owner", this->owner->display);
|
||||
data.Store("channel", this->channel);
|
||||
data.Store("key", this->key);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &sd)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *aj = static_cast<const AJoinEntry *>(obj);
|
||||
if (!aj->owner)
|
||||
return;
|
||||
|
||||
data.Store("owner", aj->owner->display);
|
||||
data.Store("channel", aj->channel);
|
||||
data.Store("key", aj->key);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &sd) const override
|
||||
{
|
||||
Anope::string sowner;
|
||||
|
||||
@@ -305,17 +315,16 @@ class NSAJoin final
|
||||
{
|
||||
CommandNSAJoin commandnsajoin;
|
||||
ExtensibleItem<AJoinList> ajoinlist;
|
||||
Serialize::Type ajoinentry_type;
|
||||
AJoinEntryType ajoinentry_type;
|
||||
|
||||
public:
|
||||
NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandnsajoin(this), ajoinlist(this, "ajoinlist"),
|
||||
ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize)
|
||||
NSAJoin(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandnsajoin(this)
|
||||
, ajoinlist(this, "ajoinlist")
|
||||
{
|
||||
|
||||
if (!IRCD || !IRCD->CanSVSJoin)
|
||||
throw ModuleException("Your IRCd does not support SVSJOIN");
|
||||
|
||||
}
|
||||
|
||||
void OnUserLogin(User *u) override
|
||||
|
||||
@@ -43,15 +43,25 @@ struct NSMiscData final
|
||||
name = n;
|
||||
data = d;
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &sdata) const override
|
||||
struct NSMiscDataType final
|
||||
: Serialize::Type
|
||||
{
|
||||
NSMiscDataType()
|
||||
: Serialize::Type("NSMiscData")
|
||||
{
|
||||
sdata.Store("nc", this->object);
|
||||
sdata.Store("name", this->name);
|
||||
sdata.Store("data", this->data);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &sdata) const override
|
||||
{
|
||||
const auto *d = static_cast<const NSMiscData *>(obj);
|
||||
sdata.Store("nc", d->object);
|
||||
sdata.Store("name", d->name);
|
||||
sdata.Store("data", d->data);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snc, sname, sdata;
|
||||
|
||||
@@ -185,11 +195,13 @@ class NSSetMisc final
|
||||
{
|
||||
CommandNSSetMisc commandnssetmisc;
|
||||
CommandNSSASetMisc commandnssasetmisc;
|
||||
Serialize::Type nsmiscdata_type;
|
||||
NSMiscDataType nsmiscdata_type;
|
||||
|
||||
public:
|
||||
NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandnssetmisc(this), commandnssasetmisc(this), nsmiscdata_type("NSMiscData", NSMiscData::Unserialize)
|
||||
NSSetMisc(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandnssetmisc(this)
|
||||
, commandnssasetmisc(this)
|
||||
{
|
||||
me = this;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,27 @@ struct NSSuspendInfo final
|
||||
, Serializable
|
||||
{
|
||||
NSSuspendInfo(Extensible *) : Serializable("NSSuspendInfo") { }
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct NSSuspendInfoType final
|
||||
: Serialize::Type
|
||||
{
|
||||
NSSuspendInfoType()
|
||||
: Serialize::Type("NSSuspendInfo")
|
||||
{
|
||||
data.Store("nick", what);
|
||||
data.Store("by", by);
|
||||
data.Store("reason", reason);
|
||||
data.Store("time", when);
|
||||
data.Store("expires", expires);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *si = static_cast<const NSSuspendInfo *>(obj);
|
||||
data.Store("nick", si->what);
|
||||
data.Store("by", si->by);
|
||||
data.Store("reason", si->reason);
|
||||
data.Store("time", si->when);
|
||||
data.Store("expires", si->expires);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string snick;
|
||||
data["nick"] >> snick;
|
||||
@@ -211,7 +221,7 @@ class NSSuspend final
|
||||
CommandNSSuspend commandnssuspend;
|
||||
CommandNSUnSuspend commandnsunsuspend;
|
||||
ExtensibleItem<NSSuspendInfo> suspend;
|
||||
Serialize::Type suspend_type;
|
||||
NSSuspendInfoType suspend_type;
|
||||
std::vector<Anope::string> show;
|
||||
|
||||
struct trim final
|
||||
@@ -234,9 +244,11 @@ class NSSuspend final
|
||||
}
|
||||
|
||||
public:
|
||||
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandnssuspend(this), commandnsunsuspend(this), suspend(this, "NS_SUSPENDED"),
|
||||
suspend_type("NSSuspendInfo", NSSuspendInfo::Unserialize)
|
||||
NSSuspend(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandnssuspend(this)
|
||||
, commandnsunsuspend(this)
|
||||
, suspend(this, "NS_SUSPENDED")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+63
-39
@@ -37,15 +37,38 @@ struct DNSZone final
|
||||
zones->erase(it);
|
||||
}
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
static DNSZone *Find(const Anope::string &name)
|
||||
{
|
||||
data.Store("name", name);
|
||||
for (auto *zone : *zones)
|
||||
{
|
||||
if (zone->name.equals_ci(name))
|
||||
{
|
||||
zone->QueueUpdate();
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct DNSZoneType final
|
||||
: Serialize::Type
|
||||
{
|
||||
DNSZoneType()
|
||||
: Serialize::Type("DNSZone")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *zone = static_cast<const DNSZone *>(obj);
|
||||
data.Store("name", zone->name);
|
||||
unsigned count = 0;
|
||||
for (const auto &server : servers)
|
||||
for (const auto &server : zone->servers)
|
||||
data.Store("server" + Anope::ToString(count++), server);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
DNSZone *zone;
|
||||
Anope::string zone_name;
|
||||
@@ -72,19 +95,6 @@ struct DNSZone final
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
static DNSZone *Find(const Anope::string &name)
|
||||
{
|
||||
for (auto *zone : *zones)
|
||||
{
|
||||
if (zone->name.equals_ci(name))
|
||||
{
|
||||
zone->QueueUpdate();
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
class DNSServer final
|
||||
@@ -99,6 +109,8 @@ class DNSServer final
|
||||
bool active = false;
|
||||
|
||||
public:
|
||||
friend class DNSServerType;
|
||||
|
||||
std::set<Anope::string, ci::less> zones;
|
||||
time_t repool = 0;
|
||||
|
||||
@@ -142,19 +154,40 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
static DNSServer *Find(const Anope::string &s)
|
||||
{
|
||||
data.Store("server_name", server_name);
|
||||
for (unsigned i = 0; i < ips.size(); ++i)
|
||||
data.Store("ip" + Anope::ToString(i), ips[i]);
|
||||
data.Store("limit", limit);
|
||||
data.Store("pooled", pooled);
|
||||
for (auto *serv : *dns_servers)
|
||||
if (serv->GetName().equals_ci(s))
|
||||
{
|
||||
serv->QueueUpdate();
|
||||
return serv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct DNSServerType final
|
||||
: Serialize::Type
|
||||
{
|
||||
DNSServerType()
|
||||
: Serialize::Type("DNSServer")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *req = static_cast<const DNSServer *>(obj);
|
||||
data.Store("server_name", req->server_name);
|
||||
for (unsigned i = 0; i < req->ips.size(); ++i)
|
||||
data.Store("ip" + Anope::ToString(i), req->ips[i]);
|
||||
data.Store("limit", req->limit);
|
||||
data.Store("pooled", req->pooled);
|
||||
unsigned count = 0;
|
||||
for (const auto &zone : zones)
|
||||
for (const auto &zone : req->zones)
|
||||
data.Store("zone" + Anope::ToString(count++), zone);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
DNSServer *req;
|
||||
Anope::string server_name;
|
||||
@@ -193,17 +226,6 @@ public:
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
static DNSServer *Find(const Anope::string &s)
|
||||
{
|
||||
for (auto *serv : *dns_servers)
|
||||
if (serv->GetName().equals_ci(s))
|
||||
{
|
||||
serv->QueueUpdate();
|
||||
return serv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
class CommandOSDNS final
|
||||
@@ -721,7 +743,8 @@ public:
|
||||
class ModuleDNS final
|
||||
: public Module
|
||||
{
|
||||
Serialize::Type zone_type, dns_type;
|
||||
DNSZoneType zone_type;
|
||||
DNSServerType dns_type;
|
||||
CommandOSDNS commandosdns;
|
||||
|
||||
time_t ttl;
|
||||
@@ -734,8 +757,9 @@ class ModuleDNS final
|
||||
time_t last_warn = 0;
|
||||
|
||||
public:
|
||||
ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR),
|
||||
zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this)
|
||||
ModuleDNS(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, EXTRA | VENDOR)
|
||||
, commandosdns(this)
|
||||
{
|
||||
for (auto *s : *dns_servers)
|
||||
{
|
||||
|
||||
@@ -19,21 +19,32 @@ struct ForbidDataImpl final
|
||||
, Serializable
|
||||
{
|
||||
ForbidDataImpl() : Serializable("ForbidData") { }
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
void ForbidDataImpl::Serialize(Serialize::Data &data) const
|
||||
struct ForbidDataTypeImpl final
|
||||
: Serialize::Type
|
||||
{
|
||||
data.Store("mask", this->mask);
|
||||
data.Store("creator", this->creator);
|
||||
data.Store("reason", this->reason);
|
||||
data.Store("created", this->created);
|
||||
data.Store("expires", this->expires);
|
||||
data.Store("type", this->type);
|
||||
ForbidDataTypeImpl()
|
||||
: Serialize::Type("ForbidData")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
void ForbidDataTypeImpl::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *fb = static_cast<const ForbidDataImpl *>(obj);
|
||||
data.Store("mask", fb->mask);
|
||||
data.Store("creator", fb->creator);
|
||||
data.Store("reason", fb->reason);
|
||||
data.Store("created", fb->created);
|
||||
data.Store("expires", fb->expires);
|
||||
data.Store("type", fb->type);
|
||||
}
|
||||
|
||||
Serializable *ForbidDataImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *ForbidDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
if (!forbid_service)
|
||||
return NULL;
|
||||
@@ -465,14 +476,15 @@ class OSForbid final
|
||||
: public Module
|
||||
{
|
||||
MyForbidService forbidService;
|
||||
Serialize::Type forbiddata_type;
|
||||
ForbidDataTypeImpl forbiddata_type;
|
||||
CommandOSForbid commandosforbid;
|
||||
|
||||
public:
|
||||
OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
forbidService(this), forbiddata_type("ForbidData", ForbidDataImpl::Unserialize), commandosforbid(this)
|
||||
OSForbid(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, forbidService(this)
|
||||
, commandosforbid(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnUserConnect(User *u, bool &exempt) override
|
||||
|
||||
@@ -18,8 +18,6 @@ struct IgnoreDataImpl final
|
||||
{
|
||||
IgnoreDataImpl() : Serializable("IgnoreData") { }
|
||||
~IgnoreDataImpl() override;
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
IgnoreDataImpl::~IgnoreDataImpl()
|
||||
@@ -28,15 +26,27 @@ IgnoreDataImpl::~IgnoreDataImpl()
|
||||
ignore_service->DelIgnore(this);
|
||||
}
|
||||
|
||||
void IgnoreDataImpl::Serialize(Serialize::Data &data) const
|
||||
struct IgnoreDataTypeImpl final
|
||||
: public Serialize::Type
|
||||
{
|
||||
data.Store("mask", this->mask);
|
||||
data.Store("creator", this->creator);
|
||||
data.Store("reason", this->reason);
|
||||
data.Store("time", this->time);
|
||||
IgnoreDataTypeImpl()
|
||||
: Serialize::Type("IgnoreData")
|
||||
{
|
||||
}
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
void IgnoreDataTypeImpl::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *ign = static_cast<const IgnoreDataImpl *>(obj);
|
||||
data.Store("mask", ign->mask);
|
||||
data.Store("creator", ign->creator);
|
||||
data.Store("reason", ign->reason);
|
||||
data.Store("time", ign->time);
|
||||
}
|
||||
|
||||
Serializable *IgnoreDataImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *IgnoreDataTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
if (!ignore_service)
|
||||
return NULL;
|
||||
@@ -398,15 +408,16 @@ public:
|
||||
class OSIgnore final
|
||||
: public Module
|
||||
{
|
||||
Serialize::Type ignoredata_type;
|
||||
IgnoreDataTypeImpl ignoredata_type;
|
||||
OSIgnoreService osignoreservice;
|
||||
CommandOSIgnore commandosignore;
|
||||
|
||||
public:
|
||||
OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
ignoredata_type("IgnoreData", IgnoreDataImpl::Unserialize), osignoreservice(this), commandosignore(this)
|
||||
OSIgnore(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, osignoreservice(this)
|
||||
, commandosignore(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Prioritize() override
|
||||
|
||||
@@ -25,16 +25,26 @@ struct OperInfoImpl final
|
||||
}
|
||||
|
||||
~OperInfoImpl() override;
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct OperInfoTypeImpl
|
||||
: Serialize::Type
|
||||
{
|
||||
OperInfoTypeImpl()
|
||||
: Serialize::Type("OperInfo")
|
||||
{
|
||||
data.Store("target", target);
|
||||
data.Store("info", info);
|
||||
data.Store("adder", adder);
|
||||
data.Store("created", created);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *oi = static_cast<const OperInfoImpl *>(obj);
|
||||
data.Store("target", oi->target);
|
||||
data.Store("info", oi->info);
|
||||
data.Store("adder", oi->adder);
|
||||
data.Store("created", oi->created);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
struct OperInfos final
|
||||
@@ -71,7 +81,7 @@ OperInfoImpl::~OperInfoImpl()
|
||||
}
|
||||
}
|
||||
|
||||
Serializable *OperInfoImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *OperInfoTypeImpl::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string starget;
|
||||
data["target"] >> starget;
|
||||
@@ -256,7 +266,7 @@ class OSInfo final
|
||||
{
|
||||
CommandOSInfo commandosinfo;
|
||||
ExtensibleItem<OperInfos> oinfo;
|
||||
Serialize::Type oinfo_type;
|
||||
OperInfoTypeImpl oinfo_type;
|
||||
|
||||
void OnInfo(CommandSource &source, Extensible *e, InfoFormatter &info)
|
||||
{
|
||||
@@ -274,10 +284,11 @@ class OSInfo final
|
||||
}
|
||||
|
||||
public:
|
||||
OSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandosinfo(this), oinfo(this, "operinfo"), oinfo_type("OperInfo", OperInfoImpl::Unserialize)
|
||||
OSInfo(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandosinfo(this)
|
||||
, oinfo(this, "operinfo")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) override
|
||||
|
||||
@@ -64,18 +64,24 @@ struct NewsMessages msgarray[] = {
|
||||
}
|
||||
};
|
||||
|
||||
struct MyNewsItem final
|
||||
: NewsItem
|
||||
struct NewsItemType final
|
||||
: Serialize::Type
|
||||
{
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
NewsItemType()
|
||||
: Serialize::Type("NewsItem")
|
||||
{
|
||||
data.Store("type", this->type);
|
||||
data.Store("text", this->text);
|
||||
data.Store("who", this->who);
|
||||
data.Store("time", this->time);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *ni = static_cast<const NewsItem *>(obj);
|
||||
data.Store("type", ni->type);
|
||||
data.Store("text", ni->text);
|
||||
data.Store("who", ni->who);
|
||||
data.Store("time", ni->time);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
if (!news_service)
|
||||
return NULL;
|
||||
@@ -84,7 +90,7 @@ struct MyNewsItem final
|
||||
if (obj)
|
||||
ni = anope_dynamic_static_cast<NewsItem *>(obj);
|
||||
else
|
||||
ni = new MyNewsItem();
|
||||
ni = new NewsItem();
|
||||
|
||||
unsigned int t;
|
||||
data["type"] >> t;
|
||||
@@ -117,7 +123,7 @@ public:
|
||||
|
||||
NewsItem *CreateNewsItem() override
|
||||
{
|
||||
return new MyNewsItem();
|
||||
return new NewsItem();
|
||||
}
|
||||
|
||||
void AddNewsItem(NewsItem *n) override
|
||||
@@ -200,7 +206,7 @@ protected:
|
||||
if (Anope::ReadOnly)
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
|
||||
NewsItem *news = new MyNewsItem();
|
||||
NewsItem *news = new NewsItem();
|
||||
news->type = ntype;
|
||||
news->text = text;
|
||||
news->time = Anope::CurTime;
|
||||
@@ -382,7 +388,7 @@ class OSNews final
|
||||
: public Module
|
||||
{
|
||||
MyNewsService newsservice;
|
||||
Serialize::Type newsitem_type;
|
||||
NewsItemType newsitem_type;
|
||||
|
||||
CommandOSLogonNews commandoslogonnews;
|
||||
CommandOSOperNews commandosopernews;
|
||||
@@ -442,9 +448,12 @@ class OSNews final
|
||||
}
|
||||
|
||||
public:
|
||||
OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
newsservice(this), newsitem_type("NewsItem", MyNewsItem::Unserialize),
|
||||
commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this)
|
||||
OSNews(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, newsservice(this)
|
||||
, commandoslogonnews(this)
|
||||
, commandosopernews(this)
|
||||
, commandosrandomnews(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,47 @@
|
||||
#include "module.h"
|
||||
#include "modules/operserv/oper.h"
|
||||
|
||||
struct OSOperType
|
||||
: Serialize::Type
|
||||
{
|
||||
OSOperType()
|
||||
: Serialize::Type("Oper")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *myo = static_cast<const MyOper *>(obj);
|
||||
data.Store("name", myo->name);
|
||||
data.Store("type", myo->ot->GetName());
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
Anope::string stype, sname;
|
||||
|
||||
data["type"] >> stype;
|
||||
data["name"] >> sname;
|
||||
|
||||
OperType *ot = OperType::Find(stype);
|
||||
if (ot == NULL)
|
||||
return NULL;
|
||||
NickCore *nc = NickCore::Find(sname);
|
||||
if (nc == NULL)
|
||||
return NULL;
|
||||
|
||||
MyOper *myo;
|
||||
if (obj)
|
||||
myo = anope_dynamic_static_cast<MyOper *>(obj);
|
||||
else
|
||||
myo = new MyOper(nc->display, ot);
|
||||
nc->o = myo;
|
||||
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
|
||||
return myo;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CommandOSOper final
|
||||
: public Command
|
||||
{
|
||||
@@ -222,12 +263,13 @@ public:
|
||||
class OSOper final
|
||||
: public Module
|
||||
{
|
||||
Serialize::Type myoper_type;
|
||||
OSOperType myoper_type;
|
||||
CommandOSOper commandosoper;
|
||||
|
||||
public:
|
||||
OSOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
myoper_type("Oper", MyOper::Unserialize), commandosoper(this)
|
||||
OSOper(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandosoper(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,47 @@ namespace
|
||||
unsigned ipv6_cidr;
|
||||
}
|
||||
|
||||
struct ExceptionType final
|
||||
: public Serialize::Type
|
||||
{
|
||||
ExceptionType()
|
||||
: Serialize::Type("Exception")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
const auto *ex = static_cast<const Exception *>(obj);
|
||||
data.Store("mask", ex->mask);
|
||||
data.Store("limit", ex->limit);
|
||||
data.Store("who", ex->who);
|
||||
data.Store("reason", ex->reason);
|
||||
data.Store("time", ex->time);
|
||||
}
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
if (!session_service)
|
||||
return NULL;
|
||||
|
||||
Exception *ex;
|
||||
if (obj)
|
||||
ex = anope_dynamic_static_cast<Exception *>(obj);
|
||||
else
|
||||
ex = new Exception;
|
||||
data["mask"] >> ex->mask;
|
||||
data["limit"] >> ex->limit;
|
||||
data["who"] >> ex->who;
|
||||
data["reason"] >> ex->reason;
|
||||
data["time"] >> ex->time;
|
||||
data["expires"] >> ex->expires;
|
||||
|
||||
if (!obj)
|
||||
session_service->AddException(ex);
|
||||
return ex;
|
||||
}
|
||||
};
|
||||
|
||||
class MySessionService final
|
||||
: public SessionService
|
||||
{
|
||||
@@ -573,15 +614,19 @@ public:
|
||||
class OSSession final
|
||||
: public Module
|
||||
{
|
||||
Serialize::Type exception_type;
|
||||
ExceptionType exception_type;
|
||||
MySessionService ss;
|
||||
CommandOSSession commandossession;
|
||||
CommandOSException commandosexception;
|
||||
ServiceReference<XLineManager> akills;
|
||||
|
||||
public:
|
||||
OSSession(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
exception_type("Exception", Exception::Unserialize), ss(this), commandossession(this), commandosexception(this), akills("XLineManager", "xlinemanager/sgline")
|
||||
OSSession(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, ss(this)
|
||||
, commandossession(this)
|
||||
, commandosexception(this)
|
||||
, akills("XLineManager", "xlinemanager/sgline")
|
||||
{
|
||||
this->SetPermanent(true);
|
||||
}
|
||||
|
||||
@@ -21,18 +21,27 @@ struct Stats final
|
||||
{
|
||||
me = this;
|
||||
}
|
||||
};
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
struct StatsType final
|
||||
: Serialize::Type
|
||||
{
|
||||
StatsType()
|
||||
: Serialize::Type("Stats")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
data.Store("maxusercnt", MaxUserCount);
|
||||
data.Store("maxusertime", MaxUserTime);
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
|
||||
{
|
||||
data["maxusercnt"] >> MaxUserCount;
|
||||
data["maxusertime"] >> MaxUserTime;
|
||||
return me;
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -316,14 +325,14 @@ class OSStats final
|
||||
: public Module
|
||||
{
|
||||
CommandOSStats commandosstats;
|
||||
Serialize::Type stats_type;
|
||||
StatsType stats_type;
|
||||
Stats stats_saver;
|
||||
|
||||
public:
|
||||
OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandosstats(this), stats_type("Stats", Stats::Unserialize)
|
||||
OSStats(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandosstats(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnUserConnect(User *u, bool &exempt) override
|
||||
|
||||
Reference in New Issue
Block a user