mirror of
https://github.com/anope/anope.git
synced 2026-06-29 04:46:37 +02:00
Move serialization from Serializable to a Serialize::Type child.
This commit is contained in:
+10
-3
@@ -74,6 +74,16 @@ public:
|
||||
class CoreExport ChanAccess
|
||||
: public Serializable
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
Anope::string mask;
|
||||
/* account this access entry is for, if any */
|
||||
Serialize::Reference<NickCore> nc;
|
||||
@@ -97,9 +107,6 @@ public:
|
||||
const Anope::string &Mask() const;
|
||||
NickCore *GetAccount() const;
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
static const unsigned int MAX_DEPTH = 4;
|
||||
|
||||
/** Check if this access entry matches the given user or account
|
||||
|
||||
+20
-6
@@ -32,6 +32,16 @@ class CoreExport NickAlias final
|
||||
: public Serializable
|
||||
, public Extensible
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
Anope::string vhost_ident, vhost_host, vhost_creator;
|
||||
time_t vhost_created = 0;
|
||||
|
||||
@@ -56,9 +66,6 @@ public:
|
||||
NickAlias(const Anope::string &nickname, NickCore *nickcore);
|
||||
~NickAlias();
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Set a vhost for the user
|
||||
* @param ident The ident
|
||||
* @param host The host
|
||||
@@ -116,6 +123,16 @@ class CoreExport NickCore final
|
||||
: public Serializable
|
||||
, public Extensible
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
/* Channels which reference this core in some way (this is on their access list, akick list, is founder, successor, etc) */
|
||||
Serialize::Checker<std::map<ChannelInfo *, int> > chanaccess;
|
||||
/* Unique identifier for the account. */
|
||||
@@ -159,9 +176,6 @@ public:
|
||||
NickCore(const Anope::string &nickdisplay, uint64_t nickid = 0);
|
||||
~NickCore();
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Changes the display for this account
|
||||
* @param na The new display, must be grouped to this account.
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,16 @@ class CoreExport BotInfo final
|
||||
: public User
|
||||
, public Serializable
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
/* Channels this bot is assigned to */
|
||||
Serialize::Checker<std::set<ChannelInfo *> > channels;
|
||||
public:
|
||||
|
||||
+8
-3
@@ -18,15 +18,20 @@ class CoreExport Memo final
|
||||
: public Serializable
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
MemoInfo *mi;
|
||||
bool unread;
|
||||
bool receipt;
|
||||
Memo();
|
||||
~Memo();
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
Anope::string owner;
|
||||
/* When it was sent */
|
||||
time_t time;
|
||||
|
||||
@@ -13,34 +13,4 @@ struct MyOper final
|
||||
, Serializable
|
||||
{
|
||||
MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { }
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
{
|
||||
data.Store("name", this->name);
|
||||
data.Store("type", this->ot->GetName());
|
||||
}
|
||||
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,8 +28,6 @@ struct Exception final
|
||||
time_t expires; /* Time when it expires. 0 == no expiry */
|
||||
|
||||
Exception() : Serializable("Exception") { }
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
class SessionService
|
||||
@@ -59,35 +57,3 @@ public:
|
||||
};
|
||||
|
||||
static ServiceReference<SessionService> session_service("SessionService", "session");
|
||||
|
||||
void Exception::Serialize(Serialize::Data &data) const
|
||||
{
|
||||
data.Store("mask", this->mask);
|
||||
data.Store("limit", this->limit);
|
||||
data.Store("who", this->who);
|
||||
data.Store("reason", this->reason);
|
||||
data.Store("time", this->time);
|
||||
data.Store("expires", this->expires);
|
||||
}
|
||||
|
||||
Serializable *Exception::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
+18
-6
@@ -25,6 +25,14 @@ class CoreExport AutoKick final
|
||||
: public Serializable
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
/* Channel this autokick is on */
|
||||
Serialize::Reference<ChannelInfo> ci;
|
||||
|
||||
@@ -38,8 +46,6 @@ public:
|
||||
|
||||
AutoKick();
|
||||
~AutoKick();
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
/* It matters that Base is here before Extensible (it is inherited by Serializable)
|
||||
@@ -48,9 +54,18 @@ class CoreExport ChannelInfo final
|
||||
: public Serializable
|
||||
, public Extensible
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
/* channels who reference this one */
|
||||
Anope::map<int> references;
|
||||
private:
|
||||
Serialize::Reference<NickCore> founder; /* Channel founder */
|
||||
Serialize::Reference<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
|
||||
Serialize::Checker<std::vector<ChanAccess *> > access; /* List of authorized users */
|
||||
@@ -97,9 +112,6 @@ public:
|
||||
~ChannelInfo();
|
||||
ChannelInfo &operator=(const ChannelInfo &) = default;
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Change the founder of the channel
|
||||
* @params nc The new founder
|
||||
*/
|
||||
|
||||
+4
-9
@@ -123,8 +123,6 @@ public:
|
||||
*/
|
||||
Serialize::Type *GetSerializableType() const { return this->s_type; }
|
||||
|
||||
virtual void Serialize(Serialize::Data &data) const = 0;
|
||||
|
||||
static const std::list<Serializable *> &GetItems();
|
||||
};
|
||||
|
||||
@@ -132,17 +130,14 @@ public:
|
||||
* of class that inherits from Serializable. Used for unserializing objects
|
||||
* of this type, as it requires a function pointer to a static member function.
|
||||
*/
|
||||
class CoreExport Serialize::Type final
|
||||
class CoreExport Serialize::Type
|
||||
: public Base
|
||||
{
|
||||
typedef Serializable *(*unserialize_func)(Serializable *obj, Serialize::Data &);
|
||||
|
||||
static std::vector<Anope::string> TypeOrder;
|
||||
static std::map<Anope::string, Serialize::Type *> Types;
|
||||
|
||||
/* The name of this type, should be a class name */
|
||||
Anope::string name;
|
||||
unserialize_func unserialize;
|
||||
/* Owner of this type. Used for placing objects of this type in separate databases
|
||||
* based on what module, if any, owns it.
|
||||
*/
|
||||
@@ -160,10 +155,9 @@ public:
|
||||
|
||||
/** Creates a new serializable type
|
||||
* @param n Type name
|
||||
* @param f Func to unserialize objects
|
||||
* @param owner Owner of this type. Leave NULL for the core.
|
||||
*/
|
||||
Type(const Anope::string &n, unserialize_func f, Module *owner = NULL);
|
||||
Type(const Anope::string &n, Module *owner = NULL);
|
||||
~Type();
|
||||
|
||||
/** Gets the name for this type
|
||||
@@ -177,7 +171,8 @@ public:
|
||||
* @param data The data to unserialize
|
||||
* @return The unserialized object. If obj != NULL this should be obj.
|
||||
*/
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
virtual void Serialize(const Serializable *obj, Serialize::Data &data) const = 0;
|
||||
virtual Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const = 0;
|
||||
|
||||
/** Check if this object type has any pending changes and update them.
|
||||
*/
|
||||
|
||||
+10
-3
@@ -16,6 +16,16 @@
|
||||
class CoreExport XLine final
|
||||
: public Serializable
|
||||
{
|
||||
public:
|
||||
struct Type final
|
||||
: public Serialize::Type
|
||||
{
|
||||
Type();
|
||||
void Serialize(const Serializable *obj, Serialize::Data &data) const override;
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override;
|
||||
};
|
||||
|
||||
private:
|
||||
void Init();
|
||||
Anope::string nick, user, host, real;
|
||||
public:
|
||||
@@ -43,9 +53,6 @@ public:
|
||||
|
||||
bool HasNickOrReal() const;
|
||||
bool IsRegex() const;
|
||||
|
||||
void Serialize(Serialize::Data &data) const override;
|
||||
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
/* Managers XLines. There is one XLineManager per type of XLine. */
|
||||
|
||||
@@ -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
|
||||
|
||||
+17
-10
@@ -158,19 +158,26 @@ NickCore *ChanAccess::GetAccount() const
|
||||
return nc;
|
||||
}
|
||||
|
||||
void ChanAccess::Serialize(Serialize::Data &data) const
|
||||
|
||||
ChanAccess::Type::Type()
|
||||
: Serialize::Type("ChanAccess")
|
||||
{
|
||||
data.Store("provider", this->provider->name);
|
||||
data.Store("ci", this->ci->name);
|
||||
data.Store("mask", this->Mask());
|
||||
data.Store("creator", this->creator);
|
||||
data.Store("description", this->description);
|
||||
data.Store("last_seen", this->last_seen);
|
||||
data.Store("created", this->created);
|
||||
data.Store("data", this->AccessSerialize());
|
||||
}
|
||||
|
||||
Serializable *ChanAccess::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void ChanAccess::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *access = static_cast<const ChanAccess *>(obj);
|
||||
data.Store("provider", access->provider->name);
|
||||
data.Store("ci", access->ci->name);
|
||||
data.Store("mask", access->Mask());
|
||||
data.Store("creator", access->creator);
|
||||
data.Store("description", access->description);
|
||||
data.Store("last_seen", access->last_seen);
|
||||
data.Store("created", access->created);
|
||||
data.Store("data", access->AccessSerialize());
|
||||
}
|
||||
|
||||
Serializable *ChanAccess::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string provider, chan;
|
||||
|
||||
|
||||
+16
-10
@@ -84,19 +84,25 @@ BotInfo::~BotInfo()
|
||||
BotListByUID->erase(this->uid);
|
||||
}
|
||||
|
||||
void BotInfo::Serialize(Serialize::Data &data) const
|
||||
BotInfo::Type::Type()
|
||||
: Serialize::Type("BotInfo")
|
||||
{
|
||||
data.Store("nick", this->nick);
|
||||
data.Store("user", this->ident);
|
||||
data.Store("host", this->host);
|
||||
data.Store("realname", this->realname);
|
||||
data.Store("created", this->created);
|
||||
data.Store("oper_only", this->oper_only);
|
||||
|
||||
Extensible::ExtensibleSerialize(this, this, data);
|
||||
}
|
||||
|
||||
Serializable *BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void BotInfo::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *bi = static_cast<const BotInfo *>(obj);
|
||||
data.Store("nick", bi->nick);
|
||||
data.Store("user", bi->ident);
|
||||
data.Store("host", bi->host);
|
||||
data.Store("realname", bi->realname);
|
||||
data.Store("created", bi->created);
|
||||
data.Store("oper_only", bi->oper_only);
|
||||
|
||||
Extensible::ExtensibleSerialize(bi, bi, data);
|
||||
}
|
||||
|
||||
Serializable *BotInfo::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string nick, user, host, realname, flags;
|
||||
|
||||
|
||||
+14
-8
@@ -34,17 +34,23 @@ Memo::~Memo()
|
||||
}
|
||||
}
|
||||
|
||||
void Memo::Serialize(Serialize::Data &data) const
|
||||
Memo::Type::Type()
|
||||
: Serialize::Type("Memo")
|
||||
{
|
||||
data.Store("owner", this->owner);
|
||||
data.Store("time", this->time);
|
||||
data.Store("sender", this->sender);
|
||||
data.Store("text", this->text);
|
||||
data.Store("unread", this->unread);
|
||||
data.Store("receipt", this->receipt);
|
||||
}
|
||||
|
||||
Serializable *Memo::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void Memo::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *m = static_cast<const Memo *>(obj);
|
||||
data.Store("owner", m->owner);
|
||||
data.Store("time", m->time);
|
||||
data.Store("sender", m->sender);
|
||||
data.Store("text", m->text);
|
||||
data.Store("unread", m->unread);
|
||||
data.Store("receipt", m->receipt);
|
||||
}
|
||||
|
||||
Serializable *Memo::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string owner;
|
||||
|
||||
|
||||
+26
-20
@@ -139,29 +139,35 @@ NickAlias *NickAlias::Find(const Anope::string &nick)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void NickAlias::Serialize(Serialize::Data &data) const
|
||||
NickAlias::Type::Type()
|
||||
: Serialize::Type("NickAlias")
|
||||
{
|
||||
data.Store("nick", this->nick);
|
||||
data.Store("last_quit", this->last_quit);
|
||||
data.Store("last_realname", this->last_realname);
|
||||
data.Store("last_usermask", this->last_usermask);
|
||||
data.Store("last_realhost", this->last_realhost);
|
||||
data.Store("time_registered", this->time_registered);
|
||||
data.Store("last_seen", this->last_seen);
|
||||
data.Store("nc", this->nc->display);
|
||||
|
||||
if (this->HasVHost())
|
||||
{
|
||||
data.Store("vhost_ident", this->GetVHostIdent());
|
||||
data.Store("vhost_host", this->GetVHostHost());
|
||||
data.Store("vhost_creator", this->GetVHostCreator());
|
||||
data.Store("vhost_time", this->GetVHostCreated());
|
||||
}
|
||||
|
||||
Extensible::ExtensibleSerialize(this, this, data);
|
||||
}
|
||||
|
||||
Serializable *NickAlias::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void NickAlias::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *na = static_cast<const NickAlias *>(obj);
|
||||
data.Store("nick", na->nick);
|
||||
data.Store("last_quit", na->last_quit);
|
||||
data.Store("last_realname", na->last_realname);
|
||||
data.Store("last_usermask", na->last_usermask);
|
||||
data.Store("last_realhost", na->last_realhost);
|
||||
data.Store("time_registered", na->time_registered);
|
||||
data.Store("last_seen", na->last_seen);
|
||||
data.Store("nc", na->nc->display);
|
||||
|
||||
if (na->HasVHost())
|
||||
{
|
||||
data.Store("vhost_ident", na->GetVHostIdent());
|
||||
data.Store("vhost_host", na->GetVHostHost());
|
||||
data.Store("vhost_creator", na->GetVHostCreator());
|
||||
data.Store("vhost_time", na->GetVHostCreated());
|
||||
}
|
||||
|
||||
Extensible::ExtensibleSerialize(na, na, data);
|
||||
}
|
||||
|
||||
Serializable *NickAlias::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string snc, snick;
|
||||
|
||||
|
||||
+18
-12
@@ -66,26 +66,32 @@ NickCore::~NickCore()
|
||||
}
|
||||
}
|
||||
|
||||
void NickCore::Serialize(Serialize::Data &data) const
|
||||
NickCore::Type::Type()
|
||||
: Serialize::Type("NickCore")
|
||||
{
|
||||
data.Store("display", this->display);
|
||||
data.Store("uniqueid", this->id);
|
||||
data.Store("pass", this->pass);
|
||||
data.Store("email", this->email);
|
||||
data.Store("language", this->language);
|
||||
data.Store("lastmail", this->lastmail);
|
||||
data.Store("time_registered", this->time_registered);
|
||||
data.Store("memomax", this->memos.memomax);
|
||||
}
|
||||
|
||||
void NickCore::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *nc = static_cast<const NickCore *>(obj);
|
||||
data.Store("display", nc->display);
|
||||
data.Store("uniqueid", nc->id);
|
||||
data.Store("pass", nc->pass);
|
||||
data.Store("email", nc->email);
|
||||
data.Store("language", nc->language);
|
||||
data.Store("lastmail", nc->lastmail);
|
||||
data.Store("time_registered", nc->time_registered);
|
||||
data.Store("memomax", nc->memos.memomax);
|
||||
|
||||
std::ostringstream oss;
|
||||
for (const auto &ignore : this->memos.ignores)
|
||||
for (const auto &ignore : nc->memos.ignores)
|
||||
oss << ignore << " ";
|
||||
data.Store("memoignores", oss.str());
|
||||
|
||||
Extensible::ExtensibleSerialize(this, this, data);
|
||||
Extensible::ExtensibleSerialize(nc, nc, data);
|
||||
}
|
||||
|
||||
Serializable *NickCore::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *NickCore::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
NickCore *nc;
|
||||
|
||||
|
||||
+45
-32
@@ -38,20 +38,26 @@ AutoKick::~AutoKick()
|
||||
}
|
||||
}
|
||||
|
||||
void AutoKick::Serialize(Serialize::Data &data) const
|
||||
AutoKick::Type::Type()
|
||||
: Serialize::Type("AutoKick")
|
||||
{
|
||||
data.Store("ci", this->ci->name);
|
||||
if (this->nc)
|
||||
data.Store("nc", this->nc->display);
|
||||
else
|
||||
data.Store("mask", this->mask);
|
||||
data.Store("reason", this->reason);
|
||||
data.Store("creator", this->creator);
|
||||
data.Store("addtime", this->addtime);
|
||||
data.Store("last_used", this->last_used);
|
||||
}
|
||||
|
||||
Serializable *AutoKick::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void AutoKick::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *ak = static_cast<const AutoKick *>(obj);
|
||||
data.Store("ci", ak->ci->name);
|
||||
if (ak->nc)
|
||||
data.Store("nc", ak->nc->display);
|
||||
else
|
||||
data.Store("mask", ak->mask);
|
||||
data.Store("reason", ak->reason);
|
||||
data.Store("creator", ak->creator);
|
||||
data.Store("addtime", ak->addtime);
|
||||
data.Store("last_used", ak->last_used);
|
||||
}
|
||||
|
||||
Serializable *AutoKick::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sci, snc;
|
||||
|
||||
@@ -178,40 +184,47 @@ ChannelInfo::~ChannelInfo()
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelInfo::Serialize(Serialize::Data &data) const
|
||||
ChannelInfo::Type::Type()
|
||||
: Serialize::Type("ChannelInfo")
|
||||
{
|
||||
data.Store("name", this->name);
|
||||
if (this->founder)
|
||||
data.Store("founder", this->founder->display);
|
||||
if (this->successor)
|
||||
data.Store("successor", this->successor->display);
|
||||
data.Store("description", this->desc);
|
||||
data.Store("time_registered", this->time_registered);
|
||||
data.Store("last_used", this->last_used);
|
||||
data.Store("last_topic", this->last_topic);
|
||||
data.Store("last_topic_setter", this->last_topic_setter);
|
||||
data.Store("last_topic_time", this->last_topic_time);
|
||||
data.Store("bantype", this->bantype);
|
||||
}
|
||||
|
||||
void ChannelInfo::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *ci = static_cast<const ChannelInfo *>(obj);
|
||||
|
||||
data.Store("name", ci->name);
|
||||
if (ci->founder)
|
||||
data.Store("founder", ci->founder->display);
|
||||
if (ci->successor)
|
||||
data.Store("successor", ci->successor->display);
|
||||
data.Store("description", ci->desc);
|
||||
data.Store("time_registered", ci->time_registered);
|
||||
data.Store("last_used", ci->last_used);
|
||||
data.Store("last_topic", ci->last_topic);
|
||||
data.Store("last_topic_setter", ci->last_topic_setter);
|
||||
data.Store("last_topic_time", ci->last_topic_time);
|
||||
data.Store("bantype", ci->bantype);
|
||||
{
|
||||
Anope::string levels_buffer;
|
||||
for (const auto &[name, level] : this->levels)
|
||||
for (const auto &[name, level] : ci->levels)
|
||||
levels_buffer += name + " " + Anope::ToString(level) + " ";
|
||||
data.Store("levels", levels_buffer);
|
||||
}
|
||||
if (this->bi)
|
||||
data.Store("bi", this->bi->nick);
|
||||
data.Store("banexpire", this->banexpire);
|
||||
data.Store("memomax", this->memos.memomax);
|
||||
if (ci->bi)
|
||||
data.Store("bi", ci->bi->nick);
|
||||
data.Store("banexpire", ci->banexpire);
|
||||
data.Store("memomax", ci->memos.memomax);
|
||||
|
||||
std::ostringstream oss;
|
||||
for (const auto &ignore : this->memos.ignores)
|
||||
for (const auto &ignore : ci->memos.ignores)
|
||||
oss << ignore << " ";
|
||||
data.Store("memoignores", oss.str());
|
||||
|
||||
Extensible::ExtensibleSerialize(this, this, data);
|
||||
Extensible::ExtensibleSerialize(ci, ci, data);
|
||||
}
|
||||
|
||||
Serializable *ChannelInfo::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *ChannelInfo::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string sname, sfounder, ssuccessor, slevels, sbi;
|
||||
|
||||
|
||||
+11
-9
@@ -27,9 +27,14 @@ std::list<Serializable *> *Serializable::SerializableItems;
|
||||
|
||||
void Serialize::RegisterTypes()
|
||||
{
|
||||
static Type nc("NickCore", NickCore::Unserialize), na("NickAlias", NickAlias::Unserialize), bi("BotInfo", BotInfo::Unserialize),
|
||||
ci("ChannelInfo", ChannelInfo::Unserialize), access("ChanAccess", ChanAccess::Unserialize),
|
||||
akick("AutoKick", AutoKick::Unserialize), memo("Memo", Memo::Unserialize), xline("XLine", XLine::Unserialize);
|
||||
static NickCore::Type nc;
|
||||
static NickAlias::Type na;
|
||||
static BotInfo::Type bi;
|
||||
static ChannelInfo::Type ci;
|
||||
static ChanAccess::Type access;
|
||||
static AutoKick::Type akick;
|
||||
static Memo::Type memo;
|
||||
static XLine::Type xline;
|
||||
}
|
||||
|
||||
void Serialize::CheckTypes()
|
||||
@@ -124,7 +129,9 @@ void Serialize::Data::SetType(const Anope::string &key, Serialize::DataType dt)
|
||||
this->types[key] = dt;
|
||||
}
|
||||
|
||||
Type::Type(const Anope::string &n, unserialize_func f, Module *o) : name(n), unserialize(f), owner(o)
|
||||
Type::Type(const Anope::string &n, Module *o)
|
||||
: name(n)
|
||||
, owner(o)
|
||||
{
|
||||
TypeOrder.push_back(this->name);
|
||||
Types[this->name] = this;
|
||||
@@ -150,11 +157,6 @@ Type::~Type()
|
||||
Types.erase(this->name);
|
||||
}
|
||||
|
||||
Serializable *Type::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
return this->unserialize(obj, data);
|
||||
}
|
||||
|
||||
void Type::Check()
|
||||
{
|
||||
FOREACH_MOD(OnSerializeCheck, (this));
|
||||
|
||||
+17
-10
@@ -151,19 +151,26 @@ bool XLine::IsRegex() const
|
||||
return !this->mask.empty() && this->mask[0] == '/' && this->mask[this->mask.length() - 1] == '/';
|
||||
}
|
||||
|
||||
void XLine::Serialize(Serialize::Data &data) const
|
||||
XLine::Type::Type()
|
||||
: Serialize::Type("XLine")
|
||||
{
|
||||
data.Store("mask", this->mask);
|
||||
data.Store("by", this->by);
|
||||
data.Store("created", this->created);
|
||||
data.Store("expires", this->expires);
|
||||
data.Store("reason", this->reason);
|
||||
data.Store("uid", this->id);
|
||||
if (this->manager)
|
||||
data.Store("manager", this->manager->name);
|
||||
}
|
||||
|
||||
Serializable *XLine::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
void XLine::Type::Serialize(const Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
const auto *xl = static_cast<const XLine *>(obj);
|
||||
|
||||
data.Store("mask", xl->mask);
|
||||
data.Store("by", xl->by);
|
||||
data.Store("created", xl->created);
|
||||
data.Store("expires", xl->expires);
|
||||
data.Store("reason", xl->reason);
|
||||
data.Store("uid", xl->id);
|
||||
if (xl->manager)
|
||||
data.Store("manager", xl->manager->name);
|
||||
}
|
||||
|
||||
Serializable *XLine::Type::Unserialize(Serializable *obj, Serialize::Data &data) const
|
||||
{
|
||||
Anope::string smanager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user