mirror of
https://github.com/anope/anope.git
synced 2026-06-29 03:26:38 +02:00
Reworked live SQL support yet again
This commit is contained in:
+14
-20
@@ -1091,39 +1091,33 @@ db_flatfile
|
||||
* db_sql
|
||||
*
|
||||
* This module allows saving and loading databases using one of the SQL engines.
|
||||
* This module does not use any real time reading or writing to SQL. Changes to
|
||||
* the SQL tables not done by Anope will have no effect and will be overwritten.
|
||||
*
|
||||
* WARNING: This module will delete every table in the database it uses. Be sure
|
||||
* to put Anope in its own separate database.
|
||||
*/
|
||||
#module { name = "db_sql" }
|
||||
|
||||
/*
|
||||
* db_sql_live
|
||||
*
|
||||
* This module allows saving and loading databases using one of the SQL engines.
|
||||
* This module reads and writes to SQL in real time. Changes to the SQL tables
|
||||
* will be immediately reflected into Anope. This module should not be loaded
|
||||
* in conjunction with db_sql.
|
||||
*/
|
||||
#module { name = "db_sql_live" }
|
||||
|
||||
db_sql
|
||||
{
|
||||
/*
|
||||
* The SQL service db_sql should use, these are configured in modules.conf.
|
||||
* The SQL service db_sql(_live) should use, these are configured in modules.conf.
|
||||
* For MySQL, this should probably be mysql/main.
|
||||
*/
|
||||
engine = "sqlite/main"
|
||||
}
|
||||
|
||||
/*
|
||||
* db_sql_live_read, db_sql_live_write
|
||||
*
|
||||
* Enables (live) SQL support.
|
||||
*
|
||||
* The db_sql_live modules are an extension to db_sql, and should only be used if
|
||||
* db_sql is being used.
|
||||
*
|
||||
* The db_sql_live_read module pulls data in real time from
|
||||
* SQL as it is needed by the core.
|
||||
* At this time this supports the three main tables: ChannelInfo, NickAlias, and NickCore.
|
||||
*
|
||||
* The db_sql_live_write module writes data to SQL in real time as it is modified by
|
||||
* the core.
|
||||
*
|
||||
*/
|
||||
#module { name = "db_sql_live_read" }
|
||||
#module { name = "db_sql_live_write" }
|
||||
|
||||
/*
|
||||
* [REQUIRED] Encryption modules.
|
||||
*
|
||||
|
||||
+9
-9
@@ -59,7 +59,7 @@ class CoreExport ChanAccess : public Serializable
|
||||
{
|
||||
public:
|
||||
AccessProvider *provider;
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
Anope::string mask;
|
||||
Anope::string creator;
|
||||
time_t last_seen;
|
||||
@@ -68,13 +68,13 @@ class CoreExport ChanAccess : public Serializable
|
||||
ChanAccess(AccessProvider *p);
|
||||
virtual ~ChanAccess();
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
virtual bool Matches(User *u, NickCore *nc);
|
||||
virtual bool Matches(const User *u, const NickCore *nc) const;
|
||||
virtual bool HasPriv(const Anope::string &name) const = 0;
|
||||
virtual Anope::string Serialize() = 0;
|
||||
virtual Anope::string Serialize() const = 0;
|
||||
virtual void Unserialize(const Anope::string &data) = 0;
|
||||
|
||||
bool operator>(const ChanAccess &other) const;
|
||||
@@ -86,12 +86,12 @@ class CoreExport ChanAccess : public Serializable
|
||||
class CoreExport AccessGroup : public std::vector<ChanAccess *>
|
||||
{
|
||||
public:
|
||||
ChannelInfo *ci;
|
||||
NickCore *nc;
|
||||
const ChannelInfo *ci;
|
||||
const NickCore *nc;
|
||||
bool SuperAdmin, Founder;
|
||||
AccessGroup();
|
||||
bool HasPriv(const Anope::string &priv) const;
|
||||
ChanAccess *Highest() const;
|
||||
const ChanAccess *Highest() const;
|
||||
bool operator>(const AccessGroup &other) const;
|
||||
bool operator<(const AccessGroup &other) const;
|
||||
bool operator>=(const AccessGroup &other) const;
|
||||
|
||||
+14
-14
@@ -23,8 +23,8 @@
|
||||
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
|
||||
typedef Anope::insensitive_map<NickCore *> nickcore_map;
|
||||
|
||||
extern CoreExport nickalias_map NickAliasList;
|
||||
extern CoreExport nickcore_map NickCoreList;
|
||||
extern serialize_checker<nickalias_map> NickAliasList;
|
||||
extern serialize_checker<nickcore_map> NickCoreList;
|
||||
|
||||
/* NickServ nickname structures. */
|
||||
|
||||
@@ -109,7 +109,7 @@ const Anope::string NickCoreFlagStrings[] = {
|
||||
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", "STATS", ""
|
||||
};
|
||||
|
||||
class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
|
||||
class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
|
||||
{
|
||||
Anope::string vhost_ident, vhost_host, vhost_creator;
|
||||
time_t vhost_created;
|
||||
@@ -117,7 +117,7 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param nickname The nick
|
||||
* @param nickcore The nickcofe for this nick
|
||||
* @param nickcore The nickcore for this nick
|
||||
*/
|
||||
NickAlias(const Anope::string &nickname, NickCore *nickcore);
|
||||
|
||||
@@ -132,11 +132,11 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa
|
||||
Anope::string last_realhost; /* Last uncloaked usermask, requires nickserv/auspex to see */
|
||||
time_t time_registered; /* When the nick was registered */
|
||||
time_t last_seen; /* When it was seen online for the last time */
|
||||
NickCore *nc; /* I'm an alias of this */
|
||||
serialize_obj<NickCore> nc; /* I'm an alias of this */
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Release a nick
|
||||
* See the comment in users.cpp
|
||||
@@ -188,7 +188,7 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa
|
||||
time_t GetVhostCreated() const;
|
||||
};
|
||||
|
||||
class CoreExport NickCore : public Base, public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
|
||||
class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
|
||||
{
|
||||
public:
|
||||
/** Default constructor
|
||||
@@ -216,11 +216,11 @@ class CoreExport NickCore : public Base, public Extensible, public Flags<NickCor
|
||||
/* Unsaved data */
|
||||
uint16_t channelcount; /* Number of channels currently registered */
|
||||
time_t lastmail; /* Last time this nick record got a mail */
|
||||
std::list<NickAlias *> aliases; /* List of aliases */
|
||||
std::list<serialize_obj<NickAlias> > aliases; /* List of aliases */
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Checks whether this account is a services oper or not.
|
||||
* @return True if this account is a services oper, false otherwise.
|
||||
@@ -291,7 +291,7 @@ class CoreExport NickCore : public Base, public Extensible, public Flags<NickCor
|
||||
*
|
||||
* Search for an fingerprint within the cert list.
|
||||
*/
|
||||
bool FindCert(const Anope::string &entry);
|
||||
bool FindCert(const Anope::string &entry) const;
|
||||
|
||||
/** Erase a fingerprint from the nick's certificate list
|
||||
*
|
||||
|
||||
+2
-2
@@ -670,7 +670,7 @@ template<typename T, size_t Size = 32> class Flags
|
||||
Flag_Values.reset();
|
||||
}
|
||||
|
||||
Anope::string ToString()
|
||||
Anope::string ToString() const
|
||||
{
|
||||
std::vector<Anope::string> v = ToVector();
|
||||
Anope::string flag_buf;
|
||||
@@ -692,7 +692,7 @@ template<typename T, size_t Size = 32> class Flags
|
||||
FromVector(v);
|
||||
}
|
||||
|
||||
std::vector<Anope::string> ToVector()
|
||||
std::vector<Anope::string> ToVector() const
|
||||
{
|
||||
std::vector<Anope::string> ret;
|
||||
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
|
||||
|
||||
+26
-24
@@ -30,6 +30,7 @@ class dynamic_reference_base
|
||||
bool invalid;
|
||||
public:
|
||||
dynamic_reference_base() : invalid(false) { }
|
||||
dynamic_reference_base(const dynamic_reference_base &other) : invalid(other.invalid) { }
|
||||
virtual ~dynamic_reference_base() { }
|
||||
inline void Invalidate() { this->invalid = true; }
|
||||
};
|
||||
@@ -40,66 +41,67 @@ class dynamic_reference : public dynamic_reference_base
|
||||
protected:
|
||||
T *ref;
|
||||
public:
|
||||
dynamic_reference() : ref(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
dynamic_reference(T *obj) : ref(obj)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
|
||||
dynamic_reference(const dynamic_reference<T> &other) : dynamic_reference_base(other), ref(other.ref)
|
||||
{
|
||||
if (ref)
|
||||
if (*this)
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual ~dynamic_reference()
|
||||
{
|
||||
if (this->invalid)
|
||||
if (*this)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->operator bool())
|
||||
ref->DelReference(this);
|
||||
}
|
||||
}
|
||||
|
||||
virtual operator bool()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
return this->ref != NULL;
|
||||
if (!this->invalid)
|
||||
return this->ref != NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual inline operator T*()
|
||||
virtual inline operator T*() const
|
||||
{
|
||||
if (this->operator bool())
|
||||
if (!this->invalid)
|
||||
return this->ref;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual inline T *operator->()
|
||||
virtual inline T* operator->()
|
||||
{
|
||||
if (this->operator bool())
|
||||
if (!this->invalid)
|
||||
return this->ref;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual inline void operator=(T *newref)
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->operator bool())
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
if (this->operator bool())
|
||||
this->invalid = false;
|
||||
if (*this)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual inline bool operator==(const dynamic_reference<T> &other) const
|
||||
{
|
||||
if (!this->invalid)
|
||||
return this->ref == other;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BASE_H
|
||||
|
||||
+8
-6
@@ -14,9 +14,11 @@
|
||||
#include "commands.h"
|
||||
|
||||
|
||||
extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick;
|
||||
extern CoreExport Anope::map<BotInfo *> BotListByUID;
|
||||
typedef Anope::insensitive_map<BotInfo *> botinfo_map;
|
||||
typedef Anope::map<BotInfo *> botinfouid_map;
|
||||
|
||||
extern serialize_checker<botinfo_map> BotListByNick;
|
||||
extern serialize_checker<botinfouid_map> BotListByUID;
|
||||
|
||||
/** Flags settable on a bot
|
||||
*/
|
||||
@@ -60,9 +62,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
|
||||
*/
|
||||
virtual ~BotInfo();
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const;
|
||||
Serialize::Data serialize() const;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
void GenerateUID();
|
||||
|
||||
@@ -90,7 +92,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
|
||||
|
||||
/** Get the number of channels this bot is assigned to
|
||||
*/
|
||||
unsigned GetChannelCount();
|
||||
unsigned GetChannelCount() const;
|
||||
|
||||
/** Join this bot to a channel
|
||||
* @param c The channel
|
||||
|
||||
+12
-12
@@ -12,7 +12,7 @@
|
||||
#include "anope.h"
|
||||
#include "extensible.h"
|
||||
#include "modes.h"
|
||||
|
||||
#include "serialize.h"
|
||||
|
||||
typedef Anope::insensitive_map<Channel *> channel_map;
|
||||
extern CoreExport channel_map ChannelList;
|
||||
@@ -40,7 +40,7 @@ enum ChannelFlag
|
||||
|
||||
const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" };
|
||||
|
||||
class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag, 3>
|
||||
class CoreExport Channel : public virtual Base, public Extensible, public Flags<ChannelFlag, 3>
|
||||
{
|
||||
public:
|
||||
typedef std::multimap<ChannelModeName, Anope::string> ModeList;
|
||||
@@ -61,7 +61,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
~Channel();
|
||||
|
||||
Anope::string name; /* Channel name */
|
||||
ChannelInfo *ci; /* Corresponding ChannelInfo */
|
||||
serialize_obj<ChannelInfo> ci; /* Corresponding ChannelInfo */
|
||||
time_t creation_time; /* When channel was created */
|
||||
|
||||
/* List of users in the channel */
|
||||
@@ -104,14 +104,14 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param u The user
|
||||
* @return A user container if found, else NULL
|
||||
*/
|
||||
UserContainer *FindUser(User *u);
|
||||
UserContainer *FindUser(const User *u) const;
|
||||
|
||||
/** Check if a user has a status on a channel
|
||||
* @param u The user
|
||||
* @param cms The status mode, or NULL to represent no status
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasUserStatus(User *u, ChannelModeStatus *cms) const;
|
||||
bool HasUserStatus(const User *u, ChannelModeStatus *cms) const;
|
||||
|
||||
/** Check if a user has a status on a channel
|
||||
* Use the overloaded function for ChannelModeStatus* to check for no status
|
||||
@@ -119,7 +119,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param Name The Mode name, eg CMODE_OP, CMODE_VOICE
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasUserStatus(User *u, ChannelModeName Name) const;
|
||||
bool HasUserStatus(const User *u, ChannelModeName Name) const;
|
||||
|
||||
/** See if a channel has a mode
|
||||
* @param Name The mode name
|
||||
@@ -156,7 +156,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void SetMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/**
|
||||
* Set a mode on a channel
|
||||
@@ -165,7 +165,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void SetMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/** Remove a mode from a channel
|
||||
* @param bi The client setting the modes
|
||||
@@ -173,7 +173,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void RemoveMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/**
|
||||
* Remove a mode from a channel
|
||||
@@ -182,7 +182,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param param Optional param arg for the mode
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void RemoveMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/** Get a param from the channel
|
||||
* @param Name The mode
|
||||
@@ -196,7 +196,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF
|
||||
* @param EnforceMLock Should mlock be enforced on this mode change
|
||||
* @param cmodes The modes to set
|
||||
*/
|
||||
void SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...);
|
||||
void SetModes(const BotInfo *bi, bool EnforceMLock, const char *cmodes, ...);
|
||||
|
||||
/** Set a string of modes internally on a channel
|
||||
* @param setter the setter (if it is a user)
|
||||
@@ -255,6 +255,6 @@ extern void do_join(const Anope::string &source, const Anope::string &channels,
|
||||
extern void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
|
||||
extern void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
|
||||
|
||||
extern void chan_set_correct_modes(User *user, Channel *c, int give_modes);
|
||||
extern void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
|
||||
|
||||
#endif // CHANNELS_H
|
||||
|
||||
@@ -36,6 +36,7 @@ class NickAlias;
|
||||
class NickCore;
|
||||
class OperType;
|
||||
class Regex;
|
||||
class Serializable;
|
||||
class Server;
|
||||
class ServerConfig;
|
||||
class Socket;
|
||||
|
||||
+5
-11
@@ -17,12 +17,6 @@ class CoreExport ExtensibleItem
|
||||
virtual void OnDelete();
|
||||
};
|
||||
|
||||
class ExtensibleString : public Anope::string, public ExtensibleItem
|
||||
{
|
||||
public:
|
||||
ExtensibleString(const Anope::string &s) : Anope::string(s), ExtensibleItem() { }
|
||||
};
|
||||
|
||||
class CoreExport Extensible
|
||||
{
|
||||
private:
|
||||
@@ -92,9 +86,9 @@ class CoreExport Extensible
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
* @return The item found
|
||||
*/
|
||||
template<typename T> T GetExt(const Anope::string &key)
|
||||
template<typename T> T GetExt(const Anope::string &key) const
|
||||
{
|
||||
extensible_map::iterator it = this->extension_items.find(key);
|
||||
extensible_map::const_iterator it = this->extension_items.find(key);
|
||||
if (it != this->extension_items.end())
|
||||
return debug_cast<T>(it->second);
|
||||
|
||||
@@ -106,7 +100,7 @@ class CoreExport Extensible
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
* @return True if the item was found.
|
||||
*/
|
||||
bool HasExt(const Anope::string &key)
|
||||
bool HasExt(const Anope::string &key) const
|
||||
{
|
||||
return this->extension_items.count(key) > 0;
|
||||
}
|
||||
@@ -116,9 +110,9 @@ class CoreExport Extensible
|
||||
* @return This function writes a list of all extension items stored
|
||||
* in this object by name into the given deque and returns void.
|
||||
*/
|
||||
void GetExtList(std::deque<Anope::string> &list)
|
||||
void GetExtList(std::deque<Anope::string> &list) const
|
||||
{
|
||||
for (extensible_map::iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it)
|
||||
for (extensible_map::const_iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it)
|
||||
list.push_back(it->first);
|
||||
}
|
||||
};
|
||||
|
||||
+7
-7
@@ -21,7 +21,7 @@
|
||||
/**** actions.c ****/
|
||||
|
||||
E bool bad_password(User *u);
|
||||
E void common_unban(ChannelInfo *ci, User *u, bool full = false);
|
||||
E void common_unban(const ChannelInfo *ci, User *u, bool full = false);
|
||||
|
||||
/**** channels.c ****/
|
||||
|
||||
@@ -34,7 +34,7 @@ E void do_join(const Anope::string &source, const Anope::string &channels, const
|
||||
E void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
|
||||
E void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
|
||||
|
||||
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
|
||||
E void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
|
||||
|
||||
/**** encrypt.c ****/
|
||||
|
||||
@@ -57,7 +57,7 @@ E std::vector<Anope::string> domains;
|
||||
E void InitLanguages();
|
||||
E const char *translate(const char *string);
|
||||
E const char *translate(User *u, const char *string);
|
||||
E const char *translate(NickCore *nc, const char *string);
|
||||
E const char *translate(const NickCore *nc, const char *string);
|
||||
E const char *anope_gettext(const char *lang, const char *string);
|
||||
|
||||
/**** main.c ****/
|
||||
@@ -115,9 +115,9 @@ E bool OnError(const Anope::string &, const std::vector<Anope::string> &);
|
||||
E bool IsFile(const Anope::string &filename);
|
||||
|
||||
E time_t dotime(const Anope::string &s);
|
||||
E Anope::string duration(const time_t &seconds, NickCore *nc = NULL);
|
||||
E Anope::string expire_left(NickCore *nc, time_t expires);
|
||||
E Anope::string do_strftime(const time_t &t, NickCore *nc = NULL, bool short_output = false);
|
||||
E Anope::string duration(const time_t &seconds, const NickCore *nc = NULL);
|
||||
E Anope::string expire_left(const NickCore *nc, time_t expires);
|
||||
E Anope::string do_strftime(const time_t &t, const NickCore *nc = NULL, bool short_output = false);
|
||||
E bool IsValidIdent(const Anope::string &ident);
|
||||
E bool IsValidHost(const Anope::string &host);
|
||||
|
||||
@@ -137,7 +137,7 @@ E Anope::string normalizeBuffer(const Anope::string &);
|
||||
|
||||
/* Number of generic modes we support */
|
||||
E unsigned GenericChannelModes, GenericUserModes;
|
||||
E std::multimap<ChannelModeName, ModeLock> def_mode_locks;
|
||||
E std::multimap<ChannelModeName, ModeLock *> def_mode_locks;
|
||||
E void SetDefaultMLock(ServerConfig *config);
|
||||
|
||||
/**** process.c ****/
|
||||
|
||||
+9
-9
@@ -48,11 +48,11 @@ struct LogFile
|
||||
class CoreExport Log
|
||||
{
|
||||
public:
|
||||
BotInfo *bi;
|
||||
User *u;
|
||||
const BotInfo *bi;
|
||||
const User *u;
|
||||
Command *c;
|
||||
Channel *chan;
|
||||
ChannelInfo *ci;
|
||||
const ChannelInfo *ci;
|
||||
Server *s;
|
||||
LogType Type;
|
||||
Anope::string Category;
|
||||
@@ -60,21 +60,21 @@ class CoreExport Log
|
||||
|
||||
std::stringstream buf;
|
||||
|
||||
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL);
|
||||
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
/* LOG_COMMAND/OVERRIDE/ADMIN */
|
||||
Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL);
|
||||
Log(LogType type, const User *u, Command *c, const ChannelInfo *ci = NULL);
|
||||
|
||||
/* LOG_CHANNEL */
|
||||
Log(User *u, Channel *c, const Anope::string &category = "");
|
||||
Log(const User *u, Channel *c, const Anope::string &category = "");
|
||||
|
||||
/* LOG_USER */
|
||||
explicit Log(User *u, const Anope::string &category = "", BotInfo *bi = NULL);
|
||||
explicit Log(const User *u, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
/* LOG_SERVER */
|
||||
explicit Log(Server *s, const Anope::string &category = "", BotInfo *bi = NULL);
|
||||
explicit Log(Server *s, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
explicit Log(BotInfo *b, const Anope::string &category = "");
|
||||
explicit Log(const BotInfo *b, const Anope::string &category = "");
|
||||
|
||||
~Log();
|
||||
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@
|
||||
|
||||
#include "anope.h"
|
||||
#include "threadengine.h"
|
||||
#include "serialize.h"
|
||||
|
||||
|
||||
extern CoreExport bool Mail(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool MailValidate(const Anope::string &email);
|
||||
|
||||
|
||||
+6
-4
@@ -38,9 +38,9 @@ class CoreExport Memo : public Flags<MemoFlag>, public Serializable
|
||||
public:
|
||||
Memo();
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
Anope::string owner;
|
||||
time_t time; /* When it was sent */
|
||||
@@ -51,9 +51,11 @@ class CoreExport Memo : public Flags<MemoFlag>, public Serializable
|
||||
struct CoreExport MemoInfo
|
||||
{
|
||||
int16_t memomax;
|
||||
std::vector<Memo *> memos;
|
||||
serialize_checker<std::vector<Memo *> > memos;
|
||||
std::vector<Anope::string> ignores;
|
||||
|
||||
MemoInfo();
|
||||
Memo *GetMemo(unsigned index) const;
|
||||
unsigned GetIndex(Memo *m) const;
|
||||
void Del(unsigned index);
|
||||
void Del(Memo *m);
|
||||
|
||||
+7
-7
@@ -113,7 +113,7 @@ enum ModeClass
|
||||
|
||||
/** This class is the basis of all modes in Anope
|
||||
*/
|
||||
class CoreExport Mode : public Base
|
||||
class CoreExport Mode : public virtual Base
|
||||
{
|
||||
public:
|
||||
/* Class of mode this is */
|
||||
@@ -231,7 +231,7 @@ class CoreExport ChannelModeList : public ChannelMode
|
||||
* @param e The entry to match against
|
||||
* @return true on match
|
||||
*/
|
||||
virtual bool Matches(User *u, const Entry *e) { return false; }
|
||||
virtual bool Matches(const User *u, const Entry *e) { return false; }
|
||||
|
||||
/** Called when a mask is added to a channel
|
||||
* @param chan The channel
|
||||
@@ -359,7 +359,7 @@ class StackerInfo
|
||||
/* The type of object this stacker info is for */
|
||||
StackerType Type;
|
||||
/* Bot this is sent from */
|
||||
BotInfo *bi;
|
||||
const BotInfo *bi;
|
||||
|
||||
/** Add a mode to this object
|
||||
* @param mode The mode
|
||||
@@ -401,7 +401,7 @@ class CoreExport ModeManager
|
||||
* @param Param A param, if there is one
|
||||
* @param Type The type this is, user or channel
|
||||
*/
|
||||
static void StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type);
|
||||
static void StackerAddInternal(const BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type);
|
||||
|
||||
public:
|
||||
/* List of all modes Anope knows about */
|
||||
@@ -469,7 +469,7 @@ class CoreExport ModeManager
|
||||
* @param Set true for setting, false for removing
|
||||
* @param Param The param, if there is one
|
||||
*/
|
||||
static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = "");
|
||||
static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = "");
|
||||
|
||||
/** Add a mode to the stacker to be set on a user
|
||||
* @param bi The client to set the modes from
|
||||
@@ -478,7 +478,7 @@ class CoreExport ModeManager
|
||||
* @param Set true for setting, false for removing
|
||||
* @param param The param, if there is one
|
||||
*/
|
||||
static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = "");
|
||||
static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = "");
|
||||
|
||||
/** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users
|
||||
*/
|
||||
@@ -531,7 +531,7 @@ class CoreExport Entry : public Flags<EntryType>
|
||||
* @param full True to match against a users real host and IP
|
||||
* @return true on match
|
||||
*/
|
||||
bool Matches(User *u, bool full = false) const;
|
||||
bool Matches(const User *u, bool full = false) const;
|
||||
};
|
||||
|
||||
#endif // MODES_H
|
||||
|
||||
+22
-34
@@ -9,14 +9,16 @@
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
#include "serialize.h"
|
||||
|
||||
#ifndef MODULES_H
|
||||
#define MODULES_H
|
||||
|
||||
#include "extensible.h"
|
||||
#include "base.h"
|
||||
#include "modes.h"
|
||||
#include "timers.h"
|
||||
#include "logger.h"
|
||||
#include "extensible.h"
|
||||
|
||||
/** This definition is used as shorthand for the various classes
|
||||
* and functions needed to make a module loadable by the OS.
|
||||
@@ -381,18 +383,13 @@ class CoreExport Module : public Extensible
|
||||
* @param ci The channel
|
||||
* @param bw The badword
|
||||
*/
|
||||
virtual void OnBadWordAdd(ChannelInfo *ci, BadWord *bw) { }
|
||||
virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { }
|
||||
|
||||
/** Called before a badword is deleted from a channel
|
||||
* @param ci The channel
|
||||
* @param bw The badword
|
||||
*/
|
||||
virtual void OnBadWordDel(ChannelInfo *ci, BadWord *bw) { }
|
||||
|
||||
/** Called in findbot()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindBot(const Anope::string &nick) { }
|
||||
virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { }
|
||||
|
||||
/** Called before a bot kicks a user
|
||||
* @param bi The bot sending the kick
|
||||
@@ -513,14 +510,14 @@ class CoreExport Module : public Extensible
|
||||
* @param xlm The xline manager it was added to
|
||||
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
|
||||
*/
|
||||
virtual EventReturn OnAddXLine(User *u, XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; }
|
||||
virtual EventReturn OnAddXLine(User *u, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called before a XLine is deleted
|
||||
* @param u The user deleting the XLine
|
||||
* @param x The XLine
|
||||
* @param xlm The xline manager it was deleted from
|
||||
*/
|
||||
virtual void OnDelXLine(User *u, XLine *x, XLineManager *xlm) { }
|
||||
virtual void OnDelXLine(User *u, const XLine *x, XLineManager *xlm) { }
|
||||
|
||||
/** Called when a user is checked for whether they are a services oper
|
||||
* @param u The user
|
||||
@@ -632,14 +629,14 @@ class CoreExport Module : public Extensible
|
||||
* @param ci The channel
|
||||
* @param ak The akick
|
||||
*/
|
||||
virtual void OnAkickAdd(User *u, ChannelInfo *ci, AutoKick *ak) { }
|
||||
virtual void OnAkickAdd(User *u, ChannelInfo *ci, const AutoKick *ak) { }
|
||||
|
||||
/** Called before removing an akick from a channel
|
||||
* @param u The user removing the akick
|
||||
* @param ci The channel
|
||||
* @param ak The akick
|
||||
*/
|
||||
virtual void OnAkickDel(User *u, ChannelInfo *ci, AutoKick *ak) { }
|
||||
virtual void OnAkickDel(User *u, ChannelInfo *ci, const AutoKick *ak) { }
|
||||
|
||||
/** Called after a user join a channel when we decide whether to kick them or not
|
||||
* @param u The user
|
||||
@@ -657,11 +654,6 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) { }
|
||||
|
||||
/** Called on cs_findchan()
|
||||
* @param chname The name being looked up
|
||||
*/
|
||||
virtual void OnFindChan(const Anope::string &chname) { }
|
||||
|
||||
/** Checks if access has the channel privilege 'priv'.
|
||||
* @param access THe access struct
|
||||
* @param priv The privilege being checked for
|
||||
@@ -776,18 +768,6 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) { }
|
||||
|
||||
/** Called in findnick()
|
||||
* Useful to modify the na returned by findnick()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindNick(const Anope::string &nick) { }
|
||||
|
||||
/** Called in findcore()
|
||||
* Useful to modify the nc returned by findcore()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindCore(const Anope::string &nick) { }
|
||||
|
||||
/** Check whether a users password is correct.
|
||||
* @param u The user
|
||||
* @param command The command the user is doing
|
||||
@@ -837,14 +817,14 @@ class CoreExport Module : public Extensible
|
||||
* @param mi The memo info
|
||||
* @param m The memo
|
||||
*/
|
||||
virtual void OnMemoDel(const NickCore *nc, MemoInfo *mi, Memo *m) { }
|
||||
virtual void OnMemoDel(NickCore *nc, MemoInfo *mi, const Memo *m) { }
|
||||
|
||||
/** Called when a memo is deleted
|
||||
* @param ci The channel of the memo being deleted
|
||||
* @param mi The memo info
|
||||
* @param m The memo
|
||||
*/
|
||||
virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, Memo *m) { }
|
||||
virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, const Memo *m) { }
|
||||
|
||||
/** Called when a mode is set on a channel
|
||||
* @param c The channel
|
||||
@@ -948,6 +928,12 @@ class CoreExport Module : public Extensible
|
||||
* @return EVENT_STOP to stop checking modes
|
||||
*/
|
||||
virtual EventReturn OnCheckModes(Channel *c) { return EVENT_CONTINUE; }
|
||||
|
||||
virtual void OnSerializeCheck(SerializeType *) { }
|
||||
virtual void OnSerializableConstruct(Serializable *) { }
|
||||
virtual void OnSerializableDestruct(Serializable *) { }
|
||||
virtual void OnSerializePtrAssign(Serializable *) { }
|
||||
virtual void OnSerializableUpdate(Serializable *) { }
|
||||
};
|
||||
|
||||
/** Implementation-specific flags which may be set in ModuleManager::Attach()
|
||||
@@ -961,18 +947,18 @@ enum Implementation
|
||||
I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
|
||||
I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
|
||||
I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert,
|
||||
I_OnNickInfo, I_OnFindNick, I_OnFindCore, I_OnCheckAuthentication,
|
||||
I_OnNickInfo, I_OnCheckAuthentication,
|
||||
I_OnNickUpdate,
|
||||
|
||||
/* ChanServ */
|
||||
I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
|
||||
/* BotServ */
|
||||
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
|
||||
I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel, I_OnFindBot,
|
||||
I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel,
|
||||
|
||||
/* HostServ */
|
||||
I_OnSetVhost, I_OnDeleteVhost,
|
||||
@@ -1001,6 +987,8 @@ enum Implementation
|
||||
I_OnEncrypt, I_OnDecrypt,
|
||||
I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
|
||||
I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog,
|
||||
|
||||
I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializePtrAssign, I_OnSerializableUpdate,
|
||||
I_END
|
||||
};
|
||||
|
||||
|
||||
+9
-9
@@ -40,18 +40,18 @@ class CoreExport XLine : public Serializable
|
||||
bool HasNickOrReal() const;
|
||||
bool IsRegex() const;
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &data);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
class CoreExport XLineManager : public Service
|
||||
{
|
||||
char type;
|
||||
/* List of XLines in this XLineManager */
|
||||
std::vector<XLine *> XLines;
|
||||
serialize_checker<std::vector<XLine *> > XLines;
|
||||
/* Akills can have the same IDs, sometimes */
|
||||
static std::multimap<Anope::string, XLine *, ci::less> XLinesByUID;
|
||||
static serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
|
||||
public:
|
||||
/* List of XLine managers we check users against in XLineManager::CheckAll */
|
||||
static std::list<XLineManager *> XLineManagers;
|
||||
@@ -118,7 +118,7 @@ class CoreExport XLineManager : public Service
|
||||
* @param index The index
|
||||
* @return The XLine, or NULL if the index is out of bounds
|
||||
*/
|
||||
XLine *GetEntry(unsigned index);
|
||||
XLine* GetEntry(unsigned index);
|
||||
|
||||
/** Clear the XLine vector
|
||||
* Note: This does not remove the XLines from the IRCd
|
||||
@@ -138,7 +138,7 @@ class CoreExport XLineManager : public Service
|
||||
* @param mask The mask
|
||||
* @return The XLine the user matches, or NULL
|
||||
*/
|
||||
XLine *HasEntry(const Anope::string &mask);
|
||||
XLine* HasEntry(const Anope::string &mask);
|
||||
|
||||
/** Check a user against all of the xlines in this XLineManager
|
||||
* @param u The user
|
||||
@@ -150,7 +150,7 @@ class CoreExport XLineManager : public Service
|
||||
* @param u The user
|
||||
* @param x The xline
|
||||
*/
|
||||
virtual bool Check(User *u, XLine *x) = 0;
|
||||
virtual bool Check(User *u, const XLine *x) = 0;
|
||||
|
||||
/** Called when a user matches a xline in this XLineManager
|
||||
* @param u The user
|
||||
@@ -161,7 +161,7 @@ class CoreExport XLineManager : public Service
|
||||
/** Called when an XLine expires
|
||||
* @param x The xline
|
||||
*/
|
||||
virtual void OnExpire(XLine *x);
|
||||
virtual void OnExpire(const XLine *x);
|
||||
|
||||
/** Called to send an XLine to the IRCd
|
||||
* @param u The user, if we know it
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ class CoreExport IRCDProto
|
||||
virtual void SendQuit(const User *u, const char *fmt, ...);
|
||||
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
|
||||
virtual void SendJoin(const User *, Channel *, const ChannelStatus *) = 0;
|
||||
virtual void SendSQLineDel(const XLine *x) { }
|
||||
virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u);
|
||||
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
|
||||
|
||||
+47
-45
@@ -15,9 +15,11 @@
|
||||
#include "extensible.h"
|
||||
#include "logger.h"
|
||||
#include "modules.h"
|
||||
#include "serialize.h"
|
||||
|
||||
typedef Anope::insensitive_map<ChannelInfo *> registered_channel_map;
|
||||
extern CoreExport registered_channel_map RegisteredChannelList;
|
||||
|
||||
extern serialize_checker<registered_channel_map> RegisteredChannelList;
|
||||
|
||||
/** Flags used for the ChannelInfo class
|
||||
*/
|
||||
@@ -90,9 +92,9 @@ struct CoreExport BadWord : Serializable
|
||||
Anope::string word;
|
||||
BadWordType type;
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
/** Flags for auto kick
|
||||
@@ -110,25 +112,25 @@ class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable
|
||||
{
|
||||
public:
|
||||
AutoKick();
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
/* Only one of these can be in use */
|
||||
Anope::string mask;
|
||||
NickCore *nc;
|
||||
serialize_obj<NickCore> nc;
|
||||
|
||||
Anope::string reason;
|
||||
Anope::string creator;
|
||||
time_t addtime;
|
||||
time_t last_used;
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
struct CoreExport ModeLock : Serializable
|
||||
{
|
||||
public:
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
bool set;
|
||||
ChannelModeName name;
|
||||
Anope::string param;
|
||||
@@ -137,14 +139,14 @@ struct CoreExport ModeLock : Serializable
|
||||
|
||||
ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime);
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
struct CoreExport LogSetting : Serializable
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
/* Our service name of the command */
|
||||
Anope::string service_name;
|
||||
/* The name of the client the command is on */
|
||||
@@ -155,24 +157,24 @@ struct CoreExport LogSetting : Serializable
|
||||
Anope::string creator;
|
||||
time_t created;
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, CI_END>, public Serializable
|
||||
{
|
||||
private:
|
||||
NickCore *founder; /* Channel founder */
|
||||
std::vector<ChanAccess *> access; /* List of authorized users */
|
||||
std::vector<AutoKick *> akick; /* List of users to kickban */
|
||||
std::vector<BadWord *> badwords; /* List of badwords */
|
||||
serialize_obj<NickCore> founder; /* Channel founder */
|
||||
serialize_checker<std::vector<ChanAccess *> > access; /* List of authorized users */
|
||||
serialize_checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
|
||||
serialize_checker<std::vector<BadWord *> > badwords; /* List of badwords */
|
||||
std::map<Anope::string, int16_t> levels;
|
||||
|
||||
public:
|
||||
typedef std::multimap<ChannelModeName, ModeLock> ModeList;
|
||||
ModeList mode_locks;
|
||||
std::vector<LogSetting> log_settings;
|
||||
typedef std::multimap<ChannelModeName, ModeLock *> ModeList;
|
||||
serialize_checker<ModeList> mode_locks;
|
||||
serialize_checker<std::vector<LogSetting *> > log_settings;
|
||||
|
||||
/** Default constructor
|
||||
* @param chname The channel name
|
||||
@@ -182,14 +184,14 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Copy constructor
|
||||
* @param ci The ChannelInfo to copy settings to
|
||||
*/
|
||||
ChannelInfo(ChannelInfo &ci);
|
||||
ChannelInfo(const ChannelInfo &ci);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~ChannelInfo();
|
||||
|
||||
Anope::string name; /* Channel name */
|
||||
NickCore *successor; /* Who gets the channel if the founder nick is dropped or expires */
|
||||
serialize_obj<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
|
||||
Anope::string desc;
|
||||
|
||||
time_t time_registered;
|
||||
@@ -206,7 +208,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
Channel *c; /* Pointer to channel record (if channel is currently in use) */
|
||||
|
||||
/* For BotServ */
|
||||
BotInfo *bi; /* Bot used on this channel */
|
||||
serialize_obj<BotInfo> bi; /* Bot used on this channel */
|
||||
Flags<BotServFlag> botflags;
|
||||
int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
|
||||
|
||||
@@ -214,9 +216,9 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
int16_t floodlines, floodsecs; /* For FLOOD kicker */
|
||||
int16_t repeattimes; /* For REPEAT kicker */
|
||||
|
||||
Anope::string serialize_name() const anope_override;
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Change the founder of the channek
|
||||
* @params nc The new founder
|
||||
@@ -231,7 +233,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Find which bot should send mode/topic/etc changes for this channel
|
||||
* @return The bot
|
||||
*/
|
||||
BotInfo *WhoSends();
|
||||
BotInfo *WhoSends() const;
|
||||
|
||||
/** Add an entry to the channel access list
|
||||
* @param access The entry
|
||||
@@ -245,13 +247,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
*
|
||||
* Retrieves an entry from the access list that matches the given index.
|
||||
*/
|
||||
ChanAccess *GetAccess(unsigned index);
|
||||
ChanAccess *GetAccess(unsigned index) const;
|
||||
|
||||
/** Retrieve the access for a user or group in the form of a vector of access entries
|
||||
* (as multiple entries can affect a single user).
|
||||
*/
|
||||
AccessGroup AccessFor(User *u);
|
||||
AccessGroup AccessFor(NickCore *nc);
|
||||
AccessGroup AccessFor(const User *u);
|
||||
AccessGroup AccessFor(const NickCore *nc);
|
||||
|
||||
/** Get the size of the accss vector for this channel
|
||||
* @return The access vector size
|
||||
@@ -272,7 +274,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
*
|
||||
* Clears the memory used by the given access entry and removes it from the vector.
|
||||
*/
|
||||
void EraseAccess(ChanAccess *taccess);
|
||||
void EraseAccess(const ChanAccess *taccess);
|
||||
|
||||
/** Clear the entire channel access list
|
||||
*
|
||||
@@ -287,7 +289,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
AutoKick* AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Add an akick entry to the channel by reason
|
||||
* @param user The user who added the akick
|
||||
@@ -296,13 +298,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Get an entry from the channel akick list
|
||||
* @param index The index in the akick vector
|
||||
* @return The akick structure, or NULL if not found
|
||||
*/
|
||||
AutoKick *GetAkick(unsigned index);
|
||||
AutoKick* GetAkick(unsigned index) const;
|
||||
|
||||
/** Get the size of the akick vector for this channel
|
||||
* @return The akick vector size
|
||||
@@ -323,13 +325,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param type The type (SINGLE START END)
|
||||
* @return The badword
|
||||
*/
|
||||
BadWord *AddBadWord(const Anope::string &word, BadWordType type);
|
||||
BadWord* AddBadWord(const Anope::string &word, BadWordType type);
|
||||
|
||||
/** Get a badword structure by index
|
||||
* @param index The index
|
||||
* @return The badword
|
||||
*/
|
||||
BadWord *GetBadWord(unsigned index);
|
||||
BadWord* GetBadWord(unsigned index) const;
|
||||
|
||||
/** Get how many badwords are on this channel
|
||||
* @return The number of badwords in the vector
|
||||
@@ -378,7 +380,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Get all of the mlocks for this channel
|
||||
* @return The mlocks
|
||||
*/
|
||||
const std::multimap<ChannelModeName, ModeLock> &GetMLock() const;
|
||||
const ModeList &GetMLock() const;
|
||||
|
||||
/** Get a list of modes on a channel
|
||||
* @param Name The mode name to get a list of
|
||||
@@ -391,7 +393,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param An optional param to match with
|
||||
* @return The MLock, if any
|
||||
*/
|
||||
ModeLock *GetMLock(ChannelModeName mname, const Anope::string ¶m = "");
|
||||
const ModeLock *GetMLock(ChannelModeName mname, const Anope::string ¶m = "");
|
||||
|
||||
/** Get the current mode locks as a string
|
||||
* @param complete True to show mlock parameters aswell
|
||||
@@ -421,7 +423,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @return the level
|
||||
* @throws CoreException if priv is not a valid privilege
|
||||
*/
|
||||
int16_t GetLevel(const Anope::string &priv);
|
||||
int16_t GetLevel(const Anope::string &priv) const;
|
||||
|
||||
/** Set the level for a privilege
|
||||
* @param priv The privilege priv
|
||||
@@ -440,8 +442,8 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
};
|
||||
|
||||
extern ChannelInfo *cs_findchan(const Anope::string &chan);
|
||||
extern bool IsFounder(User *user, ChannelInfo *ci);
|
||||
extern bool IsFounder(const User *user, const ChannelInfo *ci);
|
||||
extern void update_cs_lastseen(User *user, ChannelInfo *ci);
|
||||
extern int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret);
|
||||
extern int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
|
||||
|
||||
#endif // REGCHANNEL_H
|
||||
|
||||
+179
-10
@@ -16,6 +16,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "anope.h"
|
||||
#include "base.h"
|
||||
|
||||
namespace Serialize
|
||||
{
|
||||
@@ -30,13 +31,13 @@ class stringstream : public std::stringstream
|
||||
{
|
||||
private:
|
||||
Serialize::DataType type;
|
||||
bool key;
|
||||
unsigned _max;
|
||||
|
||||
public:
|
||||
stringstream();
|
||||
stringstream(const stringstream &ss);
|
||||
Anope::string astr() const;
|
||||
|
||||
template<typename T> std::istream &operator>>(T &val)
|
||||
{
|
||||
std::istringstream is(this->str());
|
||||
@@ -44,23 +45,31 @@ class stringstream : public std::stringstream
|
||||
return *this;
|
||||
}
|
||||
std::istream &operator>>(Anope::string &val);
|
||||
|
||||
bool operator==(const stringstream &other) const;
|
||||
bool operator!=(const stringstream &other) const;
|
||||
|
||||
stringstream &setType(Serialize::DataType t);
|
||||
Serialize::DataType getType() const;
|
||||
stringstream &setKey();
|
||||
bool getKey() const;
|
||||
stringstream &setMax(unsigned m);
|
||||
unsigned getMax() const;
|
||||
};
|
||||
|
||||
namespace Serialize
|
||||
{
|
||||
typedef std::map<Anope::string, stringstream> Data;
|
||||
}
|
||||
|
||||
extern void RegisterTypes();
|
||||
|
||||
class CoreExport Serializable
|
||||
class CoreExport Serializable : public virtual Base
|
||||
{
|
||||
private:
|
||||
static std::list<Serializable *> *serizliable_items;
|
||||
static std::list<Serializable *> *serializable_items;
|
||||
|
||||
private:
|
||||
std::list<Serializable *>::iterator s_iter;
|
||||
Serialize::Data last_commit;
|
||||
|
||||
protected:
|
||||
Serializable();
|
||||
@@ -71,35 +80,195 @@ class CoreExport Serializable
|
||||
Serializable &operator=(const Serializable &);
|
||||
|
||||
public:
|
||||
typedef std::map<Anope::string, stringstream> serialized_data;
|
||||
unsigned int id;
|
||||
|
||||
virtual Anope::string serialize_name() const = 0;
|
||||
virtual serialized_data serialize() = 0;
|
||||
void destroy();
|
||||
|
||||
void QueueUpdate();
|
||||
|
||||
bool IsCached();
|
||||
void UpdateCache();
|
||||
|
||||
virtual const Anope::string serialize_name() const = 0;
|
||||
virtual Serialize::Data serialize() const = 0;
|
||||
|
||||
static const std::list<Serializable *> &GetItems();
|
||||
};
|
||||
|
||||
class CoreExport SerializeType
|
||||
{
|
||||
typedef void (*unserialize_func)(Serializable::serialized_data &);
|
||||
typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &);
|
||||
|
||||
static std::vector<Anope::string> type_order;
|
||||
static Anope::map<SerializeType *> types;
|
||||
|
||||
Anope::string name;
|
||||
unserialize_func unserialize;
|
||||
time_t timestamp;
|
||||
|
||||
public:
|
||||
std::map<unsigned int, Serializable *> objects;
|
||||
|
||||
SerializeType(const Anope::string &n, unserialize_func f);
|
||||
~SerializeType();
|
||||
|
||||
const Anope::string &GetName();
|
||||
|
||||
void Create(Serializable::serialized_data &data);
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
|
||||
void Check();
|
||||
|
||||
time_t GetTimestamp() const;
|
||||
void UpdateTimestamp();
|
||||
|
||||
static SerializeType *Find(const Anope::string &name);
|
||||
|
||||
static const std::vector<Anope::string> &GetTypeOrder();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class serialize_checker
|
||||
{
|
||||
Anope::string name;
|
||||
T obj;
|
||||
|
||||
public:
|
||||
serialize_checker(const Anope::string &n) : name(n) { }
|
||||
|
||||
inline const T* operator->() const
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return &this->obj;
|
||||
}
|
||||
inline T* operator->()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return &this->obj;
|
||||
}
|
||||
|
||||
inline const T& operator*() const
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
inline T& operator*()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
|
||||
inline operator const T&() const
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
inline operator T&()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
};
|
||||
|
||||
#include "modules.h"
|
||||
|
||||
template<typename T>
|
||||
class serialize_obj : public dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
|
||||
public:
|
||||
serialize_obj() : ref(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
serialize_obj(T *obj) : ref(obj)
|
||||
{
|
||||
if (obj)
|
||||
obj->AddReference(this);
|
||||
}
|
||||
|
||||
serialize_obj(const serialize_obj<T> &other) : ref(other.ref)
|
||||
{
|
||||
if (*this)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
~serialize_obj()
|
||||
{
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
}
|
||||
|
||||
virtual operator bool() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
return this->ref != NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void operator=(T *newref)
|
||||
{
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
|
||||
this->ref = newref;
|
||||
this->invalid = false;
|
||||
|
||||
if (newref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual inline operator T*() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual inline T* operator*() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual inline T* operator->() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SERIALIZE_H
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ class CoreExport Server : public Flags<ServerFlag>
|
||||
* @param source The source of the message
|
||||
* @param message The message
|
||||
*/
|
||||
void Notice(BotInfo *source, const Anope::string &message);
|
||||
void Notice(const BotInfo *source, const Anope::string &message);
|
||||
|
||||
/** Find a server
|
||||
* @param name The name or SID/numeric
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
#include "anope.h"
|
||||
#include "modules.h"
|
||||
|
||||
class CoreExport Service : public Base
|
||||
class CoreExport Service : public virtual Base
|
||||
{
|
||||
static Anope::map<Anope::map<Service *> > services;
|
||||
public:
|
||||
@@ -89,7 +89,7 @@ class service_reference : public dynamic_reference<T>
|
||||
this->name = n;
|
||||
}
|
||||
|
||||
operator bool()
|
||||
operator bool() anope_override
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
|
||||
+14
-13
@@ -11,6 +11,7 @@
|
||||
#include "anope.h"
|
||||
#include "modes.h"
|
||||
#include "extensible.h"
|
||||
#include "serialize.h"
|
||||
|
||||
extern CoreExport Anope::insensitive_map<User *> UserListByNick;
|
||||
extern CoreExport Anope::map<User *> UserListByUID;
|
||||
@@ -36,7 +37,7 @@ typedef std::list<ChannelContainer *> UChannelList;
|
||||
|
||||
|
||||
/* Online user and channel data. */
|
||||
class CoreExport User : public Base, public Extensible
|
||||
class CoreExport User : public virtual Base, public Extensible
|
||||
{
|
||||
protected:
|
||||
Anope::string vident;
|
||||
@@ -45,7 +46,7 @@ class CoreExport User : public Base, public Extensible
|
||||
bool OnAccess; /* If the user is on the access list of the nick theyre on */
|
||||
Flags<UserModeName, UMODE_END * 2> modes; /* Bitset of mode names the user has set on them */
|
||||
std::map<UserModeName, Anope::string> Params; /* Map of user modes and the params this user has */
|
||||
NickCore *nc; /* NickCore account the user is currently loggged in as */
|
||||
serialize_obj<NickCore> nc; /* NickCore account the user is currently loggged in as */
|
||||
|
||||
public: // XXX: exposing a tiny bit too much
|
||||
Anope::string nick; /* User's current nick */
|
||||
@@ -159,8 +160,8 @@ class CoreExport User : public Base, public Extensible
|
||||
* @param fmt Format of the Message
|
||||
* @param ... any number of parameters
|
||||
*/
|
||||
void SendMessage(BotInfo *source, const char *fmt, ...);
|
||||
virtual void SendMessage(BotInfo *source, Anope::string msg);
|
||||
void SendMessage(const BotInfo *source, const char *fmt, ...);
|
||||
virtual void SendMessage(const BotInfo *source, Anope::string msg);
|
||||
|
||||
/** Collide a nick
|
||||
* See the comment in users.cpp
|
||||
@@ -187,19 +188,19 @@ class CoreExport User : public Base, public Extensible
|
||||
/** Get the account the user is logged in using
|
||||
* @return The account or NULL
|
||||
*/
|
||||
virtual NickCore *Account();
|
||||
virtual NickCore *Account() const;
|
||||
|
||||
/** Check if the user is identified for their nick
|
||||
* @param CheckNick True to check if the user is identified to the nickname they are on too
|
||||
* @return true or false
|
||||
*/
|
||||
virtual bool IsIdentified(bool CheckNick = false);
|
||||
virtual bool IsIdentified(bool CheckNick = false) const;
|
||||
|
||||
/** Check if the user is recognized for their nick (on the nicks access list)
|
||||
* @param CheckSecure Only returns true if the user has secure off
|
||||
* @return true or false
|
||||
*/
|
||||
virtual bool IsRecognized(bool CheckSecure = true);
|
||||
virtual bool IsRecognized(bool CheckSecure = true) const;
|
||||
|
||||
/** Check if the user is a services oper
|
||||
* @return true if they are an oper
|
||||
@@ -244,32 +245,32 @@ class CoreExport User : public Base, public Extensible
|
||||
* @param um The user mode
|
||||
* @param Param Optional param for the mode
|
||||
*/
|
||||
void SetMode(BotInfo *bi, UserMode *um, const Anope::string &Param = "");
|
||||
void SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param = "");
|
||||
|
||||
/** Set a mode on the user
|
||||
* @param bi The client setting the mode
|
||||
* @param Name The mode name
|
||||
* @param Param Optional param for the mode
|
||||
*/
|
||||
void SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param = "");
|
||||
void SetMode(const BotInfo *bi, UserModeName Name, const Anope::string &Param = "");
|
||||
|
||||
/** Remove a mode on the user
|
||||
* @param bi The client setting the mode
|
||||
* @param um The user mode
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, UserMode *um);
|
||||
void RemoveMode(const BotInfo *bi, UserMode *um);
|
||||
|
||||
/** Remove a mode from the user
|
||||
* @param bi The client setting the mode
|
||||
* @param Name The mode name
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, UserModeName Name);
|
||||
void RemoveMode(const BotInfo *bi, UserModeName Name);
|
||||
|
||||
/** Set a string of modes on a user
|
||||
* @param bi The client setting the modes
|
||||
* @param umodes The modes
|
||||
*/
|
||||
void SetModes(BotInfo *bi, const char *umodes, ...);
|
||||
void SetModes(const BotInfo *bi, const char *umodes, ...);
|
||||
|
||||
/** Set a string of modes on a user internally
|
||||
* @param umodes The modes
|
||||
@@ -287,7 +288,7 @@ class CoreExport User : public Base, public Extensible
|
||||
* @param c The channel
|
||||
* @return The channel container, or NULL
|
||||
*/
|
||||
ChannelContainer *FindChannel(const Channel *c);
|
||||
ChannelContainer *FindChannel(const Channel *c) const;
|
||||
|
||||
/** Check if the user is protected from kicks and negative mode changes
|
||||
* @return true or false
|
||||
|
||||
@@ -81,7 +81,7 @@ class CommandBSBadwords : public Command
|
||||
if (!Number || Number > ci->GetBadWordCount())
|
||||
return;
|
||||
|
||||
BadWord *bw = ci->GetBadWord(Number - 1);
|
||||
const BadWord *bw = ci->GetBadWord(Number - 1);
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(Number);
|
||||
entry["Word"] = bw->word;
|
||||
@@ -96,7 +96,7 @@ class CommandBSBadwords : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
|
||||
if (!word.empty() && !Anope::Match(bw->word, word))
|
||||
continue;
|
||||
@@ -154,7 +154,7 @@ class CommandBSBadwords : public Command
|
||||
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
|
||||
if (!bw->word.empty() && ((Config->BSCaseSensitive && realword.equals_cs(bw->word)) || (!Config->BSCaseSensitive && realword.equals_ci(bw->word))))
|
||||
{
|
||||
@@ -183,7 +183,7 @@ class CommandBSBadwords : public Command
|
||||
else
|
||||
{
|
||||
unsigned i, end;
|
||||
BadWord *badword;
|
||||
const BadWord *badword;
|
||||
|
||||
for (i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ class CommandBSBot : public Command
|
||||
const Anope::string &user = params[2];
|
||||
const Anope::string &host = params[3];
|
||||
const Anope::string &real = params[4];
|
||||
BotInfo *bi;
|
||||
|
||||
if (findbot(nick))
|
||||
{
|
||||
@@ -93,7 +92,7 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bi = new BotInfo(nick, user, host, real);
|
||||
BotInfo *bi = new BotInfo(nick, user, host, real);
|
||||
|
||||
Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname;
|
||||
|
||||
@@ -110,7 +109,6 @@ class CommandBSBot : public Command
|
||||
const Anope::string &user = params.size() > 3 ? params[3] : "";
|
||||
const Anope::string &host = params.size() > 4 ? params[4] : "";
|
||||
const Anope::string &real = params.size() > 5 ? params[5] : "";
|
||||
BotInfo *bi;
|
||||
|
||||
if (oldnick.empty() || nick.empty())
|
||||
{
|
||||
@@ -118,7 +116,8 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(bi = findbot(oldnick)))
|
||||
BotInfo *bi = findbot(oldnick);
|
||||
if (!bi)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
|
||||
return;
|
||||
@@ -263,7 +262,6 @@ class CommandBSBot : public Command
|
||||
void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const Anope::string &nick = params[1];
|
||||
BotInfo *bi;
|
||||
|
||||
if (nick.empty())
|
||||
{
|
||||
@@ -271,7 +269,8 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(bi = findbot(nick)))
|
||||
BotInfo *bi = findbot(nick);
|
||||
if (!bi)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str());
|
||||
return;
|
||||
@@ -288,7 +287,7 @@ class CommandBSBot : public Command
|
||||
Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick;
|
||||
|
||||
source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str());
|
||||
delete bi;
|
||||
bi->destroy();
|
||||
return;
|
||||
}
|
||||
public:
|
||||
|
||||
@@ -30,7 +30,7 @@ class CommandBSBotList : public Command
|
||||
|
||||
list.addColumn("Nick").addColumn("Mask");
|
||||
|
||||
for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
class CommandBSInfo : public Command
|
||||
{
|
||||
private:
|
||||
void send_bot_channels(std::vector<Anope::string> &buffers, BotInfo *bi)
|
||||
void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi)
|
||||
{
|
||||
Anope::string buf;
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
const ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == bi)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class CommandBSInfo : public Command
|
||||
buffers.push_back(buf);
|
||||
}
|
||||
|
||||
void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, NickCore *nc)
|
||||
void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, const NickCore *nc)
|
||||
{
|
||||
if (flags.HasFlag(flag))
|
||||
{
|
||||
@@ -60,7 +60,7 @@ class CommandBSInfo : public Command
|
||||
const Anope::string &query = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
BotInfo *bi = findbot(query);
|
||||
const BotInfo *bi = findbot(query);
|
||||
ChannelInfo *ci;
|
||||
InfoFormatter info(u);
|
||||
|
||||
|
||||
@@ -900,7 +900,7 @@ class BSKick : public Module
|
||||
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
|
||||
if (bw->type == BW_ANY && ((Config->BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos)))
|
||||
mustkick = true;
|
||||
@@ -1012,7 +1012,7 @@ class BSKick : public Module
|
||||
Channel *chan = (*it)->chan;
|
||||
++it;
|
||||
|
||||
if (chan->ci != NULL && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK"))
|
||||
if (chan->ci && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK"))
|
||||
{
|
||||
check_ban(chan->ci, u, TTB_AMSGS);
|
||||
bot_kick(chan->ci, u, _("Don't use AMSGs!"));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
static std::map<Anope::string, int16_t, ci::less> defaultLevels;
|
||||
|
||||
static void reset_levels(ChannelInfo *ci)
|
||||
static inline void reset_levels(ChannelInfo *ci)
|
||||
{
|
||||
ci->ClearLevels();
|
||||
for (std::map<Anope::string, int16_t, ci::less>::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it)
|
||||
@@ -36,7 +36,7 @@ class AccessChanAccess : public ChanAccess
|
||||
return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name);
|
||||
}
|
||||
|
||||
Anope::string Serialize()
|
||||
Anope::string Serialize() const
|
||||
{
|
||||
return stringify(this->level);
|
||||
}
|
||||
@@ -46,11 +46,11 @@ class AccessChanAccess : public ChanAccess
|
||||
this->level = convertTo<int>(data);
|
||||
}
|
||||
|
||||
static int DetermineLevel(ChanAccess *access)
|
||||
static int DetermineLevel(const ChanAccess *access)
|
||||
{
|
||||
if (access->provider->name == "access/access")
|
||||
{
|
||||
AccessChanAccess *aaccess = debug_cast<AccessChanAccess *>(access);
|
||||
const AccessChanAccess *aaccess = debug_cast<const AccessChanAccess *>(access);
|
||||
return aaccess->level;
|
||||
}
|
||||
else
|
||||
@@ -108,7 +108,7 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
ChanAccess *highest = u_access.Highest();
|
||||
const ChanAccess *highest = u_access.Highest();
|
||||
int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0);
|
||||
if (level >= u_level && !u_access.Founder && !u->HasPriv("chanserv/access/modify"))
|
||||
{
|
||||
@@ -123,7 +123,7 @@ class CommandCSAccess : public Command
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("ACCESS_CHANGE") || (level >= u_level && !u_access.Founder);
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL)
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask))
|
||||
{
|
||||
User *targ = finduser(mask);
|
||||
if (targ != NULL)
|
||||
@@ -137,7 +137,7 @@ class CommandCSAccess : public Command
|
||||
|
||||
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i - 1);
|
||||
const ChanAccess *access = ci->GetAccess(i - 1);
|
||||
if (mask.equals_ci(access->mask))
|
||||
{
|
||||
/* Don't allow lowering from a level >= u_level */
|
||||
@@ -230,7 +230,7 @@ class CommandCSAccess : public Command
|
||||
ChanAccess *access = ci->GetAccess(Number - 1);
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(user);
|
||||
ChanAccess *u_highest = u_access.Highest();
|
||||
const ChanAccess *u_highest = u_access.Highest();
|
||||
|
||||
if ((u_highest ? AccessChanAccess::DetermineLevel(u_highest) : 0) <= AccessChanAccess::DetermineLevel(access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display))
|
||||
{
|
||||
@@ -255,7 +255,7 @@ class CommandCSAccess : public Command
|
||||
else
|
||||
{
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
ChanAccess *highest = u_access.Highest();
|
||||
const ChanAccess *highest = u_access.Highest();
|
||||
int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0);
|
||||
|
||||
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
|
||||
@@ -308,7 +308,7 @@ class CommandCSAccess : public Command
|
||||
if (!number || number > ci->GetAccessCount())
|
||||
return;
|
||||
|
||||
ChanAccess *access = ci->GetAccess(number - 1);
|
||||
const ChanAccess *access = ci->GetAccess(number - 1);
|
||||
|
||||
Anope::string timebuf;
|
||||
if (ci->c)
|
||||
@@ -339,7 +339,7 @@ class CommandCSAccess : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i);
|
||||
const ChanAccess *access = ci->GetAccess(i);
|
||||
|
||||
if (!nick.empty() && !Anope::Match(access->mask, nick))
|
||||
continue;
|
||||
@@ -470,7 +470,7 @@ class CommandCSAccess : public Command
|
||||
has_access = true;
|
||||
else if (is_del)
|
||||
{
|
||||
NickAlias *na = findnick(nick);
|
||||
const NickAlias *na = findnick(nick);
|
||||
if (na && na->nc == u->Account())
|
||||
has_access = true;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ class CommandCSAKick : public Command
|
||||
|
||||
Anope::string mask = params[2];
|
||||
Anope::string reason = params.size() > 3 ? params[3] : "";
|
||||
NickAlias *na = findnick(mask);
|
||||
const NickAlias *na = findnick(mask);
|
||||
NickCore *nc = NULL;
|
||||
AutoKick *akick;
|
||||
const AutoKick *akick;
|
||||
|
||||
if (!na)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ class CommandCSAKick : public Command
|
||||
|
||||
/* Match against the lastusermask of all nickalias's with equal
|
||||
* or higher access. - Viper */
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
na = it->second;
|
||||
|
||||
@@ -166,7 +166,6 @@ class CommandCSAKick : public Command
|
||||
User *u = source.u;
|
||||
|
||||
const Anope::string &mask = params[2];
|
||||
AutoKick *akick;
|
||||
unsigned i, end;
|
||||
|
||||
if (!ci->GetAkickCount())
|
||||
@@ -218,12 +217,12 @@ class CommandCSAKick : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
NickAlias *na = findnick(mask);
|
||||
NickCore *nc = na ? na->nc : NULL;
|
||||
const NickAlias *na = findnick(mask);
|
||||
const NickCore *nc = na ? *na->nc : NULL;
|
||||
|
||||
for (i = 0, end = ci->GetAkickCount(); i < end; ++i)
|
||||
{
|
||||
akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
|
||||
if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) || (!akick->HasFlag(AK_ISNICK) && mask.equals_ci(akick->mask)))
|
||||
break;
|
||||
@@ -267,7 +266,7 @@ class CommandCSAKick : public Command
|
||||
if (!number || number > ci->GetAkickCount())
|
||||
return;
|
||||
|
||||
AutoKick *akick = ci->GetAkick(number - 1);
|
||||
const AutoKick *akick = ci->GetAkick(number - 1);
|
||||
|
||||
Anope::string timebuf, lastused;
|
||||
if (akick->addtime)
|
||||
@@ -296,7 +295,7 @@ class CommandCSAKick : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i)
|
||||
{
|
||||
AutoKick *akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
|
||||
if (!mask.empty())
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelInfo *target_ci = cs_findchan(target);
|
||||
if (!target_ci)
|
||||
{
|
||||
@@ -58,10 +59,10 @@ public:
|
||||
|
||||
if (what.empty())
|
||||
{
|
||||
delete target_ci;
|
||||
target_ci->destroy();
|
||||
target_ci = new ChannelInfo(*ci);
|
||||
target_ci->name = target;
|
||||
RegisteredChannelList[target_ci->name] = target_ci;
|
||||
(*RegisteredChannelList)[target_ci->name] = target_ci;
|
||||
target_ci->c = findchan(target_ci->name);
|
||||
if (target_ci->c)
|
||||
{
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
{
|
||||
for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
|
||||
{
|
||||
ChanAccess *taccess = ci->GetAccess(i);
|
||||
const ChanAccess *taccess = ci->GetAccess(i);
|
||||
AccessProvider *provider = taccess->provider;
|
||||
|
||||
ChanAccess *newaccess = provider->Create();
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
target_ci->ClearAkick();
|
||||
for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
|
||||
{
|
||||
AutoKick *akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
if (akick->HasFlag(AK_ISNICK))
|
||||
target_ci->AddAkick(akick->creator, akick->nc, akick->reason, akick->addtime, akick->last_used);
|
||||
else
|
||||
@@ -142,7 +143,7 @@ public:
|
||||
target_ci->ClearBadWords();
|
||||
for (unsigned i = 0; i < ci->GetBadWordCount(); ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
target_ci->AddBadWord(bw->word, bw->type);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class CommandCSDrop : public Command
|
||||
FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci));
|
||||
|
||||
Channel *c = ci->c;
|
||||
delete ci;
|
||||
ci->destroy();
|
||||
|
||||
source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str());
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ class CommandCSEnforce : public Command
|
||||
private:
|
||||
void DoSet(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
const ChannelInfo *ci = c->ci;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
if (ci->HasFlag(CI_SECUREOPS))
|
||||
@@ -39,10 +39,9 @@ class CommandCSEnforce : public Command
|
||||
|
||||
void DoSecureOps(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
bool hadsecureops = false;
|
||||
ChannelInfo *ci = c->ci;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
/* Dirty hack to allow chan_set_correct_modes to work ok.
|
||||
@@ -50,6 +49,7 @@ class CommandCSEnforce : public Command
|
||||
* part of the code. This way we can enforce SECUREOPS even
|
||||
* if it's off.
|
||||
*/
|
||||
bool hadsecureops = false;
|
||||
if (!ci->HasFlag(CI_SECUREOPS))
|
||||
{
|
||||
ci->SetFlag(CI_SECUREOPS);
|
||||
@@ -91,10 +91,10 @@ class CommandCSEnforce : public Command
|
||||
|
||||
void DoCModeR(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
ChannelInfo *ci = c->ci;
|
||||
Anope::string mask;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
struct EntryMsg : Serializable
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
Anope::string creator;
|
||||
Anope::string message;
|
||||
time_t when;
|
||||
@@ -29,14 +29,14 @@ struct EntryMsg : Serializable
|
||||
this->when = ct;
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "EntryMsg";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["ci"] << this->ci->name;
|
||||
data["creator"] << this->creator;
|
||||
@@ -46,7 +46,7 @@ struct EntryMsg : Serializable
|
||||
return data;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data);
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
static unsigned MaxEntries = 0;
|
||||
@@ -55,11 +55,21 @@ struct EntryMessageList : std::vector<EntryMsg>, ExtensibleItem
|
||||
{
|
||||
};
|
||||
|
||||
void EntryMsg::unserialize(serialized_data &data)
|
||||
Serializable* EntryMsg::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(data["ci"].astr());
|
||||
if (!ci)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (obj)
|
||||
{
|
||||
EntryMsg *msg = debug_cast<EntryMsg *>(obj);
|
||||
msg->ci = ci;
|
||||
data["creator"] >> msg->creator;
|
||||
data["message"] >> msg->message;
|
||||
data["when"] >> msg->when;
|
||||
return msg;
|
||||
}
|
||||
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
if (messages == NULL)
|
||||
@@ -69,6 +79,7 @@ void EntryMsg::unserialize(serialized_data &data)
|
||||
}
|
||||
|
||||
messages->push_back(EntryMsg(ci, data["creator"].astr(), data["message"].astr()));
|
||||
return &messages->back();
|
||||
}
|
||||
|
||||
class CommandEntryMessage : public Command
|
||||
|
||||
@@ -106,7 +106,7 @@ class CSStats : public Module
|
||||
Anope::string display;
|
||||
if (params.empty())
|
||||
display = source.u->Account()->display;
|
||||
else if (NickAlias *na = findnick(params[0]))
|
||||
else if (const NickAlias *na = findnick(params[0]))
|
||||
display = na->nc->display;
|
||||
else
|
||||
{
|
||||
@@ -165,4 +165,5 @@ void CommandCSGStats::Execute(CommandSource &source, const std::vector<Anope::st
|
||||
me->DoStats(source, true, params);
|
||||
}
|
||||
|
||||
MODULE_INIT(CSStats)
|
||||
MODULE_INIT(CSStats)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class FlagsChanAccess : public ChanAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
Anope::string Serialize()
|
||||
Anope::string Serialize() const
|
||||
{
|
||||
return Anope::string(this->flags.begin(), this->flags.end());
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class FlagsChanAccess : public ChanAccess
|
||||
this->flags.insert(data[i - 1]);
|
||||
}
|
||||
|
||||
static Anope::string DetermineFlags(ChanAccess *access)
|
||||
static Anope::string DetermineFlags(const ChanAccess *access)
|
||||
{
|
||||
if (access->provider->name == "access/flags")
|
||||
return access->Serialize();
|
||||
@@ -88,7 +88,7 @@ class CommandCSFlags : public Command
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL)
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask))
|
||||
{
|
||||
User *targ = finduser(mask);
|
||||
if (targ != NULL)
|
||||
@@ -234,7 +234,7 @@ class CommandCSFlags : public Command
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i);
|
||||
const ChanAccess *access = ci->GetAccess(i);
|
||||
const Anope::string &flags = FlagsChanAccess::DetermineFlags(access);
|
||||
|
||||
if (!arg.empty())
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
struct ExtensibleString : Anope::string, ExtensibleItem { };
|
||||
|
||||
class CommandCSInfo : public Command
|
||||
{
|
||||
void CheckOptStr(Anope::string &buf, ChannelInfoFlag opt, const char *str, ChannelInfo *ci, NickCore *nc)
|
||||
void CheckOptStr(Anope::string &buf, ChannelInfoFlag opt, const char *str, const ChannelInfo *ci, const NickCore *nc)
|
||||
{
|
||||
if (ci->HasFlag(opt))
|
||||
{
|
||||
@@ -68,7 +70,7 @@ class CommandCSInfo : public Command
|
||||
info["Registered"] = do_strftime(ci->time_registered);
|
||||
info["Last used"] = do_strftime(ci->last_used);
|
||||
|
||||
ModeLock *secret = ci->GetMLock(CMODE_SECRET);
|
||||
const ModeLock *secret = ci->GetMLock(CMODE_SECRET);
|
||||
if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode(CMODE_SECRET)))))
|
||||
{
|
||||
info["Last topic"] = ci->last_topic;
|
||||
|
||||
@@ -76,9 +76,9 @@ class CommandCSList : public Command
|
||||
ListFormatter list;
|
||||
list.addColumn("Name").addColumn("Description");
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
const ChannelInfo *ci = it->second;
|
||||
|
||||
if (!is_servadmin && (ci->HasFlag(CI_PRIVATE) || ci->HasFlag(CI_SUSPENDED)))
|
||||
continue;
|
||||
|
||||
+33
-32
@@ -36,23 +36,23 @@ public:
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (params.size() == 1)
|
||||
{
|
||||
if (ci->log_settings.empty())
|
||||
if (ci->log_settings->empty())
|
||||
source.Reply(_("There currently are no logging configurations for %s."), ci->name.c_str());
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
list.addColumn("Number").addColumn("Service").addColumn("Command").addColumn("Method").addColumn("");
|
||||
|
||||
for (unsigned i = 0; i < ci->log_settings.size(); ++i)
|
||||
for (unsigned i = 0; i < ci->log_settings->size(); ++i)
|
||||
{
|
||||
LogSetting &log = ci->log_settings[i];
|
||||
const LogSetting *log = ci->log_settings->at(i);
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(i + 1);
|
||||
entry["Service"] = log.command_service;
|
||||
entry["Command"] = log.command_name;
|
||||
entry["Method"] = log.method;
|
||||
entry[""] = log.extra;
|
||||
entry["Service"] = log->command_service;
|
||||
entry["Command"] = log->command_name;
|
||||
entry["Method"] = log->method;
|
||||
entry[""] = log->extra;
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
@@ -110,21 +110,22 @@ public:
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
|
||||
for (unsigned i = ci->log_settings.size(); i > 0; --i)
|
||||
for (unsigned i = ci->log_settings->size(); i > 0; --i)
|
||||
{
|
||||
LogSetting &log = ci->log_settings[i - 1];
|
||||
LogSetting *log = ci->log_settings->at(i - 1);
|
||||
|
||||
if (log.service_name == bi->commands[command_name].name && log.method.equals_ci(method))
|
||||
if (log->service_name == bi->commands[command_name].name && log->method.equals_ci(method))
|
||||
{
|
||||
if (log.extra == extra)
|
||||
if (log->extra == extra)
|
||||
{
|
||||
ci->log_settings.erase(ci->log_settings.begin() + i - 1);
|
||||
log->destroy();
|
||||
ci->log_settings->erase(ci->log_settings->begin() + i - 1);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra;
|
||||
source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
log.extra = extra;
|
||||
log->extra = extra;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra;
|
||||
source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
}
|
||||
@@ -132,17 +133,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
LogSetting log;
|
||||
log.ci = ci;
|
||||
log.service_name = bi->commands[command_name].name;
|
||||
log.command_service = bi->nick;
|
||||
log.command_name = command_name;
|
||||
log.method = method;
|
||||
log.extra = extra;
|
||||
log.created = Anope::CurTime;
|
||||
log.creator = u->nick;
|
||||
LogSetting *log = new LogSetting();
|
||||
log->ci = ci;
|
||||
log->service_name = bi->commands[command_name].name;
|
||||
log->command_service = bi->nick;
|
||||
log->command_name = command_name;
|
||||
log->method = method;
|
||||
log->extra = extra;
|
||||
log->created = Anope::CurTime;
|
||||
log->creator = u->nick;
|
||||
|
||||
ci->log_settings.push_back(log);
|
||||
ci->log_settings->push_back(log);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to log " << command << " with method " << method << (extra == "" ? "" : " ") << extra;
|
||||
|
||||
source.Reply(_("Logging is now active for command %s on %s, using log method %s%s%s."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
@@ -197,19 +198,19 @@ class CSLog : public Module
|
||||
if (l->Type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced())
|
||||
return;
|
||||
|
||||
for (unsigned i = l->ci->log_settings.size(); i > 0; --i)
|
||||
for (unsigned i = l->ci->log_settings->size(); i > 0; --i)
|
||||
{
|
||||
LogSetting &log = l->ci->log_settings[i - 1];
|
||||
const LogSetting *log = l->ci->log_settings->at(i - 1);
|
||||
|
||||
if (log.service_name == l->c->name)
|
||||
if (log->service_name == l->c->name)
|
||||
{
|
||||
Anope::string buffer = l->u->nick + " used " + log.command_name + " " + l->buf.str();
|
||||
Anope::string buffer = l->u->nick + " used " + log->command_name + " " + l->buf.str();
|
||||
|
||||
if (log.method.equals_ci("MESSAGE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
|
||||
ircdproto->SendPrivmsg(l->ci->bi, log.extra + l->ci->c->name, "%s", buffer.c_str());
|
||||
else if (log.method.equals_ci("NOTICE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
|
||||
ircdproto->SendNotice(l->ci->bi, log.extra + l->ci->c->name, "%s", buffer.c_str());
|
||||
else if (log.method.equals_ci("MEMO") && memoserv && l->ci->WhoSends() != NULL)
|
||||
if (log->method.equals_ci("MESSAGE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
|
||||
ircdproto->SendPrivmsg(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str());
|
||||
else if (log->method.equals_ci("NOTICE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL)
|
||||
ircdproto->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str());
|
||||
else if (log->method.equals_ci("MEMO") && memoserv && l->ci->WhoSends() != NULL)
|
||||
memoserv->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class CommandCSMode : public Command
|
||||
}
|
||||
else if (subcommand.equals_ci("LIST"))
|
||||
{
|
||||
const std::multimap<ChannelModeName, ModeLock> &mlocks = ci->GetMLock();
|
||||
const ChannelInfo::ModeList &mlocks = ci->GetMLock();
|
||||
if (mlocks.empty())
|
||||
{
|
||||
source.Reply(_("Channel %s has no mode locks."), ci->name.c_str());
|
||||
@@ -161,18 +161,18 @@ class CommandCSMode : public Command
|
||||
ListFormatter list;
|
||||
list.addColumn("Mode").addColumn("Param").addColumn("Creator").addColumn("Created");
|
||||
|
||||
for (std::multimap<ChannelModeName, ModeLock>::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
|
||||
for (ChannelInfo::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
|
||||
{
|
||||
const ModeLock &ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml.name);
|
||||
const ModeLock *ml = it->second;
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->name);
|
||||
if (!cm)
|
||||
continue;
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Mode"] = Anope::printf("%c%c", ml.set ? '+' : '-', cm->ModeChar);
|
||||
entry["Param"] = ml.param;
|
||||
entry["Creator"] = ml.setter;
|
||||
entry["Created"] = do_strftime(ml.created, source.u->Account(), false);
|
||||
entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->ModeChar);
|
||||
entry["Param"] = ml->param;
|
||||
entry["Creator"] = ml->setter;
|
||||
entry["Created"] = do_strftime(ml->created, source.u->Account(), false);
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,31 @@ class CommandModeBase : public Command
|
||||
User *u = source.u;
|
||||
User *u2 = finduser(nick);
|
||||
Channel *c = findchan(chan);
|
||||
ChannelInfo *ci = c ? c->ci : NULL;
|
||||
|
||||
bool is_same = u == u2;
|
||||
|
||||
AccessGroup u_access = ci ? ci->AccessFor(u) : AccessGroup(), u2_access = ci && u2 ? ci->AccessFor(u2) : AccessGroup();
|
||||
|
||||
if (!c)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
|
||||
else if (!ci)
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
else if (!u2)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!u2)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
|
||||
else if (is_same ? !ci->AccessFor(u).HasPriv(levelself) : !ci->AccessFor(u).HasPriv(level))
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelInfo *ci = c->ci;
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_same = u == u2;
|
||||
AccessGroup u_access = ci->AccessFor(u), u2_access = ci->AccessFor(u2);
|
||||
|
||||
if (is_same ? !ci->AccessFor(u).HasPriv(levelself) : !ci->AccessFor(u).HasPriv(level))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (!set && !is_same && ci->HasFlag(CI_PEACE) && u2_access >= u_access)
|
||||
source.Reply(ACCESS_DENIED);
|
||||
|
||||
@@ -46,7 +46,7 @@ class CommandCSRegister : public Command
|
||||
else if (c && !c->HasUserStatus(u, CMODE_OP))
|
||||
source.Reply(_("You must be a channel operator to register the channel."));
|
||||
else if (Config->CSMaxReg && u->Account()->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit"))
|
||||
source.Reply(u->Account()->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : _(CHAN_REACHED_CHANNEL_LIMIT), Config->CSMaxReg);
|
||||
source.Reply(u->Account()->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config->CSMaxReg);
|
||||
else
|
||||
{
|
||||
ci = new ChannelInfo(chan);
|
||||
@@ -54,11 +54,12 @@ class CommandCSRegister : public Command
|
||||
if (!chdesc.empty())
|
||||
ci->desc = chdesc;
|
||||
|
||||
ci->mode_locks = def_mode_locks;
|
||||
for (ChannelInfo::ModeList::iterator it = ci->mode_locks.begin(), it_end = ci->mode_locks.end(); it != it_end; ++it)
|
||||
for (ChannelInfo::ModeList::iterator it = def_mode_locks.begin(), it_end = def_mode_locks.end(); it != it_end; ++it)
|
||||
{
|
||||
it->second.setter = u->nick;
|
||||
it->second.ci = ci;
|
||||
ModeLock *ml = new ModeLock(*it->second);
|
||||
ml->setter = u->nick;
|
||||
ml->ci = ci;
|
||||
ci->mode_locks->insert(std::make_pair(it->first, ml));
|
||||
}
|
||||
|
||||
if (c && !c->topic.empty())
|
||||
|
||||
@@ -37,10 +37,10 @@ class CommandCSSASet : public Command
|
||||
" \n"
|
||||
"Available options:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
const Anope::string &c_name = it->first;
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
service_reference<Command> command("Command", info.name);
|
||||
|
||||
@@ -37,14 +37,14 @@ struct SeenInfo : Serializable
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "SeenInfo";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["nick"] << nick;
|
||||
data["vhost"] << vhost;
|
||||
@@ -57,9 +57,13 @@ struct SeenInfo : Serializable
|
||||
return data;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
SeenInfo *s = new SeenInfo();
|
||||
SeenInfo *s;
|
||||
if (obj)
|
||||
s = debug_cast<SeenInfo *>(obj);
|
||||
else
|
||||
s = new SeenInfo();
|
||||
|
||||
data["nick"] >> s->nick;
|
||||
data["vhost"] >> s->vhost;
|
||||
@@ -71,7 +75,9 @@ struct SeenInfo : Serializable
|
||||
data["message"] >> s->message;
|
||||
data["last"] >> s->last;
|
||||
|
||||
database[s->nick] = s;
|
||||
if (!s)
|
||||
database[s->nick] = s;
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -89,7 +95,7 @@ static SeenInfo *FindInfo(const Anope::string &nick)
|
||||
static bool ShouldHide(const Anope::string &channel, User *u)
|
||||
{
|
||||
Channel *targetchan = findchan(channel);
|
||||
ChannelInfo *targetchan_ci = targetchan ? targetchan->ci : cs_findchan(channel);
|
||||
const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : cs_findchan(channel);
|
||||
|
||||
if (targetchan && targetchan->HasMode(CMODE_SECRET))
|
||||
return true;
|
||||
@@ -303,7 +309,7 @@ class DataBasePurger : public CallBack
|
||||
if ((Anope::CurTime - cur->second->last) > purgetime)
|
||||
{
|
||||
Log(LOG_DEBUG) << cur->first << " was last seen " << do_strftime(cur->second->last) << ", purging entry";
|
||||
delete cur->second;
|
||||
cur->second->destroy();
|
||||
database.erase(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ class CommandCSSet : public Command
|
||||
" \n"
|
||||
"Available options:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
const Anope::string &c_name = it->first;
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
service_reference<Command> command("Command", info.name);
|
||||
|
||||
@@ -22,7 +22,7 @@ class CommandCSSetFounder : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037nick\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)anope_override
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
@@ -44,8 +44,7 @@ class CommandCSSetFounder : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
NickAlias *na = findnick(params[1]);
|
||||
|
||||
const NickAlias *na = findnick(params[1]);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str());
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
struct CSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
struct CSMiscData : ExtensibleItem, Serializable
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
Anope::string name;
|
||||
Anope::string data;
|
||||
|
||||
@@ -22,14 +22,14 @@ struct CSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "CSMiscData";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data sdata;
|
||||
Serialize::Data sdata;
|
||||
|
||||
sdata["ci"] << this->ci->name;
|
||||
sdata["name"] << this->name;
|
||||
@@ -38,13 +38,27 @@ struct CSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
return sdata;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(data["ci"].astr());
|
||||
if (ci == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
ci->Extend(data["name"].astr(), new CSMiscData(ci, data["name"].astr(), data["data"].astr()));
|
||||
CSMiscData *d;
|
||||
if (obj)
|
||||
{
|
||||
d = debug_cast<CSMiscData *>(obj);
|
||||
d->ci = ci;
|
||||
data["name"] >> d->name;
|
||||
data["data"] >> d->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
d = new CSMiscData(ci, data["name"].astr(), data["data"].astr());
|
||||
ci->Extend(data["name"].astr(), d);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class CommandCSSetSuccessor : public Command
|
||||
|
||||
if (params.size() > 1)
|
||||
{
|
||||
NickAlias *na = findnick(params[1]);
|
||||
const NickAlias *na = findnick(params[1]);
|
||||
|
||||
if (!na)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
struct ExtensibleString : Anope::string, ExtensibleItem
|
||||
{
|
||||
ExtensibleString(const Anope::string &s) : Anope::string(s) { }
|
||||
};
|
||||
|
||||
struct ChanSuspend : ExtensibleItem, Serializable
|
||||
{
|
||||
Anope::string chan;
|
||||
@@ -22,14 +27,14 @@ struct ChanSuspend : ExtensibleItem, Serializable
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const
|
||||
const Anope::string serialize_name() const
|
||||
{
|
||||
return "ChanSuspend";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data sd;
|
||||
Serialize::Data sd;
|
||||
|
||||
sd["chan"] << this->chan;
|
||||
sd["when"] << this->when;
|
||||
@@ -37,18 +42,24 @@ struct ChanSuspend : ExtensibleItem, Serializable
|
||||
return sd;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &sd)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &sd)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(sd["chan"].astr());
|
||||
if (ci == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
ChanSuspend *cs = new ChanSuspend();
|
||||
ChanSuspend *cs;
|
||||
if (obj)
|
||||
cs = debug_cast<ChanSuspend *>(obj);
|
||||
else
|
||||
cs = new ChanSuspend();
|
||||
|
||||
sd["chan"] >> cs->chan;
|
||||
sd["when"] >> cs->when;
|
||||
|
||||
ci->Extend("ci_suspend_expire", cs);
|
||||
if (!obj)
|
||||
ci->Extend("ci_suspend_expire", cs);
|
||||
return cs;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -220,11 +231,12 @@ class CSSuspend : public Module
|
||||
|
||||
~CSSuspend()
|
||||
{
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
it->second->Shrink("cs_suspend_expire");
|
||||
it->second->Shrink("suspend_by");
|
||||
it->second->Shrink("suspend_reason");
|
||||
ChannelInfo *ci = it->second;
|
||||
ci->Shrink("cs_suspend_expire");
|
||||
ci->Shrink("suspend_by");
|
||||
ci->Shrink("suspend_reason");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class CommandCSUp : public Command
|
||||
|
||||
if (c == NULL)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, channel.c_str());
|
||||
else if (c->ci == NULL)
|
||||
else if (!c->ci)
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
|
||||
else
|
||||
chan_set_correct_modes(u, c, 1);
|
||||
@@ -94,7 +94,7 @@ class CommandCSDown : public Command
|
||||
|
||||
if (c == NULL)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, channel.c_str());
|
||||
else if (c->ci == NULL)
|
||||
else if (!c->ci)
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
|
||||
else
|
||||
RemoveAll(u, c);
|
||||
|
||||
+10
-10
@@ -116,7 +116,7 @@ class XOPChanAccess : public ChanAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
Anope::string Serialize()
|
||||
Anope::string Serialize() const
|
||||
{
|
||||
for (int i = 0; xopAccess[i].type != XOP_UNKNOWN; ++i)
|
||||
{
|
||||
@@ -145,11 +145,11 @@ class XOPChanAccess : public ChanAccess
|
||||
this->type = XOP_UNKNOWN;
|
||||
}
|
||||
|
||||
static XOPType DetermineLevel(ChanAccess *access)
|
||||
static XOPType DetermineLevel(const ChanAccess *access)
|
||||
{
|
||||
if (access->provider->name == "access/xop")
|
||||
{
|
||||
XOPChanAccess *xaccess = debug_cast<XOPChanAccess *>(access);
|
||||
const XOPChanAccess *xaccess = debug_cast<const XOPChanAccess *>(access);
|
||||
return xaccess->type;
|
||||
}
|
||||
else
|
||||
@@ -216,7 +216,7 @@ class XOPBase : public Command
|
||||
}
|
||||
|
||||
AccessGroup access = ci->AccessFor(u);
|
||||
ChanAccess *highest = access.Highest();
|
||||
const ChanAccess *highest = access.Highest();
|
||||
int u_level = (highest ? XOPChanAccess::DetermineLevel(highest) : 0);
|
||||
|
||||
if ((!access.Founder && !access.HasPriv("ACCESS_CHANGE") && !u->HasPriv("chanserv/access/modify")) || (level <= u_level && !access.Founder))
|
||||
@@ -225,7 +225,7 @@ class XOPBase : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL)
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask))
|
||||
{
|
||||
User *targ = finduser(mask);
|
||||
if (targ != NULL)
|
||||
@@ -239,7 +239,7 @@ class XOPBase : public Command
|
||||
|
||||
for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
|
||||
{
|
||||
ChanAccess *a = ci->GetAccess(i);
|
||||
const ChanAccess *a = ci->GetAccess(i);
|
||||
|
||||
if (a->mask.equals_ci(mask))
|
||||
{
|
||||
@@ -304,7 +304,7 @@ class XOPBase : public Command
|
||||
}
|
||||
|
||||
AccessGroup access = ci->AccessFor(u);
|
||||
ChanAccess *highest = access.Highest();
|
||||
const ChanAccess *highest = access.Highest();
|
||||
bool override = false;
|
||||
if ((!mask.equals_ci(u->Account()->display) && !access.HasPriv("ACCESS_CHANGE") && !access.Founder) || ((!highest || level <= XOPChanAccess::DetermineLevel(highest)) && !access.Founder))
|
||||
{
|
||||
@@ -436,7 +436,7 @@ class XOPBase : public Command
|
||||
if (!Number || Number > ci->GetAccessCount())
|
||||
return;
|
||||
|
||||
ChanAccess *a = ci->GetAccess(Number - 1);
|
||||
const ChanAccess *a = ci->GetAccess(Number - 1);
|
||||
|
||||
if (this->type != XOPChanAccess::DetermineLevel(a))
|
||||
return;
|
||||
@@ -453,7 +453,7 @@ class XOPBase : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
ChanAccess *a = ci->GetAccess(i);
|
||||
const ChanAccess *a = ci->GetAccess(i);
|
||||
|
||||
if (XOPChanAccess::DetermineLevel(a) != level)
|
||||
continue;
|
||||
@@ -507,7 +507,7 @@ class XOPBase : public Command
|
||||
|
||||
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i - 1);
|
||||
const ChanAccess *access = ci->GetAccess(i - 1);
|
||||
if (XOPChanAccess::DetermineLevel(access) == level)
|
||||
ci->EraseAccess(i - 1);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ class CommandHelp : public Command
|
||||
return;
|
||||
|
||||
User *u = source.u;
|
||||
BotInfo *bi = source.owner;
|
||||
const BotInfo *bi = source.owner;
|
||||
|
||||
if (params.empty())
|
||||
{
|
||||
for (BotInfo::command_map::iterator it = bi->commands.begin(), it_end = bi->commands.end(); it != it_end; ++it)
|
||||
for (BotInfo::command_map::const_iterator it = bi->commands.begin(), it_end = bi->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
const Anope::string &c_name = it->first;
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
|
||||
// Smaller command exists
|
||||
Anope::string cmd = myStrGetToken(c_name, ' ', 0);
|
||||
@@ -65,11 +65,11 @@ class CommandHelp : public Command
|
||||
full_command += " " + params[i];
|
||||
full_command.erase(full_command.begin());
|
||||
|
||||
BotInfo::command_map::iterator it = bi->commands.find(full_command);
|
||||
BotInfo::command_map::const_iterator it = bi->commands.find(full_command);
|
||||
if (it == bi->commands.end())
|
||||
continue;
|
||||
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
|
||||
service_reference<Command> c("Command", info.name);
|
||||
if (!c)
|
||||
|
||||
@@ -65,8 +65,8 @@ class CommandHSDelAll : public Command
|
||||
if (na)
|
||||
{
|
||||
FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
|
||||
NickCore *nc = na->nc;
|
||||
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
|
||||
const NickCore *nc = na->nc;
|
||||
for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
|
||||
{
|
||||
na = *it;
|
||||
na->RemoveVhost();
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
|
||||
class CommandHSGroup : public Command
|
||||
{
|
||||
void Sync(NickAlias *na)
|
||||
void Sync(const NickAlias *na)
|
||||
{
|
||||
if (!na || !na->HasVhost())
|
||||
return;
|
||||
|
||||
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
|
||||
for (std::list<serialize_obj<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;)
|
||||
{
|
||||
NickAlias *nick = *it;
|
||||
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
|
||||
NickAlias *nick = *it++;
|
||||
if (nick)
|
||||
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ class CommandHSList : public Command
|
||||
ListFormatter list;
|
||||
list.addColumn("Number").addColumn("Nick").addColumn("Vhost").addColumn("Creator").addColumn("Created");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
const NickAlias *na = it->second;
|
||||
|
||||
if (!na->HasVhost())
|
||||
continue;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CommandHSOff : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
NickAlias *na = findnick(u->nick);
|
||||
const NickAlias *na = findnick(u->nick);
|
||||
|
||||
if (!na || !na->HasVhost())
|
||||
source.Reply(HOST_NOT_ASSIGNED);
|
||||
|
||||
@@ -25,7 +25,7 @@ class CommandHSOn : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
NickAlias *na = findnick(u->nick);
|
||||
const NickAlias *na = findnick(u->nick);
|
||||
if (na && u->Account() == na->nc && na->HasVhost())
|
||||
{
|
||||
if (!na->GetVhostIdent().empty())
|
||||
|
||||
@@ -30,14 +30,14 @@ struct HostRequest : ExtensibleItem, Serializable
|
||||
Anope::string host;
|
||||
time_t time;
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "HostRequest";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["nick"] << this->nick;
|
||||
data["ident"] << this->ident;
|
||||
@@ -47,19 +47,25 @@ struct HostRequest : ExtensibleItem, Serializable
|
||||
return data;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
NickAlias *na = findnick(data["nick"].astr());
|
||||
if (na == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
HostRequest *req = new HostRequest;
|
||||
HostRequest *req;
|
||||
if (obj)
|
||||
req = debug_cast<HostRequest *>(obj);
|
||||
else
|
||||
req = new HostRequest;
|
||||
req->nick = na->nick;
|
||||
data["ident"] >> req->ident;
|
||||
data["host"] >> req->host;
|
||||
data["time"] >> req->time;
|
||||
|
||||
na->Extend("hs_request", req);
|
||||
if (!obj)
|
||||
na->Extend("hs_request", req);
|
||||
return req;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -282,9 +288,9 @@ class CommandHSWaiting : public Command
|
||||
|
||||
list.addColumn("Number").addColumn("Nick").addColumn("Vhost").addColumn("Created");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
const NickAlias *na = it->second;
|
||||
HostRequest *hr = na->GetExt<HostRequest *>("hs_request");
|
||||
if (!hr)
|
||||
continue;
|
||||
@@ -358,8 +364,11 @@ class HSRequest : public Module
|
||||
|
||||
~HSRequest()
|
||||
{
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
it->second->Shrink("hs_request");
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
na->Shrink("hs_request");
|
||||
}
|
||||
}
|
||||
|
||||
void OnReload() anope_override
|
||||
@@ -387,7 +396,7 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An
|
||||
{
|
||||
Oper *o = Config->Opers[i];
|
||||
|
||||
NickAlias *na = findnick(o->name);
|
||||
const NickAlias *na = findnick(o->name);
|
||||
if (!na)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -104,15 +104,16 @@ class CommandHSSet : public Command
|
||||
|
||||
class CommandHSSetAll : public Command
|
||||
{
|
||||
void Sync(NickAlias *na)
|
||||
void Sync(const NickAlias *na)
|
||||
{
|
||||
if (!na || !na->HasVhost())
|
||||
return;
|
||||
|
||||
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
|
||||
for (std::list<serialize_obj<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;)
|
||||
{
|
||||
NickAlias *nick = *it;
|
||||
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
|
||||
NickAlias *nick = *it++;
|
||||
if (nick)
|
||||
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,20 @@ class CommandMSCancel : public Command
|
||||
source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nname.c_str());
|
||||
else
|
||||
{
|
||||
for (int i = mi->memos.size() - 1; i >= 0; --i)
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->memos[i]->sender))
|
||||
ChannelInfo *ci;
|
||||
NickAlias *na;
|
||||
if (ischan)
|
||||
ci = cs_findchan(nname);
|
||||
else
|
||||
na = findnick(nname);
|
||||
for (int i = mi->memos->size() - 1; i >= 0; --i)
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->GetMemo(i)->sender))
|
||||
{
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(findnick(nname)->nc, mi, mi->memos[i]));
|
||||
mi->Del(mi->memos[i]);
|
||||
if (ischan)
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i)));
|
||||
else
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(na->nc, mi, mi->GetMemo(i)));
|
||||
mi->Del(i);
|
||||
source.Reply(_("Last memo to \002%s\002 has been cancelled."), nname.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,28 +30,28 @@ class CommandMSCheck : public Command
|
||||
|
||||
bool found = false;
|
||||
|
||||
NickAlias *na = findnick(recipient);
|
||||
const NickAlias *na = findnick(recipient);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, recipient.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
MemoInfo *mi = &na->nc->memos;
|
||||
MemoInfo *mi = const_cast<MemoInfo *>(&na->nc->memos);
|
||||
|
||||
/* Okay, I know this looks strange but we wanna get the LAST memo, so we
|
||||
have to loop backwards */
|
||||
|
||||
for (int i = mi->memos.size() - 1; i >= 0; --i)
|
||||
for (int i = mi->memos->size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (u->Account()->display.equals_ci(mi->memos[i]->sender))
|
||||
if (u->Account()->display.equals_ci(mi->GetMemo(i)->sender))
|
||||
{
|
||||
found = true; /* Yes, we've found the memo */
|
||||
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), do_strftime(mi->memos[i]->time).c_str());
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), do_strftime(mi->GetMemo(i)->time).c_str());
|
||||
else
|
||||
source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), do_strftime(mi->memos[i]->time).c_str());
|
||||
source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), do_strftime(mi->GetMemo(i)->time).c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-16
@@ -25,13 +25,13 @@ class MemoDelCallback : public NumberList
|
||||
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > mi->memos.size())
|
||||
if (!Number || Number > mi->memos->size())
|
||||
return;
|
||||
|
||||
if (ci)
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->memos[Number - 1]));
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(Number - 1)));
|
||||
else
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.u->Account(), mi, mi->memos[Number - 1]));
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.u->Account(), mi, mi->GetMemo(Number - 1)));
|
||||
|
||||
mi->Del(Number - 1);
|
||||
source.Reply(_("Memo %d has been deleted."), Number);
|
||||
@@ -52,7 +52,7 @@ class CommandMSDel : public Command
|
||||
User *u = source.u;
|
||||
|
||||
MemoInfo *mi;
|
||||
ChannelInfo *ci = NULL;
|
||||
ChannelInfo *ci;
|
||||
Anope::string numstr = !params.empty() ? params[0] : "", chan;
|
||||
|
||||
if (!numstr.empty() && numstr[0] == '#')
|
||||
@@ -60,7 +60,8 @@ class CommandMSDel : public Command
|
||||
chan = numstr;
|
||||
numstr = params.size() > 1 ? params[1] : "";
|
||||
|
||||
if (!(ci = cs_findchan(chan)))
|
||||
ci = cs_findchan(chan);
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
return;
|
||||
@@ -78,10 +79,10 @@ class CommandMSDel : public Command
|
||||
mi = &ci->memos;
|
||||
}
|
||||
else
|
||||
mi = &u->Account()->memos;
|
||||
mi = const_cast<MemoInfo *>(&u->Account()->memos);
|
||||
if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST")))
|
||||
this->OnSyntaxError(source, numstr);
|
||||
else if (mi->memos.empty())
|
||||
else if (mi->memos->empty())
|
||||
{
|
||||
if (!chan.empty())
|
||||
source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str());
|
||||
@@ -99,24 +100,24 @@ class CommandMSDel : public Command
|
||||
{
|
||||
/* Delete last memo. */
|
||||
if (ci)
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->memos[mi->memos.size() - 1]));
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(mi->memos->size() - 1)));
|
||||
else
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->memos[mi->memos.size() - 1]));
|
||||
mi->Del(mi->memos[mi->memos.size() - 1]);
|
||||
source.Reply(_("Memo %d has been deleted."), mi->memos.size() + 1);
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->GetMemo(mi->memos->size() - 1)));
|
||||
mi->Del(mi->memos->size() - 1);
|
||||
source.Reply(_("Memo %d has been deleted."), mi->memos->size() + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Delete all memos. */
|
||||
for (unsigned i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
for (unsigned i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
{
|
||||
if (ci)
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->memos[i]));
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i)));
|
||||
else
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->memos[i]));
|
||||
delete mi->memos[i];
|
||||
FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->GetMemo(i)));
|
||||
mi->GetMemo(i)->destroy();
|
||||
}
|
||||
mi->memos.clear();
|
||||
mi->memos->clear();
|
||||
if (!chan.empty())
|
||||
source.Reply(_("All memos for channel %s have been deleted."), chan.c_str());
|
||||
else
|
||||
|
||||
@@ -27,8 +27,8 @@ class CommandMSInfo : public Command
|
||||
User *u = source.u;
|
||||
|
||||
const MemoInfo *mi;
|
||||
NickAlias *na = NULL;
|
||||
ChannelInfo *ci = NULL;
|
||||
const NickAlias *na = NULL;
|
||||
ChannelInfo *ci;
|
||||
const Anope::string &nname = !params.empty() ? params[0] : "";
|
||||
int hardmax = 0;
|
||||
|
||||
@@ -45,7 +45,8 @@ class CommandMSInfo : public Command
|
||||
}
|
||||
else if (!nname.empty() && nname[0] == '#')
|
||||
{
|
||||
if (!(ci = cs_findchan(nname)))
|
||||
ci = cs_findchan(nname);
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, nname.c_str());
|
||||
return;
|
||||
@@ -71,11 +72,11 @@ class CommandMSInfo : public Command
|
||||
|
||||
if (!nname.empty() && (ci || na->nc != u->Account()))
|
||||
{
|
||||
if (mi->memos.empty())
|
||||
if (mi->memos->empty())
|
||||
source.Reply(_("%s currently has no memos."), nname.c_str());
|
||||
else if (mi->memos.size() == 1)
|
||||
else if (mi->memos->size() == 1)
|
||||
{
|
||||
if (mi->memos[0]->HasFlag(MF_UNREAD))
|
||||
if (mi->GetMemo(0)->HasFlag(MF_UNREAD))
|
||||
source.Reply(_("%s currently has \0021\002 memo, and it has not yet been read."), nname.c_str());
|
||||
else
|
||||
source.Reply(_("%s currently has \0021\002 memo."), nname.c_str());
|
||||
@@ -83,17 +84,17 @@ class CommandMSInfo : public Command
|
||||
else
|
||||
{
|
||||
unsigned count = 0, i, end;
|
||||
for (i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
for (i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
++count;
|
||||
if (count == mi->memos.size())
|
||||
if (count == mi->memos->size())
|
||||
source.Reply(_("%s currently has \002%d\002 memos; all of them are unread."), nname.c_str(), count);
|
||||
else if (!count)
|
||||
source.Reply(_("%s currently has \002%d\002 memos."), nname.c_str(), mi->memos.size());
|
||||
source.Reply(_("%s currently has \002%d\002 memos."), nname.c_str(), mi->memos->size());
|
||||
else if (count == 1)
|
||||
source.Reply(_("%s currently has \002%d\002 memos, of which \0021\002 is unread."), nname.c_str(), mi->memos.size());
|
||||
source.Reply(_("%s currently has \002%d\002 memos, of which \0021\002 is unread."), nname.c_str(), mi->memos->size());
|
||||
else
|
||||
source.Reply(_("%s currently has \002%d\002 memos, of which \002%d\002 are unread."), nname.c_str(), mi->memos.size(), count);
|
||||
source.Reply(_("%s currently has \002%d\002 memos, of which \002%d\002 are unread."), nname.c_str(), mi->memos->size(), count);
|
||||
}
|
||||
if (!mi->memomax)
|
||||
{
|
||||
@@ -128,11 +129,11 @@ class CommandMSInfo : public Command
|
||||
}
|
||||
else /* !nname || (!ci || na->nc == u->Account()) */
|
||||
{
|
||||
if (mi->memos.empty())
|
||||
if (mi->memos->empty())
|
||||
source.Reply(_("You currently have no memos."));
|
||||
else if (mi->memos.size() == 1)
|
||||
else if (mi->memos->size() == 1)
|
||||
{
|
||||
if (mi->memos[0]->HasFlag(MF_UNREAD))
|
||||
if (mi->GetMemo(0)->HasFlag(MF_UNREAD))
|
||||
source.Reply(_("You currently have \0021\002 memo, and it has not yet been read."));
|
||||
else
|
||||
source.Reply(_("You currently have \0021\002 memo."));
|
||||
@@ -140,17 +141,17 @@ class CommandMSInfo : public Command
|
||||
else
|
||||
{
|
||||
unsigned count = 0, i, end;
|
||||
for (i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
for (i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
++count;
|
||||
if (count == mi->memos.size())
|
||||
if (count == mi->memos->size())
|
||||
source.Reply(_("You currently have \002%d\002 memos; all of them are unread."), count);
|
||||
else if (!count)
|
||||
source.Reply(_("You currently have \002%d\002 memos."), mi->memos.size());
|
||||
source.Reply(_("You currently have \002%d\002 memos."), mi->memos->size());
|
||||
else if (count == 1)
|
||||
source.Reply(_("You currently have \002%d\002 memos, of which \0021\002 is unread."), mi->memos.size());
|
||||
source.Reply(_("You currently have \002%d\002 memos, of which \0021\002 is unread."), mi->memos->size());
|
||||
else
|
||||
source.Reply(_("You currently have \002%d\002 memos, of which \002%d\002 are unread."), mi->memos.size(), count);
|
||||
source.Reply(_("You currently have \002%d\002 memos, of which \002%d\002 are unread."), mi->memos->size(), count);
|
||||
}
|
||||
|
||||
if (!mi->memomax)
|
||||
|
||||
@@ -27,7 +27,7 @@ class CommandMSList : public Command
|
||||
User *u = source.u;
|
||||
|
||||
Anope::string param = !params.empty() ? params[0] : "", chan;
|
||||
ChannelInfo *ci = NULL;
|
||||
ChannelInfo *ci;
|
||||
const MemoInfo *mi;
|
||||
|
||||
if (!param.empty() && param[0] == '#')
|
||||
@@ -35,7 +35,8 @@ class CommandMSList : public Command
|
||||
chan = param;
|
||||
param = params.size() > 1 ? params[1] : "";
|
||||
|
||||
if (!(ci = cs_findchan(chan)))
|
||||
ci = cs_findchan(chan);
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
return;
|
||||
@@ -52,7 +53,7 @@ class CommandMSList : public Command
|
||||
|
||||
if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW"))
|
||||
this->OnSyntaxError(source, param);
|
||||
else if (!mi->memos.size())
|
||||
else if (!mi->memos->size())
|
||||
{
|
||||
if (!chan.empty())
|
||||
source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str());
|
||||
@@ -79,10 +80,10 @@ class CommandMSList : public Command
|
||||
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > mi->memos.size())
|
||||
if (!Number || Number > mi->memos->size())
|
||||
return;
|
||||
|
||||
Memo *m = mi->memos[Number];
|
||||
const Memo *m = mi->GetMemo(Number);
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = (m->HasFlag(MF_UNREAD) ? "* " : " ") + stringify(Number + 1);
|
||||
@@ -99,8 +100,8 @@ class CommandMSList : public Command
|
||||
if (!param.empty())
|
||||
{
|
||||
unsigned i, end;
|
||||
for (i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
for (i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
break;
|
||||
if (i == end)
|
||||
{
|
||||
@@ -112,12 +113,12 @@ class CommandMSList : public Command
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
for (unsigned i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
{
|
||||
if (!param.empty() && !mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
if (!param.empty() && !mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
continue;
|
||||
|
||||
Memo *m = mi->memos[i];
|
||||
const Memo *m = mi->GetMemo(i);
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = (m->HasFlag(MF_UNREAD) ? "* " : " ") + stringify(i + 1);
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
#include "module.h"
|
||||
#include "memoserv.h"
|
||||
|
||||
void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ)
|
||||
static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ)
|
||||
{
|
||||
/* Only send receipt if memos are allowed */
|
||||
if (memoserv && !readonly)
|
||||
{
|
||||
/* Get nick alias for sender */
|
||||
NickAlias *na = findnick(m->sender);
|
||||
const NickAlias *na = findnick(m->sender);
|
||||
|
||||
if (!na)
|
||||
return;
|
||||
|
||||
/* Get nick core for sender */
|
||||
NickCore *nc = na->nc;
|
||||
const NickCore *nc = na->nc;
|
||||
|
||||
if (!nc)
|
||||
return;
|
||||
@@ -52,23 +52,23 @@ class MemoListCallback : public NumberList
|
||||
{
|
||||
CommandSource &source;
|
||||
MemoInfo *mi;
|
||||
ChannelInfo *ci;
|
||||
const ChannelInfo *ci;
|
||||
public:
|
||||
MemoListCallback(CommandSource &_source, MemoInfo *_mi, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi), ci(_ci)
|
||||
MemoListCallback(CommandSource &_source, MemoInfo *_mi, const ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, false), source(_source), mi(_mi), ci(_ci)
|
||||
{
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > mi->memos.size())
|
||||
if (!Number || Number > mi->memos->size())
|
||||
return;
|
||||
|
||||
MemoListCallback::DoRead(source, mi, ci, Number - 1);
|
||||
}
|
||||
|
||||
static void DoRead(CommandSource &source, MemoInfo *mi, ChannelInfo *ci, unsigned index)
|
||||
static void DoRead(CommandSource &source, MemoInfo *mi, const ChannelInfo *ci, unsigned index)
|
||||
{
|
||||
Memo *m = mi->memos[index];
|
||||
Memo *m = mi->GetMemo(index);
|
||||
if (ci)
|
||||
source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %s %d\002"), index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), index + 1);
|
||||
else
|
||||
@@ -96,7 +96,7 @@ class CommandMSRead : public Command
|
||||
User *u = source.u;
|
||||
|
||||
MemoInfo *mi;
|
||||
ChannelInfo *ci = NULL;
|
||||
ChannelInfo *ci;
|
||||
Anope::string numstr = params[0], chan;
|
||||
|
||||
if (!numstr.empty() && numstr[0] == '#')
|
||||
@@ -104,7 +104,8 @@ class CommandMSRead : public Command
|
||||
chan = numstr;
|
||||
numstr = params.size() > 1 ? params[1] : "";
|
||||
|
||||
if (!(ci = cs_findchan(chan)))
|
||||
ci = cs_findchan(chan);
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
return;
|
||||
@@ -117,11 +118,11 @@ class CommandMSRead : public Command
|
||||
mi = &ci->memos;
|
||||
}
|
||||
else
|
||||
mi = &u->Account()->memos;
|
||||
mi = const_cast<MemoInfo *>(&u->Account()->memos);
|
||||
|
||||
if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only()))
|
||||
this->OnSyntaxError(source, numstr);
|
||||
else if (mi->memos.empty())
|
||||
else if (mi->memos->empty())
|
||||
{
|
||||
if (!chan.empty())
|
||||
source.Reply(MEMO_X_HAS_NO_MEMOS, chan.c_str());
|
||||
@@ -135,8 +136,8 @@ class CommandMSRead : public Command
|
||||
if (numstr.equals_ci("NEW"))
|
||||
{
|
||||
int readcount = 0;
|
||||
for (i = 0, end = mi->memos.size(); i < end; ++i)
|
||||
if (mi->memos[i]->HasFlag(MF_UNREAD))
|
||||
for (i = 0, end = mi->memos->size(); i < end; ++i)
|
||||
if (mi->GetMemo(i)->HasFlag(MF_UNREAD))
|
||||
{
|
||||
MemoListCallback::DoRead(source, mi, ci, i);
|
||||
++readcount;
|
||||
@@ -151,7 +152,7 @@ class CommandMSRead : public Command
|
||||
}
|
||||
else if (numstr.equals_ci("LAST"))
|
||||
{
|
||||
for (i = 0, end = mi->memos.size() - 1; i < end; ++i);
|
||||
for (i = 0, end = mi->memos->size() - 1; i < end; ++i);
|
||||
MemoListCallback::DoRead(source, mi, ci, i);
|
||||
}
|
||||
else /* number[s] */
|
||||
|
||||
@@ -32,7 +32,7 @@ class CommandMSRSend : public Command
|
||||
|
||||
const Anope::string &nick = params[0];
|
||||
const Anope::string &text = params[1];
|
||||
NickAlias *na = NULL;
|
||||
const NickAlias *na = NULL;
|
||||
|
||||
/* prevent user from rsend to themselves */
|
||||
if ((na = findnick(nick)) && na->nc == u->Account())
|
||||
@@ -65,7 +65,7 @@ class CommandMSRSend : public Command
|
||||
MemoInfo *mi = memoserv->GetMemoInfo(nick, ischan);
|
||||
if (mi == NULL)
|
||||
throw CoreException("NULL mi in ms_rsend");
|
||||
Memo *m = (mi->memos.size() ? mi->memos[mi->memos.size() - 1] : NULL);
|
||||
Memo *m = (mi->memos->size() ? mi->GetMemo(mi->memos->size() - 1) : NULL);
|
||||
if (m != NULL)
|
||||
m->SetFlag(MF_RECEIPT);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ class CommandMSSendAll : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
NickAlias *na = findnick(u->nick);
|
||||
const NickAlias *na = findnick(u->nick);
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
const NickCore *nc = it->second;
|
||||
|
||||
if ((na && na->nc == nc) || !nc->display.equals_ci(u->nick))
|
||||
memoserv->Send(u->nick, nc->display, text);
|
||||
|
||||
+19
-16
@@ -20,30 +20,31 @@ class CommandMSSet : public Command
|
||||
{
|
||||
User *u = source.u;
|
||||
const Anope::string ¶m = params[1];
|
||||
NickCore *nc = u->Account();
|
||||
|
||||
if (param.equals_ci("ON"))
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->SetFlag(NI_MEMO_RECEIVE);
|
||||
nc->SetFlag(NI_MEMO_SIGNON);
|
||||
nc->SetFlag(NI_MEMO_RECEIVE);
|
||||
source.Reply(_("%s will now notify you of memos when you log on and when they are sent to you."), Config->MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("LOGON"))
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
nc->SetFlag(NI_MEMO_SIGNON);
|
||||
nc->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
source.Reply(_("%s will now notify you of memos when you log on or unset /AWAY."), Config->MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("NEW"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->SetFlag(NI_MEMO_RECEIVE);
|
||||
nc->UnsetFlag(NI_MEMO_SIGNON);
|
||||
nc->SetFlag(NI_MEMO_RECEIVE);
|
||||
source.Reply(_("%s will now notify you of memos when they are sent to you."), Config->MemoServ.c_str());
|
||||
}
|
||||
else if (param.equals_ci("MAIL"))
|
||||
{
|
||||
if (!u->Account()->email.empty())
|
||||
if (!nc->email.empty())
|
||||
{
|
||||
u->Account()->SetFlag(NI_MEMO_MAIL);
|
||||
nc->SetFlag(NI_MEMO_MAIL);
|
||||
source.Reply(_("You will now be informed about new memos via email."));
|
||||
}
|
||||
else
|
||||
@@ -51,14 +52,14 @@ class CommandMSSet : public Command
|
||||
}
|
||||
else if (param.equals_ci("NOMAIL"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_MAIL);
|
||||
nc->UnsetFlag(NI_MEMO_MAIL);
|
||||
source.Reply(_("You will no longer be informed via email."));
|
||||
}
|
||||
else if (param.equals_ci("OFF"))
|
||||
{
|
||||
u->Account()->UnsetFlag(NI_MEMO_SIGNON);
|
||||
u->Account()->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
u->Account()->UnsetFlag(NI_MEMO_MAIL);
|
||||
nc->UnsetFlag(NI_MEMO_SIGNON);
|
||||
nc->UnsetFlag(NI_MEMO_RECEIVE);
|
||||
nc->UnsetFlag(NI_MEMO_MAIL);
|
||||
source.Reply(_("%s will not send you any notification of memos."), Config->MemoServ.c_str());
|
||||
}
|
||||
else
|
||||
@@ -86,7 +87,9 @@ class CommandMSSet : public Command
|
||||
p1 = p2;
|
||||
p2 = p3;
|
||||
p3 = params.size() > 4 ? params[4] : "";
|
||||
if (!(ci = cs_findchan(chan)))
|
||||
|
||||
ci = cs_findchan(chan);
|
||||
if (!ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
return;
|
||||
@@ -102,14 +105,14 @@ class CommandMSSet : public Command
|
||||
{
|
||||
if (!p2.empty() && !p2.equals_ci("HARD") && chan.empty())
|
||||
{
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
if (!(na = findnick(p1)))
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, p1.c_str());
|
||||
return;
|
||||
}
|
||||
user = p1;
|
||||
mi = &na->nc->memos;
|
||||
mi = const_cast<MemoInfo *>(&na->nc->memos);
|
||||
nc = na->nc;
|
||||
p1 = p2;
|
||||
p2 = p3;
|
||||
@@ -209,7 +212,7 @@ class CommandMSSet : public Command
|
||||
{
|
||||
User *u = source.u;
|
||||
const Anope::string &cmd = params[0];
|
||||
MemoInfo *mi = &u->Account()->memos;
|
||||
MemoInfo *mi = const_cast<MemoInfo *>(&u->Account()->memos);
|
||||
|
||||
if (readonly)
|
||||
source.Reply(_("Sorry, memo option setting is temporarily disabled."));
|
||||
|
||||
@@ -36,9 +36,9 @@ class CommandMSStaff : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
const NickCore *nc = it->second;
|
||||
|
||||
if (nc->IsServicesOper())
|
||||
memoserv->Send(source.u->nick, nc->display, text, true);
|
||||
|
||||
@@ -18,7 +18,6 @@ class CommandNSAccess : public Command
|
||||
private:
|
||||
void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &mask)
|
||||
{
|
||||
|
||||
if (mask.empty())
|
||||
{
|
||||
this->OnSyntaxError(source, "ADD");
|
||||
@@ -110,7 +109,7 @@ class CommandNSAccess : public Command
|
||||
NickCore *nc;
|
||||
if (!nick.empty())
|
||||
{
|
||||
NickAlias *na = findnick(nick);
|
||||
const NickAlias *na = findnick(nick);
|
||||
if (na == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
|
||||
struct AJoinList : std::vector<std::pair<Anope::string, Anope::string> >, ExtensibleItem, Serializable
|
||||
{
|
||||
NickCore *nc;
|
||||
serialize_obj<NickCore> nc;
|
||||
|
||||
AJoinList(NickCore *n) : nc(n) { }
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "AJoinList";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data sd;
|
||||
Serialize::Data sd;
|
||||
|
||||
sd["nc"] << this->nc->display;
|
||||
Anope::string channels;
|
||||
@@ -43,14 +43,20 @@ struct AJoinList : std::vector<std::pair<Anope::string, Anope::string> >, Extens
|
||||
return sd;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &sd)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &sd)
|
||||
{
|
||||
NickCore *nc = findcore(sd["nc"].astr());
|
||||
if (nc == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
AJoinList *aj = new AJoinList(nc);
|
||||
nc->Extend("ns_ajoin_channels", aj);
|
||||
AJoinList *aj;
|
||||
if (obj)
|
||||
aj = debug_cast<AJoinList *>(obj);
|
||||
else
|
||||
{
|
||||
aj = new AJoinList(nc);
|
||||
nc->Extend("ns_ajoin_channels", aj);
|
||||
}
|
||||
|
||||
Anope::string token;
|
||||
spacesepstream ssep(sd["channels"].astr());
|
||||
@@ -68,6 +74,8 @@ struct AJoinList : std::vector<std::pair<Anope::string, Anope::string> >, Extens
|
||||
|
||||
aj->push_back(std::make_pair(chan, key));
|
||||
}
|
||||
|
||||
return aj;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -200,7 +208,7 @@ class NSAJoin : public Module
|
||||
void OnNickIdentify(User *u) anope_override
|
||||
{
|
||||
AJoinList *channels = u->Account()->GetExt<AJoinList *>("ns_ajoin_channels");
|
||||
BotInfo *bi = findbot(Config->NickServ);
|
||||
const BotInfo *bi = findbot(Config->NickServ);
|
||||
|
||||
if (channels == NULL || bi == NULL)
|
||||
return;
|
||||
@@ -208,9 +216,12 @@ class NSAJoin : public Module
|
||||
for (unsigned i = 0; i < channels->size(); ++i)
|
||||
{
|
||||
Channel *c = findchan(channels->at(i).first);
|
||||
ChannelInfo *ci = c != NULL ? c->ci : cs_findchan(channels->at(i).first);
|
||||
if (c == NULL && ci != NULL)
|
||||
c = ci->c;
|
||||
ChannelInfo *ci;
|
||||
|
||||
if (c)
|
||||
ci = c->ci;
|
||||
else
|
||||
ci = cs_findchan(channels->at(i).first);
|
||||
|
||||
bool need_invite = false;
|
||||
Anope::string key = channels->at(i).second;
|
||||
|
||||
@@ -30,7 +30,7 @@ class CommandNSAList : public Command
|
||||
if (params.size() && u->IsServicesOper())
|
||||
nick = params[0];
|
||||
|
||||
NickAlias *na = findnick(nick);
|
||||
const NickAlias *na = findnick(nick);
|
||||
|
||||
if (!na)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ class CommandNSAList : public Command
|
||||
|
||||
source.Reply(_("Channels that \002%s\002 has access on:"), na->nick.c_str());
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
ListFormatter::ListEntry entry;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class CommandNSCert : public Command
|
||||
{
|
||||
private:
|
||||
void DoServAdminList(CommandSource &source, NickCore *nc)
|
||||
void DoServAdminList(CommandSource &source, const NickCore *nc)
|
||||
{
|
||||
if (nc->cert.empty())
|
||||
{
|
||||
@@ -112,7 +112,7 @@ class CommandNSCert : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
void DoList(CommandSource &source, NickCore *nc)
|
||||
void DoList(CommandSource &source, const NickCore *nc)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
@@ -154,18 +154,20 @@ class CommandNSCert : public Command
|
||||
const Anope::string &cmd = params[0];
|
||||
const Anope::string &mask = params.size() > 1 ? params[1] : "";
|
||||
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
if (cmd.equals_ci("LIST") && u->IsServicesOper() && !mask.empty() && (na = findnick(mask)))
|
||||
return this->DoServAdminList(source, na->nc);
|
||||
|
||||
NickCore *nc = u->Account();
|
||||
|
||||
if (u->Account()->HasFlag(NI_SUSPENDED))
|
||||
source.Reply(NICK_X_SUSPENDED, u->Account()->display.c_str());
|
||||
else if (cmd.equals_ci("ADD"))
|
||||
return this->DoAdd(source, u->Account(), mask);
|
||||
return this->DoAdd(source, nc, mask);
|
||||
else if (cmd.equals_ci("DEL"))
|
||||
return this->DoDel(source, u->Account(), mask);
|
||||
return this->DoDel(source, nc, mask);
|
||||
else if (cmd.equals_ci("LIST"))
|
||||
return this->DoList(source, u->Account());
|
||||
return this->DoList(source, nc);
|
||||
else
|
||||
this->OnSyntaxError(source, cmd);
|
||||
|
||||
@@ -203,7 +205,7 @@ class NSCert : public Module
|
||||
|
||||
void DoAutoIdentify(User *u)
|
||||
{
|
||||
BotInfo *bi = findbot(Config->NickServ);
|
||||
const BotInfo *bi = findbot(Config->NickServ);
|
||||
NickAlias *na = findnick(u->nick);
|
||||
if (!bi || !na)
|
||||
return;
|
||||
|
||||
@@ -63,7 +63,7 @@ class CommandNSDrop : public Command
|
||||
FOREACH_MOD(I_OnNickDrop, OnNickDrop(u, na));
|
||||
|
||||
Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, u, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
|
||||
delete na;
|
||||
na->destroy();
|
||||
|
||||
if (!is_mine)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,9 @@ class CommandNSGetEMail : public Command
|
||||
|
||||
Log(LOG_ADMIN, u, this) << "on " << email;
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
const NickCore *nc = it->second;
|
||||
|
||||
if (!nc->email.empty() && nc->email.equals_ci(email))
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ class CommandNSGetPass : public Command
|
||||
User *u = source.u;
|
||||
const Anope::string &nick = params[0];
|
||||
Anope::string tmp_pass;
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
|
||||
if (!(na = findnick(nick)))
|
||||
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
|
||||
|
||||
@@ -30,7 +30,7 @@ class CommandNSGhost : public Command
|
||||
|
||||
User *u = source.u;
|
||||
User *user = finduser(nick);
|
||||
NickAlias *na = findnick(nick);
|
||||
const NickAlias *na = findnick(nick);
|
||||
|
||||
if (!user)
|
||||
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
|
||||
|
||||
@@ -58,7 +58,7 @@ class CommandNSGroup : public Command
|
||||
Log(LOG_COMMAND, u, this) << "tried to use GROUP for SUSPENDED nick " << target->nick;
|
||||
source.Reply(NICK_X_SUSPENDED, target->nick.c_str());
|
||||
}
|
||||
else if (na && target->nc == na->nc)
|
||||
else if (na && *target->nc == *na->nc)
|
||||
source.Reply(_("You are already a member of the group of \002%s\002."), target->nick.c_str());
|
||||
else if (na && na->nc != u->Account())
|
||||
source.Reply(NICK_IDENTIFY_REQUIRED, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str());
|
||||
@@ -88,7 +88,7 @@ class CommandNSGroup : public Command
|
||||
* If not, check that it is valid.
|
||||
*/
|
||||
if (na)
|
||||
delete na;
|
||||
na->destroy();
|
||||
else
|
||||
{
|
||||
size_t prefixlen = Config->NSGuestNickPrefix.length();
|
||||
@@ -108,7 +108,7 @@ class CommandNSGroup : public Command
|
||||
na->last_realname = u->realname;
|
||||
na->time_registered = na->last_seen = Anope::CurTime;
|
||||
|
||||
u->Login(na->nc);
|
||||
u->Login(target->nc);
|
||||
ircdproto->SendLogin(u);
|
||||
if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
|
||||
@@ -188,22 +188,23 @@ class CommandNSUngroup : public Command
|
||||
{
|
||||
NickCore *oldcore = na->nc;
|
||||
|
||||
std::list<NickAlias *>::iterator it = std::find(oldcore->aliases.begin(), oldcore->aliases.end(), na);
|
||||
std::list<serialize_obj<NickAlias> >::iterator it = std::find(oldcore->aliases.begin(), oldcore->aliases.end(), na);
|
||||
if (it != oldcore->aliases.end())
|
||||
oldcore->aliases.erase(it);
|
||||
|
||||
if (na->nick.equals_ci(oldcore->display))
|
||||
change_core_display(oldcore);
|
||||
|
||||
na->nc = new NickCore(na->nick);
|
||||
na->nc->aliases.push_back(na);
|
||||
NickCore *nc = new NickCore(na->nick);
|
||||
na->nc = nc;
|
||||
nc->aliases.push_back(na);
|
||||
|
||||
na->nc->pass = oldcore->pass;
|
||||
nc->pass = oldcore->pass;
|
||||
if (!oldcore->email.empty())
|
||||
na->nc->email = oldcore->email;
|
||||
nc->email = oldcore->email;
|
||||
if (!oldcore->greet.empty())
|
||||
na->nc->greet = oldcore->greet;
|
||||
na->nc->language = oldcore->language;
|
||||
nc->greet = oldcore->greet;
|
||||
nc->language = oldcore->language;
|
||||
|
||||
source.Reply(_("Nick %s has been ungrouped from %s."), na->nick.c_str(), oldcore->display.c_str());
|
||||
|
||||
@@ -240,37 +241,50 @@ class CommandNSGList : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
Anope::string nick = !params.empty() ? params[0] : "";
|
||||
const Anope::string &nick = !params.empty() ? params[0] : "";
|
||||
const NickCore *nc;
|
||||
|
||||
const NickCore *nc = u->Account();
|
||||
|
||||
if (!nick.empty() && (!nick.equals_ci(u->nick) && !u->IsServicesOper()))
|
||||
source.Reply(ACCESS_DENIED, Config->NickServ.c_str());
|
||||
else if (!nick.empty() && (!findnick(nick) || !(nc = findnick(nick)->nc)))
|
||||
source.Reply(nick.empty() ? NICK_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nick.c_str());
|
||||
else
|
||||
if (!nick.empty())
|
||||
{
|
||||
ListFormatter list;
|
||||
list.addColumn("Nick").addColumn("Expires");
|
||||
for (std::list<NickAlias *>::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
|
||||
const NickAlias *na = findnick(nick);
|
||||
if (!na)
|
||||
{
|
||||
NickAlias *na2 = *it;
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Nick"] = na2->nick;
|
||||
entry["Expires"] = (na2->HasFlag(NS_NO_EXPIRE) || !Config->NSExpire) ? "Does not expire" : ("expires in " + do_strftime(na2->last_seen + Config->NSExpire));
|
||||
list.addEntry(entry);
|
||||
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
|
||||
return;
|
||||
}
|
||||
else if (!u->IsServicesOper())
|
||||
{
|
||||
source.Reply(ACCESS_DENIED, Config->NickServ.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
source.Reply(!nick.empty() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->display.c_str());
|
||||
std::vector<Anope::string> replies;
|
||||
list.Process(replies);
|
||||
|
||||
for (unsigned i = 0; i < replies.size(); ++i)
|
||||
source.Reply(replies[i]);
|
||||
|
||||
source.Reply(_("%d nicknames in the group."), nc->aliases.size());
|
||||
nc = na->nc;
|
||||
}
|
||||
else
|
||||
nc = u->Account();
|
||||
|
||||
ListFormatter list;
|
||||
list.addColumn("Nick").addColumn("Expires");
|
||||
for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
|
||||
{
|
||||
const NickAlias *na2 = *it++;
|
||||
if (!na2)
|
||||
continue;
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Nick"] = na2->nick;
|
||||
entry["Expires"] = (na2->HasFlag(NS_NO_EXPIRE) || !Config->NSExpire) ? "Does not expire" : ("expires in " + do_strftime(na2->last_seen + Config->NSExpire));
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
source.Reply(!nick.empty() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->display.c_str());
|
||||
std::vector<Anope::string> replies;
|
||||
list.Process(replies);
|
||||
|
||||
for (unsigned i = 0; i < replies.size(); ++i)
|
||||
source.Reply(replies[i]);
|
||||
|
||||
source.Reply(_("%d nicknames in the group."), nc->aliases.size());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class CommandNSInfo : public Command
|
||||
{
|
||||
private:
|
||||
template<typename T, unsigned END> void CheckOptStr(User *u, Anope::string &buf, T opt, const char *str, Flags<T, END> *nc, bool reverse_logic = false)
|
||||
template<typename T, unsigned END> void CheckOptStr(User *u, Anope::string &buf, T opt, const char *str, const Flags<T, END> *nc, bool reverse_logic = false)
|
||||
{
|
||||
if (reverse_logic ? !nc->HasFlag(opt) : nc->HasFlag(opt))
|
||||
{
|
||||
|
||||
@@ -75,9 +75,9 @@ class CommandNSList : public Command
|
||||
|
||||
list.addColumn("Nick").addColumn("Last usermask");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
NickAlias *na = it->second;
|
||||
const NickAlias *na = it->second;
|
||||
|
||||
/* Don't show private nicks to non-services admins. */
|
||||
if (na->nc->HasFlag(NI_PRIVATE) && !is_servadmin && na->nc != mync)
|
||||
|
||||
@@ -13,7 +13,12 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
static bool SendRegmail(User *u, NickAlias *na, BotInfo *bi);
|
||||
static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi);
|
||||
|
||||
struct ExtensibleString : Anope::string, ExtensibleItem
|
||||
{
|
||||
ExtensibleString(const Anope::string &s) : Anope::string(s) { }
|
||||
};
|
||||
|
||||
class CommandNSConfirm : public Command
|
||||
{
|
||||
@@ -49,13 +54,14 @@ class CommandNSConfirm : public Command
|
||||
Anope::string *code = u->Account()->GetExt<ExtensibleString *>("ns_register_passcode");
|
||||
if (code != NULL && *code == passcode)
|
||||
{
|
||||
u->Account()->Shrink("ns_register_passcode");
|
||||
NickCore *nc = u->Account();
|
||||
nc->Shrink("ns_register_passcode");
|
||||
Log(LOG_COMMAND, u, this) << "to confirm their email";
|
||||
source.Reply(_("Your email address of \002%s\002 has been confirmed."), u->Account()->email.c_str());
|
||||
u->Account()->UnsetFlag(NI_UNCONFIRMED);
|
||||
nc->UnsetFlag(NI_UNCONFIRMED);
|
||||
|
||||
ircdproto->SendLogin(u);
|
||||
NickAlias *na = findnick(u->nick);
|
||||
const NickAlias *na = findnick(u->nick);
|
||||
if (!Config->NoNicknameOwnership && na != NULL && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
|
||||
}
|
||||
@@ -170,18 +176,19 @@ class CommandNSRegister : public Command
|
||||
source.Reply(MAIL_X_INVALID, email.c_str());
|
||||
else
|
||||
{
|
||||
na = new NickAlias(u->nick, new NickCore(u->nick));
|
||||
enc_encrypt(pass, na->nc->pass);
|
||||
NickCore *nc = new NickCore(u->nick);
|
||||
na = new NickAlias(u->nick, nc);
|
||||
enc_encrypt(pass, nc->pass);
|
||||
if (!email.empty())
|
||||
na->nc->email = email;
|
||||
nc->email = email;
|
||||
|
||||
Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
|
||||
na->last_usermask = last_usermask;
|
||||
na->last_realname = u->realname;
|
||||
if (Config->NSAddAccessOnReg)
|
||||
na->nc->AddAccess(create_mask(u));
|
||||
nc->AddAccess(create_mask(u));
|
||||
|
||||
u->Login(na->nc);
|
||||
u->Login(nc);
|
||||
|
||||
Log(LOG_COMMAND, u, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
|
||||
|
||||
@@ -198,12 +205,12 @@ class CommandNSRegister : public Command
|
||||
|
||||
if (Config->NSRegistration.equals_ci("admin"))
|
||||
{
|
||||
na->nc->SetFlag(NI_UNCONFIRMED);
|
||||
nc->SetFlag(NI_UNCONFIRMED);
|
||||
source.Reply(_("All new accounts must be validated by an administrator. Please wait for your registration to be confirmed."));
|
||||
}
|
||||
else if (Config->NSRegistration.equals_ci("mail"))
|
||||
{
|
||||
na->nc->SetFlag(NI_UNCONFIRMED);
|
||||
nc->SetFlag(NI_UNCONFIRMED);
|
||||
if (SendRegmail(u, na, source.owner))
|
||||
{
|
||||
source.Reply(_("A passcode has been sent to %s, please type %s%s confirm <passcode> to confirm your email address."), email.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str());
|
||||
@@ -276,7 +283,7 @@ class CommandNSResend : public Command
|
||||
return;
|
||||
|
||||
User *u = source.u;
|
||||
NickAlias *na = findnick(u->nick);
|
||||
const NickAlias *na = findnick(u->nick);
|
||||
|
||||
if (na == NULL)
|
||||
source.Reply(NICK_NOT_REGISTERED);
|
||||
@@ -335,8 +342,10 @@ class NSRegister : public Module
|
||||
}
|
||||
};
|
||||
|
||||
static bool SendRegmail(User *u, NickAlias *na, BotInfo *bi)
|
||||
static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi)
|
||||
{
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
Anope::string *code = na->nc->GetExt<ExtensibleString *>("ns_register_passcode");
|
||||
Anope::string codebuf;
|
||||
if (code == NULL)
|
||||
@@ -351,7 +360,7 @@ static bool SendRegmail(User *u, NickAlias *na, BotInfo *bi)
|
||||
int idx, min = 1, max = 62;
|
||||
for (idx = 0; idx < 9; ++idx)
|
||||
codebuf += chars[1 + static_cast<int>((static_cast<float>(max - min)) * static_cast<uint16_t>(rand()) / 65536.0) + min];
|
||||
na->nc->Extend("ns_register_passcode", new ExtensibleString(codebuf));
|
||||
nc->Extend("ns_register_passcode", new ExtensibleString(codebuf));
|
||||
}
|
||||
else
|
||||
codebuf = *code;
|
||||
@@ -367,7 +376,7 @@ static bool SendRegmail(User *u, NickAlias *na, BotInfo *bi)
|
||||
message = message.replace_all_cs("%N", Config->NetworkName);
|
||||
message = message.replace_all_cs("%c", codebuf);
|
||||
|
||||
return Mail(u, na->nc, bi, subject, message);
|
||||
return Mail(u, nc, bi, subject, message);
|
||||
}
|
||||
|
||||
MODULE_INIT(NSRegister)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
static bool SendResetEmail(User *u, NickAlias *na, BotInfo *bi);
|
||||
static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi);
|
||||
|
||||
class CommandNSResetPass : public Command
|
||||
{
|
||||
@@ -28,7 +28,7 @@ class CommandNSResetPass : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
|
||||
if (Config->RestrictMail && (!u->Account() || !u->HasCommand("nickserv/resetpass")))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
@@ -89,19 +89,20 @@ class NSResetPass : public Module
|
||||
ResetInfo *ri = na ? na->nc->GetExt<ResetInfo *>("ns_resetpass") : NULL;
|
||||
if (na && ri)
|
||||
{
|
||||
NickCore *nc = na->nc;
|
||||
const Anope::string &passcode = params[1];
|
||||
if (ri->time < Anope::CurTime - 3600)
|
||||
{
|
||||
na->nc->Shrink("ns_resetpass");
|
||||
nc->Shrink("ns_resetpass");
|
||||
source.Reply(_("Your password reset request has expired."));
|
||||
}
|
||||
else if (passcode.equals_cs(ri->code))
|
||||
{
|
||||
na->nc->Shrink("ns_resetpass");
|
||||
nc->Shrink("ns_resetpass");
|
||||
|
||||
Log(LOG_COMMAND, u, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify to " << na->nick;
|
||||
|
||||
na->nc->UnsetFlag(NI_UNCONFIRMED);
|
||||
nc->UnsetFlag(NI_UNCONFIRMED);
|
||||
u->Identify(na);
|
||||
|
||||
source.Reply(_("You are now identified for your nick. Change your password now."));
|
||||
@@ -118,7 +119,7 @@ class NSResetPass : public Module
|
||||
}
|
||||
};
|
||||
|
||||
static bool SendResetEmail(User *u, NickAlias *na, BotInfo *bi)
|
||||
static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi)
|
||||
{
|
||||
int min = 1, max = 62;
|
||||
int chars[] = {
|
||||
@@ -148,9 +149,10 @@ static bool SendResetEmail(User *u, NickAlias *na, BotInfo *bi)
|
||||
ResetInfo *ri = new ResetInfo;
|
||||
ri->code = passcode;
|
||||
ri->time = Anope::CurTime;
|
||||
na->nc->Extend("ns_resetpass", ri);
|
||||
NickCore *nc = na->nc;
|
||||
nc->Extend("ns_resetpass", ri);
|
||||
|
||||
return Mail(u, na->nc, bi, subject, message);
|
||||
return Mail(u, nc, bi, subject, message);
|
||||
}
|
||||
|
||||
MODULE_INIT(NSResetPass)
|
||||
|
||||
@@ -33,10 +33,10 @@ class CommandNSSASet : public Command
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
const Anope::string &c_name = it->first;
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ class CommandNSSASetPassword : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
NickAlias *setter_na = findnick(params[0]);
|
||||
const NickAlias *setter_na = findnick(params[0]);
|
||||
if (setter_na == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str());
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
static bool SendPassMail(User *u, NickAlias *na, BotInfo *bi, const Anope::string &pass);
|
||||
static bool SendPassMail(User *u, const NickAlias *na, const BotInfo *bi, const Anope::string &pass);
|
||||
|
||||
class CommandNSSendPass : public Command
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class CommandNSSendPass : public Command
|
||||
{
|
||||
User *u = source.u;
|
||||
const Anope::string &nick = params[0];
|
||||
NickAlias *na;
|
||||
const NickAlias *na;
|
||||
|
||||
if (Config->RestrictMail && (!u->Account() || !u->HasCommand("nickserv/sendpass")))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
@@ -86,7 +86,7 @@ class NSSendPass : public Module
|
||||
}
|
||||
};
|
||||
|
||||
static bool SendPassMail(User *u, NickAlias *na, BotInfo *bi, const Anope::string &pass)
|
||||
static bool SendPassMail(User *u, const NickAlias *na, const BotInfo *bi, const Anope::string &pass)
|
||||
{
|
||||
Anope::string subject = translate(na->nc, Config->MailSendpassSubject.c_str());
|
||||
Anope::string message = translate(na->nc, Config->MailSendpassMessage.c_str());
|
||||
|
||||
@@ -34,10 +34,10 @@ class CommandNSSet : public Command
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
const Anope::string &c_name = it->first;
|
||||
CommandInfo &info = it->second;
|
||||
const CommandInfo &info = it->second;
|
||||
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetAutoOp : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (na == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,14 +24,14 @@ class CommandNSSetDisplay : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *user_na = findnick(user), *na = findnick(param);
|
||||
const NickAlias *user_na = findnick(user), *na = findnick(param);
|
||||
|
||||
if (user_na == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
return;
|
||||
}
|
||||
else if (!na || na->nc != user_na->nc)
|
||||
else if (!na || *na->nc != *user_na->nc)
|
||||
{
|
||||
source.Reply(_("The new display MUST be a nickname of the nickname group %s"), user_na->nc->display.c_str());
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,12 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
static bool SendConfirmMail(User *u, BotInfo *bi)
|
||||
struct ExtensibleString : Anope::string, ExtensibleItem
|
||||
{
|
||||
ExtensibleString(const Anope::string &s) : Anope::string(s) { }
|
||||
};
|
||||
|
||||
static bool SendConfirmMail(User *u, const BotInfo *bi)
|
||||
{
|
||||
int chars[] = {
|
||||
' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||||
@@ -26,6 +31,7 @@ static bool SendConfirmMail(User *u, BotInfo *bi)
|
||||
Anope::string code;
|
||||
for (idx = 0; idx < 9; ++idx)
|
||||
code += chars[1 + static_cast<int>((static_cast<float>(max - min)) * static_cast<uint16_t>(rand()) / 65536.0) + min];
|
||||
|
||||
u->Account()->Extend("ns_set_email_passcode", new ExtensibleString(code));
|
||||
|
||||
Anope::string subject = Config->MailEmailchangeSubject;
|
||||
@@ -54,7 +60,7 @@ class CommandNSSetEmail : public Command
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
User *u = source.u;
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
@@ -168,11 +174,12 @@ class NSSetEmail : public Module
|
||||
{
|
||||
if (params[0] == *passcode)
|
||||
{
|
||||
u->Account()->email = *new_email;
|
||||
NickCore *uac = u->Account();
|
||||
uac->email = *new_email;
|
||||
Log(LOG_COMMAND, u, command) << "to confirm their email address change to " << u->Account()->email;
|
||||
source.Reply(_("Your email address has been changed to \002%s\002."), u->Account()->email.c_str());
|
||||
u->Account()->Shrink("ns_set_email");
|
||||
u->Account()->Shrink("ns_set_email_passcode");
|
||||
uac->Shrink("ns_set_email");
|
||||
uac->Shrink("ns_set_email_passcode");
|
||||
return EVENT_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetGreet : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetHide : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m, const Anope::string &arg)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetKill : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetLanguage : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetMessage : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
struct NSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
struct NSMiscData : ExtensibleItem, Serializable
|
||||
{
|
||||
NickCore *nc;
|
||||
serialize_obj<NickCore> nc;
|
||||
Anope::string name;
|
||||
Anope::string data;
|
||||
|
||||
@@ -23,14 +23,14 @@ struct NSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const anope_override
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "NSMiscData";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data sdata;
|
||||
Serialize::Data sdata;
|
||||
|
||||
sdata["nc"] << this->nc->display;
|
||||
sdata["name"] << this->name;
|
||||
@@ -39,13 +39,27 @@ struct NSMiscData : Anope::string, ExtensibleItem, Serializable
|
||||
return sdata;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
NickCore *nc = findcore(data["nc"].astr());
|
||||
if (nc == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
nc->Extend(data["name"].astr(), new NSMiscData(nc, data["name"].astr(), data["data"].astr()));
|
||||
NSMiscData *d;
|
||||
if (obj)
|
||||
{
|
||||
d = debug_cast<NSMiscData *>(obj);
|
||||
d->nc = nc;
|
||||
data["name"] >> d->name;
|
||||
data["data"] >> d->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
d = new NSMiscData(nc, data["name"].astr(), data["data"].astr());
|
||||
nc->Extend(data["name"].astr(), d);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,7 +81,7 @@ class CommandNSSetMisc : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetPrivate : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -24,7 +24,7 @@ class CommandNSSetSecure : public Command
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
NickAlias *na = findnick(user);
|
||||
const NickAlias *na = findnick(user);
|
||||
if (!na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
|
||||
@@ -27,7 +27,7 @@ class CommandNSStatus : public Command
|
||||
{
|
||||
User *u = source.u;
|
||||
const Anope::string &nick = !params.empty() ? params[0] : u->nick;
|
||||
NickAlias *na = findnick(nick);
|
||||
const NickAlias *na = findnick(nick);
|
||||
spacesepstream sep(nick);
|
||||
Anope::string nickbuf;
|
||||
|
||||
|
||||
@@ -22,14 +22,14 @@ struct NickSuspend : ExtensibleItem, Serializable
|
||||
{
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const
|
||||
const Anope::string serialize_name() const
|
||||
{
|
||||
return "NickSuspend";
|
||||
}
|
||||
|
||||
serialized_data serialize() anope_override
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data sd;
|
||||
Serialize::Data sd;
|
||||
|
||||
sd["nick"] << this->nick;
|
||||
sd["when"] << this->when;
|
||||
@@ -37,18 +37,25 @@ struct NickSuspend : ExtensibleItem, Serializable
|
||||
return sd;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &sd)
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &sd)
|
||||
{
|
||||
NickAlias *na = findnick(sd["nick"].astr());
|
||||
const NickAlias *na = findnick(sd["nick"].astr());
|
||||
if (na == NULL)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
NickSuspend *ns = new NickSuspend();
|
||||
NickSuspend *ns;
|
||||
if (obj)
|
||||
ns = debug_cast<NickSuspend *>(obj);
|
||||
else
|
||||
ns = new NickSuspend();
|
||||
|
||||
sd["nick"] >> ns->nick;
|
||||
sd["when"] >> ns->when;
|
||||
|
||||
na->nc->Extend("ns_suspend_expire", ns);
|
||||
if (!obj)
|
||||
na->nc->Extend("ns_suspend_expire", ns);
|
||||
|
||||
return ns;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -98,17 +105,19 @@ class CommandNSSuspend : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
na->nc->SetFlag(NI_SUSPENDED);
|
||||
na->nc->SetFlag(NI_SECURE);
|
||||
na->nc->UnsetFlag(NI_KILLPROTECT);
|
||||
na->nc->UnsetFlag(NI_KILL_QUICK);
|
||||
na->nc->UnsetFlag(NI_KILL_IMMED);
|
||||
NickCore *nc = na->nc;
|
||||
|
||||
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
|
||||
nc->SetFlag(NI_SUSPENDED);
|
||||
nc->SetFlag(NI_SECURE);
|
||||
nc->UnsetFlag(NI_KILLPROTECT);
|
||||
nc->UnsetFlag(NI_KILL_QUICK);
|
||||
nc->UnsetFlag(NI_KILL_IMMED);
|
||||
|
||||
for (std::list<serialize_obj<NickAlias> >::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
|
||||
{
|
||||
NickAlias *na2 = *it;
|
||||
NickAlias *na2 = *it++;
|
||||
|
||||
if (na2->nc == na->nc)
|
||||
if (na2 && *na2->nc == *na->nc)
|
||||
{
|
||||
na2->last_quit = reason;
|
||||
|
||||
@@ -127,7 +136,7 @@ class CommandNSSuspend : public Command
|
||||
ns->nick = na->nick;
|
||||
ns->when = Anope::CurTime + expiry_secs;
|
||||
|
||||
na->nc->Extend("ns_suspend_expire", ns);
|
||||
nc->Extend("ns_suspend_expire", ns);
|
||||
}
|
||||
|
||||
Log(LOG_ADMIN, u, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never");
|
||||
@@ -221,7 +230,7 @@ class NSSuspend : public Module
|
||||
|
||||
~NSSuspend()
|
||||
{
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
|
||||
it->second->Shrink("ns_suspend_expire");
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class CommandOSAKill : public Command
|
||||
{
|
||||
source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str());
|
||||
Log(LOG_ADMIN, u, this) << "tried to akill " << percent << "% of the network (" << affected << " users)";
|
||||
delete x;
|
||||
x->destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class CommandOSAKill : public Command
|
||||
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, akills));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
{
|
||||
delete x;
|
||||
x->destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class CommandOSAKill : public Command
|
||||
if (!number)
|
||||
return;
|
||||
|
||||
XLine *x = akills->GetEntry(number - 1);
|
||||
const XLine *x = akills->GetEntry(number - 1);
|
||||
|
||||
if (!x)
|
||||
return;
|
||||
@@ -286,7 +286,7 @@ class CommandOSAKill : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = akills->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = akills->GetEntry(i);
|
||||
const XLine *x = akills->GetEntry(i);
|
||||
|
||||
if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask, false, true))
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ class MyForbidService : public ForbidService
|
||||
std::vector<ForbidData *>::iterator it = std::find(this->forbidData.begin(), this->forbidData.end(), d);
|
||||
if (it != this->forbidData.end())
|
||||
this->forbidData.erase(it);
|
||||
delete d;
|
||||
d->destroy();
|
||||
}
|
||||
|
||||
ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) anope_override
|
||||
@@ -42,7 +42,7 @@ class MyForbidService : public ForbidService
|
||||
ForbidData *d = this->forbidData[i - 1];
|
||||
|
||||
if ((ftype == FT_NONE || ftype == d->type) && Anope::Match(mask, d->mask, false, true))
|
||||
return d;
|
||||
d->destroy();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class MyForbidService : public ForbidService
|
||||
|
||||
Log(LOG_NORMAL, "expire/forbid") << "Expiring forbid for " << d->mask << " type " << ftype;
|
||||
this->forbidData.erase(this->forbidData.begin() + i - 1);
|
||||
delete d;
|
||||
d->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ class OSForbid : public Module
|
||||
ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK);
|
||||
if (d != NULL)
|
||||
{
|
||||
BotInfo *bi = findbot(Config->OperServ);
|
||||
const BotInfo *bi = findbot(Config->OperServ);
|
||||
if (bi)
|
||||
{
|
||||
if (d->reason.empty())
|
||||
|
||||
@@ -18,9 +18,9 @@ struct ForbidData : Serializable
|
||||
time_t expires;
|
||||
ForbidType type;
|
||||
|
||||
Anope::string serialize_name() const anope_override { return "ForbidData"; }
|
||||
serialized_data serialize() anope_override;
|
||||
static void unserialize(serialized_data &data);
|
||||
const Anope::string serialize_name() const anope_override { return "ForbidData"; }
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
class ForbidService : public Service
|
||||
@@ -39,9 +39,9 @@ class ForbidService : public Service
|
||||
|
||||
static service_reference<ForbidService> forbid_service("ForbidService", "forbid");
|
||||
|
||||
Serializable::serialized_data ForbidData::serialize()
|
||||
Serialize::Data ForbidData::serialize() const
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["mask"] << this->mask;
|
||||
data["creator"] << this->creator;
|
||||
@@ -53,12 +53,16 @@ Serializable::serialized_data ForbidData::serialize()
|
||||
return data;
|
||||
}
|
||||
|
||||
void ForbidData::unserialize(serialized_data &data)
|
||||
Serializable* ForbidData::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
if (!forbid_service)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
ForbidData *fb = new ForbidData;
|
||||
ForbidData *fb;
|
||||
if (obj)
|
||||
fb = debug_cast<ForbidData *>(obj);
|
||||
else
|
||||
fb = new ForbidData;
|
||||
|
||||
data["mask"] >> fb->mask;
|
||||
data["creator"] >> fb->creator;
|
||||
@@ -69,7 +73,9 @@ void ForbidData::unserialize(serialized_data &data)
|
||||
data["type"] >> t;
|
||||
fb->type = static_cast<ForbidType>(t);
|
||||
|
||||
forbid_service->AddForbid(fb);
|
||||
if (!obj)
|
||||
forbid_service->AddForbid(fb);
|
||||
return fb;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user