summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt46
-rw-r--r--include/access.h174
-rw-r--r--include/accessgroup.h62
-rw-r--r--include/account.h281
-rw-r--r--include/anope.h164
-rw-r--r--include/base.h88
-rw-r--r--include/bots.h115
-rw-r--r--include/channels.h46
-rw-r--r--include/commands.h60
-rw-r--r--include/config.h88
-rw-r--r--include/defs.h66
-rw-r--r--include/event.h1232
-rw-r--r--include/extensible.h204
-rw-r--r--include/hashcomp.h91
-rw-r--r--include/language.h89
-rw-r--r--include/lists.h61
-rw-r--r--include/logger.h42
-rw-r--r--include/mail.h28
-rw-r--r--include/memo.h55
-rw-r--r--include/messages.h126
-rw-r--r--include/modes.h117
-rw-r--r--include/module.h38
-rw-r--r--include/modules.h1073
-rw-r--r--include/modules/botserv.h32
-rw-r--r--include/modules/botserv/badwords.h112
-rw-r--r--include/modules/botserv/bot.h58
-rw-r--r--include/modules/botserv/info.h33
-rw-r--r--include/modules/botserv/kick.h141
-rw-r--r--include/modules/bs_badwords.h70
-rw-r--r--include/modules/bs_kick.h44
-rw-r--r--include/modules/chanserv.h479
-rw-r--r--include/modules/chanserv/access.h72
-rw-r--r--include/modules/chanserv/akick.h77
-rw-r--r--include/modules/chanserv/drop.h35
-rw-r--r--include/modules/chanserv/entrymsg.h41
-rw-r--r--include/modules/chanserv/info.h37
-rw-r--r--include/modules/chanserv/log.h51
-rw-r--r--include/modules/chanserv/main/chanaccess.h50
-rw-r--r--include/modules/chanserv/mode.h133
-rw-r--r--include/modules/chanserv/set.h38
-rw-r--r--include/modules/chanserv/set_misc.h36
-rw-r--r--include/modules/chanserv/suspend.h69
-rw-r--r--include/modules/cs_entrymsg.h34
-rw-r--r--include/modules/cs_log.h42
-rw-r--r--include/modules/cs_mode.h89
-rw-r--r--include/modules/dns.h64
-rw-r--r--include/modules/encryption.h33
-rw-r--r--include/modules/fantasy.h54
-rw-r--r--include/modules/global.h40
-rw-r--r--include/modules/help.h42
-rw-r--r--include/modules/hostserv/del.h34
-rw-r--r--include/modules/httpd.h41
-rw-r--r--include/modules/ldap.h38
-rw-r--r--include/modules/memoserv.h165
-rw-r--r--include/modules/nickserv.h327
-rw-r--r--include/modules/nickserv/access.h34
-rw-r--r--include/modules/nickserv/ajoin.h37
-rw-r--r--include/modules/nickserv/cert.h76
-rw-r--r--include/modules/nickserv/drop.h35
-rw-r--r--include/modules/nickserv/group.h35
-rw-r--r--include/modules/nickserv/info.h37
-rw-r--r--include/modules/nickserv/set.h38
-rw-r--r--include/modules/nickserv/set_misc.h37
-rw-r--r--include/modules/nickserv/suspend.h69
-rw-r--r--include/modules/nickserv/update.h34
-rw-r--r--include/modules/ns_cert.h70
-rw-r--r--include/modules/operserv/defcon.h34
-rw-r--r--include/modules/operserv/dns.h83
-rw-r--r--include/modules/operserv/forbid.h68
-rw-r--r--include/modules/operserv/ignore.h49
-rw-r--r--include/modules/operserv/info.h39
-rw-r--r--include/modules/operserv/news.h47
-rw-r--r--include/modules/operserv/session.h97
-rw-r--r--include/modules/operserv/stats.h35
-rw-r--r--include/modules/os_forbid.h53
-rw-r--r--include/modules/os_ignore.h43
-rw-r--r--include/modules/os_news.h52
-rw-r--r--include/modules/os_session.h94
-rw-r--r--include/modules/protocol/charybdis.h60
-rw-r--r--include/modules/protocol/hybrid.h129
-rw-r--r--include/modules/protocol/plexus.h50
-rw-r--r--include/modules/protocol/ratbox.h66
-rw-r--r--include/modules/pseudoclients/chanserv.h25
-rw-r--r--include/modules/pseudoclients/global.h27
-rw-r--r--include/modules/pseudoclients/memoserv.h41
-rw-r--r--include/modules/pseudoclients/nickserv.h24
-rw-r--r--include/modules/redis.h53
-rw-r--r--include/modules/sasl.h116
-rw-r--r--include/modules/set_misc.h17
-rw-r--r--include/modules/sql.h182
-rw-r--r--include/modules/ssl.h26
-rw-r--r--include/modules/suspend.h19
-rw-r--r--include/modules/xmlrpc.h36
-rw-r--r--include/opertype.h98
-rw-r--r--include/protocol.h133
-rw-r--r--include/pstdint.h800
-rw-r--r--include/regchannel.h252
-rw-r--r--include/regexpr.h45
-rw-r--r--include/serialize.h976
-rw-r--r--include/servers.h26
-rw-r--r--include/service.h232
-rw-r--r--include/services.h43
-rw-r--r--include/socketengine.h22
-rw-r--r--include/sockets.h46
-rw-r--r--include/sysconf.h.cmake61
-rw-r--r--include/threadengine.h80
-rw-r--r--include/timers.h26
-rw-r--r--include/uplink.h61
-rw-r--r--include/users.h91
-rw-r--r--include/version.cpp22
-rw-r--r--include/xline.h144
111 files changed, 7199 insertions, 4983 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 1a96d7111..f4ed6a0a4 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -16,49 +16,7 @@ add_to_cpack_ignored_files("${version_BINARY}$" TRUE)
if(NOT WIN32)
add_to_cpack_ignored_files("version.h$" TRUE)
add_to_cpack_ignored_files("build.h$" TRUE)
-endif(NOT WIN32)
-
-set(PCH_SOURCES_GCH "")
-if(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
- string(REPLACE " " ";" PCH_CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS}")
-
- file(GLOB PCH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
- sort_list(PCH_SOURCES)
-
- foreach(PCH_SOURCE ${PCH_SOURCES})
- find_includes(${PCH_SOURCE} INCLUDES)
- set(INCLUDES_LIST)
- append_to_list(INCLUDES_LIST ${PCH_SOURCE})
- foreach(INCLUDE ${INCLUDES})
- # Extract the filename from the #include line
- extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
- if(QUOTE_TYPE STREQUAL "quotes")
- find_in_list(PCH_SOURCES "${FILENAME}" FOUND)
- if(NOT FOUND EQUAL -1)
- append_to_list(INCLUDES_LIST ${FILENAME})
- endif(NOT FOUND EQUAL -1)
- endif(QUOTE_TYPE STREQUAL "quotes")
- endforeach(INCLUDE)
-
- set(PCH_EXTRAFLAGS "")
- if(DEBUG_BUILD)
- set(PCH_EXTRAFLAGS "-g")
- endif(DEBUG_BUILD)
- if(PCH_SOURCE STREQUAL "module.h")
- set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
- endif(PCH_SOURCE STREQUAL "module.h")
- if(GETTEXT_INCLUDE)
- set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
- endif(GETTEXT_INCLUDE)
-
- set(PCH_SOURCES_GCH "${PCH_SOURCES_GCH};${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch")
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS}
- ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} -I${Anope_SOURCE_DIR}/modules/pseudoclients ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
- DEPENDS ${INCLUDES_LIST} VERBATIM
- )
- endforeach(PCH_SOURCE ${PCH_SOURCES})
-endif(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
+endif()
# Add a custom target to the above file
-add_custom_target(headers DEPENDS version ${CMAKE_CURRENT_BINARY_DIR}/version_build ${PCH_SOURCES_GCH})
+add_custom_target(headers DEPENDS version ${CMAKE_CURRENT_BINARY_DIR}/version_build)
diff --git a/include/access.h b/include/access.h
deleted file mode 100644
index 6f0124928..000000000
--- a/include/access.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#ifndef ACCESS_H
-#define ACCESS_H
-
-#include "services.h"
-#include "anope.h"
-#include "serialize.h"
-#include "service.h"
-
-enum
-{
- ACCESS_INVALID = -10000,
- ACCESS_FOUNDER = 10001
-};
-
-/* A privilege, probably configured using a privilege{} block. Most
- * commands require specific privileges to be executed. The AccessProvider
- * backing each ChanAccess determines whether that ChanAccess has a given
- * privilege.
- */
-struct CoreExport Privilege
-{
- Anope::string name;
- Anope::string desc;
- /* Rank relative to other privileges */
- int rank;
-
- Privilege(const Anope::string &name, const Anope::string &desc, int rank);
- bool operator==(const Privilege &other) const;
-};
-
-class CoreExport PrivilegeManager
-{
- static std::vector<Privilege> Privileges;
- public:
- static void AddPrivilege(Privilege p);
- static void RemovePrivilege(Privilege &p);
- static Privilege *FindPrivilege(const Anope::string &name);
- static std::vector<Privilege> &GetPrivileges();
- static void ClearPrivileges();
-};
-
-/* A provider of access. Only used for creating ChanAccesses, as
- * they contain pure virtual functions.
- */
-class CoreExport AccessProvider : public Service
-{
- public:
- AccessProvider(Module *owner, const Anope::string &name);
- virtual ~AccessProvider();
-
- /** Creates a new ChanAccess entry using this provider.
- * @return The new entry
- */
- virtual ChanAccess *Create() = 0;
-
- private:
- static std::list<AccessProvider *> Providers;
- public:
- static const std::list<AccessProvider *>& GetProviders();
-};
-
-/* Represents one entry of an access list on a channel. */
-class CoreExport ChanAccess : public Serializable
-{
- Anope::string mask;
- /* account this access entry is for, if any */
- Serialize::Reference<NickCore> nc;
-
- public:
- typedef std::vector<ChanAccess *> Path;
-
- /* The provider that created this access entry */
- AccessProvider *provider;
- /* Channel this access entry is on */
- Serialize::Reference<ChannelInfo> ci;
- Anope::string creator;
- time_t last_seen;
- time_t created;
-
- ChanAccess(AccessProvider *p);
- virtual ~ChanAccess();
-
- void SetMask(const Anope::string &mask, ChannelInfo *ci);
- const Anope::string &Mask() const;
- NickCore *GetAccount() const;
-
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-
- static const unsigned int MAX_DEPTH = 4;
-
- /** Check if this access entry matches the given user or account
- * @param u The user
- * @param nc The account
- * @param next Next channel to check if any
- */
- virtual bool Matches(const User *u, const NickCore *nc, ChannelInfo* &next) const;
-
- /** Check if this access entry has the given privilege.
- * @param name The privilege name
- */
- virtual bool HasPriv(const Anope::string &name) const = 0;
-
- /** Serialize the access given by this access entry into a human
- * readable form. chanserv/access will return a number, chanserv/xop
- * will be AOP, SOP, etc.
- */
- virtual Anope::string AccessSerialize() const = 0;
-
- /** Unserialize this access entry from the given data. This data
- * will be fetched from AccessSerialize.
- */
- virtual void AccessUnserialize(const Anope::string &data) = 0;
-
- /* Comparison operators to other Access entries */
- virtual bool operator>(const ChanAccess &other) const;
- virtual bool operator<(const ChanAccess &other) const;
- bool operator>=(const ChanAccess &other) const;
- bool operator<=(const ChanAccess &other) const;
-};
-
-/* A group of access entries. This is used commonly, for example with ChannelInfo::AccessFor,
- * to show what access a user has on a channel because users can match multiple access entries.
- */
-class CoreExport AccessGroup
-{
- public:
- /* access entries + paths */
- std::vector<ChanAccess::Path> paths;
- /* Channel these access entries are on */
- const ChannelInfo *ci;
- /* Account these entries affect, if any */
- const NickCore *nc;
- /* super_admin always gets all privs. founder is a special case where ci->founder == nc */
- bool super_admin, founder;
-
- AccessGroup();
-
- /** Check if this access group has a certain privilege. Eg, it
- * will check every ChanAccess entry of this group for any that
- * has the given privilege.
- * @param priv The privilege
- * @return true if any entry has the given privilege
- */
- bool HasPriv(const Anope::string &priv) const;
-
- /** Get the "highest" access entry from this group of entries.
- * The highest entry is determined by the entry that has the privilege
- * with the highest rank (see Privilege::rank).
- * @return The "highest" entry
- */
- const ChanAccess *Highest() const;
-
- /* Comparison operators to other AccessGroups */
- bool operator>(const AccessGroup &other) const;
- bool operator<(const AccessGroup &other) const;
- bool operator>=(const AccessGroup &other) const;
- bool operator<=(const AccessGroup &other) const;
-
- inline bool empty() const { return paths.empty(); }
-};
-
-#endif
diff --git a/include/accessgroup.h b/include/accessgroup.h
new file mode 100644
index 000000000..bc7e84089
--- /dev/null
+++ b/include/accessgroup.h
@@ -0,0 +1,62 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#include "modules/chanserv.h"
+
+#pragma once
+
+namespace ChanServ
+{
+
+/* A group of access entries. This is used commonly, for example with ChanServ::Channel::AccessFor,
+ * to show what access a user has on a channel because users can match multiple access entries.
+ */
+class CoreExport AccessGroup : public std::vector<ChanAccess *>
+{
+ public:
+ /* Channel these access entries are on */
+ ChanServ::Channel *ci = nullptr;
+ /* Account these entries affect, if any */
+ const NickServ::Account *nc = nullptr;
+ /* super_admin always gets all privs. founder is a special case where ci->founder == nc */
+ bool super_admin = false, founder = false;
+
+ /** Check if this access group has a certain privilege. Eg, it
+ * will check every ChanAccess entry of this group for any that
+ * has the given privilege.
+ * @param priv The privilege
+ * @return true if any entry has the given privilege
+ */
+ bool HasPriv(const Anope::string &priv);
+
+ /** Get the "highest" access entry from this group of entries.
+ * The highest entry is determined by the entry that has the privilege
+ * with the highest rank (see Privilege::rank).
+ * @return The "highest" entry
+ */
+ ChanAccess *Highest();
+
+ /* Comparison operators to other AccessGroups */
+ bool operator>(AccessGroup &other);
+ bool operator<(AccessGroup &other);
+ bool operator>=(AccessGroup &other);
+ bool operator<=(AccessGroup &other);
+};
+
+} // namespace ChanServ \ No newline at end of file
diff --git a/include/account.h b/include/account.h
deleted file mode 100644
index c49f5f205..000000000
--- a/include/account.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#ifndef ACCOUNT_H
-#define ACCOUNT_H
-
-#include "extensible.h"
-#include "serialize.h"
-#include "anope.h"
-#include "memo.h"
-#include "base.h"
-
-typedef Anope::hash_map<NickAlias *> nickalias_map;
-typedef Anope::hash_map<NickCore *> nickcore_map;
-
-extern CoreExport Serialize::Checker<nickalias_map> NickAliasList;
-extern CoreExport Serialize::Checker<nickcore_map> NickCoreList;
-
-/* A registered nickname.
- * It matters that Base is here before Extensible (it is inherited by Serializable)
- */
-class CoreExport NickAlias : public Serializable, public Extensible
-{
- Anope::string vhost_ident, vhost_host, vhost_creator;
- time_t vhost_created;
-
- public:
- Anope::string nick;
- Anope::string last_quit;
- Anope::string last_realname;
- /* Last usermask this nick was seen on, eg user@host */
- Anope::string last_usermask;
- /* Last uncloaked usermask, requires nickserv/auspex to see */
- Anope::string last_realhost;
- time_t time_registered;
- time_t last_seen;
- /* Account this nick is tied to. Multiple nicks can be tied to a single account. */
- Serialize::Reference<NickCore> nc;
-
- /** Constructor
- * @param nickname The nick
- * @param nickcore The nickcore for this nick
- */
- NickAlias(const Anope::string &nickname, NickCore *nickcore);
- ~NickAlias();
-
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-
- /** Set a vhost for the user
- * @param ident The ident
- * @param host The host
- * @param creator Who created the vhost
- * @param time When the vhost was craated
- */
- void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
-
- /** Remove a users vhost
- **/
- void RemoveVhost();
-
- /** Check if the user has a vhost
- * @return true or false
- */
- bool HasVhost() const;
-
- /** Retrieve the vhost ident
- * @return the ident
- */
- const Anope::string &GetVhostIdent() const;
-
- /** Retrieve the vhost host
- * @return the host
- */
- const Anope::string &GetVhostHost() const;
-
- /** Retrieve the vhost creator
- * @return the creator
- */
- const Anope::string &GetVhostCreator() const;
-
- /** Retrieve when the vhost was created
- * @return the time it was created
- */
- time_t GetVhostCreated() const;
-
- /** Finds a registered nick
- * @param nick The nick to lookup
- * @return the nick, if found
- */
- static NickAlias *Find(const Anope::string &nick);
-};
-
-/* A registered account. Each account must have a NickAlias with the same nick as the
- * account's display.
- * It matters that Base is here before Extensible (it is inherited by Serializable)
- */
-class CoreExport NickCore : public Serializable, public Extensible
-{
- /* Channels which reference this core in some way (this is on their access list, akick list, is founder, successor, etc) */
- Serialize::Checker<std::map<ChannelInfo *, int> > chanaccess;
- public:
- /* Name of the account. Find(display)->nc == this. */
- Anope::string display;
- /* User password in form of hashm:data */
- Anope::string pass;
- Anope::string email;
- /* Locale name of the language of the user. Empty means default language */
- Anope::string language;
- /* Access list, contains user@host masks of users who get certain privileges based
- * on if NI_SECURE is set and what (if any) kill protection is enabled. */
- std::vector<Anope::string> access;
- MemoInfo memos;
- std::map<Anope::string, Anope::string> last_modes;
-
- /* Nicknames registered that are grouped to this account.
- * for n in aliases, n->nc == this.
- */
- Serialize::Checker<std::vector<NickAlias *> > aliases;
-
- /* Set if this user is a services operattor. o->ot must exist. */
- Oper *o;
-
- /* Unsaved data */
-
- /* Number of channels registered by this account */
- uint16_t channelcount;
- /* Last time an email was sent to this user */
- time_t lastmail;
- /* Users online now logged into this account */
- std::list<User *> users;
-
- /** Constructor
- * @param display The display nick
- */
- NickCore(const Anope::string &nickdisplay);
- ~NickCore();
-
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-
- /** Changes the display for this account
- * @param na The new display, must be grouped to this account.
- */
- void SetDisplay(const NickAlias *na);
-
- /** Checks whether this account is a services oper or not.
- * @return True if this account is a services oper, false otherwise.
- */
- virtual bool IsServicesOper() const;
-
- /** Add an entry to the nick's access list
- *
- * @param entry The nick!ident@host entry to add to the access list
- *
- * Adds a new entry into the access list.
- */
- void AddAccess(const Anope::string &entry);
-
- /** Get an entry from the nick's access list by index
- *
- * @param entry Index in the access list vector to retrieve
- * @return The access list entry of the given index if within bounds, an empty string if the vector is empty or the index is out of bounds
- *
- * Retrieves an entry from the access list corresponding to the given index.
- */
- Anope::string GetAccess(unsigned entry) const;
-
- /** Get the number of entries on the access list for this account.
- */
- unsigned GetAccessCount() const;
-
- /** Find an entry in the nick's access list
- *
- * @param entry The nick!ident@host entry to search for
- * @return True if the entry is found in the access list, false otherwise
- *
- * Search for an entry within the access list.
- */
- bool FindAccess(const Anope::string &entry);
-
- /** Erase an entry from the nick's access list
- *
- * @param entry The nick!ident@host entry to remove
- *
- * Removes the specified access list entry from the access list.
- */
- void EraseAccess(const Anope::string &entry);
-
- /** Clears the entire nick's access list
- *
- * Deletes all the memory allocated in the access list vector and then clears the vector.
- */
- void ClearAccess();
-
- /** Is the given user on this accounts access list?
- *
- * @param u The user
- *
- * @return true if the user is on the access list
- */
- bool IsOnAccess(const User *u) const;
-
- /** Finds an account
- * @param nick The account name to find
- * @return The account, if it exists
- */
- static NickCore* Find(const Anope::string &nick);
-
- void AddChannelReference(ChannelInfo *ci);
- void RemoveChannelReference(ChannelInfo *ci);
- void GetChannelReferences(std::deque<ChannelInfo *> &queue);
-};
-
-/* A request to check if an account/password is valid. These can exist for
- * extended periods due to the time some authentication modules take.
- */
-class CoreExport IdentifyRequest
-{
- /* Owner of this request, used to cleanup requests if a module is unloaded
- * while a reqyest us pending */
- Module *owner;
- Anope::string account;
- Anope::string password;
-
- std::set<Module *> holds;
- bool dispatched;
- bool success;
-
- static std::set<IdentifyRequest *> Requests;
-
- protected:
- IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass);
- virtual ~IdentifyRequest();
-
- public:
- /* One of these is called when the request goes through */
- virtual void OnSuccess() = 0;
- virtual void OnFail() = 0;
-
- const Anope::string &GetAccount() const { return account; }
- const Anope::string &GetPassword() const { return password; }
-
- /* Holds this request. When a request is held it must be Released later
- * for the request to complete. Multiple modules may hold a request at any time,
- * but the request is not complete until every module has released it. If you do not
- * require holding this (eg, your password check is done in this thread and immediately)
- * then you don't need to hold the request before Successing it.
- * @param m The module holding this request
- */
- void Hold(Module *m);
-
- /** Releases a held request
- * @param m The module releaseing the hold
- */
- void Release(Module *m);
-
- /** Called by modules when this IdentifyRequest has successeded successfully.
- * If this request is behind held it must still be Released after calling this.
- * @param m The module confirming authentication
- */
- void Success(Module *m);
-
- /** Used to either finalize this request or marks
- * it as dispatched and begins waiting for the module(s)
- * that have holds to finish.
- */
- void Dispatch();
-
- static void ModuleUnload(Module *m);
-};
-
-#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index 48a4f7674..49e7c7ddc 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef ANOPE_H
-#define ANOPE_H
+#pragma once
#include <signal.h>
@@ -308,33 +315,40 @@ namespace Anope
inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+ struct hash
+ {
+ size_t operator()(const string &s) const;
+ };
+
+ struct compare
+ {
+ bool operator()(const string &s1, const string &s2) const;
+ };
+
struct hash_ci
{
- inline size_t operator()(const string &s) const
- {
- return TR1NS::hash<std::string>()(s.lower().str());
- }
+ size_t operator()(const string &s) const;
};
- struct hash_cs
+ struct compare_ci
{
- inline size_t operator()(const string &s) const
- {
- return TR1NS::hash<std::string>()(s.str());
- }
+ bool operator()(const string &s1, const string &s2) const;
};
- struct compare
+ struct hash_locale
{
- inline bool operator()(const string &s1, const string &s2) const
- {
- return s1.equals_ci(s2);
- }
+ size_t operator()(const string &s) const;
};
- template<typename T> class map : public std::map<string, T, ci::less> { };
- template<typename T> class multimap : public std::multimap<string, T, ci::less> { };
- template<typename T> class hash_map : public TR1NS::unordered_map<string, T, hash_ci, compare> { };
+ struct compare_locale
+ {
+ bool operator()(const string &s1, const string &s2) const;
+ };
+
+ template<typename T> using map = std::map<string, T, ci::less>;
+ template<typename T> using multimap = std::multimap<string, T, ci::less>;
+ template<typename T> using hash_map = std::unordered_map<string, T, hash_ci, compare_ci>;
+ template<typename T> using locale_hash_map = std::unordered_map<string, T, hash_locale, compare_locale>;
#ifndef REPRODUCIBLE_BUILD
static const char *const compiled = __TIME__ " " __DATE__;
@@ -366,7 +380,7 @@ namespace Anope
*/
extern CoreExport bool ReadOnly, NoFork, NoThird, NoExpire, ProtocolDebug;
- /** The root of the services installation. Usually ~/services
+ /** The root of the services installation. Usually ~/anope
*/
extern CoreExport Anope::string ServicesDir;
@@ -443,13 +457,13 @@ namespace Anope
*/
extern CoreExport void Unhex(const string &src, string &dest);
extern CoreExport void Unhex(const string &src, char *dest, size_t sz);
-
+
/** Base 64 encode a string
* @param src The string to encode
* @param target Where the encoded string is placed
*/
extern CoreExport void B64Encode(const string &src, string &target);
-
+
/** Base 64 decode a string
* @param src The base64 encoded string
* @param target The plain text result
@@ -462,14 +476,6 @@ namespace Anope
*/
extern CoreExport void Encrypt(const Anope::string &src, Anope::string &dest);
- /** Decrypts what is in 'src' to 'dest'.
- * @param src The source string to decrypt
- * @param dest The destination where the decrypted string is placed
- * @return true if decryption was successful. This is usually not the case
- * as most encryption methods we use are one way.
- */
- extern CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest);
-
/** Returns a sequence of data formatted as the format argument specifies.
** After the format parameter, the function expects at least as many
** additional arguments as specified in format.
@@ -504,21 +510,21 @@ namespace Anope
* @param nc The account to use language settings for to translate this string, if applicable
* @return A human readable string, eg "1 minute"
*/
- extern CoreExport Anope::string Duration(time_t seconds, const NickCore *nc = NULL);
+ extern CoreExport Anope::string Duration(time_t seconds, NickServ::Account *nc = NULL);
/** Generates a human readable string of type "expires in ..."
* @param expires time in seconds
* @param nc The account to use language settings for to translate this string, if applicable
* @return A human readable string, eg "expires in 5 days"
*/
- extern CoreExport Anope::string Expires(time_t seconds, const NickCore *nc = NULL);
+ extern CoreExport Anope::string Expires(time_t seconds, NickServ::Account *nc = NULL);
/** Converts a time in seconds (epoch) to a human readable format.
* @param t The time
* @param nc The account to use language settings for to translate this string, if applicable
* @param short_output If true, the output is just a date (eg, "Apr 12 20:18:22 2009 MSD"), else it includes the date and how long ago/from now that date is, (eg "Apr 12 20:18:22 2009 MSD (1313 days, 9 hours, 32 minutes ago)"
*/
- extern CoreExport Anope::string strftime(time_t t, const NickCore *nc = NULL, bool short_output = false);
+ extern CoreExport Anope::string strftime(time_t t, NickServ::Account *nc = NULL, bool short_output = false);
/** Normalize buffer, stripping control characters and colors
* @param A string to be parsed for control and color codes
@@ -633,7 +639,7 @@ class spacesepstream : public sepstream
public:
/** Initialize with space seperator
*/
- spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
+ spacesepstream(const Anope::string &source, bool allowempty = false) : sepstream(source, ' ', allowempty) { }
};
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
@@ -706,6 +712,22 @@ class ConvertException : public CoreException
virtual ~ConvertException() throw() { }
};
+template<typename T>
+typename std::enable_if<std::is_enum<T>::value, std::ostream &>::type
+operator<<(std::ostream &os, T t)
+{
+ // XXX
+ return os;
+}
+
+template<typename T>
+typename std::enable_if<std::is_enum<T>::value, std::istream &>::type
+operator>>(std::istream &is, T& t)
+{
+ // XXX
+ return is;
+}
+
/** Convert something to a string
*/
template<typename T> inline Anope::string stringify(const T &x)
@@ -778,4 +800,66 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
}
#endif
-#endif // ANOPE_H
+struct kwarg
+{
+ Anope::string name, value;
+
+ template<typename T>
+ kwarg& operator=(const T& rhs)
+ {
+ value = stringify(rhs);
+ return *this;
+ }
+};
+
+inline kwarg operator"" _kw(const char *literal, size_t n)
+{
+ return { literal };
+}
+
+struct FormatInfo
+{
+ Anope::string format;
+ std::vector<kwarg> parameters;
+ unsigned int pos = 0;
+
+ FormatInfo(const Anope::string &fmt, size_t size) : format(fmt), parameters(size) { }
+
+ template<typename T>
+ void Add(T& arg)
+ {
+ parameters[pos] = kwarg{ stringify(pos).c_str() } = stringify(arg);
+ ++pos;
+ }
+
+ template<typename Arg, typename... Args>
+ void Format(Arg &&arg, Args&&... args)
+ {
+ Add(arg);
+ Format(std::forward<Args>(args)...);
+ }
+
+ void Format()
+ {
+ for (kwarg& arg : parameters)
+ format = format.replace_all_cs("{" + arg.name + "}", arg.value);
+ }
+};
+
+template<>
+inline void FormatInfo::Add(kwarg &arg)
+{
+ parameters[pos++] = arg;
+}
+
+namespace Anope
+{
+ template<typename... Args>
+ inline Anope::string Format(const Anope::string &format, Args&&... args)
+ {
+ FormatInfo fi(format, sizeof...(Args));
+ fi.Format(std::forward<Args>(args)...);
+ return fi.format;
+ }
+}
+
diff --git a/include/base.h b/include/base.h
index 677c0cfc8..d82d2a4d2 100644
--- a/include/base.h
+++ b/include/base.h
@@ -1,13 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Adam <Adam@anope.org>
- * (C) 2008-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef BASE_H
-#define BASE_H
+#pragma once
#include "services.h"
@@ -32,13 +42,14 @@ class CoreExport Base
class ReferenceBase
{
- protected:
- bool invalid;
+ static std::set<ReferenceBase *> *references;
public:
- ReferenceBase() : invalid(false) { }
- ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
- virtual ~ReferenceBase() { }
- inline void Invalidate() { this->invalid = true; }
+ static void ResetAll();
+
+ ReferenceBase();
+ virtual ~ReferenceBase();
+ virtual void Invalidate() anope_abstract;
+ virtual void Reset() { }
};
/** Used to hold pointers to objects that may be deleted. A Reference will
@@ -49,8 +60,11 @@ class Reference : public ReferenceBase
{
protected:
T *ref;
+
+ virtual void Check() { }
+
public:
- Reference() : ref(NULL)
+ Reference() : ref(nullptr)
{
}
@@ -60,19 +74,24 @@ class Reference : public ReferenceBase
ref->AddReference(this);
}
- Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref)
+ Reference(const Reference<T> &other) : ref(other.ref)
{
- if (operator bool())
+ if (ref)
ref->AddReference(this);
}
virtual ~Reference()
{
- if (operator bool())
- ref->DelReference(this);
+ if (*this)
+ this->ref->DelReference(this);
+ }
+
+ void Invalidate() override
+ {
+ ref = nullptr;
}
- inline Reference<T>& operator=(const Reference<T> &other)
+ Reference<T>& operator=(const Reference<T> &other)
{
if (this != &other)
{
@@ -80,7 +99,6 @@ class Reference : public ReferenceBase
this->ref->DelReference(this);
this->ref = other.ref;
- this->invalid = other.invalid;
if (*this)
this->ref->AddReference(this);
@@ -88,36 +106,31 @@ class Reference : public ReferenceBase
return *this;
}
- /* We explicitly call operator bool here in several places to prevent other
- * operators, such operator T*, from being called instead, which will mess
- * with any class inheriting from this that overloads this operator.
- */
- virtual operator bool()
+ explicit operator bool()
{
- if (!this->invalid)
- return this->ref != NULL;
- return false;
+ Check();
+ return this->ref != nullptr;
}
- inline operator T*()
+ operator T*()
{
- if (operator bool())
+ if (*this)
return this->ref;
- return NULL;
+ return nullptr;
}
- inline T* operator->()
+ T* operator->()
{
- if (operator bool())
+ if (*this)
return this->ref;
- return NULL;
+ return nullptr;
}
- inline T* operator*()
+ T* operator*()
{
- if (operator bool())
+ if (*this)
return this->ref;
- return NULL;
+ return nullptr;
}
/** Note that we can't have an operator< that returns this->ref < other.ref
@@ -132,12 +145,11 @@ class Reference : public ReferenceBase
* actually referred to.
*/
- inline bool operator==(const Reference<T> &other)
+ bool operator==(const Reference<T> &other)
{
- if (!this->invalid)
+ if (*this)
return this->ref == other;
return false;
}
};
-#endif // BASE_H
diff --git a/include/bots.h b/include/bots.h
index 6b429b66d..0fa35e8a1 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -1,45 +1,43 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
- * (C) 2008-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
+ * Copyright (C) 2008-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef BOTS_H
-#define BOTS_H
+#pragma once
#include "users.h"
#include "anope.h"
#include "serialize.h"
#include "commands.h"
-
-
-typedef Anope::map<BotInfo *> botinfo_map;
-
-extern CoreExport Serialize::Checker<botinfo_map> BotListByNick, BotListByUID;
+#include "config.h"
/* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
-class CoreExport BotInfo : public User, public Serializable
+class CoreExport ServiceBot : public LocalUser
{
- /* Channels this bot is assigned to */
- Serialize::Checker<std::set<ChannelInfo *> > channels;
public:
- time_t created;
- /* Last time this bot said something (via privmsg) */
- time_t lastmsg;
+ /* Underlying botinfo for this bot */
+ Serialize::Reference<BotInfo> bi;
/* Map of actual command names -> service name/permission required */
CommandInfo::map commands;
/* Modes the bot should have as configured in service:modes */
Anope::string botmodes;
- /* Channels the bot should be in as configured in service:channels */
- std::vector<Anope::string> botchannels;
/* Whether or not this bot is introduced to the network */
bool introduced;
- /* Bot can only be assigned by irc ops */
- bool oper_only;
- /* Bot is defined in the configuration file */
- bool conf;
/** Create a new bot.
* @param nick The nickname to assign to the bot.
@@ -48,14 +46,11 @@ class CoreExport BotInfo : public User, public Serializable
* @param real The realname to give the bot.
* @param bmodes The modes to give the bot.
*/
- BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &bmodes = "");
+ ServiceBot(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &bmodes = "");
/** Destroy a bot, clearing up appropriately.
*/
- virtual ~BotInfo();
-
- void Serialize(Serialize::Data &data) const;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
+ virtual ~ServiceBot();
void GenerateUID();
@@ -68,19 +63,19 @@ class CoreExport BotInfo : public User, public Serializable
/** Return the channels this bot is assigned to
*/
- const std::set<ChannelInfo *> &GetChannels() const;
+ std::vector<ChanServ::Channel *> GetChannels() const;
/** Assign this bot to a given channel, removing the existing assigned bot if one exists.
* @param u The user assigning the bot, or NULL
* @param ci The channel registration to assign the bot to.
*/
- void Assign(User *u, ChannelInfo *ci);
+ void Assign(User *u, ChanServ::Channel *ci);
/** Remove this bot from a given channel.
* @param u The user requesting the unassign, or NULL.
* @param ci The channel registration to remove the bot from.
*/
- void UnAssign(User *u, ChannelInfo *ci);
+ void UnAssign(User *u, ChanServ::Channel *ci);
/** Get the number of channels this bot is assigned to
*/
@@ -124,12 +119,68 @@ class CoreExport BotInfo : public User, public Serializable
*/
CommandInfo *GetCommand(const Anope::string &cname);
+ CommandInfo *FindCommand(const Anope::string &service);
+
/** Find a bot by nick
* @param nick The nick
* @param nick_only True to only look by nick, and not by UID
* @return The bot, if it exists
*/
- static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
+ static ServiceBot* Find(const Anope::string &nick, bool nick_only = false);
+};
+
+class BotInfo : public Serialize::Object
+{
+ friend class BotInfoType;
+
+ Anope::string nick, user, host, realname;
+ time_t created = 0;
+ bool operonly = false;
+
+ public:
+ static constexpr const char *const NAME = "botinfo";
+
+ ServiceBot *bot;
+ Configuration::Block *conf = nullptr;
+
+ using Serialize::Object::Object;
+
+ void Delete() override;
+
+ void SetNick(const Anope::string &);
+ Anope::string GetNick();
+
+ void SetUser(const Anope::string &);
+ Anope::string GetUser();
+
+ void SetHost(const Anope::string &);
+ Anope::string GetHost();
+
+ void SetRealName(const Anope::string &);
+ Anope::string GetRealName();
+
+ void SetCreated(const time_t &);
+ time_t GetCreated();
+
+ void SetOperOnly(const bool &);
+ bool GetOperOnly();
+};
+
+class BotInfoType : public Serialize::Type<BotInfo>
+{
+ public:
+ Serialize::Field<BotInfo, Anope::string> nick, user, host, realname;
+ Serialize::Field<BotInfo, time_t> created;
+ Serialize::Field<BotInfo, bool> operonly;
+
+ BotInfoType() : Serialize::Type<BotInfo>(nullptr)
+ , nick(this, "nick", &BotInfo::nick)
+ , user(this, "user", &BotInfo::user)
+ , host(this, "host", &BotInfo::host)
+ , realname(this, "realname", &BotInfo::realname)
+ , created(this, "created", &BotInfo::created)
+ , operonly(this, "operonly", &BotInfo::operonly)
+ {
+ }
};
-#endif // BOTS_H
diff --git a/include/channels.h b/include/channels.h
index 547db9f20..664f06a0a 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -1,20 +1,30 @@
-/* Channel support
+/*
+ * Anope IRC Services
*
- * (C) 2008-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef CHANNELS_H
-#define CHANNELS_H
+#pragma once
#include "anope.h"
#include "extensible.h"
#include "modes.h"
#include "serialize.h"
-typedef Anope::hash_map<Channel *> channel_map;
+using channel_map = Anope::locale_hash_map<Channel *>;
extern CoreExport channel_map ChannelList;
@@ -44,7 +54,7 @@ class CoreExport Channel : public Base, public Extensible
/* Channel name */
Anope::string name;
/* Set if this channel is registered. ci->c == this. Contains information relevant to the registered channel */
- Serialize::Reference<ChannelInfo> ci;
+ Serialize::Reference<ChanServ::Channel> ci;
/* When the channel was created */
time_t creation_time;
/* If the channel has just been created in a netjoin */
@@ -149,7 +159,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param The param
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void SetModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
+ void SetModeInternal(const MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** Remove a mode internally on a channel, this is not sent out to the IRCd
* @param setter The Setter
@@ -157,7 +167,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param The param
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void RemoveModeInternal(MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
+ void RemoveModeInternal(const MessageSource &source, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/** Set a mode on a channel
* @param bi The client setting the modes
@@ -165,7 +175,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param Optional param arg for the mode
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
+ void SetMode(User *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/**
* Set a mode on a channel
@@ -174,7 +184,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param Optional param arg for the mode
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "", bool enforce_mlock = true);
+ void SetMode(User *bi, const Anope::string &name, const Anope::string &param = "", bool enforce_mlock = true);
/** Remove a mode from a channel
* @param bi The client setting the modes
@@ -182,7 +192,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param Optional param arg for the mode
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
+ void RemoveMode(User *bi, ChannelMode *cm, const Anope::string &param = "", bool enforce_mlock = true);
/**
* Remove a mode from a channel
@@ -191,7 +201,7 @@ class CoreExport Channel : public Base, public Extensible
* @param param Optional param arg for the mode
* @param enforce_mlock true if mlocks should be enforced, false to override mlock
*/
- void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "", bool enforce_mlock = true);
+ void RemoveMode(User *bi, const Anope::string &name, const Anope::string &param = "", bool enforce_mlock = true);
/** Get a modes parameter for the channel
* @param name The mode
@@ -205,7 +215,7 @@ class CoreExport Channel : public Base, public Extensible
* @param enforce_mlock Should mlock be enforced on this mode change
* @param cmodes The modes to set
*/
- void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...);
+ void SetModes(User *bi, bool enforce_mlock, const char *cmodes, ...);
/** Set a string of modes internally on a channel
* @param source The setter
@@ -225,8 +235,9 @@ class CoreExport Channel : public Base, public Extensible
* @param source The sender of the kick
* @param nick The nick being kicked
* @param reason The reason for the kick
+ * @return true if the kick was scucessful, false if a module blocked the kick or was otherwise unsuccessful
*/
- void KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason);
+ bool KickInternal(const MessageSource &source, const Anope::string &nick, const Anope::string &reason);
/** Kick a user from the channel
* @param bi The sender, can be NULL for the service bot for this channel
@@ -234,7 +245,7 @@ class CoreExport Channel : public Base, public Extensible
* @param reason The reason for the kick
* @return true if the kick was scucessful, false if a module blocked the kick
*/
- bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...);
+ bool Kick(User *bi, User *u, const char *reason = NULL, ...);
/** Get all modes set on this channel, excluding status modes.
* @return a map of modes and their optional parameters.
@@ -307,4 +318,3 @@ class CoreExport Channel : public Base, public Extensible
static void DeleteChannels();
};
-#endif // CHANNELS_H
diff --git a/include/commands.h b/include/commands.h
index dee85c56f..8cdb0d544 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -1,27 +1,36 @@
-/* Declarations for command data.
+/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef COMMAND_H
-#define COMMAND_H
+#pragma once
#include "service.h"
#include "anope.h"
#include "channels.h"
+#include "language.h"
+#include "modules/nickserv.h"// XXX clang
struct CommandGroup
{
Anope::string name, description;
};
-/* Used in BotInfo::commands */
+/* Used in ServiceBot::commands */
struct CommandInfo
{
typedef Anope::map<CommandInfo> map;
@@ -30,6 +39,8 @@ struct CommandInfo
/* Service name of the command */
Anope::string name;
+ /* User visible name */
+ Anope::string cname;
/* Permission required to execute the command */
Anope::string permission;
/* Group this command is in */
@@ -46,7 +57,7 @@ struct CommandInfo
struct CoreExport CommandReply
{
virtual ~CommandReply() { }
- virtual void SendMessage(BotInfo *source, const Anope::string &msg) = 0;
+ virtual void SendMessage(const MessageSource &, const Anope::string &msg) anope_abstract;
};
/* The source for a command */
@@ -58,27 +69,33 @@ class CoreExport CommandSource
Reference<User> u;
public:
/* The account executing the command */
- Reference<NickCore> nc;
+ Reference<NickServ::Account> nc;
/* Where the reply should go */
CommandReply *reply;
/* Channel the command was executed on (fantasy) */
Reference<Channel> c;
/* The service this command is on */
- Reference<BotInfo> service;
+ Reference<ServiceBot> service;
/* The actual name of the command being executed */
Anope::string command;
/* The permission of the command being executed */
Anope::string permission;
- CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *reply, BotInfo *bi);
+ CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *reply, ServiceBot *bi);
const Anope::string &GetNick() const;
User *GetUser();
- NickCore *GetAccount();
- AccessGroup AccessFor(ChannelInfo *ci);
- bool IsFounder(ChannelInfo *ci);
+ NickServ::Account *GetAccount();
+ ChanServ::AccessGroup AccessFor(ChanServ::Channel *ci);
+ bool IsFounder(ChanServ::Channel *ci);
+
+ template<typename... Args>
+ void Reply(const char *message, Args&&... args)
+ {
+ const char *translated_message = Language::Translate(this->nc, message);
+ Reply(Anope::Format(translated_message, std::forward<Args>(args)...));
+ }
- void Reply(const char *message, ...);
void Reply(const Anope::string &message);
bool HasCommand(const Anope::string &cmd);
@@ -107,6 +124,8 @@ class CoreExport Command : public Service
/* Module which owns us */
Module *module;
+ static constexpr const char *NAME = "Command";
+
protected:
/** Create a new command.
* @param owner The owner of the command
@@ -125,12 +144,12 @@ class CoreExport Command : public Service
void ClearSyntax();
void SetSyntax(const Anope::string &s);
- void SendSyntax(CommandSource &);
void AllowUnregistered(bool b);
void RequireUser(bool b);
public:
+ void SendSyntax(CommandSource &);
bool AllowUnregistered() const;
bool RequireUser() const;
@@ -144,7 +163,7 @@ class CoreExport Command : public Service
* @param source The source
* @param params Command parameters
*/
- virtual void Execute(CommandSource &source, const std::vector<Anope::string> &params) = 0;
+ virtual void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_abstract;
/** Called when HELP is requsted for the client this command is on.
* @param source The source
@@ -179,7 +198,6 @@ class CoreExport Command : public Service
* @param name If found, is set to the comand name, eg REGISTER
* @return true if the given command service exists
*/
- static bool FindCommandFromService(const Anope::string &command_service, BotInfo* &bi, Anope::string &name);
+ static bool FindCommandFromService(const Anope::string &command_service, ServiceBot* &bi, Anope::string &name);
};
-#endif // COMMANDS_H
diff --git a/include/config.h b/include/config.h
index e59bd6a85..dccadbe79 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,22 +1,26 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
-#include "account.h"
-#include "regchannel.h"
#include "users.h"
#include "opertype.h"
-#include <stack>
namespace Configuration
{
@@ -38,7 +42,8 @@ namespace Configuration
Block(const Anope::string &);
const Anope::string &GetName() const;
int CountBlock(const Anope::string &name);
- Block* GetBlock(const Anope::string &name, int num = 0);
+ Block* GetBlock(const Anope::string &name);
+ Block* GetBlock(const Anope::string &name, int num);
template<typename T> inline T Get(const Anope::string &tag)
{
@@ -49,7 +54,7 @@ namespace Configuration
*/
template<typename T> T Get(const Anope::string &tag, const Anope::string &def) const
{
- const Anope::string &value = this->Get<const Anope::string>(tag, def);
+ const Anope::string &value = this->Get<Anope::string>(tag, def);
if (!value.empty())
try
{
@@ -59,13 +64,20 @@ namespace Configuration
return T();
}
- bool Set(const Anope::string &tag, const Anope::string &value);
+ template<typename T> void Set(const Anope::string &tag, const T &value)
+ {
+ Set(tag, stringify(value));
+ }
+
const item_map* GetItems() const;
};
- template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const;
+ template<> CoreExport Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const;
template<> CoreExport time_t Block::Get(const Anope::string &tag, const Anope::string &def) const;
template<> CoreExport bool Block::Get(const Anope::string &tag, const Anope::string &def) const;
+ template<> CoreExport unsigned int Block::Get(const Anope::string &tag, const Anope::string &def) const;
+
+ template<> void Block::Set(const Anope::string &tag, const Anope::string &value);
/** Represents a configuration file
*/
@@ -87,6 +99,8 @@ namespace Configuration
};
struct Uplink;
+ struct Usermode;
+ struct Channelmode;
struct CoreExport Conf : Block
{
@@ -102,6 +116,8 @@ namespace Configuration
time_t TimeoutCheck;
/* options:usestrictprivmsg */
bool UseStrictPrivmsg;
+ /* flag for options:regexengine */
+ std::regex::flag_type regex_flags;
/* networkinfo:nickchars */
Anope::string NickChars;
@@ -115,14 +131,20 @@ namespace Configuration
std::vector<Anope::string> Ulines;
/* List of available opertypes */
std::vector<OperType *> MyOperTypes;
- /* List of pairs of opers and their opertype from the config */
- std::vector<Oper *> Opers;
+ /* names of opers configured in the configuration */
+ std::vector<Anope::string> Opers;
/* Map of fantasy commands */
CommandInfo::map Fantasy;
/* Command groups */
std::vector<CommandGroup> CommandGroups;
/* List of modules to autoload */
std::vector<Anope::string> ModulesAutoLoad;
+ /* After how many characters do we wrap lines? */
+ unsigned int LineWrap;
+ std::vector<Usermode> Usermodes;
+ std::vector<Channelmode> Channelmodes;
+ unsigned char CaseMapUpper[256] = { 0 }, CaseMapLower[256] = { 0 };
+ std::locale *locale = nullptr;
/* module configuration blocks */
std::map<Anope::string, Block *> modules;
@@ -137,7 +159,7 @@ namespace Configuration
Block *GetModule(Module *);
Block *GetModule(const Anope::string &name);
- BotInfo *GetClient(const Anope::string &name);
+ ServiceBot *GetClient(const Anope::string &name);
Block *GetCommand(CommandSource &);
};
@@ -153,14 +175,26 @@ namespace Configuration
inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && ipv6 == other.ipv6; }
inline bool operator!=(const Uplink &other) const { return !(*this == other); }
};
+
+ struct Usermode
+ {
+ Anope::string name;
+ char character;
+ bool param;
+ bool oper_only, setable;
+ };
+
+ struct Channelmode
+ {
+ Anope::string name, param_regex;
+ char character;
+ char status; /* status char, if any +/@ */
+ int level; /* relative level */
+ bool oper_only, list, param, param_unset, setable;
+
+ };
}
-/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
- * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
- * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
- * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
- * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
- */
class ConfigException : public CoreException
{
public:
@@ -170,14 +204,10 @@ class ConfigException : public CoreException
/** This constructor can be used to specify an error message before throwing.
*/
ConfigException(const Anope::string &message) : CoreException(message, "Config Parser") { }
- /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
- * Actually no, it does nothing. Never mind.
- * @throws Nothing!
- */
- virtual ~ConfigException() throw() { }
+
+ virtual ~ConfigException() throw() = default;
};
extern Configuration::File ServicesConf;
extern CoreExport Configuration::Conf *Config;
-#endif // CONFIG_H
diff --git a/include/defs.h b/include/defs.h
index 5cc0cb7ac..b25183062 100644
--- a/include/defs.h
+++ b/include/defs.h
@@ -1,53 +1,79 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2004-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-class AccessGroup;
+
class AutoKick;
class BotInfo;
-class CallBack;
-class ChanAccess;
class Channel;
-class ChannelInfo;
+class ChannelMode;
class ChannelStatus;
+namespace ChanServ
+{
+ class AccessGroup;
+ class ChanAccess;
+ class Channel;
+}
struct ChanUserContainer;
class ClientSocket;
class Command;
class CommandSource;
namespace Configuration { struct Conf; }
class ConnectionSocket;
-namespace DNS { struct Query; }
class Entry;
-class IdentifyRequest;
+class ExtensibleBase;
class InfoFormatter;
class IRCDProto;
class ListenSocket;
class Log;
-class Memo;
+class LogInfo;
+namespace NickServ
+{
+ class Account;
+ class Nick;
+ class IdentifyRequest;
+}
+namespace MemoServ
+{
+ class Memo;
+ class MemoInfo;
+}
class MessageSource;
class Module;
-class NickAlias;
-class NickCore;
class OperType;
class ReferenceBase;
class Regex;
-class Serializable;
+class ServiceBot;
+namespace Serialize
+{
+ using ID = uint64_t;
+ struct Edge;
+ class FieldBase;
+ class TypeBase;
+ class Object;
+}
class Server;
class Socket;
class Thread;
class User;
class XLine;
class XLineManager;
-struct BadWord;
-struct Exception;
-struct MemoInfo;
-struct ModeLock;
-struct Oper;
+class Oper;
namespace SASL { struct Message; }
+class UserMode;
+
diff --git a/include/event.h b/include/event.h
new file mode 100644
index 000000000..b71eef738
--- /dev/null
+++ b/include/event.h
@@ -0,0 +1,1232 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Adam <Adam@anope.org>
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "service.h"
+#include "base.h"
+
+/** Possible return types from events.
+ */
+enum EventReturn
+{
+ EVENT_STOP,
+ EVENT_CONTINUE,
+ EVENT_ALLOW
+};
+
+class Events : public Service
+{
+ public:
+ Events(Module *o, const Anope::string &ename) : Service(o, ename) { }
+};
+
+/* uninstantiated */
+template<typename EventHandler, typename Func, typename Return, typename... Args>
+struct Caller;
+
+/* specialization for void */
+template<typename EventHandler, typename Func, typename... Args>
+struct Caller<EventHandler, Func, void, Args...>
+{
+ void operator()(const std::vector<EventHandler *> &handlers, Func func, Args&&... args)
+ {
+ for (EventHandler *eh : handlers)
+ (eh->*func)(std::forward<Args>(args)...);
+ }
+};
+
+/* specialization for EventReturn */
+template<typename EventHandler, typename Func, typename... Args>
+struct Caller<EventHandler, Func, EventReturn, Args...>
+{
+ EventReturn operator()(const std::vector<EventHandler *> &handlers, Func func, Args&&... args)
+ {
+ EventReturn ret = EVENT_CONTINUE;
+
+ for (EventHandler *eh : handlers)
+ {
+ ret = (eh->*func)(std::forward<Args>(args)...);
+ if (ret != EVENT_CONTINUE)
+ return ret;
+ }
+
+ return ret;
+ }
+};
+
+template<typename EventHandler>
+class EventHook;
+
+template<typename EventHandler>
+class EventDispatcher
+{
+ static_assert(std::is_base_of<Events, EventHandler>::value, "");
+
+ ServiceReferenceList<EventHandler> handlers;
+
+ public:
+ EventDispatcher(const Anope::string &name) : handlers(name) { }
+
+ template<typename Func, typename... Args>
+ auto Dispatch(Func func, Args&&... args) -> decltype(((static_cast<EventHandler*>(nullptr))->*func)(args...))
+ {
+ const std::vector<EventHandler *> h = this->handlers.GetServices();
+ return Caller<EventHandler, Func, decltype(((static_cast<EventHandler*>(nullptr))->*func)(args...)), Args...>()(h, func, std::forward<Args>(args)...);
+ }
+};
+
+template<typename EventHandler>
+class EventHook : public EventHandler
+{
+ static_assert(std::is_base_of<Events, EventHandler>::value, "");
+
+ public:
+ enum class Priority
+ {
+ FIRST,
+ LAST
+ }
+ priority;
+
+ EventHook(Module *creator) : EventHook(creator, Priority::LAST) { }
+
+ EventHook(Module *creator, Priority p)
+ : EventHandler(creator, EventHandler::NAME)
+ , priority(p)
+ {
+#warning "priority doesnt work"
+ }
+};
+
+class EventManager
+{
+ Anope::hash_map<EventDispatcher<Events> *> cache;
+
+ template<typename T>
+ EventDispatcher<T> *GetDispatcher(const Anope::string &name)
+ {
+ auto it = cache.find(name);
+ if (it != cache.end())
+ return reinterpret_cast<EventDispatcher<T> *>(it->second);
+
+ auto dispatcher = new EventDispatcher<T>(name);
+ cache[name] = reinterpret_cast<EventDispatcher<Events> *>(dispatcher);
+ return dispatcher;
+ }
+
+ static EventManager *eventManager;
+
+ public:
+ template<
+ typename Type,
+ typename Function,
+ typename... Args
+ >
+ auto Dispatch(Function Type::*func, Args&&... args) -> decltype(((static_cast<Type*>(nullptr))->*func)(args...))
+ {
+ static_assert(std::is_base_of<Events, Type>::value, "");
+
+ EventDispatcher<Type> *dispatcher = GetDispatcher<Type>(Type::NAME);
+ return dispatcher->Dispatch(func, std::forward<Args>(args)...);
+ }
+
+ static void Init();
+ static EventManager *Get();
+};
+
+namespace Event
+{
+ struct CoreExport PreUserKicked : Events
+ {
+ static constexpr const char *NAME = "preuserkicked";
+
+ using Events::Events;
+
+ /** Called before a user has been kicked from a channel.
+ * @param source The kicker
+ * @param cu The user, channel, and status of the user being kicked
+ * @param kickmsg The reason for the kick.
+ * @return EVENT_STOP to stop the kick, which can only be done if source is 'Me' or from me
+ */
+ virtual EventReturn OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_abstract;
+ };
+
+ struct CoreExport UserKicked : Events
+ {
+ static constexpr const char *NAME = "userkicked";
+
+ using Events::Events;
+
+ /** Called when a user has been kicked from a channel.
+ * @param source The kicker
+ * @param target The user being kicked
+ * @param channel The channel the user was kicked from, which may no longer exist
+ * @param status The status the kicked user had on the channel before they were kicked
+ * @param kickmsg The reason for the kick.
+ */
+ virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_abstract;
+ };
+
+ struct CoreExport PreBotAssign : Events
+ {
+ static constexpr const char *NAME = "prebotassign";
+
+ using Events::Events;
+
+ /** Called before a bot is assigned to a channel.
+ * @param sender The user assigning the bot
+ * @param ci The channel the bot is to be assigned to.
+ * @param bi The bot being assigned.
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign.
+ */
+ virtual EventReturn OnPreBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport BotAssign : Events
+ {
+ static constexpr const char *NAME = "botassign";
+
+ using Events::Events;
+
+ /** Called when a bot is assigned ot a channel
+ */
+ virtual void OnBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport BotUnAssign : Events
+ {
+ static constexpr const char *NAME = "botunassign";
+
+ using Events::Events;
+
+ /** Called before a bot is unassigned from a channel.
+ * @param sender The user unassigning the bot
+ * @param ci The channel the bot is being removed from
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign.
+ */
+ virtual EventReturn OnBotUnAssign(User *sender, ChanServ::Channel *ci) anope_abstract;
+ };
+
+ struct CoreExport UserConnect : Events
+ {
+ static constexpr const char *NAME = "userconnect";
+
+ using Events::Events;
+
+ /** Called when a new user connects to the network.
+ * @param u The connecting user.
+ * @param exempt set to true/is true if the user should be excepted from bans etc
+ */
+ virtual void OnUserConnect(User *u, bool &exempt) anope_abstract;
+ };
+
+ struct CoreExport NewServer : Events
+ {
+ static constexpr const char *NAME = "newserver";
+
+ using Events::Events;
+
+ /** Called when a new server connects to the network.
+ * @param s The server that has connected to the network
+ */
+ virtual void OnNewServer(Server *s) anope_abstract;
+ };
+
+ struct CoreExport UserNickChange : Events
+ {
+ static constexpr const char *NAME = "usernickchange";
+
+ using Events::Events;
+
+ /** Called after a user changed the nick
+ * @param u The user.
+ * @param oldnick The old nick of the user
+ */
+ virtual void OnUserNickChange(User *u, const Anope::string &oldnick) anope_abstract;
+ };
+
+ struct CoreExport PreCommand : Events
+ {
+ static constexpr const char *NAME = "precommand";
+
+ using Events::Events;
+
+ /** Called before a command is due to be executed.
+ * @param source The source of the command
+ * @param command The command the user is executing
+ * @param params The parameters the user is sending
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
+ */
+ virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_abstract;
+ };
+
+ struct CoreExport PostCommand : Events
+ {
+ static constexpr const char *NAME = "postcommand";
+
+ using Events::Events;
+
+ /** Called after a command has been executed.
+ * @param source The source of the command
+ * @param command The command the user executed
+ * @param params The parameters the user sent
+ */
+ virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> &params) anope_abstract;
+ };
+
+ struct CoreExport SaveDatabase : Events
+ {
+ static constexpr const char *NAME = "savedatabase";
+
+ using Events::Events;
+
+ /** Called when the databases are saved
+ */
+ virtual void OnSaveDatabase() anope_abstract;
+ };
+
+ struct CoreExport LoadDatabase : Events
+ {
+ static constexpr const char *NAME = "loaddatabase";
+
+ using Events::Events;
+
+ /** Called when the databases are loaded
+ * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop
+ */
+ virtual EventReturn OnLoadDatabase() anope_abstract;
+ };
+
+ struct CoreExport Encrypt : Events
+ {
+ static constexpr const char *NAME = "encrypt";
+
+ using Events::Events;
+
+ /** Called when anope needs to check passwords against encryption
+ * see src/encrypt.c for detailed informations
+ */
+ virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_abstract;
+ };
+
+ struct CoreExport CreateBot : Events
+ {
+ static constexpr const char *NAME = "createbot";
+
+ using Events::Events;
+
+ /** Called when a bot is created or destroyed
+ */
+ virtual void OnCreateBot(ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport DelBot : Events
+ {
+ static constexpr const char *NAME = "delbot";
+
+ using Events::Events;
+
+ virtual void OnDelBot(ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport PrePartChannel : Events
+ {
+ static constexpr const char *NAME = "prepartchannel";
+
+ using Events::Events;
+
+ /** Called before a user parts a channel
+ * @param u The user
+ * @param c The channel
+ */
+ virtual void OnPrePartChannel(User *u, Channel *c) anope_abstract;
+ };
+
+ struct CoreExport PartChannel : Events
+ {
+ static constexpr const char *NAME = "partchannel";
+
+ using Events::Events;
+
+ /** Called when a user parts a channel
+ * @param u The user
+ * @param c The channel, may be NULL if the channel no longer exists
+ * @param channel The channel name
+ * @param msg The part reason
+ */
+ virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) anope_abstract;
+ };
+
+ struct CoreExport LeaveChannel : Events
+ {
+ static constexpr const char *NAME = "leavechannel";
+
+ using Events::Events;
+
+ /** Called when a user leaves a channel.
+ * From either parting, being kicked, or quitting/killed!
+ * @param u The user
+ * @param c The channel
+ */
+ virtual void OnLeaveChannel(User *u, Channel *c) anope_abstract;
+ };
+
+ struct CoreExport JoinChannel : Events
+ {
+ static constexpr const char *NAME = "joinchannel";
+
+ using Events::Events;
+
+ /** Called after a user joins a channel
+ * If this event triggers the user is allowed to be in the channel, and will
+ * not be kicked for restricted/akick/forbidden, etc. If you want to kick the user,
+ * use the CheckKick event instead.
+ * @param u The user
+ * @param channel The channel
+ */
+ virtual void OnJoinChannel(User *u, Channel *c) anope_abstract;
+ };
+
+ struct CoreExport TopicUpdated : Events
+ {
+ static constexpr const char *NAME = "topicupdated";
+
+ using Events::Events;
+
+ /** Called when a new topic is set
+ * @param source
+ * @param c The channel
+ * @param setter The user who set the new topic
+ * @param topic The new topic
+ */
+ virtual void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_abstract;
+ };
+
+ struct CoreExport PreServerConnect : Events
+ {
+ static constexpr const char *NAME = "preserverconnect";
+
+ using Events::Events;
+
+ /** Called before Anope connecs to its uplink
+ */
+ virtual void OnPreServerConnect() anope_abstract;
+ };
+
+ struct CoreExport ServerConnect : Events
+ {
+ static constexpr const char *NAME = "serverconnect";
+
+ using Events::Events;
+
+ /** Called when Anope connects to its uplink
+ */
+ virtual void OnServerConnect() anope_abstract;
+ };
+
+ struct CoreExport PreUplinkSync : Events
+ {
+ static constexpr const char *NAME = "preuplinksync";
+
+ using Events::Events;
+
+ /** Called when we are almost done synching with the uplink, just before we send the EOB
+ */
+ virtual void OnPreUplinkSync(Server *serv) anope_abstract;
+ };
+
+ struct CoreExport ServerDisconnect : Events
+ {
+ static constexpr const char *NAME = "serverdisconnect";
+
+ using Events::Events;
+
+ /** Called when Anope disconnects from its uplink, before it tries to reconnect
+ */
+ virtual void OnServerDisconnect() anope_abstract;
+ };
+
+ struct CoreExport Restart : Events
+ {
+ static constexpr const char *NAME = "restart";
+
+ using Events::Events;
+
+ /** Called when services restart
+ */
+ virtual void OnRestart() anope_abstract;
+ };
+
+ struct CoreExport Shutdown : Events
+ {
+ static constexpr const char *NAME = "shutdown";
+
+ using Events::Events;
+
+ /** Called when services shutdown
+ */
+ virtual void OnShutdown() anope_abstract;
+ };
+
+ struct CoreExport AddXLine : Events
+ {
+ static constexpr const char *NAME = "addxline";
+
+ using Events::Events;
+
+ /** Called before a XLine is added
+ * @param source The source of the XLine
+ * @param x The XLine
+ * @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(CommandSource &source, const XLine *x, XLineManager *xlm) anope_abstract;
+ };
+
+ struct CoreExport DelXLine : Events
+ {
+ static constexpr const char *NAME = "delxline";
+
+ using Events::Events;
+
+ /** Called before a XLine is deleted
+ * @param source The source of the XLine
+ * @param x The XLine
+ * @param xlm The xline manager it was deleted from
+ */
+ virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) anope_abstract;
+ };
+
+ struct CoreExport IsServicesOperEvent : Events
+ {
+ static constexpr const char *NAME = "isservicesoper";
+
+ using Events::Events;
+
+ /** Called when a user is checked for whether they are a services oper
+ * @param u The user
+ * @return EVENT_ALLOW to allow, anything else to deny
+ */
+ virtual EventReturn IsServicesOper(User *u) anope_abstract;
+ };
+
+ struct CoreExport ServerQuit : Events
+ {
+ static constexpr const char *NAME = "serverquit";
+
+ using Events::Events;
+
+ /** Called when a server quits
+ * @param server The server
+ */
+ virtual void OnServerQuit(Server *server) anope_abstract;
+ };
+
+ struct CoreExport UserQuit : Events
+ {
+ static constexpr const char *NAME = "userquit";
+
+ using Events::Events;
+
+ /** Called when a user quits, or is killed
+ * @param u The user
+ * @param msg The quit message
+ */
+ virtual void OnUserQuit(User *u, const Anope::string &msg) anope_abstract;
+ };
+
+ struct CoreExport PreUserLogoff : Events
+ {
+ static constexpr const char *NAME = "preuserlogoff";
+
+ using Events::Events;
+
+ /** Called when a user is quit, before and after being internally removed from
+ * This is different from OnUserQuit, which takes place at the time of the quit.
+ * This happens shortly after when all message processing is finished.
+ * all lists (channels, user list, etc)
+ * @param u The user
+ */
+ virtual void OnPreUserLogoff(User *u) anope_abstract;
+ };
+
+ struct CoreExport PostUserLogoff : Events
+ {
+ static constexpr const char *NAME = "postuserlogoff";
+
+ using Events::Events;
+
+ virtual void OnPostUserLogoff(User *u) anope_abstract;
+ };
+
+ struct CoreExport AccessDel : Events
+ {
+ static constexpr const char *NAME = "accessdel";
+
+ using Events::Events;
+
+ /** Called after an access entry is deleted from a channel
+ * @param ci The channel
+ * @param source The source of the command
+ * @param access The access entry that was removed
+ */
+ virtual void OnAccessDel(ChanServ::Channel *ci, CommandSource &source, ChanServ::ChanAccess *access) anope_abstract;
+ };
+
+ struct CoreExport AccessAdd : Events
+ {
+ static constexpr const char *NAME = "accessadd";
+
+ using Events::Events;
+
+ /** Called when access is added
+ * @param ci The channel
+ * @param source The source of the command
+ * @param access The access changed
+ */
+ virtual void OnAccessAdd(ChanServ::Channel *ci, CommandSource &source, ChanServ::ChanAccess *access) anope_abstract;
+ };
+
+ struct CoreExport AccessClear : Events
+ {
+ static constexpr const char *NAME = "accessclear";
+
+ using Events::Events;
+
+ /** Called when the access list is cleared
+ * @param ci The channel
+ * @param u The user who cleared the access
+ */
+ virtual void OnAccessClear(ChanServ::Channel *ci, CommandSource &source) anope_abstract;
+ };
+
+ struct CoreExport ChanRegistered : Events
+ {
+ static constexpr const char *NAME = "chanregistered";
+
+ using Events::Events;
+
+ /** Called when a channel is registered
+ * @param ci The channel
+ */
+ virtual void OnChanRegistered(ChanServ::Channel *ci) anope_abstract;
+ };
+
+ struct CoreExport DelChan : Events
+ {
+ static constexpr const char *NAME = "delchan";
+
+ using Events::Events;
+
+ /** Called when a channel is being deleted, for any reason
+ * @param ci The channel
+ */
+ virtual void OnDelChan(ChanServ::Channel *ci) anope_abstract;
+ };
+
+ struct CoreExport ChannelCreate : Events
+ {
+ static constexpr const char *NAME = "channelcreate";
+
+ using Events::Events;
+
+ /** Called when a new channel is created
+ * Note that this channel may not be introduced to the uplink at this point.
+ * @param c The channel
+ */
+ virtual void OnChannelCreate(Channel *c) anope_abstract;
+ };
+
+ struct CoreExport ChannelDelete : Events
+ {
+ static constexpr const char *NAME = "channeldelete";
+
+ using Events::Events;
+
+ /** Called when a channel is deleted
+ * @param c The channel
+ */
+ virtual void OnChannelDelete(Channel *c) anope_abstract;
+ };
+
+ struct CoreExport CheckKick : Events
+ {
+ static constexpr const char *NAME = "checkkick";
+
+ using Events::Events;
+
+ /** Called after a user join a channel when we decide whether to kick them or not
+ * @param u The user
+ * @param c The channel
+ * @param kick Set to true to kick
+ * @param mask The mask to ban, if any
+ * @param reason The reason for the kick
+ * @return EVENT_STOP to prevent the user from joining by kicking/banning the user
+ */
+ virtual EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) anope_abstract;
+ };
+
+ struct CoreExport CheckPriv : Events
+ {
+ static constexpr const char *NAME = "checkpriv";
+
+ using Events::Events;
+
+ /** Checks if access has the channel privilege 'priv'.
+ * @param access THe access struct
+ * @param priv The privilege being checked for
+ * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing
+ */
+ virtual EventReturn OnCheckPriv(const ChanServ::ChanAccess *access, const Anope::string &priv) anope_abstract;
+ };
+
+ struct CoreExport GroupCheckPriv : Events
+ {
+ static constexpr const char *NAME = "groupcheckpriv";
+
+ using Events::Events;
+
+ /** Check whether an access group has a privilege
+ * @param group The group
+ * @param priv The privilege
+ * @return MOD_ALLOW to allow, MOD_STOP to stop
+ */
+ virtual EventReturn OnGroupCheckPriv(const ChanServ::AccessGroup *group, const Anope::string &priv) anope_abstract;
+ };
+
+ struct CoreExport NickIdentify : Events
+ {
+ static constexpr const char *NAME = "nickidentify";
+
+ using Events::Events;
+
+ /** Called when a user identifies to a nick
+ * @param u The user
+ */
+ virtual void OnNickIdentify(User *u) anope_abstract;
+ };
+
+ struct CoreExport UserLogin : Events
+ {
+ static constexpr const char *NAME = "userlogin";
+
+ using Events::Events;
+
+ /** Called when a user is logged into an account
+ * @param u The user
+ */
+ virtual void OnUserLogin(User *u) anope_abstract;
+ };
+
+ struct CoreExport NickLogout : Events
+ {
+ static constexpr const char *NAME = "nicklogout";
+
+ using Events::Events;
+
+ /** Called when a nick logs out
+ * @param u The nick
+ */
+ virtual void OnNickLogout(User *u) anope_abstract;
+ };
+
+ struct CoreExport DelNick : Events
+ {
+ static constexpr const char *NAME = "delnick";
+
+ using Events::Events;
+
+ /** Called on delnick()
+ * @param na pointer to the nickalias
+ */
+ virtual void OnDelNick(NickServ::Nick *na) anope_abstract;
+ };
+
+ struct CoreExport DelCore : Events
+ {
+ static constexpr const char *NAME = "delcore";
+
+ using Events::Events;
+
+ /** Called on delcore()
+ * @param nc pointer to the NickServ::Account
+ */
+ virtual void OnDelCore(NickServ::Account *nc) anope_abstract;
+ };
+
+ struct CoreExport ChangeCoreDisplay : Events
+ {
+ static constexpr const char *NAME = "changecoredisplay";
+
+ using Events::Events;
+
+ /** Called on change_core_display()
+ * @param nc pointer to the NickServ::Account
+ * @param newdisplay the new display
+ */
+ virtual void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) anope_abstract;
+ };
+
+ struct CoreExport NickClearAccess : Events
+ {
+ static constexpr const char *NAME = "nickclearaccess";
+
+ using Events::Events;
+
+ /** called from NickServ::Account::ClearAccess()
+ * @param nc pointer to the NickServ::Account
+ */
+ virtual void OnNickClearAccess(NickServ::Account *nc) anope_abstract;
+ };
+
+ struct CoreExport NickAddAccess : Events
+ {
+ static constexpr const char *NAME = "nickaddaccess";
+
+ using Events::Events;
+
+ /** Called when a user adds an entry to their access list
+ * @param nc The nick
+ * @param entry The entry
+ */
+ virtual void OnNickAddAccess(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
+ };
+
+ struct CoreExport NickEraseAccess : Events
+ {
+ static constexpr const char *NAME = "nickeraseaccess";
+
+ using Events::Events;
+
+ /** Called from NickServ::Account::EraseAccess()
+ * @param nc pointer to the NickServ::Account
+ * @param entry The access mask
+ */
+ virtual void OnNickEraseAccess(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
+ };
+
+ struct CoreExport CheckAuthentication : Events
+ {
+ static constexpr const char *NAME = "checkauthentication";
+
+ using Events::Events;
+
+ /** Check whether a username and password is correct
+ * @param u The user trying to identify, if applicable.
+ * @param req The login request
+ */
+ virtual void OnCheckAuthentication(User *u, NickServ::IdentifyRequest *req) anope_abstract;
+ };
+
+ struct CoreExport Fingerprint : Events
+ {
+ static constexpr const char *NAME = "fingerprint";
+
+ using Events::Events;
+
+ /** Called when we get informed about a users SSL fingerprint
+ * when we call this, the fingerprint should already be stored in the user struct
+ * @param u pointer to the user
+ */
+ virtual void OnFingerprint(User *u) anope_abstract;
+ };
+
+ struct CoreExport UserAway : Events
+ {
+ static constexpr const char *NAME = "useraway";
+
+ using Events::Events;
+
+ /** Called when a user becomes (un)away
+ * @param message The message, is .empty() if unaway
+ */
+ virtual void OnUserAway(User *u, const Anope::string &message) anope_abstract;
+ };
+
+ struct CoreExport Invite : Events
+ {
+ static constexpr const char *NAME = "invite";
+
+ using Events::Events;
+
+ /** Called when a user invites one of our users to a channel
+ * @param source The user doing the inviting
+ * @param c The channel the user is inviting to
+ * @param targ The user being invited
+ */
+ virtual void OnInvite(User *source, Channel *c, User *targ) anope_abstract;
+ };
+
+ struct CoreExport SetVhost : Events
+ {
+ static constexpr const char *NAME = "setvhost";
+
+ using Events::Events;
+
+ /** Called when a vhost is set
+ * @param na The nickalias of the vhost
+ */
+ virtual void OnSetVhost(NickServ::Nick *na) anope_abstract;
+ };
+
+ struct CoreExport SetDisplayedHost : Events
+ {
+ static constexpr const char *NAME = "setdisplayedhost";
+
+ using Events::Events;
+
+ /** Called when a users host changes
+ * @param u The user
+ */
+ virtual void OnSetDisplayedHost(User *) anope_abstract;
+ };
+
+ struct CoreExport ChannelModeSet : Events
+ {
+ static constexpr const char *NAME = "channelmodeset";
+
+ using Events::Events;
+
+ /** Called when a mode is set on a channel
+ * @param c The channel
+ * @param setter The user or server that is setting the mode
+ * @param mode The mode
+ * @param param The mode param, if there is one
+ * @return EVENT_STOP to make mlock/secureops etc checks not happen
+ */
+ virtual EventReturn OnChannelModeSet(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_abstract;
+ };
+
+ struct CoreExport ChannelModeUnset : Events
+ {
+ static constexpr const char *NAME = "channelmodeunset";
+
+ using Events::Events;
+
+ /** Called when a mode is unset on a channel
+ * @param c The channel
+ * @param setter The user or server that is unsetting the mode
+ * @param mode The mode
+ * @param param The mode param, if there is one
+ * @return EVENT_STOP to make mlock/secureops etc checks not happen
+ */
+ virtual EventReturn OnChannelModeUnset(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string &param) anope_abstract;
+ };
+
+ struct CoreExport UserModeSet : Events
+ {
+ static constexpr const char *NAME = "usermodeset";
+
+ using Events::Events;
+
+ /** Called when a mode is set on a user
+ * @param setter who/what is setting the mode
+ * @param u The user
+ * @param mname The mode name
+ */
+ virtual void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_abstract;
+ };
+
+ struct CoreExport UserModeUnset : Events
+ {
+ static constexpr const char *NAME = "usermodeunset";
+
+ using Events::Events;
+
+ /** Called when a mode is unset from a user
+ * @param setter who/what is setting the mode
+ * @param u The user
+ * @param mname The mode name
+ */
+ virtual void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_abstract;
+ };
+
+ struct CoreExport ChannelModeAdd : Events
+ {
+ static constexpr const char *NAME = "channelmodeadd";
+
+ using Events::Events;
+
+ /** Called when a channel mode is introducted into Anope
+ * @param cm The mode
+ */
+ virtual void OnChannelModeAdd(ChannelMode *cm) anope_abstract;
+ };
+
+ struct CoreExport UserModeAdd : Events
+ {
+ static constexpr const char *NAME = "usermodeadd";
+
+ using Events::Events;
+
+ /** Called when a user mode is introducted into Anope
+ * @param um The mode
+ */
+ virtual void OnUserModeAdd(UserMode *um) anope_abstract;
+ };
+
+ struct CoreExport ModuleLoad : Events
+ {
+ static constexpr const char *NAME = "moduleload";
+
+ using Events::Events;
+
+ /** Called after a module is loaded
+ * @param u The user loading the module, can be NULL
+ * @param m The module
+ */
+ virtual void OnModuleLoad(User *u, Module *m) anope_abstract;
+ };
+
+ struct CoreExport ModuleUnload : Events
+ {
+ static constexpr const char *NAME = "moduleunload";
+
+ using Events::Events;
+
+ /** Called before a module is unloaded
+ * @param u The user, can be NULL
+ * @param m The module
+ */
+ virtual void OnModuleUnload(User *u, Module *m) anope_abstract;
+ };
+
+ struct CoreExport ServerSync : Events
+ {
+ static constexpr const char *NAME = "serversync";
+
+ using Events::Events;
+
+ /** Called when a server is synced
+ * @param s The server, can be our uplink server
+ */
+ virtual void OnServerSync(Server *s) anope_abstract;
+ };
+
+ struct CoreExport UplinkSync : Events
+ {
+ static constexpr const char *NAME = "uplinksync";
+
+ using Events::Events;
+
+ /** Called when we sync with our uplink
+ * @param s Our uplink
+ */
+ virtual void OnUplinkSync(Server *s) anope_abstract;
+ };
+
+ struct CoreExport BotPrivmsg : Events
+ {
+ static constexpr const char *NAME = "botprivmsg";
+
+ using Events::Events;
+
+ /** Called when we receive a PRIVMSG for one of our clients
+ * @param u The user sending the PRIVMSG
+ * @param bi The target of the PRIVMSG
+ * @param message The message
+ * @return EVENT_STOP to halt processing
+ */
+ virtual EventReturn OnBotPrivmsg(User *u, ServiceBot *bi, Anope::string &message) anope_abstract;
+ };
+
+ struct CoreExport BotNotice : Events
+ {
+ static constexpr const char *NAME = "botnotice";
+
+ using Events::Events;
+
+ /** Called when we receive a NOTICE for one of our clients
+ * @param u The user sending the NOTICE
+ * @param bi The target of the NOTICE
+ * @param message The message
+ */
+ virtual void OnBotNotice(User *u, ServiceBot *bi, Anope::string &message) anope_abstract;
+ };
+
+ struct CoreExport Privmsg : Events
+ {
+ static constexpr const char *NAME = "privmsg";
+
+ using Events::Events;
+
+ /** Called when we receive a PRIVMSG for a registered channel we are in
+ * @param u The source of the message
+ * @param c The channel
+ * @param msg The message
+ */
+ virtual void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_abstract;
+ };
+
+ struct CoreExport Log : Events
+ {
+ static constexpr const char *NAME = "log";
+
+ using Events::Events;
+
+ /** Called when a message is logged
+ * @param l The log message
+ */
+ virtual void OnLog(::Log *l) anope_abstract;
+ };
+
+ struct CoreExport LogMessage : Events
+ {
+ static constexpr const char *NAME = "logmessage";
+
+ using Events::Events;
+
+ /** Called when a log message is actually logged to a given log info
+ * The message has already passed validation checks by the LogInfo
+ * @param li The loginfo whee the message is being logged
+ * @param l The log message
+ * @param msg The final formatted message, derived from 'l'
+ */
+ virtual void OnLogMessage(LogInfo *li, const ::Log *l, const Anope::string &msg) anope_abstract;
+ };
+
+ struct CoreExport CheckModes : Events
+ {
+ static constexpr const char *NAME = "checkmodes";
+
+ using Events::Events;
+
+ /** Called when a channels modes are being checked to see if they are allowed,
+ * mostly to ensure mlock/+r are set.
+ * @param c The channel
+ */
+ virtual void OnCheckModes(Reference<Channel> &c) anope_abstract;
+ };
+
+ struct CoreExport ChannelSync : Events
+ {
+ static constexpr const char *NAME = "channelsync";
+
+ using Events::Events;
+
+ /** Called when a channel is synced.
+ * Channels are synced after a sjoin is finished processing
+ * for a newly created channel to set the correct modes, topic,
+ * set.
+ */
+ virtual void OnChannelSync(Channel *c) anope_abstract;
+ };
+
+ struct CoreExport SetCorrectModes : Events
+ {
+ static constexpr const char *NAME = "setcorrectmodes";
+
+ using Events::Events;
+
+ /** Called to set the correct modes on the user on the given channel
+ * @param user The user
+ * @param chan The channel
+ * @param access The user's access on the channel
+ * @param give_modes If giving modes is desired
+ * @param take_modes If taking modes is desired
+ */
+ virtual void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) anope_abstract;
+ };
+
+ struct CoreExport Message : Events
+ {
+ static constexpr const char *NAME = "message";
+
+ using Events::Events;
+
+ /** Called whenever a message is received from the uplink
+ * @param source The source of the message
+ * @param command The command being executed
+ * @param params Parameters
+ * @return EVENT_STOP to prevent the protocol module from processing this message
+ */
+ virtual EventReturn OnMessage(MessageSource &source, Anope::string &command, std::vector<Anope::string> &param) anope_abstract;
+ };
+
+ struct CoreExport CanSet : Events
+ {
+ static constexpr const char *NAME = "canset";
+
+ using Events::Events;
+
+ /** Called to determine if a chnanel mode can be set by a user
+ * @param u The user
+ * @param cm The mode
+ */
+ virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) anope_abstract;
+ };
+
+ struct CoreExport CheckDelete : Events
+ {
+ static constexpr const char *NAME = "checkdelete";
+
+ using Events::Events;
+
+ virtual EventReturn OnCheckDelete(Channel *) anope_abstract;
+ };
+
+ struct CoreExport ExpireTick : Events
+ {
+ static constexpr const char *NAME = "expiretick";
+
+ using Events::Events;
+
+ /** Called every options:expiretimeout seconds. Should be used to expire nicks,
+ * channels, etc.
+ */
+ virtual void OnExpireTick() anope_abstract;
+ };
+
+ struct CoreExport SerializeEvents : Events
+ {
+ static constexpr const char *NAME = "serialize";
+
+ using Events::Events;
+
+ virtual EventReturn OnSerializeList(Serialize::TypeBase *type, std::vector<Serialize::ID> &ids) anope_abstract;
+
+ virtual EventReturn OnSerializeFind(Serialize::TypeBase *type, Serialize::FieldBase *field, const Anope::string &value, Serialize::ID &id) anope_abstract;
+
+ virtual EventReturn OnSerializeGet(Serialize::Object *object, Serialize::FieldBase *field, Anope::string &value) anope_abstract;
+
+ virtual EventReturn OnSerializeGetSerializable(Serialize::Object *object, Serialize::FieldBase *field, Anope::string &type, Serialize::ID &id) anope_abstract;
+
+ virtual EventReturn OnSerializeGetRefs(Serialize::Object *object, Serialize::TypeBase *type, std::vector<Serialize::Edge> &) anope_abstract;
+
+ virtual EventReturn OnSerializeDeref(Serialize::ID value, Serialize::TypeBase *type) anope_abstract;
+
+ virtual EventReturn OnSerializableGetId(Serialize::ID &id) anope_abstract;
+
+ virtual void OnSerializableDelete(Serialize::Object *) anope_abstract;
+
+ virtual EventReturn OnSerializeSet(Serialize::Object *object, Serialize::FieldBase *field, const Anope::string &value) anope_abstract;
+
+ virtual EventReturn OnSerializeSetSerializable(Serialize::Object *object, Serialize::FieldBase *field, Serialize::Object *value) anope_abstract;
+
+ virtual EventReturn OnSerializeUnset(Serialize::Object *object, Serialize::FieldBase *field) anope_abstract;
+
+ virtual EventReturn OnSerializeUnsetSerializable(Serialize::Object *object, Serialize::FieldBase *field) anope_abstract;
+
+ virtual EventReturn OnSerializeHasField(Serialize::Object *object, Serialize::FieldBase *field) anope_abstract;
+
+ virtual void OnSerializableCreate(Serialize::Object *) anope_abstract;
+ };
+}
diff --git a/include/extensible.h b/include/extensible.h
index aec29a8f6..2e1079631 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -1,16 +1,25 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2009-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef EXTENSIBLE_H
-#define EXTENSIBLE_H
+#pragma once
#include "anope.h"
-#include "serialize.h"
#include "service.h"
#include "logger.h"
@@ -22,47 +31,37 @@ class CoreExport ExtensibleBase : public Service
std::map<Extensible *, void *> items;
ExtensibleBase(Module *m, const Anope::string &n);
- ~ExtensibleBase();
+ ExtensibleBase(Module *m, const Anope::string &t, const Anope::string &n);
public:
- virtual void Unset(Extensible *obj) = 0;
-
- /* called when an object we are keep track of is serializing */
- virtual void ExtensibleSerialize(const Extensible *, const Serializable *, Serialize::Data &) const { }
- virtual void ExtensibleUnserialize(Extensible *, Serializable *, Serialize::Data &) { }
+ virtual void Unset(Extensible *obj) anope_abstract;
+
+ static constexpr const char *NAME = "Extensible";
};
class CoreExport Extensible
{
public:
- std::set<ExtensibleBase *> extension_items;
+ std::vector<ExtensibleBase *> extension_items;
virtual ~Extensible();
- void UnsetExtensibles();
-
- template<typename T> T* GetExt(const Anope::string &name) const;
- bool HasExt(const Anope::string &name) const;
+ template<typename T> T* GetExt(const Anope::string &name);
+ bool HasExtOK(const Anope::string &name);
template<typename T> T* Extend(const Anope::string &name, const T &what);
- template<typename T> T* Extend(const Anope::string &name);
- template<typename T> T* Require(const Anope::string &name);
- template<typename T> void Shrink(const Anope::string &name);
- static void ExtensibleSerialize(const Extensible *, const Serializable *, Serialize::Data &data);
- static void ExtensibleUnserialize(Extensible *, Serializable *, Serialize::Data &data);
+ template<typename T> void Shrink(const Anope::string &name);
};
template<typename T>
-class BaseExtensibleItem : public ExtensibleBase
+class ExtensibleItem : public ExtensibleBase
{
- protected:
- virtual T *Create(Extensible *) = 0;
-
public:
- BaseExtensibleItem(Module *m, const Anope::string &n) : ExtensibleBase(m, n) { }
+ ExtensibleItem(Module *m, const Anope::string &n) : ExtensibleBase(m, n) { }
+ ExtensibleItem(Module *m, const Anope::string &t, const Anope::string &n) : ExtensibleBase(m, t, n) { }
- ~BaseExtensibleItem()
+ ~ExtensibleItem()
{
while (!items.empty())
{
@@ -70,48 +69,49 @@ class BaseExtensibleItem : public ExtensibleBase
Extensible *obj = it->first;
T *value = static_cast<T *>(it->second);
- obj->extension_items.erase(this);
+ auto it2 = std::find(obj->extension_items.begin(), obj->extension_items.end(), this);
+ if (it2 != obj->extension_items.end())
+ obj->extension_items.erase(it2);
items.erase(it);
+
delete value;
}
}
T* Set(Extensible *obj, const T &value)
{
- T* t = Set(obj);
- if (t)
- *t = value;
- return t;
- }
-
- T* Set(Extensible *obj)
- {
- T* t = Create(obj);
+ T* t = new T(value);
Unset(obj);
+
items[obj] = t;
- obj->extension_items.insert(this);
+ obj->extension_items.push_back(this);
+
return t;
}
- void Unset(Extensible *obj) anope_override
+ void Unset(Extensible *obj) override
{
T *value = Get(obj);
+
items.erase(obj);
- obj->extension_items.erase(this);
+ auto it = std::find(obj->extension_items.begin(), obj->extension_items.end(), this);
+ if (it != obj->extension_items.end())
+ obj->extension_items.erase(it);
+
delete value;
}
- T* Get(const Extensible *obj) const
+ T* Get(Extensible *obj)
{
- std::map<Extensible *, void *>::const_iterator it = items.find(const_cast<Extensible *>(obj));
+ std::map<Extensible *, void *>::const_iterator it = items.find(obj);
if (it != items.end())
return static_cast<T *>(it->second);
- return NULL;
+ return nullptr;
}
- bool HasExt(const Extensible *obj) const
+ bool HasExt(Extensible *obj)
{
- return items.find(const_cast<Extensible *>(obj)) != items.end();
+ return items.find(obj) != items.end();
}
T* Require(Extensible *obj)
@@ -120,98 +120,18 @@ class BaseExtensibleItem : public ExtensibleBase
if (t)
return t;
- return Set(obj);
- }
-};
-
-template<typename T>
-class ExtensibleItem : public BaseExtensibleItem<T>
-{
- protected:
- T* Create(Extensible *obj) anope_override
- {
- return new T(obj);
- }
- public:
- ExtensibleItem(Module *m, const Anope::string &n) : BaseExtensibleItem<T>(m, n) { }
-};
-
-template<typename T>
-class PrimitiveExtensibleItem : public BaseExtensibleItem<T>
-{
- protected:
- T* Create(Extensible *obj) anope_override
- {
- return new T();
- }
- public:
- PrimitiveExtensibleItem(Module *m, const Anope::string &n) : BaseExtensibleItem<T>(m, n) { }
-};
-
-template<>
-class PrimitiveExtensibleItem<bool> : public BaseExtensibleItem<bool>
-{
- protected:
- bool* Create(Extensible *) anope_override
- {
- return NULL;
+ return Set(obj, T());
}
- public:
- PrimitiveExtensibleItem(Module *m, const Anope::string &n) : BaseExtensibleItem<bool>(m, n) { }
};
template<typename T>
-class SerializableExtensibleItem : public PrimitiveExtensibleItem<T>
+struct ExtensibleRef : ServiceReference<ExtensibleItem<T>>
{
- public:
- SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<T>(m, n) { }
-
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
- {
- T* t = this->Get(e);
- data[this->name] << *t;
- }
-
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
- {
- T t;
- if (data[this->name] >> t)
- this->Set(e, t);
- else
- this->Unset(e);
- }
-};
-
-template<>
-class SerializableExtensibleItem<bool> : public PrimitiveExtensibleItem<bool>
-{
- public:
- SerializableExtensibleItem(Module *m, const Anope::string &n) : PrimitiveExtensibleItem<bool>(m, n) { }
-
- void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const anope_override
- {
- data[this->name] << true;
- }
-
- void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) anope_override
- {
- bool b = false;
- data[this->name] >> b;
- if (b)
- this->Set(e);
- else
- this->Unset(e);
- }
+ ExtensibleRef(const Anope::string &n) : ServiceReference<ExtensibleItem<T>>(n) { }
};
template<typename T>
-struct ExtensibleRef : ServiceReference<BaseExtensibleItem<T> >
-{
- ExtensibleRef(const Anope::string &n) : ServiceReference<BaseExtensibleItem<T> >("Extensible", n) { }
-};
-
-template<typename T>
-T* Extensible::GetExt(const Anope::string &name) const
+T* Extensible::GetExt(const Anope::string &name)
{
ExtensibleRef<T> ref(name);
if (ref)
@@ -224,33 +144,18 @@ T* Extensible::GetExt(const Anope::string &name) const
template<typename T>
T* Extensible::Extend(const Anope::string &name, const T &what)
{
- T* t = Extend<T>(name);
- if (t)
- *t = what;
- return t;
-}
-
-template<typename T>
-T* Extensible::Extend(const Anope::string &name)
-{
ExtensibleRef<T> ref(name);
if (ref)
- return ref->Set(this);
+ {
+ ref->Set(this, what);
+ return ref->Get(this);
+ }
Log(LOG_DEBUG) << "Extend for nonexistent type " << name << " on " << static_cast<void *>(this);
return NULL;
}
template<typename T>
-T* Extensible::Require(const Anope::string &name)
-{
- if (HasExt(name))
- return GetExt<T>(name);
- else
- return Extend<T>(name);
-}
-
-template<typename T>
void Extensible::Shrink(const Anope::string &name)
{
ExtensibleRef<T> ref(name);
@@ -260,4 +165,3 @@ void Extensible::Shrink(const Anope::string &name)
Log(LOG_DEBUG) << "Shrink for nonexistent type " << name << " on " << static_cast<void *>(this);
}
-#endif // EXTENSIBLE_H
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 4f319c21d..d246bfd2b 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -1,24 +1,28 @@
/*
+ * Anope IRC Services
*
- * (C) 2002-2011 InspIRCd Development Team
- * (C) 2009-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2002-2011 InspIRCd Development Team
+ * Copyright (C) 2008-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef HASHCOMP_H
-#define HASHCOMP_H
+#pragma once
#include <string>
#include <locale>
-
-#if defined _LIBCPP_VERSION || defined _WIN32
#include <unordered_map>
-#define TR1NS std
-#else
-#include <tr1/unordered_map>
-#define TR1NS std::tr1
-#endif
#include "services.h"
@@ -26,56 +30,8 @@ namespace Anope
{
class string;
- /* Casemap in use by Anope. ci::string's comparation functions use this (and thus Anope::string) */
- extern std::locale casemap;
-
- extern void CaseMapRebuild();
extern unsigned char tolower(unsigned char);
extern unsigned char toupper(unsigned char);
-
- /* ASCII case insensitive ctype. */
- template<typename char_type>
- class ascii_ctype : public std::ctype<char_type>
- {
- public:
- char_type do_toupper(char_type c) const anope_override
- {
- if (c >= 'a' && c <= 'z')
- return c - 32;
- else
- return c;
- }
-
- char_type do_tolower(char_type c) const anope_override
- {
- if (c >= 'A' && c <= 'Z')
- return c + 32;
- else
- return c;
- }
- };
-
- /* rfc1459 case insensitive ctype, { = [, } = ], and | = \ */
- template<typename char_type>
- class rfc1459_ctype : public ascii_ctype<char_type>
- {
- public:
- char_type do_toupper(char_type c) const anope_override
- {
- if (c == '{' || c == '}' || c == '|')
- return c - 32;
- else
- return ascii_ctype<char_type>::do_toupper(c);
- }
-
- char_type do_tolower(char_type c) const anope_override
- {
- if (c == '[' || c == ']' || c == '\\')
- return c + 32;
- else
- return ascii_ctype<char_type>::do_tolower(c);
- }
- };
}
/** The ci namespace contains a number of helper classes relevant to case insensitive strings.
@@ -196,4 +152,17 @@ inline bool operator!=(const std::string &leftval, const ci::string &rightval)
return !(leftval.c_str() == rightval);
}
-#endif // HASHCOMP_H
+namespace Anope {
+namespace locale {
+
+#ifdef Boost_FOUND
+
+extern std::locale generate(const std::string &);
+extern int compare(const std::string &, const std::string &);
+extern long hash(const std::string &);
+
+#endif
+
+}
+}
+
diff --git a/include/language.h b/include/language.h
index a214ef214..2cfdfe40d 100644
--- a/include/language.h
+++ b/include/language.h
@@ -1,9 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "anope.h"
@@ -11,7 +22,7 @@
namespace Language
{
- /* Languages we support as configured in services.conf. They are
+ /* Languages we support as configured in anope.conf. They are
* added to this list if we detect a language exists in the correct
* location for each language.
*/
@@ -23,7 +34,7 @@ namespace Language
* and we detect a language file exists for at least one of the supported
* languages for the module, then we add the module's domain (its name)
* here.
- *
+ *
* When strings are translated they are checked against all domains.
*/
extern std::vector<Anope::string> Domains;
@@ -38,6 +49,7 @@ namespace Language
* @return The translated string if found, else the original string.
*/
extern CoreExport const char *Translate(const char *string);
+ extern CoreExport const char *Translate(const Anope::string &string);
/** Translates a string to the language of the given user.
* @param u The user to transate the string for
@@ -45,13 +57,15 @@ namespace Language
* @return The translated string if found, else the original string.
*/
extern CoreExport const char *Translate(User *u, const char *string);
+ extern CoreExport const char *Translate(User *u, const Anope::string &string);
/** Translates a string to the language of the given account.
* @param nc The account to translate the string for
* @param string A string to translate
* @return The translated string if count, else the original string
*/
- extern CoreExport const char *Translate(const NickCore *nc, const char *string);
+ extern CoreExport const char *Translate(NickServ::Account *nc, const char *string);
+ extern CoreExport const char *Translate(NickServ::Account *nc, const Anope::string &string);
/** Translatesa string to the given language.
* @param lang The language to translate to
@@ -62,66 +76,3 @@ namespace Language
} // namespace Language
-/* Commonly used language strings */
-#define MORE_INFO _("\002%s%s HELP %s\002 for more information.")
-#define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
-#define BAD_EXPIRY_TIME _("Invalid expiry time.")
-#define USERHOST_MASK_TOO_WIDE _("%s coverage is too wide; Please use a more specific mask.")
-#define READ_ONLY_MODE _("Services are in read-only mode!")
-#define PASSWORD_INCORRECT _("Password incorrect.")
-#define ACCESS_DENIED _("Access denied.")
-#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should be at least\n" \
- "five characters long, should not be something easily guessed\n" \
- "(e.g. your real name or your nick), and cannot contain the space or tab characters.")
-#define PASSWORD_TOO_LONG _("Your password is too long. It must not exceed %u characters.")
-#define NICK_NOT_REGISTERED _("Your nick isn't registered.")
-#define NICK_X_NOT_REGISTERED _("Nick \002%s\002 isn't registered.")
-#define NICK_X_NOT_IN_USE _("Nick \002%s\002 isn't currently in use.")
-#define NICK_X_NOT_ON_CHAN _("\002%s\002 is not currently on channel %s.")
-#define NICK_X_SUSPENDED _("Nick %s is currently suspended.")
-#define CHAN_X_SUSPENDED _("Channel %s is currently suspended.")
-#define CHAN_X_NOT_REGISTERED _("Channel \002%s\002 isn't registered.")
-#define CHAN_X_NOT_IN_USE _("Channel \002%s\002 doesn't exist.")
-#define NICK_IDENTIFY_REQUIRED _("Password authentication required for that command.")
-#define MAIL_X_INVALID _("\002%s\002 is not a valid e-mail address.")
-#define UNKNOWN _("<unknown>")
-#define NO_EXPIRE _("does not expire")
-#define LIST_INCORRECT_RANGE _("Incorrect range specified. The correct syntax is \002#\037from\037-\037to\037\002.")
-#define NICK_IS_REGISTERED _("This nick is owned by someone else. Please choose another.\n" \
- "(If this is your nick, type \002%s%s IDENTIFY \037password\037\002.)")
-#define NICK_IS_SECURE _("This nickname is registered and protected. If it is your\n" \
- "nick, type \002%s%s IDENTIFY \037password\037\002. Otherwise,\n" \
- "please choose a different nick.")
-#define FORCENICKCHANGE_NOW _("This nickname has been registered; you may not use it.")
-#define NICK_CANNOT_BE_REGISTERED _("Nickname \002%s\002 may not be registered.")
-#define NICK_ALREADY_REGISTERED _("Nickname \002%s\002 is already registered!")
-#define NICK_SET_DISPLAY_CHANGED _("The new display is now \002%s\002.")
-#define NICK_CONFIRM_INVALID _("Invalid passcode has been entered, please check the e-mail again, and retry.")
-#define CHAN_NOT_ALLOWED_TO_JOIN _("You are not permitted to be on this channel.")
-#define CHAN_X_INVALID _("Channel %s is not a valid channel.")
-#define CHAN_REACHED_CHANNEL_LIMIT _("Sorry, you have already reached your limit of \002%d\002 channels.")
-#define CHAN_EXCEEDED_CHANNEL_LIMIT _("Sorry, you have already exceeded your limit of \002%d\002 channels.")
-#define CHAN_SYMBOL_REQUIRED _("Please use the symbol of \002#\002 when attempting to register.")
-#define CHAN_SETTING_CHANGED _("%s for %s set to %s.")
-#define CHAN_SETTING_UNSET _("%s for %s unset.")
-#define CHAN_ACCESS_LEVEL_RANGE _("Access level must be between %d and %d inclusive.")
-#define CHAN_INFO_HEADER _("Information for channel \002%s\002:")
-#define CHAN_EXCEPTED _("\002%s\002 matches an except on %s and cannot be banned until the except has been removed.")
-#define MEMO_NEW_X_MEMO_ARRIVED _("There is a new memo on channel %s.\n" \
- "Type \002%s%s READ %s %d\002 to read it.")
-#define MEMO_NEW_MEMO_ARRIVED _("You have a new memo from %s.\n" \
- "Type \002%s%s READ %d\002 to read it.")
-#define MEMO_HAVE_NO_MEMOS _("You have no memos.")
-#define MEMO_X_HAS_NO_MEMOS _("%s has no memos.")
-#define MEMO_SEND_DISABLED _("Sorry, memo sending is temporarily disabled.")
-#define MEMO_HAVE_NO_NEW_MEMOS _("You have no new memos.")
-#define MEMO_X_HAS_NO_NEW_MEMOS _("%s has no new memos.")
-#define BOT_DOES_NOT_EXIST _("Bot \002%s\002 does not exist.")
-#define BOT_NOT_ASSIGNED _("You must assign a bot to the channel before using this command.")
-#define BOT_NOT_ON_CHANNEL _("Bot is not on channel \002%s\002.")
-#define HOST_SET_ERROR _("A vHost must be in the format of a valid hostname.")
-#define HOST_SET_IDENT_ERROR _("A vHost ident must be in the format of a valid ident.")
-#define HOST_SET_TOOLONG _("Error! The vHost is too long, please use a hostname shorter than %d characters.")
-#define HOST_SET_IDENTTOOLONG _("Error! The vHost ident is too long, please use an ident shorter than %d characters.")
-#define HOST_NOT_ASSIGNED _("Please contact an Operator to get a vHost assigned to this nick.")
-#define HOST_NO_VIDENT _("Your IRCd does not support vIdent's, if this is incorrect, please report this as a possible bug")
diff --git a/include/lists.h b/include/lists.h
index 594f2c5ad..f5014933d 100644
--- a/include/lists.h
+++ b/include/lists.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef LISTS_H
-#define LISTS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -24,39 +31,16 @@
*/
class CoreExport NumberList
{
- private:
- bool is_valid;
-
- std::set<unsigned> numbers;
+ std::function<void(void)> endf;
- bool desc;
public:
/** Processes a numbered list
* @param list The list
- * @param descending True to make HandleNumber get called with numbers in descending order
+ * @param descending True to call the number handler callback with the numbers in descending order
*/
- NumberList(const Anope::string &list, bool descending);
+ NumberList(const Anope::string &list, bool descending, std::function<void(unsigned int)> nf, std::function<void(void)> ef);
- /** Destructor, does nothing
- */
- virtual ~NumberList();
-
- /** Should be called after the constructors are done running. This calls the callbacks.
- */
- void Process();
-
- /** Called with a number from the list
- * @param number The number
- */
- virtual void HandleNumber(unsigned number);
-
- /** Called when there is an error with the numbered list
- * Return false to immediately stop processing the list and return
- * This is all done before we start calling HandleNumber, so no numbers will have been processed yet
- * @param list The list
- * @return false to stop processing
- */
- virtual bool InvalidRange(const Anope::string &list);
+ ~NumberList();
};
/** This class handles formatting LIST/VIEW replies.
@@ -66,11 +50,11 @@ class CoreExport ListFormatter
public:
typedef std::map<Anope::string, Anope::string> ListEntry;
private:
- NickCore *nc;
+ NickServ::Account *nc;
std::vector<Anope::string> columns;
std::vector<ListEntry> entries;
public:
- ListFormatter(NickCore *nc);
+ ListFormatter(NickServ::Account *nc);
ListFormatter &AddColumn(const Anope::string &name);
void AddEntry(const ListEntry &entry);
bool IsEmpty() const;
@@ -81,14 +65,13 @@ class CoreExport ListFormatter
*/
class CoreExport InfoFormatter
{
- NickCore *nc;
+ NickServ::Account *nc;
std::vector<std::pair<Anope::string, Anope::string> > replies;
unsigned longest;
public:
- InfoFormatter(NickCore *nc);
+ InfoFormatter(NickServ::Account *nc);
void Process(std::vector<Anope::string> &);
Anope::string &operator[](const Anope::string &key);
void AddOption(const Anope::string &opt);
};
-#endif // LISTS_H
diff --git a/include/logger.h b/include/logger.h
index 349ca5a55..f3b00068b 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef LOGGER_H
-#define LOGGER_H
+#pragma once
#include "anope.h"
#include "defs.h"
@@ -53,11 +60,11 @@ class CoreExport Log
{
public:
/* Bot that should log this message */
- BotInfo *bi;
+ ServiceBot *bi;
/* For commands, the user executing the command, but might not always exist */
User *u;
/* For commands, the account executing the command, but will not always exist */
- NickCore *nc;
+ NickServ::Account *nc;
/* For commands, the command being executed */
Command *c;
/* For commands, the command source */
@@ -65,7 +72,7 @@ class CoreExport Log
/* Used for LOG_CHANNEL */
Channel *chan;
/* For commands, the channel the command was executed on, will not always exist */
- const ChannelInfo *ci;
+ ChanServ::Channel *ci;
/* For LOG_SERVER */
Server *s;
/* For LOG_MODULE */
@@ -75,23 +82,23 @@ 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 = "", ServiceBot *bi = NULL);
/* LOG_COMMAND/OVERRIDE/ADMIN */
- Log(LogType type, CommandSource &source, Command *c, ChannelInfo *ci = NULL);
+ Log(LogType type, CommandSource &source, Command *c, ChanServ::Channel *ci = NULL);
/* LOG_CHANNEL */
Log(User *u, Channel *c, const Anope::string &category = "");
/* LOG_USER */
- Log(User *u, const Anope::string &category = "", BotInfo *bi = NULL);
+ Log(User *u, const Anope::string &category = "", ServiceBot *bi = NULL);
/* LOG_SERVER */
- Log(Server *s, const Anope::string &category = "", BotInfo *bi = NULL);
+ Log(Server *s, const Anope::string &category = "", ServiceBot *bi = NULL);
- Log(BotInfo *b, const Anope::string &category = "");
+ Log(ServiceBot *b, const Anope::string &category = "");
- Log(Module *m, const Anope::string &category = "", BotInfo *bi = NULL);
+ Log(Module *m, const Anope::string &category = "", ServiceBot *bi = NULL);
~Log();
@@ -113,7 +120,7 @@ class CoreExport Log
class CoreExport LogInfo
{
public:
- BotInfo *bot;
+ ServiceBot *bot;
std::vector<Anope::string> targets;
std::vector<LogFile *> logfiles;
int last_day;
@@ -141,4 +148,3 @@ class CoreExport LogInfo
void ProcessMessage(const Log *l);
};
-#endif // LOGGER_H
diff --git a/include/mail.h b/include/mail.h
index 4b3aaa9bd..911c2011d 100644
--- a/include/mail.h
+++ b/include/mail.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAIL_H
-#define MAIL_H
+#pragma once
#include "anope.h"
#include "threadengine.h"
@@ -18,8 +25,8 @@
namespace Mail
{
- extern CoreExport bool Send(User *from, NickCore *to, BotInfo *service, const Anope::string &subject, const Anope::string &message);
- extern CoreExport bool Send(NickCore *to, const Anope::string &subject, const Anope::string &message);
+ extern CoreExport bool Send(User *from, NickServ::Account *to, ServiceBot *service, const Anope::string &subject, const Anope::string &message);
+ extern CoreExport bool Send(NickServ::Account *to, const Anope::string &subject, const Anope::string &message);
extern CoreExport bool Validate(const Anope::string &email);
/* A email message being sent */
@@ -48,9 +55,8 @@ namespace Mail
~Message();
/* Called from within the thread to actually send the mail */
- void Run() anope_override;
+ void Run() override;
};
} // namespace Mail
-#endif // MAIL_H
diff --git a/include/memo.h b/include/memo.h
deleted file mode 100644
index 5d92b6566..000000000
--- a/include/memo.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#ifndef MEMO_H
-#define MEMO_H
-
-#include "anope.h"
-#include "serialize.h"
-
-class CoreExport Memo : public Serializable
-{
- public:
- MemoInfo *mi;
- bool unread;
- bool receipt;
- Memo();
- ~Memo();
-
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-
- Anope::string owner;
- /* When it was sent */
- time_t time;
- Anope::string sender;
- Anope::string text;
-};
-
-/* Memo info structures. Since both nicknames and channels can have memos,
- * we encapsulate memo data in a MemoInfo to make it easier to handle.
- */
-struct CoreExport MemoInfo
-{
- int16_t memomax;
- 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);
- bool HasIgnore(User *u);
-
- static MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_chan);
-};
-
-#endif // MEMO_H
diff --git a/include/messages.h b/include/messages.h
index dde8a506e..9c0b7f862 100644
--- a/include/messages.h
+++ b/include/messages.h
@@ -1,12 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2004-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "protocol.h"
@@ -22,39 +30,39 @@ namespace Message
struct CoreExport Away : IRCDMessage
{
Away(Module *creator, const Anope::string &mname = "AWAY") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Capab : IRCDMessage
{
Capab(Module *creator, const Anope::string &mname = "CAPAB") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Error : IRCDMessage
{
Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
struct CoreExport Invite : IRCDMessage
{
Invite(Module *creator, const Anope::string &mname = "INVITE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Join : IRCDMessage
{
Join(Module *creator, const Anope::string &mname = "JOIN") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
-
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+
typedef std::pair<ChannelStatus, User *> SJoinUser;
-
+
/** Handle a SJOIN.
* @param source The source of the SJOIN
* @param chan The channel the users are joining to
@@ -64,110 +72,110 @@ namespace Message
*/
static void SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list<SJoinUser> &users);
};
-
+
struct CoreExport Kick : IRCDMessage
{
Kick(Module *creator, const Anope::string &mname = "KICK") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Kill : IRCDMessage
{
Kill(Module *creator, const Anope::string &mname = "KILL") : IRCDMessage(creator, mname, 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
struct CoreExport Mode : IRCDMessage
{
Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport MOTD : IRCDMessage
{
MOTD(Module *creator, const Anope::string &mname = "MOTD") : IRCDMessage(creator, mname, 1) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Notice : IRCDMessage
{
Notice(Module *creator, const Anope::string &mname = "NOTICE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
struct CoreExport Part : IRCDMessage
{
Part(Module *creator, const Anope::string &mname = "PART") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Ping : IRCDMessage
{
Ping(Module *creator, const Anope::string &mname = "PING") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Privmsg : IRCDMessage
{
Privmsg(Module *creator, const Anope::string &mname = "PRIVMSG") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Quit : IRCDMessage
{
Quit(Module *creator, const Anope::string &mname = "QUIT") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport SQuit : IRCDMessage
{
SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Stats : IRCDMessage
{
Stats(Module *creator, const Anope::string &mname = "STATS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Time : IRCDMessage
{
Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Topic : IRCDMessage
{
Topic(Module *creator, const Anope::string &mname = "TOPIC") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Version : IRCDMessage
{
Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
-
+
struct CoreExport Whois : IRCDMessage
{
Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override;
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
} // namespace Message
diff --git a/include/modes.h b/include/modes.h
index 03f6f8a58..706b0b716 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -1,13 +1,24 @@
-/* Mode support
+/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Adam <Adam@anope.org>
- * (C) 2008-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Adam <Adam@anope.org>
+ * Copyright (C) 2009-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef MODES_H
-#define MODES_H
+#pragma once
#include "anope.h"
#include "base.h"
@@ -48,6 +59,9 @@ class CoreExport Mode : public Base
/* Type of mode this is, eg MODE_LIST */
ModeType type;
+ bool setable = true;
+ bool oper_only = false;
+
/** constructor
* @param mname The mode name
* @param mclass The type of mode this is
@@ -57,6 +71,9 @@ class CoreExport Mode : public Base
Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type);
virtual ~Mode();
+ void SetSetable(bool b) { setable = b; }
+ void SetOperOnly(bool b) { oper_only = b; }
+
/** Can a user set this mode, used for mlock
* @param u The user
*/
@@ -105,7 +122,7 @@ class CoreExport ChannelMode : public Mode
*/
ChannelMode(const Anope::string &name, char mc);
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
virtual void Check() { }
@@ -146,18 +163,6 @@ class CoreExport ChannelModeList : public ChannelMode
* @return true on match
*/
virtual bool Matches(User *u, const Entry *e) { return false; }
-
- /** Called when a mask is added to a channel
- * @param chan The channel
- * @param mask The mask
- */
- virtual void OnAdd(Channel *chan, const Anope::string &mask) { }
-
- /** Called when a mask is removed from a channel
- * @param chan The channel
- * @param mask The mask
- */
- virtual void OnDel(Channel *chan, const Anope::string &mask) { }
};
/** This is a mode with a paramater, eg +k/l. These modes should use/inherit from this
@@ -175,11 +180,13 @@ class CoreExport ChannelModeParam : public ChannelMode
/* Should we send an arg when unsetting this mode? */
bool minus_no_arg;
+ std::regex param_validation;
+
/** Is the param valid
* @param value The param
* @return true for yes, false for no
*/
- virtual bool IsValid(Anope::string &value) const { return true; }
+ virtual bool IsValid(Anope::string &value) const;
};
/** This is a mode that is a channel status, eg +v/h/o/a/q.
@@ -197,7 +204,7 @@ class CoreExport ChannelModeStatus : public ChannelMode
/** constructor
* @param name The mode name
* @param mc The mode char
- * @param msymbol The symbol for the mode, eg @ %
+ * @param msymbol The symbol for the mode, eg @ %
* @param mlevel A level for the mode, which is usually determined by the PREFIX capab
*/
ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel);
@@ -217,11 +224,11 @@ class CoreExport ChannelModeVirtual : public T
~ChannelModeVirtual();
- void Check() anope_override;
+ void Check() override;
- ChannelMode *Wrap(Anope::string &param) anope_override;
+ ChannelMode *Wrap(Anope::string &param) override;
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) = 0;
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override anope_abstract;
};
/* The status a user has on a channel (+v, +h, +o) etc */
@@ -240,53 +247,6 @@ class CoreExport ChannelStatus
Anope::string BuildModePrefixList() const;
};
-class CoreExport UserModeOperOnly : public UserMode
-{
- public:
- UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
-class CoreExport UserModeNoone : public UserMode
-{
- public:
- UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
-/** Channel mode +k (key)
- */
-class CoreExport ChannelModeKey : public ChannelModeParam
-{
- public:
- ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { }
-
- bool IsValid(Anope::string &value) const anope_override;
-};
-
-/** This class is used for oper only channel modes
- */
-class CoreExport ChannelModeOperOnly : public ChannelMode
-{
- public:
- ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
-
- /* Opers only */
- bool CanSet(User *u) const anope_override;
-};
-
-/** This class is used for channel modes only servers may set
- */
-class CoreExport ChannelModeNoone : public ChannelMode
-{
- public:
- ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
/** This is the mode manager
* It contains functions for adding modes to Anope so Anope can track them
* and do things such as MLOCK.
@@ -296,11 +256,6 @@ class CoreExport ChannelModeNoone : public ChannelMode
class CoreExport ModeManager
{
public:
-
- /* Number of generic channel and user modes we are tracking */
- static unsigned GenericChannelModes;
- static unsigned GenericUserModes;
-
/** Add a user mode to Anope
* @param um A UserMode or UserMode derived class
* @return true on success, false on error
@@ -365,7 +320,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(User *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
@@ -374,7 +329,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(User *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
*/
@@ -385,6 +340,8 @@ class CoreExport ModeManager
static void StackerDel(User *u);
static void StackerDel(Channel *c);
static void StackerDel(Mode *m);
+
+ static void Apply(Configuration::Conf *old);
};
/** Represents a mask set on a channel (b/e/I)
@@ -395,7 +352,7 @@ class CoreExport Entry
Anope::string mask;
public:
unsigned short cidr_len;
- int family;
+ int family = 0;
Anope::string nick, user, host, real;
/** Constructor
@@ -418,5 +375,3 @@ class CoreExport Entry
*/
bool Matches(User *u, bool full = false) const;
};
-
-#endif // MODES_H
diff --git a/include/module.h b/include/module.h
index c8abe21f4..e761dd822 100644
--- a/include/module.h
+++ b/include/module.h
@@ -1,39 +1,42 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2005-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef MODULE_H
-#define MODULE_H
+#pragma once
-#include "access.h"
-#include "account.h"
#include "anope.h"
#include "base.h"
#include "bots.h"
#include "channels.h"
#include "commands.h"
#include "config.h"
+#include "event.h"
#include "extensible.h"
#include "hashcomp.h"
#include "language.h"
#include "lists.h"
#include "logger.h"
#include "mail.h"
-#include "memo.h"
#include "messages.h"
#include "modes.h"
#include "modules.h"
#include "opertype.h"
#include "protocol.h"
-#include "regexpr.h"
-#include "regchannel.h"
#include "serialize.h"
#include "servers.h"
#include "service.h"
@@ -46,9 +49,8 @@
#include "users.h"
#include "xline.h"
-#include "modules/pseudoclients/chanserv.h"
-#include "modules/pseudoclients/global.h"
-#include "modules/pseudoclients/memoserv.h"
-#include "modules/pseudoclients/nickserv.h"
-
-#endif // MODULE_H
+#include "modules/chanserv.h"
+#include "modules/nickserv.h"
+#include "modules/botserv.h"
+#include "modules/memoserv.h"
+#include "accessgroup.h"
diff --git a/include/modules.h b/include/modules.h
index 52fc4c676..ff9303c4f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1,19 +1,25 @@
-/* Modular support
+/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#include "serialize.h"
-
-#ifndef MODULES_H
-#define MODULES_H
+#pragma once
+#include "serialize.h"
#include "base.h"
#include "modes.h"
#include "timers.h"
@@ -21,133 +27,81 @@
#include "extensible.h"
#include "version.h"
+class ModuleDef;
+struct ModuleVersionC;
+
+enum
+{
+ ANOPE_MODAPI_VER = 1
+};
+
+struct AnopeModule
+{
+ unsigned int api_version;
+ ModuleDef* (*init)();
+ void (*fini)(ModuleDef *);
+ ModuleVersionC (*version)();
+};
+
+class ModuleDef
+{
+ std::vector<Anope::string> dependencies;
+
+ public:
+ virtual ~ModuleDef() = default;
+ virtual Module *Create(const Anope::string &modname, const Anope::string &creator) anope_abstract;
+ virtual void Destroy(Module *) anope_abstract;
+ virtual void BuildModuleInfo() anope_abstract;
+
+ void Depends(const Anope::string &modname);
+ const std::vector<Anope::string> &GetDependencies();
+};
+
+template<class ModuleClass> void ModuleInfo(ModuleDef *moddef) { }
+
/** This definition is used as shorthand for the various classes
* and functions needed to make a module loadable by the OS.
- * It defines the class factory and external AnopeInit and AnopeFini functions.
*/
-#ifdef _WIN32
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
- extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
+#define MODULE_INIT(ModuleClass) \
+ class ModuleClass ## ModuleDef : public ModuleDef \
{ \
- return new x(modname, creator); \
- } \
- BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
+ Module *Create(const Anope::string &modname, const Anope::string &creator) override \
+ { \
+ return new ModuleClass(modname, creator); \
+ } \
+ void Destroy(Module *module) override \
+ { \
+ delete module; \
+ } \
+ void BuildModuleInfo() override \
+ { \
+ ModuleInfo<ModuleClass>(this); \
+ } \
+ }; \
+ static ModuleDef *CreateModuleDef() \
{ \
- return TRUE; \
+ return new ModuleClass ## ModuleDef(); \
} \
- extern "C" DllExport void AnopeFini(x *); \
- extern "C" void AnopeFini(x *m) \
+ static void DeleteModuleDef(ModuleDef *def) \
{ \
- delete m; \
+ delete def; \
} \
- extern "C" DllExport ModuleVersionC AnopeVersion() \
+ static ModuleVersionC AnopeModuleVersion() \
{ \
ModuleVersionC ver; \
ver.version_major = VERSION_MAJOR; \
ver.version_minor = VERSION_MINOR; \
ver.version_patch = VERSION_PATCH; \
return ver; \
- }
-#else
-# define MODULE_INIT(x) \
- extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
- { \
- return new x(modname, creator); \
- } \
- extern "C" DllExport void AnopeFini(x *m) \
- { \
- delete m; \
} \
- extern "C" DllExport ModuleVersionC AnopeVersion() \
+ extern "C" DllExport struct AnopeModule AnopeMod; \
+ struct AnopeModule AnopeMod = \
{ \
- ModuleVersionC ver; \
- ver.version_major = VERSION_MAJOR; \
- ver.version_minor = VERSION_MINOR; \
- ver.version_patch = VERSION_PATCH; \
- return ver; \
- }
-#endif
-
-/**
- * This #define allows us to call a method in all
- * loaded modules in a readable simple way, e.g.:
- *
- * FOREACH_MOD(OnUserConnect, (user, exempt));
- */
-#define FOREACH_MOD(ename, args) \
-if (true) \
-{ \
- std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
- for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
- { \
- try \
- { \
- (*_i)->ename args; \
- } \
- catch (const ModuleException &modexcept) \
- { \
- Log() << "Exception caught: " << modexcept.GetReason(); \
- } \
- catch (const NotImplementedException &) \
- { \
- _i = _modules.erase(_i); \
- continue; \
- } \
- ++_i; \
- } \
-} \
-else \
- static_cast<void>(0)
-
-/**
- * This define is similar to the one above but returns a result.
- * The first module to return a result other than EVENT_CONTINUE is the value to be accepted,
- * and any modules after are ignored. This is used like:
- *
- * EventReturn MOD_RESULT;
- * FOREACH_RESULT(OnUserConnect, MOD_RESULT, (user, exempt));
- */
-#define FOREACH_RESULT(ename, ret, args) \
-if (true) \
-{ \
- ret = EVENT_CONTINUE; \
- std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
- for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
- { \
- try \
- { \
- EventReturn res = (*_i)->ename args; \
- if (res != EVENT_CONTINUE) \
- { \
- ret = res; \
- break; \
- } \
- } \
- catch (const ModuleException &modexcept) \
- { \
- Log() << "Exception caught: " << modexcept.GetReason(); \
- } \
- catch (const NotImplementedException &) \
- { \
- _i = _modules.erase(_i); \
- continue; \
- } \
- ++_i; \
- } \
-} \
-else \
- static_cast<void>(0)
-
-
-/** Possible return types from events.
- */
-enum EventReturn
-{
- EVENT_STOP,
- EVENT_CONTINUE,
- EVENT_ALLOW
-};
+ ANOPE_MODAPI_VER, \
+ CreateModuleDef, \
+ DeleteModuleDef, \
+ AnopeModuleVersion \
+ };
enum ModuleReturn
{
@@ -162,9 +116,6 @@ enum ModuleReturn
MOD_ERR_VERSION
};
-/** Priority types which can be returned from Module::Prioritize()
- */
-enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
/* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */
enum
{
@@ -223,8 +174,6 @@ class ModuleVersion
int GetPatch() const;
};
-class NotImplementedException : public CoreException { };
-
/** Every module in Anope is actually a class.
*/
class CoreExport Module : public Extensible
@@ -248,6 +197,9 @@ class CoreExport Module : public Extensible
*/
void *handle;
+ ModuleDef *def = nullptr;
+ AnopeModule *module = nullptr;
+
/** Time this module was created
*/
time_t created;
@@ -295,832 +247,13 @@ class CoreExport Module : public Extensible
*/
void SetAuthor(const Anope::string &author);
- virtual void Prioritize();
-
- /* Everything below here are events. Modules must ModuleManager::Attach to these events
- * before they will be called.
- */
-
- /** Called before a user has been kicked from a channel.
- * @param source The kicker
- * @param cu The user, channel, and status of the user being kicked
- * @param kickmsg The reason for the kick.
- */
- virtual void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); }
-
- /** Called when a user has been kicked from a channel.
- * @param source The kicker
- * @param target The user being kicked
- * @param channel The channel the user was kicked from, which may no longer exist
- * @param status The status the kicked user had on the channel before they were kicked
- * @param kickmsg The reason for the kick.
- */
- virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); }
-
- /** Called when Services' configuration is being (re)loaded.
- * @param conf The config that is being built now and will replace the global Config object
- * @throws A ConfigException to abort the config (re)loading process.
- */
- virtual void OnReload(Configuration::Conf *conf) { throw NotImplementedException(); }
-
- /** Called before a bot is assigned to a channel.
- * @param sender The user assigning the bot
- * @param ci The channel the bot is to be assigned to.
- * @param bi The bot being assigned.
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign.
- */
- virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called when a bot is assigned ot a channel
- */
- virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called before a bot is unassigned from a channel.
- * @param sender The user unassigning the bot
- * @param ci The channel the bot is being removed from
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign.
- */
- virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a new user connects to the network.
- * @param u The connecting user.
- * @param exempt set to true/is true if the user should be excepted from bans etc
- */
- virtual void OnUserConnect(User *u, bool &exempt) { throw NotImplementedException(); }
-
- /** Called when a new server connects to the network.
- * @param s The server that has connected to the network
- */
- virtual void OnNewServer(Server *s) { throw NotImplementedException(); }
-
- /** Called after a user changed the nick
- * @param u The user.
- * @param oldnick The old nick of the user
- */
- virtual void OnUserNickChange(User *u, const Anope::string &oldnick) { throw NotImplementedException(); }
-
- /** Called when someone uses the generic/help command
- * @param source Command source
- * @param params Params
- * @return EVENT_STOP to stop processing
- */
- virtual EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called when someone uses the generic/help command
- * @param source Command source
- * @param params Params
- */
- virtual void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called before a command is due to be executed.
- * @param source The source of the command
- * @param command The command the user is executing
- * @param params The parameters the user is sending
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
- */
- virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called after a command has been executed.
- * @param source The source of the command
- * @param command The command the user executed
- * @param params The parameters the user sent
- */
- virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called when the databases are saved
- */
- virtual void OnSaveDatabase() { throw NotImplementedException(); }
-
- /** Called when the databases are loaded
- * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop
- */
- virtual EventReturn OnLoadDatabase() { throw NotImplementedException(); }
-
- /** Called when anope needs to check passwords against encryption
- * see src/encrypt.c for detailed informations
- */
- virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
- virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
-
- /** Called on fantasy command
- * @param source The source of the command
- * @param c The command
- * @param ci The channel it's being used in
- * @param params The params
- * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
- */
- virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called on fantasy command without access
- * @param source The source of the command
- * @param c The command
- * @param ci The channel it's being used in
- * @param params The params
- * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
- */
- virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> &params) { throw NotImplementedException(); }
-
- /** Called when a bot places a ban
- * @param u User being banned
- * @param ci Channel the ban is placed on
- * @param mask The mask being banned
- */
- virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) { throw NotImplementedException(); }
-
- /** Called before a badword is added to the badword list
- * @param ci The channel
- * @param bw The badword
- */
- virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); }
-
- /** Called before a badword is deleted from a channel
- * @param ci The channel
- * @param bw The badword
- */
- virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); }
-
- /** Called when a bot is created or destroyed
- */
- virtual void OnCreateBot(BotInfo *bi) { throw NotImplementedException(); }
- virtual void OnDelBot(BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called before a bot kicks a user
- * @param bi The bot sending the kick
- * @param c The channel the user is being kicked on
- * @param u The user being kicked
- * @param reason The reason
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
- */
- virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) { throw NotImplementedException(); }
-
- /** Called before a user parts a channel
- * @param u The user
- * @param c The channel
- */
- virtual void OnPrePartChannel(User *u, Channel *c) {}
-
- /** Called when a user parts a channel
- * @param u The user
- * @param c The channel, may be NULL if the channel no longer exists
- * @param channel The channel name
- * @param msg The part reason
- */
- virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) { throw NotImplementedException(); }
-
- /** Called when a user leaves a channel.
- * From either parting, being kicked, or quitting/killed!
- * @param u The user
- * @param c The channel
- */
- virtual void OnLeaveChannel(User *u, Channel *c) { throw NotImplementedException(); }
-
- /** Called after a user joins a channel
- * If this event triggers the user is allowed to be in the channel, and will
- * not be kicked for restricted/akick/forbidden, etc. If you want to kick the user,
- * use the CheckKick event instead.
- * @param u The user
- * @param channel The channel
- */
- virtual void OnJoinChannel(User *u, Channel *c) { throw NotImplementedException(); }
-
- /** Called when a new topic is set
- * @param source The user changing the topic, if any
- * @param c The channel
- * @param setter The user who set the new topic, if there is no source
- * @param topic The new topic
- */
- virtual void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); }
-
- /** Called before a channel expires
- * @param ci The channel
- * @param expire Set to true to allow the chan to expire
- */
- virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) { throw NotImplementedException(); }
-
- /** Called before a channel expires
- * @param ci The channel
- */
- virtual void OnChanExpire(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called before Anope connecs to its uplink
- */
- virtual void OnPreServerConnect() { throw NotImplementedException(); }
-
- /** Called when Anope connects to its uplink
- */
- virtual void OnServerConnect() { throw NotImplementedException(); }
-
- /** Called when we are almost done synching with the uplink, just before we send the EOB
- */
- virtual void OnPreUplinkSync(Server *serv) { throw NotImplementedException(); }
-
- /** Called when Anope disconnects from its uplink, before it tries to reconnect
- */
- virtual void OnServerDisconnect() { throw NotImplementedException(); }
-
- /** Called when services restart
- */
- virtual void OnRestart() { throw NotImplementedException(); }
-
- /** Called when services shutdown
- */
- virtual void OnShutdown() { throw NotImplementedException(); }
-
- /** Called before a nick expires
- * @param na The nick
- * @param expire Set to true to allow the nick to expire
- */
- virtual void OnPreNickExpire(NickAlias *na, bool &expire) { throw NotImplementedException(); }
-
- /** Called when a nick drops
- * @param na The nick
- */
- virtual void OnNickExpire(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when defcon level changes
- * @param level The level
- */
- virtual void OnDefconLevel(int level) { throw NotImplementedException(); }
-
- /** Called after an exception has been added
- * @param ex The exception
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
- */
- virtual EventReturn OnExceptionAdd(Exception *ex) { throw NotImplementedException(); }
-
- /** Called before an exception is deleted
- * @param source The source deleting it
- * @param ex The exceotion
- */
- virtual void OnExceptionDel(CommandSource &source, Exception *ex) { throw NotImplementedException(); }
-
- /** Called before a XLine is added
- * @param source The source of the XLine
- * @param x The XLine
- * @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(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); }
-
- /** Called before a XLine is deleted
- * @param source The source of the XLine
- * @param x The XLine
- * @param xlm The xline manager it was deleted from
- */
- virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); }
-
- /** Called when a user is checked for whether they are a services oper
- * @param u The user
- * @return EVENT_ALLOW to allow, anything else to deny
- */
- virtual EventReturn IsServicesOper(User *u) { throw NotImplementedException(); }
-
- /** Called when a server quits
- * @param server The server
- */
- virtual void OnServerQuit(Server *server) { throw NotImplementedException(); }
-
- /** Called when a user quits, or is killed
- * @param u The user
- * @param msg The quit message
- */
- virtual void OnUserQuit(User *u, const Anope::string &msg) { throw NotImplementedException(); }
-
- /** Called when a user is quit, before and after being internally removed from
- * This is different from OnUserQuit, which takes place at the time of the quit.
- * This happens shortly after when all message processing is finished.
- * all lists (channels, user list, etc)
- * @param u The user
- */
- virtual void OnPreUserLogoff(User *u) { throw NotImplementedException(); }
- virtual void OnPostUserLogoff(User *u) { throw NotImplementedException(); }
-
- /** Called when a new bot is made
- * @param bi The bot
- */
- virtual void OnBotCreate(BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called when a bot is changed
- * @param bi The bot
- */
- virtual void OnBotChange(BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called when a bot is deleted
- * @param bi The bot
- */
- virtual void OnBotDelete(BotInfo *bi) { throw NotImplementedException(); }
-
- /** Called after an access entry is deleted from a channel
- * @param ci The channel
- * @param source The source of the command
- * @param access The access entry that was removed
- */
- virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); }
-
- /** Called when access is added
- * @param ci The channel
- * @param source The source of the command
- * @param access The access changed
- */
- virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); }
-
- /** Called when the access list is cleared
- * @param ci The channel
- * @param u The user who cleared the access
- */
- virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { throw NotImplementedException(); }
-
- /** Called when a level for a channel is changed
- * @param source The source of the command
- * @param ci The channel the level was changed on
- * @param priv The privilege changed
- * @param what The new level
- */
- virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { throw NotImplementedException(); }
-
- /** Called right before a channel is dropped
- * @param source The user dropping the channel
- * @param ci The channel
- */
- virtual EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a channel is registered
- * @param ci The channel
- */
- virtual void OnChanRegistered(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a channel is suspended
- * @param ci The channel
- */
- virtual void OnChanSuspend(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a channel is unsuspended
- * @param ci The channel
- */
- virtual void OnChanUnsuspend(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a channel is being created, for any reason
- * @param ci The channel
- */
- virtual void OnCreateChan(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a channel is being deleted, for any reason
- * @param ci The channel
- */
- virtual void OnDelChan(ChannelInfo *ci) { throw NotImplementedException(); }
-
- /** Called when a new channel is created
- * Note that this channel may not be introduced to the uplink at this point.
- * @param c The channel
- */
- virtual void OnChannelCreate(Channel *c) { throw NotImplementedException(); }
-
- /** Called when a channel is deleted
- * @param c The channel
- */
- virtual void OnChannelDelete(Channel *c) { throw NotImplementedException(); }
-
- /** Called after adding an akick to a channel
- * @param source The source of the command
- * @param ci The channel
- * @param ak The akick
- */
- virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); }
-
- /** Called before removing an akick from a channel
- * @param source The source of the command
- * @param ci The channel
- * @param ak The akick
- */
- virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); }
-
- /** Called after a user join a channel when we decide whether to kick them or not
- * @param u The user
- * @param c The channel
- * @param kick Set to true to kick
- * @param mask The mask to ban, if any
- * @param reason The reason for the kick
- * @return EVENT_STOP to prevent the user from joining by kicking/banning the user
- */
- virtual EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) { throw NotImplementedException(); }
-
- /** Called when a user requests info for a channel
- * @param source The user requesting info
- * @param ci The channel the user is requesting info for
- * @param info Data to show the user requesting information
- * @param show_hidden true if we should show the user everything
- */
- virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); }
-
- /** Checks if access has the channel privilege 'priv'.
- * @param access THe access struct
- * @param priv The privilege being checked for
- * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing
- */
- virtual EventReturn OnCheckPriv(const ChanAccess *access, const Anope::string &priv) { throw NotImplementedException(); }
-
- /** Check whether an access group has a privilege
- * @param group The group
- * @param priv The privilege
- * @return MOD_ALLOW to allow, MOD_STOP to stop
- */
- virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { throw NotImplementedException(); }
-
- /** Called when a nick is dropped
- * @param source The source of the command
- * @param na The nick
- */
- virtual void OnNickDrop(CommandSource &source, NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when a user groups their nick
- * @param u The user grouping
- * @param target The target they're grouping to
- */
- virtual void OnNickGroup(User *u, NickAlias *target) { throw NotImplementedException(); }
-
- /** Called when a user identifies to a nick
- * @param u The user
- */
- virtual void OnNickIdentify(User *u) { throw NotImplementedException(); }
-
- /** Called when a user is logged into an account
- * @param u The user
- */
- virtual void OnUserLogin(User *u) { throw NotImplementedException(); }
-
- /** Called when a nick logs out
- * @param u The nick
- */
- virtual void OnNickLogout(User *u) { throw NotImplementedException(); }
-
- /** Called when a nick is registered
- * @param user The user registering the nick, of any
- * @param The nick
- * @param pass The password of the newly registered nick
- */
- virtual void OnNickRegister(User *user, NickAlias *na, const Anope::string &pass) { throw NotImplementedException(); }
-
- /** Called when a nick is confirmed. This will never be called if registration confirmation is not enabled.
- * @param user The user confirming the nick
- * @param The account being confirmed
- */
- virtual void OnNickConfirm(User *user, NickCore *) { throw NotImplementedException(); }
-
- /** Called when a nick is suspended
- * @param na The nick alias
- */
- virtual void OnNickSuspend(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when a nick is unsuspneded
- * @param na The nick alias
- */
- virtual void OnNickUnsuspended(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called on delnick()
- * @ param na pointer to the nickalias
- */
- virtual void OnDelNick(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when a nickcore is created
- * @param nc The nickcore
- */
- virtual void OnNickCoreCreate(NickCore *nc) { throw NotImplementedException(); }
-
- /** Called on delcore()
- * @param nc pointer to the NickCore
- */
- virtual void OnDelCore(NickCore *nc) { throw NotImplementedException(); }
-
- /** Called on change_core_display()
- * @param nc pointer to the NickCore
- * @param newdisplay the new display
- */
- virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) { throw NotImplementedException(); }
-
- /** called from NickCore::ClearAccess()
- * @param nc pointer to the NickCore
- */
- virtual void OnNickClearAccess(NickCore *nc) { throw NotImplementedException(); }
-
- /** Called when a user adds an entry to their access list
- * @param nc The nick
- * @param entry The entry
- */
- virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
-
- /** Called from NickCore::EraseAccess()
- * @param nc pointer to the NickCore
- * @param entry The access mask
- */
- virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
-
- /** called from NickCore::ClearCert()
- * @param nc pointer to the NickCore
- */
- virtual void OnNickClearCert(NickCore *nc) { throw NotImplementedException(); }
-
- /** Called when a user adds an entry to their cert list
- * @param nc The nick
- * @param entry The entry
- */
- virtual void OnNickAddCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
-
- /** Called from NickCore::EraseCert()
- * @param nc pointer to the NickCore
- * @param entry The fingerprint
- */
- virtual void OnNickEraseCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
-
- /** Called when a user requests info for a nick
- * @param source The user requesting info
- * @param na The nick the user is requesting info from
- * @param info Data to show the user requesting information
- * @param show_hidden true if we should show the user everything
- */
- virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); }
-
- /** Called when a user uses botserv/info on a bot or channel.
- */
- virtual void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) { throw NotImplementedException(); }
-
- /** Check whether a username and password is correct
- * @param u The user trying to identify, if applicable.
- * @param req The login request
- */
- virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) { throw NotImplementedException(); }
-
- /** Called when a user does /ns update
- * @param u The user
- */
- virtual void OnNickUpdate(User *u) { throw NotImplementedException(); }
-
- /** Called when we get informed about a users SSL fingerprint
- * when we call this, the fingerprint should already be stored in the user struct
- * @param u pointer to the user
- */
- virtual void OnFingerprint(User *u) { throw NotImplementedException(); }
-
- /** Called when a user becomes (un)away
- * @param message The message, is .empty() if unaway
- */
- virtual void OnUserAway(User *u, const Anope::string &message) { throw NotImplementedException(); }
-
- /** Called when a user invites one of our users to a channel
- * @param source The user doing the inviting
- * @param c The channel the user is inviting to
- * @param targ The user being invited
- */
- virtual void OnInvite(User *source, Channel *c, User *targ) { throw NotImplementedException(); }
-
- /** Called when a vhost is deleted
- * @param na The nickalias of the vhost
- */
- virtual void OnDeleteVhost(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when a vhost is set
- * @param na The nickalias of the vhost
- */
- virtual void OnSetVhost(NickAlias *na) { throw NotImplementedException(); }
-
- /** Called when a users host changes
- * @param u The user
- */
- virtual void OnSetDisplayedHost(User *) { throw NotImplementedException(); }
-
- /** Called when a memo is sent
- * @param source The source of the memo
- * @param target The target of the memo
- * @param mi Memo info for target
- * @param m The memo
- */
- virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { throw NotImplementedException(); }
-
- /** Called when a memo is deleted
- * @param target The target the memo is being deleted from (nick or channel)
- * @param mi The memo info
- * @param m The memo
- */
- virtual void OnMemoDel(const Anope::string &target, MemoInfo *mi, const Memo *m) { throw NotImplementedException(); }
-
- /** Called when a mode is set on a channel
- * @param c The channel
- * @param setter The user or server that is setting the mode
- * @param mode The mode
- * @param param The mode param, if there is one
- * @return EVENT_STOP to make mlock/secureops etc checks not happen
- */
- virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) { throw NotImplementedException(); }
-
- /** Called when a mode is unset on a channel
- * @param c The channel
- * @param setter The user or server that is unsetting the mode
- * @param mode The mode
- * @param param The mode param, if there is one
- * @return EVENT_STOP to make mlock/secureops etc checks not happen
- */
- virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string &param) { throw NotImplementedException(); }
-
- /** Called when a mode is set on a user
- * @param setter who/what is setting the mode
- * @param u The user
- * @param mname The mode name
- */
- virtual void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); }
-
- /** Called when a mode is unset from a user
- * @param setter who/what is setting the mode
- * @param u The user
- * @param mname The mode name
- */
- virtual void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); }
-
- /** Called when a channel mode is introducted into Anope
- * @param cm The mode
- */
- virtual void OnChannelModeAdd(ChannelMode *cm) { throw NotImplementedException(); }
-
- /** Called when a user mode is introducted into Anope
- * @param um The mode
- */
- virtual void OnUserModeAdd(UserMode *um) { throw NotImplementedException(); }
-
- /** Called when a mode is about to be mlocked
- * @param ci The channel the mode is being locked on
- * @param lock The mode lock
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
- */
- virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); }
-
- /** Called when a mode is about to be unlocked
- * @param ci The channel the mode is being unlocked from
- * @param lock The mode lock
- * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
- */
- virtual EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); }
-
- /** Called after a module is loaded
- * @param u The user loading the module, can be NULL
- * @param m The module
- */
- virtual void OnModuleLoad(User *u, Module *m) { throw NotImplementedException(); }
-
- /** Called before a module is unloaded
- * @param u The user, can be NULL
- * @param m The module
- */
- virtual void OnModuleUnload(User *u, Module *m) { throw NotImplementedException(); }
-
- /** Called when a server is synced
- * @param s The server, can be our uplink server
- */
- virtual void OnServerSync(Server *s) { throw NotImplementedException(); }
-
- /** Called when we sync with our uplink
- * @param s Our uplink
- */
- virtual void OnUplinkSync(Server *s) { throw NotImplementedException(); }
-
- /** Called when we receive a PRIVMSG for one of our clients
- * @param u The user sending the PRIVMSG
- * @param bi The target of the PRIVMSG
- * @param message The message
- * @return EVENT_STOP to halt processing
- */
- virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); }
-
- /** Called when we receive a NOTICE for one of our clients
- * @param u The user sending the NOTICE
- * @param bi The target of the NOTICE
- * @param message The message
- */
- virtual void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); }
-
- /** Called when we receive a PRIVMSG for a registered channel we are in
- * @param u The source of the message
- * @param c The channel
- * @param msg The message
- */
- virtual void OnPrivmsg(User *u, Channel *c, Anope::string &msg) { throw NotImplementedException(); }
-
- /** Called when a message is logged
- * @param l The log message
- */
- virtual void OnLog(Log *l) { throw NotImplementedException(); }
-
- /** Called when a log message is actually logged to a given log info
- * The message has already passed validation checks by the LogInfo
- * @param li The loginfo whee the message is being logged
- * @param l The log message
- * @param msg The final formatted message, derived from 'l'
- */
- virtual void OnLogMessage(LogInfo *li, const Log *l, const Anope::string &msg) { throw NotImplementedException(); }
-
- /** Called when a DNS request (question) is received.
- * @param req The dns request
- * @param reply The reply that will be sent
- */
- virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) { throw NotImplementedException(); }
-
- /** Called when a channels modes are being checked to see if they are allowed,
- * mostly to ensure mlock/+r are set.
- * @param c The channel
- */
- virtual void OnCheckModes(Reference<Channel> &c) { throw NotImplementedException(); }
-
- /** Called when a channel is synced.
- * Channels are synced after a sjoin is finished processing
- * for a newly created channel to set the correct modes, topic,
- * set.
- */
- virtual void OnChannelSync(Channel *c) { throw NotImplementedException(); }
-
- /** Called to set the correct modes on the user on the given channel
- * @param user The user
- * @param chan The channel
- * @param access The user's access on the channel
- * @param give_modes If giving modes is desired
- * @param take_modes If taking modes is desired
- */
- virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) { throw NotImplementedException(); }
-
- virtual void OnSerializeCheck(Serialize::Type *) { throw NotImplementedException(); }
- virtual void OnSerializableConstruct(Serializable *) { throw NotImplementedException(); }
- virtual void OnSerializableDestruct(Serializable *) { throw NotImplementedException(); }
- virtual void OnSerializableUpdate(Serializable *) { throw NotImplementedException(); }
- virtual void OnSerializeTypeCreate(Serialize::Type *) { throw NotImplementedException(); }
-
- /** Called when a chanserv/set command is used
- * @param source The source of the command
- * @param cmd The command
- * @param ci The channel the command was used on
- * @param setting The setting passed to the command. Probably ON/OFF.
- * @return EVENT_ALLOW to bypass access checks, EVENT_STOP to halt immediately.
- */
- virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) { throw NotImplementedException(); }
-
- /** Called when a nickserv/set command is used.
- * @param source The source of the command
- * @param cmd The command
- * @param nc The nickcore being modifed
- * @param setting The setting passed to the command. Probably ON/OFF.
- * @return EVENT_STOP to halt immediately
- */
- virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickCore *nc, const Anope::string &setting) { throw NotImplementedException(); }
-
- /** Called whenever a message is received from the uplink
- * @param source The source of the message
- * @param command The command being executed
- * @param params Parameters
- * @return EVENT_STOP to prevent the protocol module from processing this message
- */
- virtual EventReturn OnMessage(MessageSource &source, Anope::string &command, std::vector<Anope::string> &param) { throw NotImplementedException(); }
-
- /** Called to determine if a chnanel mode can be set by a user
- * @param u The user
- * @param cm The mode
- */
- virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) { throw NotImplementedException(); }
-
- virtual EventReturn OnCheckDelete(Channel *) { throw NotImplementedException(); }
-
- /** Called every options:expiretimeout seconds. Should be used to expire nicks,
- * channels, etc.
- */
- virtual void OnExpireTick() { throw NotImplementedException(); }
-
- /** Called when a nick is validated. That is, to determine if a user is permissted
- * to be on the given nick.
- * @param u The user
- * @param na The nick they are on
- * @return EVENT_STOP to force the user off of the nick
+ /** Get the version of Anope this module was
+ * compiled against
+ * @return The version
*/
- virtual EventReturn OnNickValidate(User *u, NickAlias *na) { throw NotImplementedException(); }
-};
+ ModuleVersion GetVersion() const;
-enum Implementation
-{
- I_OnPreUserKicked, I_OnUserKicked, I_OnReload, I_OnPreBotAssign, I_OnBotAssign, I_OnBotUnAssign, I_OnUserConnect,
- I_OnNewServer, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnPreCommand, I_OnPostCommand, I_OnSaveDatabase,
- I_OnLoadDatabase, I_OnEncrypt, I_OnDecrypt, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd,
- I_OnBadWordDel, I_OnCreateBot, I_OnDelBot, I_OnBotKick, I_OnPrePartChannel, I_OnPartChannel, I_OnLeaveChannel,
- I_OnJoinChannel, I_OnTopicUpdated, I_OnPreChanExpire, I_OnChanExpire, I_OnPreServerConnect, I_OnServerConnect,
- I_OnPreUplinkSync, I_OnServerDisconnect, I_OnRestart, I_OnShutdown, I_OnPreNickExpire, I_OnNickExpire, I_OnDefconLevel,
- I_OnExceptionAdd, I_OnExceptionDel, I_OnAddXLine, I_OnDelXLine, I_IsServicesOper, I_OnServerQuit, I_OnUserQuit,
- I_OnPreUserLogoff, I_OnPostUserLogoff, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnAccessDel, I_OnAccessAdd,
- I_OnAccessClear, I_OnLevelChange, I_OnChanDrop, I_OnChanRegistered, I_OnChanSuspend, I_OnChanUnsuspend,
- I_OnCreateChan, I_OnDelChan, I_OnChannelCreate, I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
- I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnNickDrop, I_OnNickGroup, I_OnNickIdentify,
- I_OnUserLogin, I_OnNickLogout, I_OnNickRegister, I_OnNickConfirm, I_OnNickSuspend, I_OnNickUnsuspended, I_OnDelNick, I_OnNickCoreCreate,
- I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert,
- I_OnNickAddCert, I_OnNickEraseCert, I_OnNickInfo, I_OnBotInfo, I_OnCheckAuthentication, I_OnNickUpdate,
- I_OnFingerprint, I_OnUserAway, I_OnInvite, I_OnDeleteVhost, I_OnSetVhost, I_OnSetDisplayedHost, I_OnMemoSend, I_OnMemoDel,
- I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
- I_OnMLock, I_OnUnMLock, I_OnModuleLoad, I_OnModuleUnload, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnBotNotice,
- I_OnPrivmsg, I_OnLog, I_OnLogMessage, I_OnDnsRequest, I_OnCheckModes, I_OnChannelSync, I_OnSetCorrectModes,
- I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate,
- I_OnSerializeTypeCreate, I_OnSetChannelOption, I_OnSetNickOption, I_OnMessage, I_OnCanSet, I_OnCheckDelete,
- I_OnExpireTick, I_OnNickValidate,
- I_SIZE
+ virtual void OnReload(Configuration::Conf *conf) { }
};
/** Used to manage modules.
@@ -1128,10 +261,6 @@ enum Implementation
class CoreExport ModuleManager
{
public:
- /** Event handler hooks.
- */
- static std::vector<Module *> EventHandlers[I_SIZE];
-
/** List of all modules loaded in Anope
*/
static std::list<Module *> Modules;
@@ -1176,36 +305,6 @@ class CoreExport ModuleManager
*/
static void RequireVersion(int major, int minor, int patch);
- /** Change the priority of one event in a module.
- * Each module event has a list of modules which are attached to that event type. If you wish to be called before or after other specific modules, you may use this
- * method (usually within void Module::Prioritize()) to set your events priority. You may use this call in other methods too, however, this is not supported behaviour
- * for a module.
- * @param mod The module to change the priority of
- * @param i The event to change the priority of
- * @param s The state you wish to use for this event. Use one of
- * PRIO_FIRST to set the event to be first called, PRIO_LAST to set it to be the last called, or PRIO_BEFORE and PRIO_AFTER
- * to set it to be before or after one or more other modules.
- * @param modules If PRIO_BEFORE or PRIO_AFTER is set in parameter 's', then this contains a list of one or more modules your module must be
- * placed before or after. Your module will be placed before the highest priority module in this list for PRIO_BEFORE, or after the lowest
- * priority module in this list for PRIO_AFTER.
- * @param sz The number of modules being passed for PRIO_BEFORE and PRIO_AFTER. Defaults to 1, as most of the time you will only want to prioritize your module
- * to be before or after one other module.
- */
- static bool SetPriority(Module *mod, Implementation i, Priority s, Module **modules = NULL, size_t sz = 1);
-
- /** Change the priority of all events in a module.
- * @param mod The module to set the priority of
- * @param s The priority of all events in the module.
- * Note that with this method, it is not possible to effectively use PRIO_BEFORE or PRIO_AFTER, you should use the more fine tuned
- * SetPriority method for this, where you may specify other modules to be prioritized against.
- */
- static bool SetPriority(Module *mod, Priority s);
-
- /** Detach all events from a module (used on unload)
- * @param mod Module to detach from
- */
- static void DetachAll(Module *mod);
-
/** Unloading all modules except the protocol module.
*/
static void UnloadAll();
@@ -1216,11 +315,5 @@ class CoreExport ModuleManager
* @return MOD_ERR_OK on success, anything else on fail
*/
static ModuleReturn DeleteModule(Module *m);
-
- /** Get the version of Anope the module was compiled against
- * @return The version
- */
- static ModuleVersion GetVersion(void *handle);
};
-#endif // MODULES_H
diff --git a/include/modules/botserv.h b/include/modules/botserv.h
new file mode 100644
index 000000000..89342cef2
--- /dev/null
+++ b/include/modules/botserv.h
@@ -0,0 +1,32 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+namespace BotServ
+{
+ class BotServService : public Service
+ {
+ public:
+ BotServService(Module *m) : Service(m, "BotServService", "BotServ")
+ {
+ }
+
+ };
+}
diff --git a/include/modules/botserv/badwords.h b/include/modules/botserv/badwords.h
new file mode 100644
index 000000000..09f8040ae
--- /dev/null
+++ b/include/modules/botserv/badwords.h
@@ -0,0 +1,112 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+/** Flags for badwords
+ */
+enum BadWordType
+{
+ /* Always kicks if the word is said */
+ BW_ANY,
+ /* User must say the entire word */
+ BW_SINGLE,
+ /* The word has to start with the badword */
+ BW_START,
+ /* The word has to end with the badword */
+ BW_END
+};
+
+/* Structure used to contain bad words. */
+class BadWord : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+ public:
+ static constexpr const char *NAME = "badword";
+
+ virtual ~BadWord() = default;
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetWord() anope_abstract;
+ virtual void SetWord(const Anope::string &) anope_abstract;
+
+ virtual BadWordType GetType() anope_abstract;
+ virtual void SetType(const BadWordType &) anope_abstract;
+};
+
+class BadWords : public Service
+{
+ public:
+ static constexpr const char *NAME = "badwords";
+
+ BadWords(Module *me) : Service(me, NAME) { }
+
+ /** Add a badword to the badword list
+ * @param word The badword
+ * @param type The type (SINGLE START END)
+ * @return The badword
+ */
+ virtual BadWord* AddBadWord(ChanServ::Channel *, const Anope::string &word, BadWordType type) anope_abstract;
+
+ virtual std::vector<BadWord *> GetBadWords(ChanServ::Channel *ci) anope_abstract;
+
+ /** Get a badword structure by index
+ * @param index The index
+ * @return The badword
+ */
+ virtual BadWord* GetBadWord(ChanServ::Channel *, unsigned index) anope_abstract;
+
+ /** Get how many badwords are on this channel
+ * @return The number of badwords in the vector
+ */
+ virtual unsigned GetBadWordCount(ChanServ::Channel *) anope_abstract;
+
+ /** Remove a badword
+ * @param index The index of the badword
+ */
+ virtual void EraseBadWord(ChanServ::Channel *, unsigned index) anope_abstract;
+
+ /** Clear all badwords from the channel
+ */
+ virtual void ClearBadWords(ChanServ::Channel *) anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport BadWordEvents : Events
+ {
+ static constexpr const char *NAME = "badwords";
+
+ using Events::Events;
+
+ /** Called before a badword is added to the badword list
+ * @param ci The channel
+ * @param bw The badword
+ */
+ virtual void OnBadWordAdd(ChanServ::Channel *ci, const BadWord *bw) anope_abstract;
+
+ /** Called before a badword is deleted from a channel
+ * @param ci The channel
+ * @param bw The badword
+ */
+ virtual void OnBadWordDel(ChanServ::Channel *ci, const BadWord *bw) anope_abstract;
+ };
+}
+
diff --git a/include/modules/botserv/bot.h b/include/modules/botserv/bot.h
new file mode 100644
index 000000000..21cda65bf
--- /dev/null
+++ b/include/modules/botserv/bot.h
@@ -0,0 +1,58 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport BotCreate : Events
+ {
+ static constexpr const char *NAME = "botcreate";
+
+ using Events::Events;
+
+ /** Called when a new bot is made
+ * @param bi The bot
+ */
+ virtual void OnBotCreate(ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport BotChange : Events
+ {
+ static constexpr const char *NAME = "botchange";
+
+ using Events::Events;
+
+ /** Called when a bot is changed
+ * @param bi The bot
+ */
+ virtual void OnBotChange(ServiceBot *bi) anope_abstract;
+ };
+
+ struct CoreExport BotDelete : Events
+ {
+ static constexpr const char *NAME = "botdelete";
+
+ using Events::Events;
+
+ /** Called when a bot is deleted
+ * @param bi The bot
+ */
+ virtual void OnBotDelete(ServiceBot *bi) anope_abstract;
+ };
+}
+
diff --git a/include/modules/botserv/info.h b/include/modules/botserv/info.h
new file mode 100644
index 000000000..643c45363
--- /dev/null
+++ b/include/modules/botserv/info.h
@@ -0,0 +1,33 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport ServiceBotEvent : Events
+ {
+ static constexpr const char *NAME = "servicebotevent";
+
+ using Events::Events;
+
+ /** Called when a user uses botserv/info on a bot or channel.
+ */
+ virtual void OnServiceBot(CommandSource &source, ServiceBot *bi, ChanServ::Channel *ci, InfoFormatter &info) anope_abstract;
+ };
+}
+
diff --git a/include/modules/botserv/kick.h b/include/modules/botserv/kick.h
new file mode 100644
index 000000000..99ae14b5e
--- /dev/null
+++ b/include/modules/botserv/kick.h
@@ -0,0 +1,141 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+class KickerData : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "kickerdata";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual bool GetAmsgs() anope_abstract;
+ virtual void SetAmsgs(const bool &) anope_abstract;
+
+ virtual bool GetBadwords() anope_abstract;
+ virtual void SetBadwords(const bool &) anope_abstract;
+
+ virtual bool GetBolds() anope_abstract;
+ virtual void SetBolds(const bool &) anope_abstract;
+
+ virtual bool GetCaps() anope_abstract;
+ virtual void SetCaps(const bool &) anope_abstract;
+
+ virtual bool GetColors() anope_abstract;
+ virtual void SetColors(const bool &) anope_abstract;
+
+ virtual bool GetFlood() anope_abstract;
+ virtual void SetFlood(const bool &) anope_abstract;
+
+ virtual bool GetItalics() anope_abstract;
+ virtual void SetItalics(const bool &) anope_abstract;
+
+ virtual bool GetRepeat() anope_abstract;
+ virtual void SetRepeat(const bool &) anope_abstract;
+
+ virtual bool GetReverses() anope_abstract;
+ virtual void SetReverses(const bool &) anope_abstract;
+
+ virtual bool GetUnderlines() anope_abstract;
+ virtual void SetUnderlines(const bool &) anope_abstract;
+
+ virtual int16_t GetTTBBolds() anope_abstract;
+ virtual void SetTTBBolds(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBColors() anope_abstract;
+ virtual void SetTTBColors(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBReverses() anope_abstract;
+ virtual void SetTTBReverses(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBUnderlines() anope_abstract;
+ virtual void SetTTBUnderlines(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBBadwords() anope_abstract;
+ virtual void SetTTBBadwords(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBCaps() anope_abstract;
+ virtual void SetTTBCaps(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBFlood() anope_abstract;
+ virtual void SetTTBFlood(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBRepeat() anope_abstract;
+ virtual void SetTTBRepeat(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBItalics() anope_abstract;
+ virtual void SetTTBItalics(const int16_t &) anope_abstract;
+
+ virtual int16_t GetTTBAmsgs() anope_abstract;
+ virtual void SetTTBAmsgs(const int16_t &) anope_abstract;
+
+ virtual int16_t GetCapsMin() anope_abstract;
+ virtual void SetCapsMin(const int16_t &) anope_abstract;
+
+ virtual int16_t GetCapsPercent() anope_abstract;
+ virtual void SetCapsPercent(const int16_t &) anope_abstract;
+
+ virtual int16_t GetFloodLines() anope_abstract;
+ virtual void SetFloodLines(const int16_t &) anope_abstract;
+
+ virtual int16_t GetFloodSecs() anope_abstract;
+ virtual void SetFloodSecs(const int16_t &) anope_abstract;
+
+ virtual int16_t GetRepeatTimes() anope_abstract;
+ virtual void SetRepeatTimes(const int16_t &) anope_abstract;
+
+ virtual bool GetDontKickOps() anope_abstract;
+ virtual void SetDontKickOps(const bool &) anope_abstract;
+
+ virtual bool GetDontKickVoices() anope_abstract;
+ virtual void SetDontKickVoices(const bool &) anope_abstract;
+};
+
+inline KickerData *GetKickerData(ChanServ::Channel *ci)
+{
+ KickerData *kd = ci->GetRef<KickerData *>();
+ if (!kd)
+ {
+ kd = Serialize::New<KickerData *>();
+ if (kd != nullptr)
+ {
+ kd->SetChannel(ci);
+ }
+ }
+ return kd;
+}
+
+namespace Event
+{
+ struct CoreExport BotBan : Events
+ {
+ static constexpr const char *NAME = "botban";
+
+ using Events::Events;
+
+ /** Called when a bot places a ban
+ * @param u User being banned
+ * @param ci Channel the ban is placed on
+ * @param mask The mask being banned
+ */
+ virtual void OnBotBan(User *u, ChanServ::Channel *ci, const Anope::string &mask) anope_abstract;
+ };
+}
diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h
deleted file mode 100644
index 80c5f17b6..000000000
--- a/include/modules/bs_badwords.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* BotServ core functions
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-/** Flags for badwords
- */
-enum BadWordType
-{
- /* Always kicks if the word is said */
- BW_ANY,
- /* User must way the entire word */
- BW_SINGLE,
- /* The word has to start with the badword */
- BW_START,
- /* The word has to end with the badword */
- BW_END
-};
-
-/* Structure used to contain bad words. */
-struct BadWord
-{
- Anope::string chan;
- Anope::string word;
- BadWordType type;
-
- virtual ~BadWord() { }
- protected:
- BadWord() { }
-};
-
-struct BadWords
-{
- virtual ~BadWords() { }
-
- /** Add a badword to the badword list
- * @param word The badword
- * @param type The type (SINGLE START END)
- * @return The badword
- */
- virtual BadWord* AddBadWord(const Anope::string &word, BadWordType type) = 0;
-
- /** Get a badword structure by index
- * @param index The index
- * @return The badword
- */
- virtual BadWord* GetBadWord(unsigned index) const = 0;
-
- /** Get how many badwords are on this channel
- * @return The number of badwords in the vector
- */
- virtual unsigned GetBadWordCount() const = 0;
-
- /** Remove a badword
- * @param index The index of the badword
- */
- virtual void EraseBadWord(unsigned index) = 0;
-
- /** Clear all badwords from the channel
- */
- virtual void ClearBadWords() = 0;
-
- virtual void Check() = 0;
-};
diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h
deleted file mode 100644
index 8fba141f1..000000000
--- a/include/modules/bs_kick.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* BotServ core functions
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-/* Indices for TTB (Times To Ban) */
-enum
-{
- TTB_BOLDS,
- TTB_COLORS,
- TTB_REVERSES,
- TTB_UNDERLINES,
- TTB_BADWORDS,
- TTB_CAPS,
- TTB_FLOOD,
- TTB_REPEAT,
- TTB_ITALICS,
- TTB_AMSGS,
- TTB_SIZE
-};
-
-struct KickerData
-{
- bool amsgs, badwords, bolds, caps, colors, flood, italics, repeat, reverses, underlines;
- int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
- int16_t capsmin, capspercent; /* For CAPS kicker */
- int16_t floodlines, floodsecs; /* For FLOOD kicker */
- int16_t repeattimes; /* For REPEAT kicker */
-
- bool dontkickops, dontkickvoices;
-
- protected:
- KickerData() { }
-
- public:
- virtual ~KickerData() { }
- virtual void Check(ChannelInfo *ci) = 0;
-};
diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h
new file mode 100644
index 000000000..8c5687cc2
--- /dev/null
+++ b/include/modules/chanserv.h
@@ -0,0 +1,479 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "event.h"
+#include "channels.h"
+#include "modules/nickserv.h"
+#include "modules/memoserv.h"
+#include "bots.h"
+
+namespace ChanServ
+{
+ static struct
+ {
+ Anope::string name;
+ Anope::string desc;
+ } descriptions[] = {
+ {"ACCESS_CHANGE", _("Allowed to modify the access list")},
+ {"ACCESS_LIST", _("Allowed to view the access list")},
+ {"AKICK", _("Allowed to use the AKICK command")},
+ {"ASSIGN", _("Allowed to assign/unassign a bot")},
+ {"AUTOHALFOP", _("Automatic halfop upon join")},
+ {"AUTOOP", _("Automatic channel operator status upon join")},
+ {"AUTOOWNER", _("Automatic owner upon join")},
+ {"AUTOPROTECT", _("Automatic protect upon join")},
+ {"AUTOVOICE", _("Automatic voice on join")},
+ {"BADWORDS", _("Allowed to modify channel badwords list")},
+ {"BAN", _("Allowed to ban users")},
+ {"FANTASIA", _("Allowed to use fantasy commands")},
+ {"FOUNDER", _("Allowed to issue commands restricted to channel founders")},
+ {"GETKEY", _("Allowed to use GETKEY command")},
+ {"GREET", _("Greet message displayed on join")},
+ {"HALFOP", _("Allowed to (de)halfop users")},
+ {"HALFOPME", _("Allowed to (de)halfop him/herself")},
+ {"INFO", _("Allowed to get full INFO output")},
+ {"INVITE", _("Allowed to use the INVITE command")},
+ {"KICK", _("Allowed to use the KICK command")},
+ {"MEMO", _("Allowed to read channel memos")},
+ {"MODE", _("Allowed to use the MODE command")},
+ {"NOKICK", _("Prevents users being kicked by Services")},
+ {"OP", _("Allowed to (de)op users")},
+ {"OPME", _("Allowed to (de)op him/herself")},
+ {"OWNER", _("Allowed to (de)owner users")},
+ {"OWNERME", _("Allowed to (de)owner him/herself")},
+ {"PROTECT", _("Allowed to (de)protect users")},
+ {"PROTECTME", _("Allowed to (de)protect him/herself")},
+ {"SAY", _("Allowed to use SAY and ACT commands")},
+ {"SET", _("Allowed to set channel settings")},
+ {"SIGNKICK", _("No signed kick when SIGNKICK LEVEL is used")},
+ {"TOPIC", _("Allowed to change channel topics")},
+ {"UNBAN", _("Allowed to unban users")},
+ {"VOICE", _("Allowed to (de)voice users")},
+ {"VOICEME", _("Allowed to (de)voice him/herself")}
+ };
+
+ /* A privilege, probably configured using a privilege{} block. Most
+ * commands require specific privileges to be executed.
+ */
+ struct CoreExport Privilege
+ {
+ Anope::string name;
+ Anope::string desc;
+ /* Rank relative to other privileges */
+ int rank;
+ int level;
+
+ Privilege(const Anope::string &n, const Anope::string &d, int r, int l) : name(n), desc(d), rank(r), level(l)
+ {
+ if (this->desc.empty())
+ for (unsigned j = 0; j < sizeof(descriptions) / sizeof(*descriptions); ++j)
+ if (descriptions[j].name.equals_ci(name))
+ this->desc = descriptions[j].desc;
+ }
+
+ bool operator==(const Privilege &other) const
+ {
+ return this->name.equals_ci(other.name);
+ }
+ };
+
+ class Channel;
+ using registered_channel_map = Anope::locale_hash_map<Channel *>;
+
+ class Level : public Serialize::Object
+ {
+ public:
+ static constexpr const char *const NAME = "level";
+
+ using Serialize::Object::Object;
+
+ virtual Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(Channel *) anope_abstract;
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual int GetLevel() anope_abstract;
+ virtual void SetLevel(const int &) anope_abstract;
+ };
+
+ class Mode : public Serialize::Object
+ {
+ public:
+ static constexpr const char *const NAME = "mlockmode";
+
+ using Serialize::Object::Object;
+
+ virtual Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(Channel *) anope_abstract;
+
+ virtual Anope::string GetMode() anope_abstract;
+ virtual void SetMode(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetParam() anope_abstract;
+ virtual void SetParam(const Anope::string &) anope_abstract;
+ };
+
+ class ChanServService : public Service
+ {
+ public:
+ static constexpr const char *NAME = "chanserv";
+
+ ChanServService(Module *m) : Service(m, NAME)
+ {
+ }
+
+ virtual Channel *Find(const Anope::string &name) anope_abstract;
+ virtual registered_channel_map& GetChannels() anope_abstract;
+
+ /* Have ChanServ hold the channel, that is, join and set +nsti and wait
+ * for a few minutes so no one can join or rejoin.
+ */
+ virtual void Hold(::Channel *c) anope_abstract;
+
+ virtual void AddPrivilege(Privilege p) anope_abstract;
+ virtual void RemovePrivilege(Privilege &p) anope_abstract;
+ virtual Privilege *FindPrivilege(const Anope::string &name) anope_abstract;
+ virtual std::vector<Privilege> &GetPrivileges() anope_abstract;
+ virtual void ClearPrivileges() anope_abstract;
+ };
+
+ extern ChanServService *service;
+
+ inline Channel *Find(const Anope::string name)
+ {
+ return service ? service->Find(name) : nullptr;
+ }
+
+ namespace Event
+ {
+ struct CoreExport PreChanExpire : Events
+ {
+ static constexpr const char *NAME = "prechanexpire";
+
+ using Events::Events;
+
+ /** Called before a channel expires
+ * @param ci The channel
+ * @param expire Set to true to allow the chan to expire
+ */
+ virtual void OnPreChanExpire(Channel *ci, bool &expire) anope_abstract;
+ };
+
+ struct CoreExport ChanExpire : Events
+ {
+ static constexpr const char *NAME = "chanexpire";
+
+ using Events::Events;
+
+ /** Called before a channel expires
+ * @param ci The channel
+ */
+ virtual void OnChanExpire(Channel *ci) anope_abstract;
+ };
+ }
+
+ /* It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Channel : public Serialize::Object
+ {
+ public:
+ ::Channel *c = nullptr; /* Pointer to channel, if the channel exists */
+
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "channel";
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetDesc() anope_abstract;
+ virtual void SetDesc(const Anope::string &) anope_abstract;
+
+ virtual time_t GetTimeRegistered() anope_abstract;
+ virtual void SetTimeRegistered(const time_t &) anope_abstract;
+
+ virtual time_t GetLastUsed() anope_abstract;
+ virtual void SetLastUsed(const time_t &) anope_abstract;
+
+ virtual Anope::string GetLastTopic() anope_abstract;
+ virtual void SetLastTopic(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLastTopicSetter() anope_abstract;
+ virtual void SetLastTopicSetter(const Anope::string &) anope_abstract;
+
+ virtual time_t GetLastTopicTime() anope_abstract;
+ virtual void SetLastTopicTime(const time_t &) anope_abstract;
+
+ virtual int16_t GetBanType() anope_abstract;
+ virtual void SetBanType(const int16_t &) anope_abstract;
+
+ virtual time_t GetBanExpire() anope_abstract;
+ virtual void SetBanExpire(const time_t &) anope_abstract;
+
+ virtual BotInfo *GetBI() anope_abstract;
+ virtual void SetBI(BotInfo *) anope_abstract;
+
+ virtual ServiceBot *GetBot() anope_abstract;
+ virtual void SetBot(ServiceBot *) anope_abstract;
+
+ /** Is the user the real founder?
+ * @param user The user
+ * @return true or false
+ */
+ virtual bool IsFounder(const User *user) anope_abstract;
+
+ /** Change the founder of the channel
+ * @params nc The new founder
+ */
+ virtual void SetFounder(NickServ::Account *nc) anope_abstract;
+
+ /** Get the founder of the channel
+ * @return The founder
+ */
+ virtual NickServ::Account *GetFounder() anope_abstract;
+
+ virtual void SetSuccessor(NickServ::Account *nc) anope_abstract;
+ virtual NickServ::Account *GetSuccessor() anope_abstract;
+
+ /** Find which bot should send mode/topic/etc changes for this channel
+ * @return The bot
+ */
+ ServiceBot *WhoSends()
+ {
+ if (this)
+ if (ServiceBot *bi = GetBot())
+ return bi;
+
+ ServiceBot *ChanServ = Config->GetClient("ChanServ");
+ if (ChanServ)
+ return ChanServ;
+
+#warning "if(this)"
+ //XXX
+// if (!BotListByNick->empty())
+// return BotListByNick->begin()->second;
+
+ return NULL;
+ }
+
+ /** Get an entry from the channel access list by index
+ *
+ * @param index The index in the access list vector
+ * @return A ChanAccess struct corresponding to the index given, or NULL if outside the bounds
+ *
+ * Retrieves an entry from the access list that matches the given index.
+ */
+ virtual ChanAccess *GetAccess(unsigned index) /*const*/ anope_abstract;
+
+ /** 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).
+ */
+ virtual AccessGroup AccessFor(const User *u, bool updateLastUsed = true) anope_abstract;
+ virtual AccessGroup AccessFor(NickServ::Account *nc, bool updateLastUsed = true) anope_abstract;
+
+ /** Get the size of the accss vector for this channel
+ * @return The access vector size
+ */
+ virtual unsigned GetAccessCount() /*const*/ anope_abstract;
+
+ /** Clear the entire channel access list
+ *
+ * Clears the entire access list by deleting every item and then clearing the vector.
+ */
+ virtual void ClearAccess() anope_abstract;
+
+ /** Add an akick entry to the channel by NickServ::Account
+ * @param user The user who added the akick
+ * @param akicknc The nickcore being akicked
+ * @param reason The reason for the akick
+ * @param t The time the akick was added, defaults to now
+ * @param lu The time the akick was last used, defaults to never
+ */
+ virtual AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;
+
+ /** Add an akick entry to the channel by reason
+ * @param user The user who added the akick
+ * @param mask The mask of the akick
+ * @param reason The reason for the akick
+ * @param t The time the akick was added, defaults to now
+ * @param lu The time the akick was last used, defaults to never
+ */
+ virtual AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) anope_abstract;
+
+ /** 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
+ */
+ virtual AutoKick* GetAkick(unsigned index) anope_abstract;
+
+ /** Get the size of the akick vector for this channel
+ * @return The akick vector size
+ */
+ virtual unsigned GetAkickCount() anope_abstract;
+
+ /** Clear the whole akick list
+ */
+ virtual void ClearAkick() anope_abstract;
+
+ /** Get the level for a privilege
+ * @param priv The privilege name
+ * @return the level
+ * @throws CoreException if priv is not a valid privilege
+ */
+ virtual int16_t GetLevel(const Anope::string &priv) anope_abstract;
+
+ /** Set the level for a privilege
+ * @param priv The privilege priv
+ * @param level The new level
+ */
+ virtual void SetLevel(const Anope::string &priv, int16_t level) anope_abstract;
+
+ /** Remove a privilege from the channel
+ * @param priv The privilege
+ */
+ virtual void RemoveLevel(const Anope::string &priv) anope_abstract;
+
+ /** Clear all privileges from the channel
+ */
+ virtual void ClearLevels() anope_abstract;
+
+ /** Gets a ban mask for the given user based on the bantype
+ * of the channel.
+ * @param u The user
+ * @return A ban mask that affects the user
+ */
+ virtual Anope::string GetIdealBan(User *u) anope_abstract;
+
+ virtual MemoServ::MemoInfo *GetMemos() anope_abstract;
+ };
+
+ enum
+ {
+ ACCESS_INVALID = -10000,
+ ACCESS_FOUNDER = 10001
+ };
+
+ /* Represents one entry of an access list on a channel. */
+ class CoreExport ChanAccess : public Serialize::Object
+ {
+ public:
+ static constexpr const char *const NAME = "access";
+
+ Channel *channel = nullptr;
+ Serialize::Object *object = nullptr;
+ Anope::string creator, mask;
+ time_t last_seen = 0, created = 0;
+
+ using Serialize::Object::Object;
+
+ virtual Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(Channel *ci) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &c) anope_abstract;
+
+ virtual time_t GetLastSeen() anope_abstract;
+ virtual void SetLastSeen(const time_t &t) anope_abstract;
+
+ virtual time_t GetCreated() anope_abstract;
+ virtual void SetCreated(const time_t &t) anope_abstract;
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+
+ virtual Serialize::Object *GetObj() anope_abstract;
+ virtual void SetObj(Serialize::Object *) anope_abstract;
+
+ virtual Anope::string Mask() anope_abstract;
+ virtual NickServ::Account *GetAccount() anope_abstract;
+
+ /** Check if this access entry matches the given user or account
+ * @param u The user
+ * @param acc The account
+ */
+ virtual bool Matches(const User *u, NickServ::Account *acc) anope_abstract;
+
+ /** Check if this access entry has the given privilege.
+ * @param name The privilege name
+ */
+ virtual bool HasPriv(const Anope::string &name) anope_abstract;
+
+ /** Serialize the access given by this access entry into a human
+ * readable form. chanserv/access will return a number, chanserv/xop
+ * will be AOP, SOP, etc.
+ */
+ virtual Anope::string AccessSerialize() anope_abstract;
+
+ /** Unserialize this access entry from the given data. This data
+ * will be fetched from AccessSerialize.
+ */
+ virtual void AccessUnserialize(const Anope::string &data) anope_abstract;
+
+ /* Comparison operators to other Access entries */
+ virtual bool operator>(ChanAccess &other)
+ {
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return this_p && !other_p;
+ }
+
+ return false;
+ }
+
+ virtual bool operator<(ChanAccess &other)
+ {
+ const std::vector<Privilege> &privs = service->GetPrivileges();
+ for (unsigned i = privs.size(); i > 0; --i)
+ {
+ bool this_p = this->HasPriv(privs[i - 1].name),
+ other_p = other.HasPriv(privs[i - 1].name);
+
+ if (!this_p && !other_p)
+ continue;
+
+ return !this_p && other_p;
+ }
+
+ return false;
+ }
+
+ bool operator>=(ChanAccess &other)
+ {
+ return !(*this < other);
+ }
+
+ bool operator<=(ChanAccess &other)
+ {
+ return !(*this > other);
+ }
+ };
+}
+
diff --git a/include/modules/chanserv/access.h b/include/modules/chanserv/access.h
new file mode 100644
index 000000000..f826d0c66
--- /dev/null
+++ b/include/modules/chanserv/access.h
@@ -0,0 +1,72 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#include "main/chanaccess.h"
+
+namespace Event
+{
+ struct CoreExport LevelChange : Events
+ {
+ static constexpr const char *NAME = "levelchange";
+
+ using Events::Events;
+
+ /** Called when a level for a channel is changed
+ * @param source The source of the command
+ * @param ci The channel the level was changed on
+ * @param priv The privilege changed
+ * @param what The new level
+ */
+ virtual void OnLevelChange(CommandSource &source, ChanServ::Channel *ci, const Anope::string &priv, int16_t what) anope_abstract;
+ };
+}
+
+class AccessChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "accesschanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual int GetLevel() anope_abstract;
+ virtual void SetLevel(const int &) anope_abstract;
+};
+
+class XOPChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "xopchanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual const Anope::string &GetType() anope_abstract;
+ virtual void SetType(const Anope::string &) anope_abstract;
+};
+
+class FlagsChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "flagschanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual const Anope::string &GetFlags() anope_abstract;
+ virtual void SetFlags(const Anope::string &) anope_abstract;
+};
+
diff --git a/include/modules/chanserv/akick.h b/include/modules/chanserv/akick.h
new file mode 100644
index 000000000..fdebcc198
--- /dev/null
+++ b/include/modules/chanserv/akick.h
@@ -0,0 +1,77 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#include "modules/nickserv.h"
+
+ /* AutoKick data. */
+class CoreExport AutoKick : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+ public:
+ static constexpr const char *const NAME = "akick";
+
+ virtual ~AutoKick() = default;
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+
+ virtual NickServ::Account *GetAccount() anope_abstract;
+ virtual void SetAccount(NickServ::Account *) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual time_t GetAddTime() anope_abstract;
+ virtual void SetAddTime(const time_t &) anope_abstract;
+
+ virtual time_t GetLastUsed() anope_abstract;
+ virtual void SetLastUsed(const time_t &) anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport Akick : Events
+ {
+ static constexpr const char *NAME = "akick";
+
+ using Events::Events;
+
+ /** Called after adding an akick to a channel
+ * @param source The source of the command
+ * @param ci The channel
+ * @param ak The akick
+ */
+ virtual void OnAkickAdd(CommandSource &source, ChanServ::Channel *ci, const AutoKick *ak) anope_abstract;
+
+ /** Called before removing an akick from a channel
+ * @param source The source of the command
+ * @param ci The channel
+ * @param ak The akick
+ */
+ virtual void OnAkickDel(CommandSource &source, ChanServ::Channel *ci, const AutoKick *ak) anope_abstract;
+ };
+}
+
diff --git a/include/modules/chanserv/drop.h b/include/modules/chanserv/drop.h
new file mode 100644
index 000000000..4ab5dd097
--- /dev/null
+++ b/include/modules/chanserv/drop.h
@@ -0,0 +1,35 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport ChanDrop : Events
+ {
+ static constexpr const char *NAME = "chandrop";
+
+ using Events::Events;
+
+ /** Called right before a channel is dropped
+ * @param source The user dropping the channel
+ * @param ci The channel
+ */
+ virtual EventReturn OnChanDrop(CommandSource &source, ChanServ::Channel *ci) anope_abstract;
+ };
+}
+
diff --git a/include/modules/chanserv/entrymsg.h b/include/modules/chanserv/entrymsg.h
new file mode 100644
index 000000000..738be25d5
--- /dev/null
+++ b/include/modules/chanserv/entrymsg.h
@@ -0,0 +1,41 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class EntryMsg : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "entrymsg";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetMessage() anope_abstract;
+ virtual void SetMessage(const Anope::string &) anope_abstract;
+
+ virtual time_t GetWhen() anope_abstract;
+ virtual void SetWhen(const time_t &) anope_abstract;
+};
+
+
diff --git a/include/modules/chanserv/info.h b/include/modules/chanserv/info.h
new file mode 100644
index 000000000..08ab7a387
--- /dev/null
+++ b/include/modules/chanserv/info.h
@@ -0,0 +1,37 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport ChanInfo : Events
+ {
+ static constexpr const char *NAME = "chaninfo";
+
+ using Events::Events;
+
+ /** Called when a user requests info for a channel
+ * @param source The user requesting info
+ * @param ci The channel the user is requesting info for
+ * @param info Data to show the user requesting information
+ * @param show_hidden true if we should show the user everything
+ */
+ virtual void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) anope_abstract;
+ };
+}
+
diff --git a/include/modules/chanserv/log.h b/include/modules/chanserv/log.h
new file mode 100644
index 000000000..26f1cac37
--- /dev/null
+++ b/include/modules/chanserv/log.h
@@ -0,0 +1,51 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class LogSetting : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "logsetting";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetServiceName() anope_abstract;
+ virtual void SetServiceName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCommandService() anope_abstract;
+ virtual void SetCommandService(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCommandName() anope_abstract;
+ virtual void SetCommandName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetMethod() anope_abstract;
+ virtual void SetMethod(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetExtra() anope_abstract;
+ virtual void SetExtra(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual time_t GetCreated() anope_abstract;
+ virtual void SetCreated(const time_t &) anope_abstract;
+};
diff --git a/include/modules/chanserv/main/chanaccess.h b/include/modules/chanserv/main/chanaccess.h
new file mode 100644
index 000000000..a126da685
--- /dev/null
+++ b/include/modules/chanserv/main/chanaccess.h
@@ -0,0 +1,50 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+class ChanAccessImpl : public ChanServ::ChanAccess
+{
+ public:
+ ChanAccessImpl(Serialize::TypeBase *type) : ChanServ::ChanAccess(type) { }
+ ChanAccessImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::ChanAccess(type, id) { }
+
+ ChanServ::Channel *GetChannel() override;
+ void SetChannel(ChanServ::Channel *ci) override;
+
+ Anope::string GetCreator() override;
+ void SetCreator(const Anope::string &c) override;
+
+ time_t GetLastSeen() override;
+ void SetLastSeen(const time_t &t) override;
+
+ time_t GetCreated() override;
+ void SetCreated(const time_t &t) override;
+
+ Anope::string GetMask() override;
+ void SetMask(const Anope::string &) override;
+
+ Serialize::Object *GetObj() override;
+ void SetObj(Serialize::Object *) override;
+
+ Anope::string Mask() override;
+ NickServ::Account *GetAccount() override;
+
+ bool Matches(const User *u, NickServ::Account *acc) override;
+};
diff --git a/include/modules/chanserv/mode.h b/include/modules/chanserv/mode.h
new file mode 100644
index 000000000..d580982b6
--- /dev/null
+++ b/include/modules/chanserv/mode.h
@@ -0,0 +1,133 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class ModeLock : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "modelock";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual bool GetSet() anope_abstract;
+ virtual void SetSet(const bool &) anope_abstract;
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetParam() anope_abstract;
+ virtual void SetParam(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetSetter() anope_abstract;
+ virtual void SetSetter(const Anope::string &) anope_abstract;
+
+ virtual time_t GetCreated() anope_abstract;
+ virtual void SetCreated(const time_t &) anope_abstract;
+};
+
+class ModeLocks : public Service
+{
+ public:
+ static constexpr const char *NAME = "mlocks";
+
+ ModeLocks(Module *me) : Service(me, NAME) { }
+
+ typedef std::vector<ModeLock *> ModeList;
+
+ /** Check if a mode is mlocked
+ * @param mode The mode
+ * @param An optional param
+ * @param status True to check mlock on, false for mlock off
+ * @return true on success, false on fail
+ */
+ virtual bool HasMLock(ChanServ::Channel *, ChannelMode *mode, const Anope::string &param, bool status) const anope_abstract;
+
+ /** Set a mlock
+ * @param mode The mode
+ * @param status True for mlock on, false for mlock off
+ * @param param An optional param arg for + mlocked modes
+ * @param setter Who is setting the mlock
+ * @param created When the mlock was created
+ * @return true on success, false on failure (module blocking)
+ */
+ virtual bool SetMLock(ChanServ::Channel *, ChannelMode *mode, bool status, const Anope::string &param = "", Anope::string setter = "", time_t created = Anope::CurTime) anope_abstract;
+
+ /** Remove a mlock
+ * @param mode The mode
+ * @param status True for mlock on, false for mlock off
+ * @param param The param of the mode, required if it is a list or status mode
+ * @return true on success, false on failure
+ */
+ virtual bool RemoveMLock(ChanServ::Channel *, ChannelMode *mode, bool status, const Anope::string &param = "") anope_abstract;
+
+ /** Clear all mlocks on the channel
+ */
+ virtual void ClearMLock(ChanServ::Channel *) anope_abstract;
+
+ /** Get all of the mlocks for this channel
+ * @return The mlocks
+ */
+ virtual ModeList GetMLock(ChanServ::Channel *) const anope_abstract;
+
+ /** Get a list of mode locks on a channel
+ * @param name The mode name to get a list of
+ * @return a list of mlocks for the given mode
+ */
+ virtual std::list<ModeLock *> GetModeLockList(ChanServ::Channel *, const Anope::string &name) anope_abstract;
+
+ /** Get details for a specific mlock
+ * @param mname The mode name
+ * @param An optional param to match with
+ * @return The MLock, if any
+ */
+ virtual ModeLock *GetMLock(ChanServ::Channel *, const Anope::string &mname, const Anope::string &param = "") anope_abstract;
+
+ /** Get the current mode locks as a string
+ * @param complete True to show mlock parameters as well
+ * @return A string of mode locks, eg: +nrt
+ */
+ virtual Anope::string GetMLockAsString(ChanServ::Channel *, bool complete) const anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport MLockEvents : Events
+ {
+ static constexpr const char *NAME = "mlockevents";
+
+ using Events::Events;
+
+ /** Called when a mode is about to be mlocked
+ * @param ci The channel the mode is being locked on
+ * @param lock The mode lock
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
+ */
+ virtual EventReturn OnMLock(ChanServ::Channel *ci, ModeLock *lock) anope_abstract;
+
+ /** Called when a mode is about to be unlocked
+ * @param ci The channel the mode is being unlocked from
+ * @param lock The mode lock
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
+ */
+ virtual EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) anope_abstract;
+ };
+}
diff --git a/include/modules/chanserv/set.h b/include/modules/chanserv/set.h
new file mode 100644
index 000000000..e28818299
--- /dev/null
+++ b/include/modules/chanserv/set.h
@@ -0,0 +1,38 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport SetChannelOption : Events
+ {
+ static constexpr const char *NAME = "setchanneloption";
+
+ using Events::Events;
+
+ /** Called when a chanserv/set command is used
+ * @param source The source of the command
+ * @param cmd The command
+ * @param ci The channel the command was used on
+ * @param setting The setting passed to the command. Probably ON/OFF.
+ * @return EVENT_ALLOW to bypass access checks, EVENT_STOP to halt immediately.
+ */
+ virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChanServ::Channel *ci, const Anope::string &setting) anope_abstract;
+ };
+}
+
diff --git a/include/modules/chanserv/set_misc.h b/include/modules/chanserv/set_misc.h
new file mode 100644
index 000000000..ade348ae4
--- /dev/null
+++ b/include/modules/chanserv/set_misc.h
@@ -0,0 +1,36 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class CSMiscData : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "csmiscdata";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetData() anope_abstract;
+ virtual void SetData(const Anope::string &) anope_abstract;
+};
diff --git a/include/modules/chanserv/suspend.h b/include/modules/chanserv/suspend.h
new file mode 100644
index 000000000..3d968c0db
--- /dev/null
+++ b/include/modules/chanserv/suspend.h
@@ -0,0 +1,69 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class CSSuspendInfo : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "cssuspendinfo";
+
+ virtual ChanServ::Channel *GetChannel() anope_abstract;
+ virtual void SetChannel(ChanServ::Channel *) anope_abstract;
+
+ virtual Anope::string GetBy() anope_abstract;
+ virtual void SetBy(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual time_t GetWhen() anope_abstract;
+ virtual void SetWhen(const time_t &) anope_abstract;
+
+ virtual time_t GetExpires() anope_abstract;
+ virtual void SetExpires(const time_t &) anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport ChanSuspend : Events
+ {
+ static constexpr const char *NAME = "chansuspend";
+
+ using Events::Events;
+
+ /** Called when a channel is suspended
+ * @param ci The channel
+ */
+ virtual void OnChanSuspend(ChanServ::Channel *ci) anope_abstract;
+ };
+ struct CoreExport ChanUnsuspend : Events
+ {
+ static constexpr const char *NAME = "chanunsuspend";
+
+ using Events::Events;
+
+ /** Called when a channel is unsuspended
+ * @param ci The channel
+ */
+ virtual void OnChanUnsuspend(ChanServ::Channel *ci) anope_abstract;
+ };
+}
+
diff --git a/include/modules/cs_entrymsg.h b/include/modules/cs_entrymsg.h
deleted file mode 100644
index 8636bfdbb..000000000
--- a/include/modules/cs_entrymsg.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-struct EntryMsg
-{
- Anope::string chan;
- Anope::string creator;
- Anope::string message;
- time_t when;
-
- virtual ~EntryMsg() { }
- protected:
- EntryMsg() { }
-};
-
-struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >
-{
- protected:
- EntryMessageList() : Serialize::Checker<std::vector<EntryMsg *> >("EntryMsg") { }
-
- public:
- virtual ~EntryMessageList()
- {
- for (unsigned i = (*this)->size(); i > 0; --i)
- delete (*this)->at(i - 1);
- }
-
- virtual EntryMsg* Create() = 0;
-};
diff --git a/include/modules/cs_log.h b/include/modules/cs_log.h
deleted file mode 100644
index d14179c70..000000000
--- a/include/modules/cs_log.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ChanServ core functions
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-struct LogSetting
-{
- Anope::string chan;
- /* Our service name of the command */
- Anope::string service_name;
- /* The name of the client the command is on */
- Anope::string command_service;
- /* Name of the command to the user, can have spaces */
- Anope::string command_name;
- Anope::string method, extra;
- Anope::string creator;
- time_t created;
-
- virtual ~LogSetting() { }
- protected:
- LogSetting() { }
-};
-
-struct LogSettings : Serialize::Checker<std::vector<LogSetting *> >
-{
- typedef std::vector<LogSetting *>::iterator iterator;
-
- protected:
- LogSettings() : Serialize::Checker<std::vector<LogSetting *> >("LogSetting")
- {
- }
-
- public:
- virtual ~LogSettings() { }
- virtual LogSetting *Create() = 0;
-};
diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h
deleted file mode 100644
index 29a9a63ff..000000000
--- a/include/modules/cs_mode.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ChanServ core functions
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-struct ModeLock
-{
- Anope::string ci;
- bool set;
- Anope::string name;
- Anope::string param;
- Anope::string setter;
- time_t created;
-
- virtual ~ModeLock() { }
- protected:
- ModeLock() { }
-};
-
-struct ModeLocks
-{
- typedef std::vector<ModeLock *> ModeList;
-
- virtual ~ModeLocks() { }
-
- /** Check if a mode is mlocked
- * @param mode The mode
- * @param An optional param
- * @param status True to check mlock on, false for mlock off
- * @return true on success, false on fail
- */
- virtual bool HasMLock(ChannelMode *mode, const Anope::string &param, bool status) const = 0;
-
- /** Set a mlock
- * @param mode The mode
- * @param status True for mlock on, false for mlock off
- * @param param An optional param arg for + mlocked modes
- * @param setter Who is setting the mlock
- * @param created When the mlock was created
- * @return true on success, false on failure (module blocking)
- */
- virtual bool SetMLock(ChannelMode *mode, bool status, const Anope::string &param = "", Anope::string setter = "", time_t created = Anope::CurTime) = 0;
-
- /** Remove a mlock
- * @param mode The mode
- * @param status True for mlock on, false for mlock off
- * @param param The param of the mode, required if it is a list or status mode
- * @return true on success, false on failure
- */
- virtual bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string &param = "") = 0;
-
- virtual void RemoveMLock(ModeLock *mlock) = 0;
-
- /** Clear all mlocks on the channel
- */
- virtual void ClearMLock() = 0;
-
- /** Get all of the mlocks for this channel
- * @return The mlocks
- */
- virtual const ModeList &GetMLock() const = 0;
-
- /** Get a list of mode locks on a channel
- * @param name The mode name to get a list of
- * @return a list of mlocks for the given mode
- */
- virtual std::list<ModeLock *> GetModeLockList(const Anope::string &name) = 0;
-
- /** Get details for a specific mlock
- * @param mname The mode name
- * @param An optional param to match with
- * @return The MLock, if any
- */
- virtual const ModeLock *GetMLock(const Anope::string &mname, const Anope::string &param = "") = 0;
-
- /** Get the current mode locks as a string
- * @param complete True to show mlock parameters as well
- * @return A string of mode locks, eg: +nrt
- */
- virtual Anope::string GetMLockAsString(bool complete) const = 0;
-
- virtual void Check() = 0;
-};
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 646691cb1..e98826ce7 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -1,12 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#ifndef DNS_H
@@ -78,11 +86,11 @@ namespace DNS
Question() : type(QUERY_NONE), qclass(0) { }
Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { }
- inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
+ inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
struct hash
{
- size_t operator()(const Question &q) const
+ size_t operator()(const Question &q) const
{
return Anope::hash_ci()(q.name);
}
@@ -94,7 +102,7 @@ namespace DNS
unsigned int ttl;
Anope::string rdata;
time_t created;
-
+
ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { }
ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { }
};
@@ -104,7 +112,7 @@ namespace DNS
std::vector<Question> questions;
std::vector<ResourceRecord> answers, authorities, additional;
Error error;
-
+
Query() : error(ERROR_NONE) { }
Query(const Question &q) : error(ERROR_NONE) { questions.push_back(q); }
};
@@ -117,17 +125,19 @@ namespace DNS
class Manager : public Service
{
public:
- Manager(Module *creator) : Service(creator, "DNS::Manager", "dns/manager") { }
+ static constexpr const char *NAME = "dns/manager";
+
+ Manager(Module *creator) : Service(creator, NAME) { }
virtual ~Manager() { }
- virtual void Process(Request *req) = 0;
- virtual void RemoveRequest(Request *req) = 0;
+ virtual void Process(Request *req) anope_abstract;
+ virtual void RemoveRequest(Request *req) anope_abstract;
- virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) = 0;
+ virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) anope_abstract;
- virtual void UpdateSerial() = 0;
- virtual void Notify(const Anope::string &zone) = 0;
- virtual uint32_t GetSerial() const = 0;
+ virtual void UpdateSerial() anope_abstract;
+ virtual void Notify(const Anope::string &zone) anope_abstract;
+ virtual uint32_t GetSerial() const anope_abstract;
};
/** A DNS query.
@@ -154,7 +164,7 @@ namespace DNS
/** Called when this request succeeds
* @param r The query sent back from the nameserver
*/
- virtual void OnLookupComplete(const Query *r) = 0;
+ virtual void OnLookupComplete(const Query *r) anope_abstract;
/** Called when this request fails or times out.
* @param r The query sent back from the nameserver, check the error code.
@@ -164,7 +174,7 @@ namespace DNS
/** Used to time out the query, xalls OnError and lets the TimerManager
* delete this request.
*/
- void Tick(time_t) anope_override
+ void Tick(time_t) override
{
Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name;
Query rr(*this);
@@ -175,4 +185,22 @@ namespace DNS
} // namespace DNS
+namespace Event
+{
+ struct CoreExport DnsRequest : Events
+ {
+ static constexpr const char *NAME = "dnsrequest";
+
+ using Events::Events;
+
+ /** Called when a DNS request (question) is recieved.
+ * @param req The dns request
+ * @param reply The reply that will be sent
+ */
+ virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) anope_abstract;
+ };
+}
+
#endif // DNS_H
+
+
diff --git a/include/modules/encryption.h b/include/modules/encryption.h
index 50ca066c3..3f4af559d 100644
--- a/include/modules/encryption.h
+++ b/include/modules/encryption.h
@@ -1,12 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
namespace Encryption
@@ -18,18 +26,21 @@ namespace Encryption
{
public:
virtual ~Context() { }
- virtual void Update(const unsigned char *data, size_t len) = 0;
- virtual void Finalize() = 0;
- virtual Hash GetFinalizedHash() = 0;
+ virtual void Update(const unsigned char *data, size_t len) anope_abstract;
+ virtual void Finalize() anope_abstract;
+ virtual Hash GetFinalizedHash() anope_abstract;
};
class Provider : public Service
{
public:
- Provider(Module *creator, const Anope::string &sname) : Service(creator, "Encryption::Provider", sname) { }
+ static constexpr const char *NAME = "hash";
+
+ Provider(Module *creator, const Anope::string &sname) : Service(creator, NAME, sname) { }
virtual ~Provider() { }
- virtual Context *CreateContext(IV * = NULL) = 0;
- virtual IV GetDefaultIV() = 0;
+ virtual Context *CreateContext(IV * = NULL) anope_abstract;
+ virtual IV GetDefaultIV() anope_abstract;
};
}
+
diff --git a/include/modules/fantasy.h b/include/modules/fantasy.h
new file mode 100644
index 000000000..463dc1c39
--- /dev/null
+++ b/include/modules/fantasy.h
@@ -0,0 +1,54 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct BotFantasy : Events
+ {
+ static constexpr const char *NAME = "botfantasy";
+
+ using Events::Events;
+
+ /** Called on fantasy command
+ * @param source The source of the command
+ * @param c The command
+ * @param ci The channel it's being used in
+ * @param params The params
+ * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
+ */
+ virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChanServ::Channel *ci, const std::vector<Anope::string> &params) anope_abstract;
+ };
+
+ struct CoreExport BotNoFantasyAccess : Events
+ {
+ static constexpr const char *NAME = "botnofantasyaccess";
+
+ using Events::Events;
+
+ /** Called on fantasy command without access
+ * @param source The source of the command
+ * @param c The command
+ * @param ci The channel it's being used in
+ * @param params The params
+ * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
+ */
+ virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChanServ::Channel *ci, const std::vector<Anope::string> &params) anope_abstract;
+ };
+}
+
diff --git a/include/modules/global.h b/include/modules/global.h
new file mode 100644
index 000000000..2d49f895e
--- /dev/null
+++ b/include/modules/global.h
@@ -0,0 +1,40 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Global
+{
+ class GlobalService : public Service
+ {
+ public:
+ static constexpr const char *NAME = "global";
+
+ GlobalService(Module *m) : Service(m, NAME)
+ {
+ }
+
+ /** Send out a global message to all users
+ * @param sender Our client which should send the global
+ * @param source The sender of the global
+ * @param message The message
+ */
+ virtual void SendGlobal(ServiceBot *sender, const Anope::string &source, const Anope::string &message) anope_abstract;
+ };
+}
+
+
diff --git a/include/modules/help.h b/include/modules/help.h
new file mode 100644
index 000000000..5ba2214b7
--- /dev/null
+++ b/include/modules/help.h
@@ -0,0 +1,42 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport Help : Events
+ {
+ static constexpr const char *NAME = "help";
+
+ using Events::Events;
+
+ /** Called when someone uses the generic/help command
+ * @param source Command source
+ * @param params Params
+ * @return EVENT_STOP to stop processing
+ */
+ virtual EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_abstract;
+
+ /** Called when someone uses the generic/help command
+ * @param source Command source
+ * @param params Params
+ */
+ virtual void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_abstract;
+ };
+}
+
diff --git a/include/modules/hostserv/del.h b/include/modules/hostserv/del.h
new file mode 100644
index 000000000..5ba1c4238
--- /dev/null
+++ b/include/modules/hostserv/del.h
@@ -0,0 +1,34 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport DeleteVhost : Events
+ {
+ static constexpr const char *NAME = "deletevhost";
+
+ using Events::Events;
+
+ /** Called when a vhost is deleted
+ * @param na The nickalias of the vhost
+ */
+ virtual void OnDeleteVhost(NickServ::Nick *na) anope_abstract;
+ };
+}
+
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 8df3c181b..ce28e0622 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -1,13 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2012-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef ANOPE_HTTPD_H
-#define ANOPE_HTTPD_H
+#pragma once
enum HTTPError
{
@@ -112,7 +122,7 @@ class HTTPPage : public Base
* @param The HTTP header sent from the client to request the page
* @param The HTTP header that will be sent back to the client
*/
- virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0;
+ virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_abstract;
};
class HTTPClient : public ClientSocket, public BinarySocket, public Base
@@ -131,8 +141,8 @@ class HTTPClient : public ClientSocket, public BinarySocket, public Base
return this->clientaddr.addr();
}
- virtual void SendError(HTTPError err, const Anope::string &msg) = 0;
- virtual void SendReply(HTTPReply *) = 0;
+ virtual void SendError(HTTPError err, const Anope::string &msg) anope_abstract;
+ virtual void SendReply(HTTPReply *) anope_abstract;
};
class HTTPProvider : public ListenSocket, public Service
@@ -140,11 +150,16 @@ class HTTPProvider : public ListenSocket, public Service
Anope::string ip;
unsigned short port;
bool ssl;
+
public:
+ static constexpr const char *NAME = "http";
+
Anope::string ext_ip;
std::vector<Anope::string> ext_headers;
- HTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, bool s) : ListenSocket(i, p, i.find(':') != Anope::string::npos), Service(c, "HTTPProvider", n), ip(i), port(p), ssl(s) { }
+ HTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, bool s)
+ : ListenSocket(i, p, i.find(':') != Anope::string::npos)
+ , Service(c, NAME, n), ip(i), port(p), ssl(s) { }
const Anope::string &GetIP() const
{
@@ -161,9 +176,9 @@ class HTTPProvider : public ListenSocket, public Service
return this->ssl;
}
- virtual bool RegisterPage(HTTPPage *page) = 0;
- virtual void UnregisterPage(HTTPPage *page) = 0;
- virtual HTTPPage* FindPage(const Anope::string &name) = 0;
+ virtual bool RegisterPage(HTTPPage *page) anope_abstract;
+ virtual void UnregisterPage(HTTPPage *page) anope_abstract;
+ virtual HTTPPage* FindPage(const Anope::string &name) anope_abstract;
};
namespace HTTPUtils
@@ -236,5 +251,3 @@ namespace HTTPUtils
return dst;
}
}
-
-#endif // ANOPE_HTTPD_H
diff --git a/include/modules/ldap.h b/include/modules/ldap.h
index 373c9cfa3..da560adf2 100644
--- a/include/modules/ldap.h
+++ b/include/modules/ldap.h
@@ -1,13 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef ANOPE_LDAP_H
-#define ANOPE_LDAP_H
+#pragma once
class LDAPException : public ModuleException
{
@@ -118,8 +128,8 @@ class LDAPInterface
LDAPInterface(Module *m) : owner(m) { }
virtual ~LDAPInterface() { }
- virtual void OnResult(const LDAPResult &r) = 0;
- virtual void OnError(const LDAPResult &err) = 0;
+ virtual void OnResult(const LDAPResult &r) anope_abstract;
+ virtual void OnError(const LDAPResult &err) anope_abstract;
virtual void OnDelete() { }
};
@@ -131,41 +141,39 @@ class LDAPProvider : public Service
/** Attempt to bind to the LDAP server as an admin
* @param i The LDAPInterface the result is sent to
*/
- virtual void BindAsAdmin(LDAPInterface *i) = 0;
+ virtual void BindAsAdmin(LDAPInterface *i) anope_abstract;
/** Bind to LDAP
* @param i The LDAPInterface the result is sent to
* @param who The binddn
* @param pass The password
*/
- virtual void Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) = 0;
+ virtual void Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) anope_abstract;
/** Search ldap for the specified filter
* @param i The LDAPInterface the result is sent to
* @param base The base DN to search
* @param filter The filter to apply
*/
- virtual void Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) = 0;
+ virtual void Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) anope_abstract;
/** Add an entry to LDAP
* @param i The LDAPInterface the result is sent to
* @param dn The dn of the entry to add
* @param attributes The attributes
*/
- virtual void Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) = 0;
+ virtual void Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) anope_abstract;
/** Delete an entry from LDAP
* @param i The LDAPInterface the result is sent to
* @param dn The dn of the entry to delete
*/
- virtual void Del(LDAPInterface *i, const Anope::string &dn) = 0;
+ virtual void Del(LDAPInterface *i, const Anope::string &dn) anope_abstract;
/** Modify an existing entry in LDAP
* @param i The LDAPInterface the result is sent to
* @param base The base DN to modify
* @param attributes The attributes to modify
*/
- virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0;
+ virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) anope_abstract;
};
-
-#endif // ANOPE_LDAP_H
diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h
new file mode 100644
index 000000000..1268facef
--- /dev/null
+++ b/include/modules/memoserv.h
@@ -0,0 +1,165 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "module.h"
+
+namespace MemoServ
+{
+ class Ignore;
+
+ class MemoServService : public Service
+ {
+ public:
+ static constexpr const char *NAME = "memoserv";
+
+ enum MemoResult
+ {
+ MEMO_SUCCESS,
+ MEMO_INVALID_TARGET,
+ MEMO_TOO_FAST,
+ MEMO_TARGET_FULL
+ };
+
+ MemoServService(Module *m) : Service(m, "MemoServService", NAME)
+ {
+ }
+
+ /** Sends a memo.
+ * @param source The source of the memo, can be anythin.
+ * @param target The target of the memo, nick or channel.
+ * @param message Memo text
+ * @param force true to force the memo, restrictions/delays etc are not checked
+ */
+ virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) anope_abstract;
+
+ /** Check for new memos and notify the user if there are any
+ * @param u The user
+ */
+ virtual void Check(User *u) anope_abstract;
+
+ virtual MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_registered, bool &is_chan, bool create) anope_abstract;
+ };
+
+ extern MemoServService *service;
+
+ namespace Event
+ {
+ struct CoreExport MemoSend : Events
+ {
+ static constexpr const char *NAME = "memosend";
+
+ using Events::Events;
+
+ /** Called when a memo is sent
+ * @param source The source of the memo
+ * @param target The target of the memo
+ * @param mi Memo info for target
+ * @param m The memo
+ */
+ virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) anope_abstract;
+ };
+
+ struct CoreExport MemoDel : Events
+ {
+ static constexpr const char *NAME = "memodel";
+
+ using Events::Events;
+
+ /** Called when a memo is deleted
+ * @param target The target the memo is being deleted from (nick or channel)
+ * @param mi The memo info
+ * @param m The memo
+ */
+ virtual void OnMemoDel(const Anope::string &target, MemoInfo *mi, const Memo *m) anope_abstract;
+ };
+ }
+
+ class Memo : public Serialize::Object
+ {
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "memo";
+
+ virtual MemoInfo *GetMemoInfo() anope_abstract;
+ virtual void SetMemoInfo(MemoInfo *) anope_abstract;
+
+ virtual time_t GetTime() anope_abstract;
+ virtual void SetTime(const time_t &) anope_abstract;
+
+ virtual Anope::string GetSender() anope_abstract;
+ virtual void SetSender(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetText() anope_abstract;
+ virtual void SetText(const Anope::string &) anope_abstract;
+
+ virtual bool GetUnread() anope_abstract;
+ virtual void SetUnread(const bool &) anope_abstract;
+
+ virtual bool GetReceipt() anope_abstract;
+ virtual void SetReceipt(const bool &) anope_abstract;
+ };
+
+ /* Memo info structures. Since both nicknames and channels can have memos,
+ * we encapsulate memo data in a MemoInfo to make it easier to handle.
+ */
+ class MemoInfo : public Serialize::Object
+ {
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "memoinfo";
+
+ virtual Memo *GetMemo(unsigned index) anope_abstract;
+
+ virtual unsigned GetIndex(Memo *m) anope_abstract;
+
+ virtual void Del(unsigned index) anope_abstract;
+
+ virtual bool HasIgnore(User *u) anope_abstract;
+
+ virtual Serialize::Object *GetOwner() anope_abstract;
+ virtual void SetOwner(Serialize::Object *) anope_abstract;
+
+ virtual int16_t GetMemoMax() anope_abstract;
+ virtual void SetMemoMax(const int16_t &) anope_abstract;
+
+ virtual std::vector<Memo *> GetMemos() anope_abstract;
+ virtual std::vector<Ignore *> GetIgnores() anope_abstract;
+ };
+
+ class Ignore : public Serialize::Object
+ {
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "memoignore";
+
+ virtual MemoInfo *GetMemoInfo() anope_abstract;
+ virtual void SetMemoInfo(MemoInfo *) anope_abstract;
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &mask) anope_abstract;
+ };
+}
diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h
new file mode 100644
index 000000000..43e2a21ce
--- /dev/null
+++ b/include/modules/nickserv.h
@@ -0,0 +1,327 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "event.h"
+#include "service.h"
+#include "serialize.h"
+
+namespace NickServ
+{
+ class Nick;
+ class Account;
+ class IdentifyRequestListener;
+
+ using nickalias_map = Anope::locale_hash_map<Nick *>;
+ using nickcore_map = Anope::locale_hash_map<Account *>;
+
+ class NickServService : public Service
+ {
+ public:
+ NickServService(Module *m) : Service(m, "NickServService", "NickServ")
+ {
+ }
+
+ virtual void Validate(User *u) anope_abstract;
+ virtual void Collide(User *u, Nick *na) anope_abstract;
+ virtual void Release(Nick *na) anope_abstract;
+
+ virtual IdentifyRequest *CreateIdentifyRequest(IdentifyRequestListener *l, Module *owner, const Anope::string &acc, const Anope::string &pass) anope_abstract;
+ virtual std::set<IdentifyRequest *>& GetIdentifyRequests() anope_abstract;
+
+ virtual std::vector<Nick *> GetNickList() anope_abstract;
+ virtual nickalias_map& GetNickMap() anope_abstract;
+
+ virtual std::vector<Account *> GetAccountList() anope_abstract;
+ virtual nickcore_map& GetAccountMap() anope_abstract;
+
+ virtual Nick *FindNick(const Anope::string &nick) anope_abstract;
+ virtual Account *FindAccount(const Anope::string &acc) anope_abstract;
+ };
+
+ extern NickServService *service;
+
+ inline Nick *FindNick(const Anope::string &nick)
+ {
+ return service ? service->FindNick(nick) : nullptr;
+ }
+
+ inline Account *FindAccount(const Anope::string &account)
+ {
+ return service ? service->FindAccount(account) : nullptr;
+ }
+
+ namespace Event
+ {
+ struct CoreExport PreNickExpire : Events
+ {
+ static constexpr const char *NAME = "prenickexpire";
+
+ using Events::Events;
+
+ /** Called before a nick expires
+ * @param na The nick
+ * @param expire Set to true to allow the nick to expire
+ */
+ virtual void OnPreNickExpire(Nick *na, bool &expire) anope_abstract;
+ };
+
+ struct CoreExport NickExpire : Events
+ {
+ static constexpr const char *NAME = "nickexpire";
+
+ using Events::Events;
+
+ /** Called when a nick drops
+ * @param na The nick
+ */
+ virtual void OnNickExpire(Nick *na) anope_abstract;
+ };
+
+ struct CoreExport NickRegister : Events
+ {
+ static constexpr const char *NAME = "nickregister";
+
+ using Events::Events;
+
+ /** Called when a nick is registered
+ * @param user The user registering the nick, of any
+ * @param The nick
+ * @param password The password of the nick
+ */
+ virtual void OnNickRegister(User *user, Nick *na, const Anope::string &password) anope_abstract;
+ };
+
+ struct CoreExport NickConfirm : Events
+ {
+ static constexpr const char *NAME = "nickconfirm";
+
+ using Events::Events;
+
+ virtual void OnNickConfirm(User *, Account *) anope_abstract;
+ };
+
+ struct CoreExport NickValidate : Events
+ {
+ static constexpr const char *NAME = "nickvalidate";
+
+ using Events::Events;
+
+ /** Called when a nick is validated. That is, to determine if a user is permissted
+ * to be on the given nick.
+ * @param u The user
+ * @param na The nick they are on
+ * @return EVENT_STOP to force the user off of the nick
+ */
+ virtual EventReturn OnNickValidate(User *u, Nick *na) anope_abstract;
+ };
+ }
+
+ /* A registered nickname.
+ * It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Nick : public Serialize::Object
+ {
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "nick";
+
+ virtual Anope::string GetNick() anope_abstract;
+ virtual void SetNick(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLastQuit() anope_abstract;
+ virtual void SetLastQuit(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLastRealname() anope_abstract;
+ virtual void SetLastRealname(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLastUsermask() anope_abstract;
+ virtual void SetLastUsermask(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLastRealhost() anope_abstract;
+ virtual void SetLastRealhost(const Anope::string &) anope_abstract;
+
+ virtual time_t GetTimeRegistered() anope_abstract;
+ virtual void SetTimeRegistered(const time_t &) anope_abstract;
+
+ virtual time_t GetLastSeen() anope_abstract;
+ virtual void SetLastSeen(const time_t &) anope_abstract;
+
+ virtual Account *GetAccount() anope_abstract;
+ virtual void SetAccount(Account *acc) anope_abstract;
+
+ /** Set a vhost for the user
+ * @param ident The ident
+ * @param host The host
+ * @param creator Who created the vhost
+ * @param time When the vhost was craated
+ */
+ virtual void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime) anope_abstract;
+ virtual void RemoveVhost() anope_abstract;
+ virtual bool HasVhost() anope_abstract;
+
+ virtual Anope::string GetVhostIdent() anope_abstract;
+ virtual void SetVhostIdent(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetVhostHost() anope_abstract;
+ virtual void SetVhostHost(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetVhostCreator() anope_abstract;
+ virtual void SetVhostCreator(const Anope::string &) anope_abstract;
+
+ virtual time_t GetVhostCreated() anope_abstract;
+ virtual void SetVhostCreated(const time_t &) anope_abstract;
+ };
+
+ /* A registered account. Each account must have a Nick with the same nick as the
+ * account's display.
+ * It matters that Base is here before Extensible (it is inherited by Serializable)
+ */
+ class CoreExport Account : public Serialize::Object
+ {
+ public:
+ static constexpr const char *const NAME = "account";
+
+ /* Set if this user is a services operattor. o->ot must exist. */
+ Serialize::Reference<Oper> o;
+
+ /* Unsaved data */
+
+ /* Last time an email was sent to this user */
+ time_t lastmail = 0;
+ /* Users online now logged into this account */
+ std::vector<User *> users;
+
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ virtual Anope::string GetDisplay() anope_abstract;
+ virtual void SetDisplay(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetPassword() anope_abstract;
+ virtual void SetPassword(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetEmail() anope_abstract;
+ virtual void SetEmail(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetLanguage() anope_abstract;
+ virtual void SetLanguage(const Anope::string &) anope_abstract;
+
+ /** Changes the display for this account
+ * @param na The new display, must be grouped to this account.
+ */
+ virtual void SetDisplay(Nick *na) anope_abstract;
+
+ /** Checks whether this account is a services oper or not.
+ * @return True if this account is a services oper, false otherwise.
+ */
+ virtual bool IsServicesOper() const anope_abstract;
+
+ /** Is the given user on this accounts access list?
+ *
+ * @param u The user
+ *
+ * @return true if the user is on the access list
+ */
+ virtual bool IsOnAccess(User *u) anope_abstract;
+
+ virtual MemoServ::MemoInfo *GetMemos() anope_abstract;
+
+ virtual unsigned int GetChannelCount() anope_abstract;
+ };
+
+ /* A request to check if an account/password is valid. These can exist for
+ * extended periods due to the time some authentication modules take.
+ */
+ class CoreExport IdentifyRequest
+ {
+ protected:
+ /* Owner of this request, used to cleanup requests if a module is unloaded
+ * while a request us pending */
+ Module *owner;
+ IdentifyRequestListener *l;
+ Anope::string account;
+ Anope::string password;
+
+ std::set<Module *> holds;
+ bool dispatched = false;
+ bool success = false;
+
+ IdentifyRequest(IdentifyRequestListener *li, Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), l(li), account(acc), password(pass) { }
+ public:
+ virtual ~IdentifyRequest() { }
+
+ const Anope::string &GetAccount() const { return account; }
+ const Anope::string &GetPassword() const { return password; }
+ Module *GetOwner() const { return owner; }
+
+ /* Holds this request. When a request is held it must be Released later
+ * for the request to complete. Multiple modules may hold a request at any time,
+ * but the request is not complete until every module has released it. If you do not
+ * require holding this (eg, your password check is done in this thread and immediately)
+ * then you don't need to hold the request before Successing it.
+ * @param m The module holding this request
+ */
+ virtual void Hold(Module *m) anope_abstract;
+
+ /** Releases a held request
+ * @param m The module releaseing the hold
+ */
+ virtual void Release(Module *m) anope_abstract;
+
+ /** Called by modules when this IdentifyRequest has successeded successfully.
+ * If this request is behind held it must still be Released after calling this.
+ * @param m The module confirming authentication
+ */
+ virtual void Success(Module *m) anope_abstract;
+
+ /** Used to either finalize this request or marks
+ * it as dispatched and begins waiting for the module(s)
+ * that have holds to finish.
+ */
+ virtual void Dispatch() anope_abstract;
+ };
+
+ class IdentifyRequestListener
+ {
+ public:
+ virtual ~IdentifyRequestListener() { }
+ virtual void OnSuccess(IdentifyRequest *) anope_abstract;
+ virtual void OnFail(IdentifyRequest *) anope_abstract;
+ };
+
+ class Mode : public Serialize::Object
+ {
+ public:
+ static constexpr const char *const NAME = "mode";
+
+ using Serialize::Object::Object;
+
+ virtual Account *GetAccount() anope_abstract;
+ virtual void SetAccount(Account *) anope_abstract;
+
+ virtual Anope::string GetMode() anope_abstract;
+ virtual void SetMode(const Anope::string &) anope_abstract;
+ };
+
+}
diff --git a/include/modules/nickserv/access.h b/include/modules/nickserv/access.h
new file mode 100644
index 000000000..e8fb70f18
--- /dev/null
+++ b/include/modules/nickserv/access.h
@@ -0,0 +1,34 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class NickAccess : public Serialize::Object
+{
+ public:
+ static constexpr const char *const NAME = "nsaccess";
+
+ using Serialize::Object::Object;
+
+ virtual NickServ::Account *GetAccount() anope_abstract;
+ virtual void SetAccount(NickServ::Account *) anope_abstract;
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+};
+
+
diff --git a/include/modules/nickserv/ajoin.h b/include/modules/nickserv/ajoin.h
new file mode 100644
index 000000000..c23eecbe9
--- /dev/null
+++ b/include/modules/nickserv/ajoin.h
@@ -0,0 +1,37 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class AutoJoin : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "autojoin";
+
+ virtual NickServ::Account *GetOwner() anope_abstract;
+ virtual void SetOwner(NickServ::Account *acc) anope_abstract;
+
+ virtual Anope::string GetChannel() anope_abstract;
+ virtual void SetChannel(const Anope::string &c) anope_abstract;
+
+ virtual Anope::string GetKey() anope_abstract;
+ virtual void SetKey(const Anope::string &k) anope_abstract;
+};
+
diff --git a/include/modules/nickserv/cert.h b/include/modules/nickserv/cert.h
new file mode 100644
index 000000000..be33b3d4a
--- /dev/null
+++ b/include/modules/nickserv/cert.h
@@ -0,0 +1,76 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class NSCertEntry;
+
+class CertService : public Service
+{
+ public:
+ static constexpr const char *NAME = "certs";
+
+ CertService(Module *c) : Service(c, NAME) { }
+
+ virtual NickServ::Account* FindAccountFromCert(const Anope::string &cert) anope_abstract;
+
+ virtual bool Matches(User *, NickServ::Account *) anope_abstract;
+
+ virtual NSCertEntry *FindCert(const std::vector<NSCertEntry *> &cl, const Anope::string &certfp) anope_abstract;
+};
+
+class NSCertEntry : public Serialize::Object
+{
+ public:
+ static constexpr const char *NAME = "nscert";
+
+ using Serialize::Object::Object;
+
+ virtual NickServ::Account *GetAccount() anope_abstract;
+ virtual void SetAccount(NickServ::Account *) anope_abstract;
+
+ virtual Anope::string GetCert() anope_abstract;
+ virtual void SetCert(const Anope::string &) anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport NickCertEvents : Events
+ {
+ static constexpr const char *NAME = "nickcertevents";
+
+ using Events::Events;
+
+ /** Called when a user adds an entry to their cert list
+ * @param nc The nick
+ * @param entry The entry
+ */
+ virtual void OnNickAddCert(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
+
+ /** Called from NickServ::Account::EraseCert()
+ * @param nc pointer to the NickServ::Account
+ * @param entry The fingerprint
+ */
+ virtual void OnNickEraseCert(NickServ::Account *nc, const Anope::string &entry) anope_abstract;
+
+ /** called from NickServ::Account::ClearCert()
+ * @param nc pointer to the NickServ::Account
+ */
+ virtual void OnNickClearCert(NickServ::Account *nc) anope_abstract;
+ };
+}
+
diff --git a/include/modules/nickserv/drop.h b/include/modules/nickserv/drop.h
new file mode 100644
index 000000000..3363e63ed
--- /dev/null
+++ b/include/modules/nickserv/drop.h
@@ -0,0 +1,35 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport NickDrop : Events
+ {
+ static constexpr const char *NAME = "nickdrop";
+
+ using Events::Events;
+
+ /** Called when a nick is dropped
+ * @param source The source of the command
+ * @param na The nick
+ */
+ virtual void OnNickDrop(CommandSource &source, NickServ::Nick *na) anope_abstract;
+ };
+}
+
diff --git a/include/modules/nickserv/group.h b/include/modules/nickserv/group.h
new file mode 100644
index 000000000..b403f5d4e
--- /dev/null
+++ b/include/modules/nickserv/group.h
@@ -0,0 +1,35 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport NickGroup : Events
+ {
+ static constexpr const char *NAME = "nickgroup";
+
+ using Events::Events;
+
+ /** Called when a user groups their nick
+ * @param u The user grouping
+ * @param target The target they're grouping to
+ */
+ virtual void OnNickGroup(User *u, NickServ::Nick *target) anope_abstract;
+ };
+}
+
diff --git a/include/modules/nickserv/info.h b/include/modules/nickserv/info.h
new file mode 100644
index 000000000..2a1777bd3
--- /dev/null
+++ b/include/modules/nickserv/info.h
@@ -0,0 +1,37 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport NickInfo : Events
+ {
+ static constexpr const char *NAME = "nickinfo";
+
+ using Events::Events;
+
+ /** Called when a user requests info for a nick
+ * @param source The user requesting info
+ * @param na The nick the user is requesting info from
+ * @param info Data to show the user requesting information
+ * @param show_hidden true if we should show the user everything
+ */
+ virtual void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) anope_abstract;
+ };
+}
+
diff --git a/include/modules/nickserv/set.h b/include/modules/nickserv/set.h
new file mode 100644
index 000000000..f635b81b0
--- /dev/null
+++ b/include/modules/nickserv/set.h
@@ -0,0 +1,38 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport SetNickOption : Events
+ {
+ static constexpr const char *NAME = "setnickoption";
+
+ using Events::Events;
+
+ /** Called when a nickserv/set command is used.
+ * @param source The source of the command
+ * @param cmd The command
+ * @param nc The nickcore being modifed
+ * @param setting The setting passed to the command. Probably ON/OFF.
+ * @return EVENT_STOP to halt immediately
+ */
+ virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickServ::Account *nc, const Anope::string &setting) anope_abstract;
+ };
+}
+
diff --git a/include/modules/nickserv/set_misc.h b/include/modules/nickserv/set_misc.h
new file mode 100644
index 000000000..da042e353
--- /dev/null
+++ b/include/modules/nickserv/set_misc.h
@@ -0,0 +1,37 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class NSMiscData : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "nsmiscdata";
+
+ virtual NickServ::Account *GetAccount() anope_abstract;
+ virtual void SetAccount(NickServ::Account *) anope_abstract;
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetData() anope_abstract;
+ virtual void SetData(const Anope::string &) anope_abstract;
+};
+
diff --git a/include/modules/nickserv/suspend.h b/include/modules/nickserv/suspend.h
new file mode 100644
index 000000000..c690a95f7
--- /dev/null
+++ b/include/modules/nickserv/suspend.h
@@ -0,0 +1,69 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class NSSuspendInfo : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "nssuspendinfo";
+
+ virtual NickServ::Account *GetAccount() anope_abstract;
+ virtual void SetAccount(NickServ::Account *) anope_abstract;
+
+ virtual Anope::string GetBy() anope_abstract;
+ virtual void SetBy(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual time_t GetWhen() anope_abstract;
+ virtual void SetWhen(const time_t &) anope_abstract;
+
+ virtual time_t GetExpires() anope_abstract;
+ virtual void SetExpires(const time_t &) anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport NickSuspend : Events
+ {
+ static constexpr const char *NAME = "nicksuspend";
+
+ using Events::Events;
+
+ /** Called when a nick is suspended
+ * @param na The nick alias
+ */
+ virtual void OnNickSuspend(NickServ::Nick *na) anope_abstract;
+ };
+
+ struct CoreExport NickUnsuspend : Events
+ {
+ static constexpr const char *NAME = "nickunsuspend";
+
+ using Events::Events;
+
+ /** Called when a nick is unsuspneded
+ * @param na The nick alias
+ */
+ virtual void OnNickUnsuspend(NickServ::Nick *na) anope_abstract;
+ };
+}
diff --git a/include/modules/nickserv/update.h b/include/modules/nickserv/update.h
new file mode 100644
index 000000000..0dbc1424f
--- /dev/null
+++ b/include/modules/nickserv/update.h
@@ -0,0 +1,34 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport NickUpdate : Events
+ {
+ static constexpr const char *NAME = "nickupdate";
+
+ using Events::Events;
+
+ /** Called when a user does /ns update
+ * @param u The user
+ */
+ virtual void OnNickUpdate(User *u) anope_abstract;
+ };
+}
+
diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h
deleted file mode 100644
index 637948923..000000000
--- a/include/modules/ns_cert.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* NickServ core functions
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-struct NSCertList
-{
- protected:
- NSCertList() { }
- public:
- virtual ~NSCertList() { }
-
- /** Add an entry to the nick's certificate list
- *
- * @param entry The fingerprint to add to the cert list
- *
- * Adds a new entry into the cert list.
- */
- virtual void AddCert(const Anope::string &entry) = 0;
-
- /** Get an entry from the nick's cert list by index
- *
- * @param entry Index in the certificaate list vector to retrieve
- * @return The fingerprint entry of the given index if within bounds, an empty string if the vector is empty or the index is out of bounds
- *
- * Retrieves an entry from the certificate list corresponding to the given index.
- */
- virtual Anope::string GetCert(unsigned entry) const = 0;
-
- virtual unsigned GetCertCount() const = 0;
-
- /** Find an entry in the nick's cert list
- *
- * @param entry The fingerprint to search for
- * @return True if the fingerprint is found in the cert list, false otherwise
- *
- * Search for an fingerprint within the cert list.
- */
- virtual bool FindCert(const Anope::string &entry) const = 0;
-
- /** Erase a fingerprint from the nick's certificate list
- *
- * @param entry The fingerprint to remove
- *
- * Removes the specified fingerprint from the cert list.
- */
- virtual void EraseCert(const Anope::string &entry) = 0;
-
- /** Clears the entire nick's cert list
- *
- * Deletes all the memory allocated in the certificate list vector and then clears the vector.
- */
- virtual void ClearCert() = 0;
-
- virtual void Check() = 0;
-};
-
-class CertService : public Service
-{
- public:
- CertService(Module *c) : Service(c, "CertService", "certs") { }
-
- virtual NickCore* FindAccountFromCert(const Anope::string &cert) = 0;
-};
diff --git a/include/modules/operserv/defcon.h b/include/modules/operserv/defcon.h
new file mode 100644
index 000000000..735081405
--- /dev/null
+++ b/include/modules/operserv/defcon.h
@@ -0,0 +1,34 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport DefconLevel : Events
+ {
+ static constexpr const char *NAME = "defconlevel";
+
+ using Events::Events;
+
+ /** Called when defcon level changes
+ * @param level The level
+ */
+ virtual void OnDefconLevel(int level) anope_abstract;
+ };
+}
+
diff --git a/include/modules/operserv/dns.h b/include/modules/operserv/dns.h
new file mode 100644
index 000000000..af413a92c
--- /dev/null
+++ b/include/modules/operserv/dns.h
@@ -0,0 +1,83 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class DNSZone : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "dnszone";
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+};
+
+class DNSServer : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "dnsserver";
+
+ virtual DNSZone *GetZone() anope_abstract;
+ virtual void SetZone(DNSZone *) anope_abstract;
+
+ virtual Anope::string GetName() anope_abstract;
+ virtual void SetName(const Anope::string &) anope_abstract;
+
+ virtual unsigned int GetLimit() anope_abstract;
+ virtual void SetLimit(const unsigned int &) anope_abstract;
+
+ virtual bool GetPooled() anope_abstract;
+ virtual void SetPool(const bool &) anope_abstract;
+};
+
+class DNSZoneMembership : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "dnszonemembership";
+
+ virtual DNSServer *GetServer() anope_abstract;
+ virtual void SetServer(DNSServer *) anope_abstract;
+
+ virtual DNSZone *GetZone() anope_abstract;
+ virtual void SetZone(DNSZone *) anope_abstract;
+};
+
+class DNSIP : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "dnsip";
+
+ virtual DNSServer *GetServer() anope_abstract;
+ virtual void SetServer(DNSServer *) anope_abstract;
+
+ virtual Anope::string GetIP() anope_abstract;
+ virtual void SetIP(const Anope::string &) anope_abstract;
+};
+
+
diff --git a/include/modules/operserv/forbid.h b/include/modules/operserv/forbid.h
new file mode 100644
index 000000000..2b87d707d
--- /dev/null
+++ b/include/modules/operserv/forbid.h
@@ -0,0 +1,68 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+enum ForbidType
+{
+ FT_NICK = 1,
+ FT_CHAN,
+ FT_EMAIL,
+ FT_REGISTER,
+ FT_SIZE
+};
+
+class ForbidData : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *NAME = "forbid";
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual time_t GetCreated() anope_abstract;
+ virtual void SetCreated(const time_t &) anope_abstract;
+
+ virtual time_t GetExpires() anope_abstract;
+ virtual void SetExpires(const time_t &) anope_abstract;
+
+ virtual ForbidType GetType() anope_abstract;
+ virtual void SetType(const ForbidType &) anope_abstract;
+};
+
+class ForbidService : public Service
+{
+ public:
+ static constexpr const char *NAME = "forbid";
+
+ ForbidService(Module *m) : Service(m, NAME) { }
+
+ virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) anope_abstract;
+
+ virtual std::vector<ForbidData *> GetForbids() anope_abstract;
+};
+
+
diff --git a/include/modules/operserv/ignore.h b/include/modules/operserv/ignore.h
new file mode 100644
index 000000000..56235f6da
--- /dev/null
+++ b/include/modules/operserv/ignore.h
@@ -0,0 +1,49 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class Ignore : public Serialize::Object
+{
+ public:
+ static constexpr const char *NAME = "ignore";
+
+ using Serialize::Object::Object;
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual time_t GetTime() anope_abstract;
+ virtual void SetTime(const time_t &) anope_abstract;
+};
+
+class IgnoreService : public Service
+{
+ public:
+ static constexpr const char *NAME = "ignore";
+
+ IgnoreService(Module *c) : Service(c, NAME) { }
+
+ virtual Ignore *Find(const Anope::string &mask) anope_abstract;
+};
+
diff --git a/include/modules/operserv/info.h b/include/modules/operserv/info.h
new file mode 100644
index 000000000..0e2198880
--- /dev/null
+++ b/include/modules/operserv/info.h
@@ -0,0 +1,39 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+class OperInfo : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *const NAME = "operinfo";
+
+ virtual Serialize::Object *GetTarget() anope_abstract;
+ virtual void SetTarget(Serialize::Object *) anope_abstract;
+
+ virtual Anope::string GetInfo() anope_abstract;
+ virtual void SetInfo(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetCreator() anope_abstract;
+ virtual void SetCreator(const Anope::string &) anope_abstract;
+
+ virtual time_t GetCreated() anope_abstract;
+ virtual void SetCreated(const time_t &) anope_abstract;
+};
diff --git a/include/modules/operserv/news.h b/include/modules/operserv/news.h
new file mode 100644
index 000000000..46c720d3d
--- /dev/null
+++ b/include/modules/operserv/news.h
@@ -0,0 +1,47 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+enum NewsType
+{
+ NEWS_LOGON,
+ NEWS_RANDOM,
+ NEWS_OPER
+};
+
+class NewsItem : public Serialize::Object
+{
+ public:
+ static constexpr const char *const NAME = "newsitem";
+
+ using Serialize::Object::Object;
+
+ virtual NewsType GetNewsType() anope_abstract;
+ virtual void SetNewsType(const NewsType &) anope_abstract;
+
+ virtual Anope::string GetText() anope_abstract;
+ virtual void SetText(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetWho() anope_abstract;
+ virtual void SetWho(const Anope::string &) anope_abstract;
+
+ virtual time_t GetTime() anope_abstract;
+ virtual void SetTime(const time_t &) anope_abstract;
+};
diff --git a/include/modules/operserv/session.h b/include/modules/operserv/session.h
new file mode 100644
index 000000000..5373609a0
--- /dev/null
+++ b/include/modules/operserv/session.h
@@ -0,0 +1,97 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+struct Session
+{
+ cidr addr; /* A cidr (sockaddrs + len) representing this session */
+ unsigned int count = 1; /* Number of clients with this host */
+ unsigned int hits = 0; /* Number of subsequent kills for a host */
+
+ Session(const sockaddrs &ip, int len) : addr(ip, len) { }
+};
+
+class Exception : public Serialize::Object
+{
+ protected:
+ using Serialize::Object::Object;
+
+ public:
+ static constexpr const char *NAME = "exception";
+
+ virtual Anope::string GetMask() anope_abstract;
+ virtual void SetMask(const Anope::string &) anope_abstract;
+
+ virtual unsigned int GetLimit() anope_abstract;
+ virtual void SetLimit(unsigned int) anope_abstract;
+
+ virtual Anope::string GetWho() anope_abstract;
+ virtual void SetWho(const Anope::string &) anope_abstract;
+
+ virtual Anope::string GetReason() anope_abstract;
+ virtual void SetReason(const Anope::string &) anope_abstract;
+
+ virtual time_t GetTime() anope_abstract;
+ virtual void SetTime(const time_t &) anope_abstract;
+
+ virtual time_t GetExpires() anope_abstract;
+ virtual void SetExpires(const time_t &) anope_abstract;
+};
+
+class SessionService : public Service
+{
+ public:
+ static constexpr const char *NAME = "session";
+
+ typedef std::unordered_map<cidr, Session *, cidr::hash> SessionMap;
+
+ SessionService(Module *m) : Service(m, NAME) { }
+
+ virtual Exception *FindException(User *u) anope_abstract;
+
+ virtual Exception *FindException(const Anope::string &host) anope_abstract;
+
+ virtual Session *FindSession(const Anope::string &ip) anope_abstract;
+
+ virtual SessionMap &GetSessions() anope_abstract;
+};
+
+namespace Event
+{
+ struct CoreExport Exception : Events
+ {
+ static constexpr const char *NAME = "exception";
+
+ using Events::Events;
+
+ /** Called after an exception has been added
+ * @param ex The exception
+ * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
+ */
+ virtual EventReturn OnExceptionAdd(::Exception *ex) anope_abstract;
+
+ /** Called before an exception is deleted
+ * @param source The source deleting it
+ * @param ex The exceotion
+ */
+ virtual void OnExceptionDel(CommandSource &source, ::Exception *ex) anope_abstract;
+ };
+}
+
diff --git a/include/modules/operserv/stats.h b/include/modules/operserv/stats.h
new file mode 100644
index 000000000..9e6878c73
--- /dev/null
+++ b/include/modules/operserv/stats.h
@@ -0,0 +1,35 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+class Stats : public Serialize::Object
+{
+ public:
+ static constexpr const char *const NAME = "stats";
+
+ using Serialize::Object::Object;
+
+ virtual unsigned int GetMaxUserCount() anope_abstract;
+ virtual void SetMaxUserCount(unsigned int i) anope_abstract;
+
+ virtual time_t GetMaxUserTime() anope_abstract;
+ virtual void SetMaxUserTime(time_t t) anope_abstract;
+};
+
diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h
deleted file mode 100644
index b4702d844..000000000
--- a/include/modules/os_forbid.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef OS_FORBID_H
-#define OS_FORBID_H
-
-enum ForbidType
-{
- FT_NICK = 1,
- FT_CHAN,
- FT_EMAIL,
- FT_REGISTER,
- FT_SIZE
-};
-
-struct ForbidData
-{
- Anope::string mask;
- Anope::string creator;
- Anope::string reason;
- time_t created;
- time_t expires;
- ForbidType type;
-
- virtual ~ForbidData() { }
- protected:
- ForbidData() : created(0), expires(0) { }
-};
-
-class ForbidService : public Service
-{
- public:
- ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { }
-
- virtual void AddForbid(ForbidData *d) = 0;
-
- virtual void RemoveForbid(ForbidData *d) = 0;
-
- virtual ForbidData* CreateForbid() = 0;
-
- virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0;
-
- virtual std::vector<ForbidData *> GetForbids() = 0;
-};
-
-static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid");
-
-#endif
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
deleted file mode 100644
index 9ba07a92d..000000000
--- a/include/modules/os_ignore.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* OperServ ignore interface
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-struct IgnoreData
-{
- Anope::string mask;
- Anope::string creator;
- Anope::string reason;
- time_t time; /* When do we stop ignoring them? */
-
- virtual ~IgnoreData() { }
- protected:
- IgnoreData() : time(0) { }
-};
-
-class IgnoreService : public Service
-{
- protected:
- IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { }
-
- public:
- virtual void AddIgnore(IgnoreData *) = 0;
-
- virtual void DelIgnore(IgnoreData *) = 0;
-
- virtual void ClearIgnores() = 0;
-
- virtual IgnoreData *Create() = 0;
-
- virtual IgnoreData *Find(const Anope::string &mask) = 0;
-
- virtual std::vector<IgnoreData *> &GetIgnores() = 0;
-};
-
-static ServiceReference<IgnoreService> ignore_service("IgnoreService", "ignore");
diff --git a/include/modules/os_news.h b/include/modules/os_news.h
deleted file mode 100644
index e7303850a..000000000
--- a/include/modules/os_news.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef OS_NEWS
-#define OS_NEWS
-
-enum NewsType
-{
- NEWS_LOGON,
- NEWS_RANDOM,
- NEWS_OPER
-};
-
-struct NewsMessages
-{
- NewsType type;
- Anope::string name;
- const char *msgs[10];
-};
-
-struct NewsItem : Serializable
-{
- NewsType type;
- Anope::string text;
- Anope::string who;
- time_t time;
-
- NewsItem() : Serializable("NewsItem") { }
-};
-
-class NewsService : public Service
-{
- public:
- NewsService(Module *m) : Service(m, "NewsService", "news") { }
-
- virtual NewsItem *CreateNewsItem() = 0;
-
- virtual void AddNewsItem(NewsItem *n) = 0;
-
- virtual void DelNewsItem(NewsItem *n) = 0;
-
- virtual std::vector<NewsItem *> &GetNewsList(NewsType t) = 0;
-};
-
-static ServiceReference<NewsService> news_service("NewsService", "news");
-
-#endif // OS_NEWS
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
deleted file mode 100644
index a1bab86ad..000000000
--- a/include/modules/os_session.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef OS_SESSION_H
-#define OS_SESSION_H
-
-struct Session
-{
- cidr addr; /* A cidr (sockaddrs + len) representing this session */
- unsigned count; /* Number of clients with this host */
- unsigned hits; /* Number of subsequent kills for a host */
-
- Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { }
-};
-
-struct Exception : Serializable
-{
- Anope::string mask; /* Hosts to which this exception applies */
- unsigned limit; /* Session limit for exception */
- Anope::string who; /* Nick of person who added the exception */
- Anope::string reason; /* Reason for exception's addition */
- time_t time; /* When this exception was added */
- time_t expires; /* Time when it expires. 0 == no expiry */
-
- Exception() : Serializable("Exception") { }
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
-};
-
-class SessionService : public Service
-{
- public:
- typedef TR1NS::unordered_map<cidr, Session *, cidr::hash> SessionMap;
- typedef std::vector<Exception *> ExceptionVector;
-
- SessionService(Module *m) : Service(m, "SessionService", "session") { }
-
- virtual Exception *CreateException() = 0;
-
- virtual void AddException(Exception *e) = 0;
-
- virtual void DelException(Exception *e) = 0;
-
- virtual Exception *FindException(User *u) = 0;
-
- virtual Exception *FindException(const Anope::string &host) = 0;
-
- virtual ExceptionVector &GetExceptions() = 0;
-
- virtual Session *FindSession(const Anope::string &ip) = 0;
-
- virtual SessionMap &GetSessions() = 0;
-};
-
-static ServiceReference<SessionService> session_service("SessionService", "session");
-
-void Exception::Serialize(Serialize::Data &data) const
-{
- data["mask"] << this->mask;
- data["limit"] << this->limit;
- data["who"] << this->who;
- data["reason"] << this->reason;
- data["time"] << this->time;
- data["expires"] << this->expires;
-}
-
-Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data)
-{
- if (!session_service)
- return NULL;
-
- Exception *ex;
- if (obj)
- ex = anope_dynamic_static_cast<Exception *>(obj);
- else
- ex = new Exception;
- data["mask"] >> ex->mask;
- data["limit"] >> ex->limit;
- data["who"] >> ex->who;
- data["reason"] >> ex->reason;
- data["time"] >> ex->time;
- data["expires"] >> ex->expires;
-
- if (!obj)
- session_service->AddException(ex);
- return ex;
-}
-
-#endif
diff --git a/include/modules/protocol/charybdis.h b/include/modules/protocol/charybdis.h
new file mode 100644
index 000000000..36de05544
--- /dev/null
+++ b/include/modules/protocol/charybdis.h
@@ -0,0 +1,60 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+namespace charybdis
+{
+
+class Encap : public IRCDMessage
+{
+ ServiceReference<SASL::Service> sasl;
+
+ public:
+ Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT);}
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class EUID : public IRCDMessage
+{
+ public:
+ EUID(Module *creator) : IRCDMessage(creator, "EUID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Server : public IRCDMessage
+{
+ public:
+ Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ // SERVER dev.anope.de 1 :charybdis test server
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Pass : public IRCDMessage
+{
+ public:
+ Pass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+} // namespace charybdis
diff --git a/include/modules/protocol/hybrid.h b/include/modules/protocol/hybrid.h
new file mode 100644
index 000000000..4991ec624
--- /dev/null
+++ b/include/modules/protocol/hybrid.h
@@ -0,0 +1,129 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+namespace hybrid
+{
+
+class BMask : public IRCDMessage
+{
+ public:
+ BMask(Module *creator) : IRCDMessage(creator, "BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class EOB : public IRCDMessage
+{
+ public:
+ EOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Join : public Message::Join
+{
+ public:
+ Join(Module *creator) : Message::Join(creator, "JOIN") { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Nick : public IRCDMessage
+{
+ public:
+ Nick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Pong : public IRCDMessage
+{
+ public:
+ Pong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Server : public IRCDMessage
+{
+ public:
+ Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class SID : public IRCDMessage
+{
+ public:
+ SID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class SJoin : public IRCDMessage
+{
+ public:
+ SJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class SVSMode : public IRCDMessage
+{
+ public:
+ SVSMode(Module *creator) : IRCDMessage(creator, "SVSMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class TBurst : public IRCDMessage
+{
+ public:
+ TBurst(Module *creator) : IRCDMessage(creator, "TBURST", 5) { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class TMode : public IRCDMessage
+{
+ public:
+ TMode(Module *creator) : IRCDMessage(creator, "TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class UID : public IRCDMessage
+{
+ public:
+ UID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class CertFP : public IRCDMessage
+{
+ public:
+ CertFP(Module *creator) : IRCDMessage(creator, "CERTFP", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+} // namespace hybrid \ No newline at end of file
diff --git a/include/modules/protocol/plexus.h b/include/modules/protocol/plexus.h
new file mode 100644
index 000000000..1d6f79780
--- /dev/null
+++ b/include/modules/protocol/plexus.h
@@ -0,0 +1,50 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+namespace plexus
+{
+
+class Encap : public IRCDMessage
+{
+ public:
+ Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Server : public IRCDMessage
+{
+ public:
+ Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class UID : public IRCDMessage
+{
+ public:
+ UID(Module *creator) : IRCDMessage(creator, "UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+}
+
diff --git a/include/modules/protocol/ratbox.h b/include/modules/protocol/ratbox.h
new file mode 100644
index 000000000..d5101321a
--- /dev/null
+++ b/include/modules/protocol/ratbox.h
@@ -0,0 +1,66 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+namespace ratbox
+{
+
+class Encap : public IRCDMessage
+{
+ public:
+ Encap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+
+ // Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Join : public Message::Join
+{
+ public:
+ Join(Module *creator) : Message::Join(creator, "JOIN") { }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class Server : public IRCDMessage
+{
+ public:
+ Server(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class TB : public IRCDMessage
+{
+ public:
+ TB(Module *creator) : IRCDMessage(creator, "TB", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+class UID : public IRCDMessage
+{
+ public:
+ UID(Module *creator) : IRCDMessage(creator, "UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+
+ void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
+};
+
+} // namespace ratbox
diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h
deleted file mode 100644
index a10e07939..000000000
--- a/include/modules/pseudoclients/chanserv.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef CHANSERV_H
-#define CHANSERV_H
-
-class ChanServService : public Service
-{
- public:
- ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ")
- {
- }
-
- /* Have ChanServ hold the channel, that is, join and set +nsti and wait
- * for a few minutes so no one can join or rejoin.
- */
- virtual void Hold(Channel *c) = 0;
-};
-
-#endif // CHANSERV_H
diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h
deleted file mode 100644
index c557ce099..000000000
--- a/include/modules/pseudoclients/global.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-class GlobalService : public Service
-{
- public:
- GlobalService(Module *m) : Service(m, "GlobalService", "Global")
- {
- }
-
- /** Send out a global message to all users
- * @param sender Our client which should send the global
- * @param source The sender of the global
- * @param message The message
- */
- virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
-};
-
-#endif // GLOBAL_H
diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h
deleted file mode 100644
index abfbc3344..000000000
--- a/include/modules/pseudoclients/memoserv.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef MEMOSERV_H
-#define MEMOSERV_H
-
-class MemoServService : public Service
-{
- public:
- enum MemoResult
- {
- MEMO_SUCCESS,
- MEMO_INVALID_TARGET,
- MEMO_TOO_FAST,
- MEMO_TARGET_FULL
- };
-
- MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ")
- {
- }
-
- /** Sends a memo.
- * @param source The source of the memo, can be anythin.
- * @param target The target of the memo, nick or channel.
- * @param message Memo text
- * @param force true to force the memo, restrictions/delays etc are not checked
- */
- virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0;
-
- /** Check for new memos and notify the user if there are any
- * @param u The user
- */
- virtual void Check(User *u) = 0;
-};
-
-#endif // MEMOSERV_H
diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h
deleted file mode 100644
index 1b1d3e422..000000000
--- a/include/modules/pseudoclients/nickserv.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *
- * (C) 2011-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef NICKSERV_H
-#define NICKSERV_H
-
-class NickServService : public Service
-{
- public:
- NickServService(Module *m) : Service(m, "NickServService", "NickServ")
- {
- }
-
- virtual void Validate(User *u) = 0;
- virtual void Collide(User *u, NickAlias *na) = 0;
- virtual void Release(NickAlias *na) = 0;
-};
-
-#endif // NICKSERV_H
diff --git a/include/modules/redis.h b/include/modules/redis.h
index 2f530735b..dc8c1e75f 100644
--- a/include/modules/redis.h
+++ b/include/modules/redis.h
@@ -1,9 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2013-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
namespace Redis
@@ -23,7 +34,7 @@ namespace Redis
Reply() { Clear(); }
~Reply() { Clear(); }
-
+
void Clear()
{
type = NOT_PARSED;
@@ -47,26 +58,40 @@ namespace Redis
Module *owner;
Interface(Module *m) : owner(m) { }
- virtual ~Interface() { }
+ virtual ~Interface() = default;
- virtual void OnResult(const Reply &r) = 0;
+ virtual void OnResult(const Reply &r) anope_abstract;
virtual void OnError(const Anope::string &error) { Log(owner) << error; }
};
+ class FInterface : public Interface
+ {
+ public:
+ using Func = std::function<void(const Reply &)>;
+ Func function;
+
+ FInterface(Module *m, Func f) : Interface(m), function(f) { }
+
+ void OnResult(const Reply &r) override { function(r); }
+ };
+
class Provider : public Service
{
public:
- Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { }
+ static constexpr const char *NAME = "redis";
+
+ Provider(Module *c, const Anope::string &n) : Service(c, NAME, n) { }
- virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0;
- virtual void SendCommand(Interface *i, const Anope::string &str) = 0;
+ virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) anope_abstract;
+ virtual void SendCommand(Interface *i, const Anope::string &str) anope_abstract;
- virtual bool BlockAndProcess() = 0;
+ virtual bool BlockAndProcess() anope_abstract;
- virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0;
- virtual void Unsubscribe(const Anope::string &pattern) = 0;
+ virtual void Subscribe(Interface *i, const Anope::string &) anope_abstract;
+ virtual void Unsubscribe(const Anope::string &pattern) anope_abstract;
- virtual void StartTransaction() = 0;
- virtual void CommitTransaction() = 0;
+ virtual void StartTransaction() anope_abstract;
+ virtual void CommitTransaction() anope_abstract;
};
}
+
diff --git a/include/modules/sasl.h b/include/modules/sasl.h
index 6cb1d21c9..50808b9ea 100644
--- a/include/modules/sasl.h
+++ b/include/modules/sasl.h
@@ -1,9 +1,20 @@
/*
+ * Anope IRC Services
*
- * (C) 2014-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2014-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
namespace SASL
@@ -23,105 +34,74 @@ namespace SASL
class Service : public ::Service
{
public:
- Service(Module *o) : ::Service(o, "SASL::Service", "sasl") { }
+ static constexpr const char *NAME = "sasl";
+
+ Service(Module *o) : ::Service(o, NAME) { }
- virtual void ProcessMessage(const Message &) = 0;
+ virtual void ProcessMessage(const Message &) anope_abstract;
- virtual Anope::string GetAgent() = 0;
+ virtual Anope::string GetAgent() anope_abstract;
- virtual Session* GetSession(const Anope::string &uid) = 0;
+ virtual Session* GetSession(const Anope::string &uid) anope_abstract;
- virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0;
+ virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) anope_abstract;
- virtual void Succeed(Session *, NickCore *) = 0;
- virtual void Fail(Session *) = 0;
- virtual void SendMechs(Session *) = 0;
- virtual void DeleteSessions(Mechanism *, bool = false) = 0;
- virtual void RemoveSession(Session *) = 0;
+ virtual void Succeed(Session *, NickServ::Account *) anope_abstract;
+ virtual void Fail(Session *) anope_abstract;
+ virtual void SendMechs(Session *) anope_abstract;
+ virtual void DeleteSessions(Mechanism *, bool = false) anope_abstract;
+ virtual void RemoveSession(Session *) anope_abstract;
};
- static ServiceReference<SASL::Service> sasl("SASL::Service", "sasl");
-
- struct Session
+ class Session
{
+ SASL::Service *service;
+
+ public:
time_t created;
Anope::string uid;
Reference<Mechanism> mech;
- Session(Mechanism *m, const Anope::string &u) : created(Anope::CurTime), uid(u), mech(m) { }
+ Session(SASL::Service *s, Mechanism *m, const Anope::string &u) : service(s), created(Anope::CurTime), uid(u), mech(m) { }
+
virtual ~Session()
{
- if (sasl)
- sasl->RemoveSession(this);
+ service->RemoveSession(this);
}
};
/* PLAIN, EXTERNAL, etc */
class Mechanism : public ::Service
{
+ SASL::Service *service;
+
public:
- Mechanism(Module *o, const Anope::string &sname) : Service(o, "SASL::Mechanism", sname) { }
+ static constexpr const char *NAME = "sasl/mechanism";
+
+ Mechanism(SASL::Service *s, Module *o, const Anope::string &sname) : Service(o, NAME, sname), service(s) { }
+
+ SASL::Service *GetService() const { return service; }
- virtual Session* CreateSession(const Anope::string &uid) { return new Session(this, uid); }
+ virtual Session* CreateSession(const Anope::string &uid) { return new Session(service, this, uid); }
- virtual void ProcessMessage(Session *session, const Message &) = 0;
+ virtual void ProcessMessage(Session *session, const Message &) anope_abstract;
virtual ~Mechanism()
{
- if (sasl)
- sasl->DeleteSessions(this, true);
+ service->DeleteSessions(this, true);
}
};
- class IdentifyRequest : public ::IdentifyRequest
+ class IdentifyRequestListener : public NickServ::IdentifyRequestListener
{
+ SASL::Service *service = nullptr;
Anope::string uid;
public:
- IdentifyRequest(Module *m, const Anope::string &id, const Anope::string &acc, const Anope::string &pass) : ::IdentifyRequest(m, acc, pass), uid(id) { }
+ IdentifyRequestListener(SASL::Service *s, const Anope::string &id) : service(s), uid(id) { }
- void OnSuccess() anope_override
- {
- if (!sasl)
- return;
-
- NickAlias *na = NickAlias::Find(GetAccount());
- if (!na || na->nc->HasExt("NS_SUSPENDED"))
- return OnFail();
-
- unsigned int maxlogins = Config->GetModule("ns_identify")->Get<unsigned int>("maxlogins");
- if (maxlogins && na->nc->users.size() >= maxlogins)
- return OnFail();
-
- Session *s = sasl->GetSession(uid);
- if (s)
- {
- Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << this->GetAccount() << " using SASL";
- sasl->Succeed(s, na->nc);
- delete s;
- }
- }
+ void OnSuccess(NickServ::IdentifyRequest *req) override;
- void OnFail() anope_override
- {
- if (!sasl)
- return;
-
- Session *s = sasl->GetSession(uid);
- if (s)
- {
- sasl->Fail(s);
- delete s;
- }
-
- Anope::string accountstatus;
- NickAlias *na = NickAlias::Find(GetAccount());
- if (!na)
- accountstatus = "nonexistent ";
- else if (na->nc->HasExt("NS_SUSPENDED"))
- accountstatus = "suspended ";
-
- Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify for " << accountstatus << "account " << this->GetAccount() << " using SASL";
- }
+ void OnFail(NickServ::IdentifyRequest *req) override;
};
}
diff --git a/include/modules/set_misc.h b/include/modules/set_misc.h
deleted file mode 100644
index f925119e2..000000000
--- a/include/modules/set_misc.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-struct MiscData
-{
- Anope::string object;
- Anope::string name;
- Anope::string data;
-
- MiscData() { }
- virtual ~MiscData() { }
-};
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 375de14b6..2e84db152 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -1,80 +1,24 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
namespace SQL
{
-
- class Data : public Serialize::Data
- {
- public:
- typedef std::map<Anope::string, std::stringstream *> Map;
- Map data;
- std::map<Anope::string, Type> types;
-
- ~Data()
- {
- Clear();
- }
-
- std::iostream& operator[](const Anope::string &key) anope_override
- {
- std::stringstream *&ss = data[key];
- if (!ss)
- ss = new std::stringstream();
- return *ss;
- }
-
- std::set<Anope::string> KeySet() const anope_override
- {
- std::set<Anope::string> keys;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- keys.insert(it->first);
- return keys;
- }
-
- size_t Hash() const anope_override
- {
- size_t hash = 0;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- if (!it->second->str().empty())
- hash ^= Anope::hash_cs()(it->second->str());
- return hash;
- }
-
- std::map<Anope::string, std::iostream *> GetData() const
- {
- std::map<Anope::string, std::iostream *> d;
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- d[it->first] = it->second;
- return d;
- }
-
- void Clear()
- {
- for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it)
- delete it->second;
- this->data.clear();
- }
-
- void SetType(const Anope::string &key, Type t) anope_override
- {
- this->types[key] = t;
- }
-
- Type GetType(const Anope::string &key) const anope_override
- {
- std::map<Anope::string, Type>::const_iterator it = this->types.find(key);
- if (it != this->types.end())
- return it->second;
- return DT_TEXT;
- }
- };
-
/** A SQL exception, can be thrown at various points
*/
class Exception : public ModuleException
@@ -92,6 +36,7 @@ namespace SQL
{
Anope::string data;
bool escape;
+ bool null;
};
struct Query
@@ -129,15 +74,41 @@ namespace SQL
}
catch (const ConvertException &ex) { }
}
+
+ void SetNull(const Anope::string &key)
+ {
+ QueryData &qd = this->parameters[key];
+
+ qd.data = "";
+ qd.escape = false;
+ qd.null = true;
+ }
+
+ Anope::string Unsafe() const
+ {
+ Anope::string q = query;
+ for (auto it = parameters.begin(); it != parameters.end(); ++it)
+ q = q.replace_all_cs("@" + it->first + "@", it->second.data);
+ return q;
+ }
};
/** A result from a SQL query
*/
class Result
{
+ public:
+ struct Value
+ {
+ bool null = false;
+ Anope::string value;
+ };
+
protected:
- /* Rows, column, item */
- std::vector<std::map<Anope::string, Anope::string> > entries;
+ std::vector<Anope::string> columns;
+ // row, column
+ std::vector<std::vector<Value>> values;
+
Query query;
Anope::string error;
public:
@@ -149,17 +120,20 @@ namespace SQL
inline operator bool() const { return this->error.empty(); }
- inline const unsigned int GetID() const { return this->id; }
+ inline unsigned int GetID() const { return this->id; }
inline const Query &GetQuery() const { return this->query; }
inline const Anope::string &GetError() const { return this->error; }
- int Rows() const { return this->entries.size(); }
+ int Rows() const
+ {
+ return this->values.size();
+ }
- const std::map<Anope::string, Anope::string> &Row(size_t index) const
+ const std::vector<Value> &Row(size_t index) const
{
try
{
- return this->entries.at(index);
+ return this->values.at(index);
}
catch (const std::out_of_range &)
{
@@ -167,15 +141,35 @@ namespace SQL
}
}
- const Anope::string Get(size_t index, const Anope::string &col) const
+ const Value &GetValue(size_t index, const Anope::string &col) const
{
- const std::map<Anope::string, Anope::string> rows = this->Row(index);
+ const std::vector<Value> &v = this->Row(index);
- std::map<Anope::string, Anope::string>::const_iterator it = rows.find(col);
- if (it == rows.end())
+ auto it = std::find(this->columns.begin(), this->columns.end(), col);
+ if (it == this->columns.end())
throw Exception("Unknown column name in SQLResult: " + col);
+ unsigned int col_idx = it - this->columns.begin();
- return it->second;
+ try
+ {
+ return v[col_idx];
+ }
+ catch (const std::out_of_range &)
+ {
+ throw Exception("Out of bounds access to SQLResult");
+ }
+ }
+
+ const Anope::string &Get(size_t index, const Anope::string &col) const
+ {
+ const Value &value = GetValue(index, col);
+ return value.value;
+ }
+
+ bool IsNull(size_t index, const Anope::string &col) const
+ {
+ const Value &value = GetValue(index, col);
+ return value.null;
}
};
@@ -189,8 +183,8 @@ namespace SQL
Interface(Module *m) : owner(m) { }
virtual ~Interface() { }
- virtual void OnResult(const Result &r) = 0;
- virtual void OnError(const Result &r) = 0;
+ virtual void OnResult(const Result &r) anope_abstract;
+ virtual void OnError(const Result &r) anope_abstract;
};
/** Class providing the SQL service, modules call this to execute queries
@@ -198,19 +192,27 @@ namespace SQL
class Provider : public Service
{
public:
- Provider(Module *c, const Anope::string &n) : Service(c, "SQL::Provider", n) { }
+ static constexpr const char *NAME = "sql";
+
+ Provider(Module *c, const Anope::string &n) : Service(c, NAME, n) { }
- virtual void Run(Interface *i, const Query &query) = 0;
+ virtual void Run(Interface *i, const Query &query) anope_abstract;
- virtual Result RunQuery(const Query &query) = 0;
+ virtual Result RunQuery(const Query &query) anope_abstract;
- virtual std::vector<Query> CreateTable(const Anope::string &table, const Data &data) = 0;
+ virtual std::vector<Query> InitSchema(const Anope::string &prefix) anope_abstract;
+ virtual std::vector<Query> Replace(const Anope::string &table, const Query &, const std::set<Anope::string> &) anope_abstract;
+ virtual std::vector<Query> CreateTable(const Anope::string &prefix, const Anope::string &table) anope_abstract;
+ virtual std::vector<Query> AlterTable(const Anope::string &, const Anope::string &table, const Anope::string &field, bool object) anope_abstract;
+ virtual std::vector<Query> CreateIndex(const Anope::string &table, const Anope::string &field) anope_abstract;
- virtual Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) = 0;
+ virtual Query BeginTransaction() anope_abstract;
+ virtual Query Commit() anope_abstract;
- virtual Query GetTables(const Anope::string &prefix) = 0;
+ virtual Serialize::ID GetID(const Anope::string &) anope_abstract;
- virtual Anope::string FromUnixtime(time_t) = 0;
+ virtual Query GetTables(const Anope::string &prefix) anope_abstract;
};
}
+
diff --git a/include/modules/ssl.h b/include/modules/ssl.h
index d682933b5..f3bc2b067 100644
--- a/include/modules/ssl.h
+++ b/include/modules/ssl.h
@@ -1,15 +1,31 @@
/*
+ * Anope IRC Services
*
- * (C) 2010-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
+#pragma once
+
class SSLService : public Service
{
public:
- SSLService(Module *o, const Anope::string &n) : Service(o, "SSLService", n) { }
+ static constexpr const char *NAME = "ssl";
- virtual void Init(Socket *s) = 0;
+ SSLService(Module *o, const Anope::string &n) : Service(o, NAME, n) { }
+
+ virtual void Init(Socket *s) anope_abstract;
};
+
diff --git a/include/modules/suspend.h b/include/modules/suspend.h
deleted file mode 100644
index c5255b317..000000000
--- a/include/modules/suspend.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-struct SuspendInfo
-{
- Anope::string what, by, reason;
- time_t when, expires;
-
- SuspendInfo() { }
- virtual ~SuspendInfo() { }
-};
diff --git a/include/modules/xmlrpc.h b/include/modules/xmlrpc.h
index 87fa353ed..2e943f70f 100644
--- a/include/modules/xmlrpc.h
+++ b/include/modules/xmlrpc.h
@@ -1,11 +1,24 @@
/*
+ * Anope IRC Services
*
- * (C) 2010-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
+#pragma once
+
#include "httpd.h"
class XMLRPCRequest
@@ -17,7 +30,7 @@ class XMLRPCRequest
Anope::string id;
std::deque<Anope::string> data;
HTTPReply& r;
-
+
XMLRPCRequest(HTTPReply &_r) : r(_r) { }
inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }
@@ -29,19 +42,22 @@ class XMLRPCEvent
{
public:
virtual ~XMLRPCEvent() { }
- virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0;
+ virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) anope_abstract;
};
class XMLRPCServiceInterface : public Service
{
public:
- XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "XMLRPCServiceInterface", sname) { }
+ static constexpr const char *NAME = "XMLRPCServiceInterface";
+
+ XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, NAME) { }
- virtual void Register(XMLRPCEvent *event) = 0;
+ virtual void Register(XMLRPCEvent *event) anope_abstract;
- virtual void Unregister(XMLRPCEvent *event) = 0;
+ virtual void Unregister(XMLRPCEvent *event) anope_abstract;
- virtual Anope::string Sanitize(const Anope::string &string) = 0;
+ virtual Anope::string Sanitize(const Anope::string &string) anope_abstract;
- virtual void Reply(XMLRPCRequest &request) = 0;
+ virtual void Reply(XMLRPCRequest &request) anope_abstract;
};
+
diff --git a/include/opertype.h b/include/opertype.h
index 3727bdb2c..da8460e44 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -1,39 +1,64 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
- * (C) 2008-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
+ * Copyright (C) 2009-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef OPERTYPE_H
-#define OPERTYPE_H
+#pragma once
#include "services.h"
-#include "account.h"
+#include "serialize.h"
-/* A services operator. Usually made by the configuration file, but not always.
- * NickAlias::Find(name)->nc->o == this
- */
-struct CoreExport Oper
+class Oper : public Serialize::Object
{
- /* The oper's nick */
- Anope::string name;
- /* The type of operator this operator is */
- OperType *ot;
- /* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
- bool require_oper;
- Anope::string password;
- Anope::string certfp;
- /* Hosts allowed to use this operator block */
- std::vector<Anope::string> hosts;
- Anope::string vhost;
-
- Oper(const Anope::string &n, OperType *o);
- virtual ~Oper();
-
- static std::vector<Oper *> opers;
-
+ friend class OperBlockType;
+
+ Anope::string name, password, certfp, host, vhost, type;
+ bool require_oper = false;
+
+ public:
+ static constexpr const char *const NAME = "oper";
+
+ Configuration::Conf *conf = nullptr;
+ Module *owner = nullptr;
+
+ using Serialize::Object::Object;
+
+ Anope::string GetName();
+ void SetName(const Anope::string &);
+
+ Anope::string GetPassword();
+ void SetPassword(const Anope::string &);
+
+ Anope::string GetCertFP();
+ void SetCertFP(const Anope::string &);
+
+ Anope::string GetHost();
+ void SetHost(const Anope::string &);
+
+ Anope::string GetVhost();
+ void SetVhost(const Anope::string &);
+
+ OperType *GetType();
+ void SetType(OperType *);
+
+ bool GetRequireOper();
+ void SetRequireOper(const bool &);
+
/** Find an oper block by name
* @param name The name
* @return the oper block
@@ -41,6 +66,24 @@ struct CoreExport Oper
static Oper *Find(const Anope::string &name);
};
+class OperBlockType : public Serialize::Type<Oper>
+{
+ public:
+ Serialize::Field<Oper, Anope::string> name, password, certfp, host, vhost, type;
+ Serialize::Field<Oper, bool> require_oper;
+
+ OperBlockType() : Serialize::Type<Oper>(nullptr)
+ , name(this, "name", &Oper::name)
+ , password(this, "password", &Oper::password)
+ , certfp(this, "certfp", &Oper::certfp)
+ , host(this, "host", &Oper::host)
+ , vhost(this, "vhost", &Oper::vhost)
+ , type(this, "type", &Oper::type)
+ , require_oper(this, "require_oper", &Oper::require_oper)
+ {
+ }
+};
+
class CoreExport OperType
{
private:
@@ -124,4 +167,3 @@ class CoreExport OperType
const std::list<Anope::string> GetPrivs() const;
};
-#endif // OPERTYPE_H
diff --git a/include/protocol.h b/include/protocol.h
index d8029d53d..4fdc97f0c 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -1,21 +1,30 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef PROTOCOL_H
-#define PROTOCOL_H
+#pragma once
#include "services.h"
#include "anope.h"
#include "service.h"
+class IRCMessage;
+
/* Encapsultes the IRCd protocol we are speaking. */
class CoreExport IRCDProto : public Service
{
@@ -24,6 +33,8 @@ class CoreExport IRCDProto : public Service
protected:
IRCDProto(Module *creator, const Anope::string &proto_name);
public:
+ static constexpr const char *NAME = "ircdproto";
+
virtual ~IRCDProto();
virtual void SendSVSKillInternal(const MessageSource &, User *, const Anope::string &);
@@ -40,7 +51,7 @@ class CoreExport IRCDProto : public Service
const Anope::string &GetProtocolName();
virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector<Anope::string> &);
- virtual Anope::string Format(const Anope::string &source, const Anope::string &message);
+ virtual Anope::string Format(IRCMessage &);
/* Modes used by default by our clients */
Anope::string DefaultPseudoclientModes;
@@ -104,20 +115,20 @@ class CoreExport IRCDProto : public Service
* @param u The user affected by the akill, if known
* @param x The akill
*/
- virtual void SendAkill(User *, XLine *) = 0;
- virtual void SendAkillDel(const XLine *) = 0;
+ virtual void SendAkill(User *, XLine *) anope_abstract;
+ virtual void SendAkillDel(XLine *) anope_abstract;
/* Realname ban */
- virtual void SendSGLine(User *, const XLine *) { }
- virtual void SendSGLineDel(const XLine *) { }
+ virtual void SendSGLine(User *, XLine *) { }
+ virtual void SendSGLineDel(XLine *) { }
/* IP ban */
- virtual void SendSZLine(User *u, const XLine *) { }
- virtual void SendSZLineDel(const XLine *) { }
+ virtual void SendSZLine(User *u, XLine *) { }
+ virtual void SendSZLineDel(XLine *) { }
/* Nick ban (and sometimes channel) */
- virtual void SendSQLine(User *, const XLine *x) { }
- virtual void SendSQLineDel(const XLine *x) { }
+ virtual void SendSQLine(User *, XLine *x) { }
+ virtual void SendSQLineDel(XLine *x) { }
virtual void SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason);
@@ -134,7 +145,7 @@ class CoreExport IRCDProto : public Service
/** Introduces a client to the rest of the network
* @param u The client to introduce
*/
- virtual void SendClientIntroduction(User *u) = 0;
+ virtual void SendClientIntroduction(User *u) anope_abstract;
virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...);
@@ -143,11 +154,18 @@ class CoreExport IRCDProto : public Service
virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) = 0;
- virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
+ virtual void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) anope_abstract;
+ virtual void SendGlobalPrivmsg(ServiceBot *bi, const Server *desc, const Anope::string &msg) anope_abstract;
virtual void SendQuit(User *u, const char *fmt, ...);
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
+
+ /**
+ * Send a PONG reply to a received PING.
+ * servname should be left empty to send a one param reply.
+ * @param servname Daemon or client that is responding to the PING.
+ * @param who Origin of the PING and destination of the PONG message.
+ **/
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
/** Joins one of our users to a channel.
@@ -157,7 +175,7 @@ class CoreExport IRCDProto : public Service
* be set on the user. This may include the modes in the join, but will usually place them on the mode
* stacker to be set "soon".
*/
- virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0;
+ virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) anope_abstract;
virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...);
/** Force joins a user that isn't ours to a channel.
@@ -181,7 +199,7 @@ class CoreExport IRCDProto : public Service
/** Sets oper flags on a user, currently only supported by Unreal
*/
- virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &) { }
+ virtual void SendSVSO(ServiceBot *, const Anope::string &, const Anope::string &) { }
/** Sends a nick change of one of our clients.
*/
@@ -194,8 +212,8 @@ class CoreExport IRCDProto : public Service
/** Used to introduce ourselves to our uplink. Usually will SendServer(Me) and any other
* initial handshake requirements.
*/
- virtual void SendConnect() = 0;
-
+ virtual void SendConnect() anope_abstract;
+
/** Called right before we begin our burst, after we have handshaked successfully with the uplink/
* At this point none of our servesr, users, or channels exist on the uplink
*/
@@ -209,13 +227,13 @@ class CoreExport IRCDProto : public Service
/** Introduces a server to the uplink
*/
- virtual void SendServer(const Server *) = 0;
+ virtual void SendServer(const Server *) anope_abstract;
virtual void SendSquit(Server *, const Anope::string &message);
virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
- virtual void SendLogin(User *u, NickAlias *na) = 0;
- virtual void SendLogout(User *u) = 0;
+ virtual void SendLogin(User *u, NickServ::Nick *na) anope_abstract;
+ virtual void SendLogout(User *u) anope_abstract;
/** Send a channel creation message to the uplink.
* On most TS6 IRCds this is a SJOIN with no nick
@@ -256,9 +274,10 @@ class CoreExport MessageSource
MessageSource(User *u);
MessageSource(Server *s);
const Anope::string &GetName() const;
+ const Anope::string &GetUID() const;
const Anope::string &GetSource() const;
User *GetUser() const;
- BotInfo *GetBot() const;
+ ServiceBot *GetBot() const;
Server *GetServer() const;
};
@@ -275,9 +294,11 @@ class CoreExport IRCDMessage : public Service
unsigned param_count;
std::set<IRCDMessageFlag> flags;
public:
+ static constexpr const char *NAME = "IRCDMessage";
+
IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
unsigned GetParamCount() const;
- virtual void Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
+ virtual void Run(MessageSource &, const std::vector<Anope::string> &params) anope_abstract;
void SetFlag(IRCDMessageFlag f) { flags.insert(f); }
bool HasFlag(IRCDMessageFlag f) const { return flags.count(f); }
@@ -285,4 +306,58 @@ class CoreExport IRCDMessage : public Service
extern CoreExport IRCDProto *IRCD;
-#endif // PROTOCOL_H
+class IRCMessage
+{
+ MessageSource source;
+ Anope::string command;
+ std::vector<Anope::string> parameters;
+
+ void Push() { }
+
+ public:
+ template<typename... Args>
+ IRCMessage(const MessageSource &_source, const Anope::string &_command, Args&&... args)
+ : source(_source)
+ , command(_command)
+ {
+ parameters.reserve(sizeof...(args));
+
+ Push(std::forward<Args>(args)...);
+ }
+
+ template<typename T, typename... Args>
+ void Push(const T& t, Args&&... args)
+ {
+ parameters.push_back(stringify(t));
+
+ Push(std::forward<Args>(args)...);
+ }
+
+ void TokenizeAndPush(const Anope::string &buf, char sepToken = ' ')
+ {
+ sepstream sep(buf, sepToken);
+ Anope::string token;
+ while (sep.GetToken(token))
+ Push(token);
+ }
+
+ const MessageSource &GetSource() const
+ {
+ return source;
+ }
+
+ void SetSource(const MessageSource &source)
+ {
+ this->source = source;
+ }
+
+ const Anope::string &GetCommand() const
+ {
+ return command;
+ }
+
+ const std::vector<Anope::string> &GetParameters() const
+ {
+ return parameters;
+ }
+};
diff --git a/include/pstdint.h b/include/pstdint.h
deleted file mode 100644
index a8de63fd7..000000000
--- a/include/pstdint.h
+++ /dev/null
@@ -1,800 +0,0 @@
-/* A portable stdint.h
- ****************************************************************************
- * BSD License:
- ****************************************************************************
- *
- * Copyright (c) 2005-2011 Paul Hsieh
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************
- *
- * Version 0.1.12
- *
- * The ANSI C standard committee, for the C99 standard, specified the
- * inclusion of a new standard include file called stdint.h. This is
- * a very useful and long desired include file which contains several
- * very precise definitions for integer scalar types that is
- * critically important for making portable several classes of
- * applications including cryptography, hashing, variable length
- * integer libraries and so on. But for most developers its likely
- * useful just for programming sanity.
- *
- * The problem is that most compiler vendors have decided not to
- * implement the C99 standard, and the next C++ language standard
- * (which has a lot more mindshare these days) will be a long time in
- * coming and its unknown whether or not it will include stdint.h or
- * how much adoption it will have. Either way, it will be a long time
- * before all compilers come with a stdint.h and it also does nothing
- * for the extremely large number of compilers available today which
- * do not include this file, or anything comparable to it.
- *
- * So that's what this file is all about. Its an attempt to build a
- * single universal include file that works on as many platforms as
- * possible to deliver what stdint.h is supposed to. A few things
- * that should be noted about this file:
- *
- * 1) It is not guaranteed to be portable and/or present an identical
- * interface on all platforms. The extreme variability of the
- * ANSI C standard makes this an impossibility right from the
- * very get go. Its really only meant to be useful for the vast
- * majority of platforms that possess the capability of
- * implementing usefully and precisely defined, standard sized
- * integer scalars. Systems which are not intrinsically 2s
- * complement may produce invalid constants.
- *
- * 2) There is an unavoidable use of non-reserved symbols.
- *
- * 3) Other standard include files are invoked.
- *
- * 4) This file may come in conflict with future platforms that do
- * include stdint.h. The hope is that one or the other can be
- * used with no real difference.
- *
- * 5) In the current version, if your platform can't represent
- * int32_t, int16_t and int8_t, it just dumps out with a compiler
- * error.
- *
- * 6) 64 bit integers may or may not be defined. Test for their
- * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
- * Note that this is different from the C99 specification which
- * requires the existence of 64 bit support in the compiler. If
- * this is not defined for your platform, yet it is capable of
- * dealing with 64 bits then it is because this file has not yet
- * been extended to cover all of your system's capabilities.
- *
- * 7) (u)intptr_t may or may not be defined. Test for its presence
- * with the test: #ifdef PTRDIFF_MAX. If this is not defined
- * for your platform, then it is because this file has not yet
- * been extended to cover all of your system's capabilities, not
- * because its optional.
- *
- * 8) The following might not been defined even if your platform is
- * capable of defining it:
- *
- * WCHAR_MIN
- * WCHAR_MAX
- * (u)int64_t
- * PTRDIFF_MIN
- * PTRDIFF_MAX
- * (u)intptr_t
- *
- * 9) The following have not been defined:
- *
- * WINT_MIN
- * WINT_MAX
- *
- * 10) The criteria for defining (u)int_least(*)_t isn't clear,
- * except for systems which don't have a type that precisely
- * defined 8, 16, or 32 bit types (which this include file does
- * not support anyways). Default definitions have been given.
- *
- * 11) The criteria for defining (u)int_fast(*)_t isn't something I
- * would trust to any particular compiler vendor or the ANSI C
- * committee. It is well known that "compatible systems" are
- * commonly created that have very different performance
- * characteristics from the systems they are compatible with,
- * especially those whose vendors make both the compiler and the
- * system. Default definitions have been given, but its strongly
- * recommended that users never use these definitions for any
- * reason (they do *NOT* deliver any serious guarantee of
- * improved performance -- not in this file, nor any vendor's
- * stdint.h).
- *
- * 12) The following macros:
- *
- * PRINTF_INTMAX_MODIFIER
- * PRINTF_INT64_MODIFIER
- * PRINTF_INT32_MODIFIER
- * PRINTF_INT16_MODIFIER
- * PRINTF_LEAST64_MODIFIER
- * PRINTF_LEAST32_MODIFIER
- * PRINTF_LEAST16_MODIFIER
- * PRINTF_INTPTR_MODIFIER
- *
- * are strings which have been defined as the modifiers required
- * for the "d", "u" and "x" printf formats to correctly output
- * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
- * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
- * PRINTF_INTPTR_MODIFIER is not defined for some systems which
- * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
- * defined if INT64_MAX is not defined. These are an extension
- * beyond what C99 specifies must be in stdint.h.
- *
- * In addition, the following macros are defined:
- *
- * PRINTF_INTMAX_HEX_WIDTH
- * PRINTF_INT64_HEX_WIDTH
- * PRINTF_INT32_HEX_WIDTH
- * PRINTF_INT16_HEX_WIDTH
- * PRINTF_INT8_HEX_WIDTH
- * PRINTF_INTMAX_DEC_WIDTH
- * PRINTF_INT64_DEC_WIDTH
- * PRINTF_INT32_DEC_WIDTH
- * PRINTF_INT16_DEC_WIDTH
- * PRINTF_INT8_DEC_WIDTH
- *
- * Which specifies the maximum number of characters required to
- * print the number of that type in either hexadecimal or decimal.
- * These are an extension beyond what C99 specifies must be in
- * stdint.h.
- *
- * Compilers tested (all with 0 warnings at their highest respective
- * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
- * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
- * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
- *
- * This file should be considered a work in progress. Suggestions for
- * improvements, especially those which increase coverage are strongly
- * encouraged.
- *
- * Acknowledgements
- *
- * The following people have made significant contributions to the
- * development and testing of this file:
- *
- * Chris Howie
- * John Steele Scott
- * Dave Thorup
- * John Dill
- *
- */
-
-#include <stddef.h>
-#include <limits.h>
-#include <signal.h>
-
-/*
- * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
- * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
- */
-
-#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
-#include <stdint.h>
-#define _PSTDINT_H_INCLUDED
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-# endif
-# ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-# endif
-# ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-# endif
-# ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-# endif
-# ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-# endif
-# ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-# endif
-# ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-# endif
-# ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-
-/*
- * Something really weird is going on with Open Watcom. Just pull some of
- * these duplicated definitions from Open Watcom's stdint.h file for now.
- */
-
-# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
-# if !defined (INT64_C)
-# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
-# endif
-# if !defined (UINT64_C)
-# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
-# endif
-# if !defined (INT32_C)
-# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
-# endif
-# if !defined (UINT32_C)
-# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
-# endif
-# if !defined (INT16_C)
-# define INT16_C(x) (x)
-# endif
-# if !defined (UINT16_C)
-# define UINT16_C(x) (x)
-# endif
-# if !defined (INT8_C)
-# define INT8_C(x) (x)
-# endif
-# if !defined (UINT8_C)
-# define UINT8_C(x) (x)
-# endif
-# if !defined (UINT64_MAX)
-# define UINT64_MAX 18446744073709551615ULL
-# endif
-# if !defined (INT64_MAX)
-# define INT64_MAX 9223372036854775807LL
-# endif
-# if !defined (UINT32_MAX)
-# define UINT32_MAX 4294967295UL
-# endif
-# if !defined (INT32_MAX)
-# define INT32_MAX 2147483647L
-# endif
-# if !defined (INTMAX_MAX)
-# define INTMAX_MAX INT64_MAX
-# endif
-# if !defined (INTMAX_MIN)
-# define INTMAX_MIN INT64_MIN
-# endif
-# endif
-#endif
-
-#ifndef _PSTDINT_H_INCLUDED
-#define _PSTDINT_H_INCLUDED
-
-#ifndef SIZE_MAX
-# define SIZE_MAX (~(size_t)0)
-#endif
-
-/*
- * Deduce the type assignments from limits.h under the assumption that
- * integer sizes in bits are powers of 2, and follow the ANSI
- * definitions.
- */
-
-#ifndef UINT8_MAX
-# define UINT8_MAX 0xff
-#endif
-#ifndef uint8_t
-# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
- typedef unsigned char uint8_t;
-# define UINT8_C(v) ((uint8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef INT8_MAX
-# define INT8_MAX 0x7f
-#endif
-#ifndef INT8_MIN
-# define INT8_MIN INT8_C(0x80)
-#endif
-#ifndef int8_t
-# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
- typedef signed char int8_t;
-# define INT8_C(v) ((int8_t) v)
-# else
-# error "Platform not supported"
-# endif
-#endif
-
-#ifndef UINT16_MAX
-# define UINT16_MAX 0xffff
-#endif
-#ifndef uint16_t
-#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
- typedef unsigned int uint16_t;
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-# define UINT16_C(v) ((uint16_t) (v))
-#elif (USHRT_MAX == UINT16_MAX)
- typedef unsigned short uint16_t;
-# define UINT16_C(v) ((uint16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT16_MAX
-# define INT16_MAX 0x7fff
-#endif
-#ifndef INT16_MIN
-# define INT16_MIN INT16_C(0x8000)
-#endif
-#ifndef int16_t
-#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
- typedef signed int int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT16_MAX)
- typedef signed short int16_t;
-# define INT16_C(v) ((int16_t) (v))
-# ifndef PRINTF_INT16_MODIFIER
-# define PRINTF_INT16_MODIFIER "h"
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef UINT32_MAX
-# define UINT32_MAX (0xffffffffUL)
-#endif
-#ifndef uint32_t
-#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
- typedef unsigned long uint32_t;
-# define UINT32_C(v) v ## UL
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (UINT_MAX == UINT32_MAX)
- typedef unsigned int uint32_t;
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-# define UINT32_C(v) v ## U
-#elif (USHRT_MAX == UINT32_MAX)
- typedef unsigned short uint32_t;
-# define UINT32_C(v) ((unsigned short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-#ifndef INT32_MAX
-# define INT32_MAX (0x7fffffffL)
-#endif
-#ifndef INT32_MIN
-# define INT32_MIN INT32_C(0x80000000)
-#endif
-#ifndef int32_t
-#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
- typedef signed long int32_t;
-# define INT32_C(v) v ## L
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER "l"
-# endif
-#elif (INT_MAX == INT32_MAX)
- typedef signed int int32_t;
-# define INT32_C(v) v
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#elif (SHRT_MAX == INT32_MAX)
- typedef signed short int32_t;
-# define INT32_C(v) ((short) (v))
-# ifndef PRINTF_INT32_MODIFIER
-# define PRINTF_INT32_MODIFIER ""
-# endif
-#else
-#error "Platform not supported"
-#endif
-#endif
-
-/*
- * The macro stdint_int64_defined is temporarily used to record
- * whether or not 64 integer support is available. It must be
- * defined for any 64 integer extensions for new platforms that are
- * added.
- */
-
-#undef stdint_int64_defined
-#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
-# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# endif
-#endif
-
-#if !defined (stdint_int64_defined)
-# if defined(__GNUC__)
-# define stdint_int64_defined
- __extension__ typedef long long int64_t;
- __extension__ typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
-# define stdint_int64_defined
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-# define UINT64_C(v) v ## ULL
-# define INT64_C(v) v ## LL
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "ll"
-# endif
-# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
-# define stdint_int64_defined
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
-# define UINT64_C(v) v ## UI64
-# define INT64_C(v) v ## I64
-# ifndef PRINTF_INT64_MODIFIER
-# define PRINTF_INT64_MODIFIER "I64"
-# endif
-# endif
-#endif
-
-#if !defined (LONG_LONG_MAX) && defined (INT64_C)
-# define LONG_LONG_MAX INT64_C (9223372036854775807)
-#endif
-#ifndef ULONG_LONG_MAX
-# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
-#endif
-
-#if !defined (INT64_MAX) && defined (INT64_C)
-# define INT64_MAX INT64_C (9223372036854775807)
-#endif
-#if !defined (INT64_MIN) && defined (INT64_C)
-# define INT64_MIN INT64_C (-9223372036854775808)
-#endif
-#if !defined (UINT64_MAX) && defined (INT64_C)
-# define UINT64_MAX UINT64_C (18446744073709551615)
-#endif
-
-/*
- * Width of hexadecimal for number field.
- */
-
-#ifndef PRINTF_INT64_HEX_WIDTH
-# define PRINTF_INT64_HEX_WIDTH "16"
-#endif
-#ifndef PRINTF_INT32_HEX_WIDTH
-# define PRINTF_INT32_HEX_WIDTH "8"
-#endif
-#ifndef PRINTF_INT16_HEX_WIDTH
-# define PRINTF_INT16_HEX_WIDTH "4"
-#endif
-#ifndef PRINTF_INT8_HEX_WIDTH
-# define PRINTF_INT8_HEX_WIDTH "2"
-#endif
-
-#ifndef PRINTF_INT64_DEC_WIDTH
-# define PRINTF_INT64_DEC_WIDTH "20"
-#endif
-#ifndef PRINTF_INT32_DEC_WIDTH
-# define PRINTF_INT32_DEC_WIDTH "10"
-#endif
-#ifndef PRINTF_INT16_DEC_WIDTH
-# define PRINTF_INT16_DEC_WIDTH "5"
-#endif
-#ifndef PRINTF_INT8_DEC_WIDTH
-# define PRINTF_INT8_DEC_WIDTH "3"
-#endif
-
-/*
- * Ok, lets not worry about 128 bit integers for now. Moore's law says
- * we don't need to worry about that until about 2040 at which point
- * we'll have bigger things to worry about.
- */
-
-#ifdef stdint_int64_defined
- typedef int64_t intmax_t;
- typedef uint64_t uintmax_t;
-# define INTMAX_MAX INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define UINTMAX_MAX UINT64_MAX
-# define UINTMAX_C(v) UINT64_C(v)
-# define INTMAX_C(v) INT64_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
-# endif
-#else
- typedef int32_t intmax_t;
- typedef uint32_t uintmax_t;
-# define INTMAX_MAX INT32_MAX
-# define UINTMAX_MAX UINT32_MAX
-# define UINTMAX_C(v) UINT32_C(v)
-# define INTMAX_C(v) INT32_C(v)
-# ifndef PRINTF_INTMAX_MODIFIER
-# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
-# endif
-# ifndef PRINTF_INTMAX_HEX_WIDTH
-# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
-# endif
-# ifndef PRINTF_INTMAX_DEC_WIDTH
-# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
-# endif
-#endif
-
-/*
- * Because this file currently only supports platforms which have
- * precise powers of 2 as bit sizes for the default integers, the
- * least definitions are all trivial. Its possible that a future
- * version of this file could have different definitions.
- */
-
-#ifndef stdint_least_defined
- typedef int8_t int_least8_t;
- typedef uint8_t uint_least8_t;
- typedef int16_t int_least16_t;
- typedef uint16_t uint_least16_t;
- typedef int32_t int_least32_t;
- typedef uint32_t uint_least32_t;
-# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
-# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
-# define UINT_LEAST8_MAX UINT8_MAX
-# define INT_LEAST8_MAX INT8_MAX
-# define UINT_LEAST16_MAX UINT16_MAX
-# define INT_LEAST16_MAX INT16_MAX
-# define UINT_LEAST32_MAX UINT32_MAX
-# define INT_LEAST32_MAX INT32_MAX
-# define INT_LEAST8_MIN INT8_MIN
-# define INT_LEAST16_MIN INT16_MIN
-# define INT_LEAST32_MIN INT32_MIN
-# ifdef stdint_int64_defined
- typedef int64_t int_least64_t;
- typedef uint64_t uint_least64_t;
-# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
-# define UINT_LEAST64_MAX UINT64_MAX
-# define INT_LEAST64_MAX INT64_MAX
-# define INT_LEAST64_MIN INT64_MIN
-# endif
-#endif
-#undef stdint_least_defined
-
-/*
- * The ANSI C committee pretending to know or specify anything about
- * performance is the epitome of misguided arrogance. The mandate of
- * this file is to *ONLY* ever support that absolute minimum
- * definition of the fast integer types, for compatibility purposes.
- * No extensions, and no attempt to suggest what may or may not be a
- * faster integer type will ever be made in this file. Developers are
- * warned to stay away from these types when using this or any other
- * stdint.h.
- */
-
-typedef int_least8_t int_fast8_t;
-typedef uint_least8_t uint_fast8_t;
-typedef int_least16_t int_fast16_t;
-typedef uint_least16_t uint_fast16_t;
-typedef int_least32_t int_fast32_t;
-typedef uint_least32_t uint_fast32_t;
-#define UINT_FAST8_MAX UINT_LEAST8_MAX
-#define INT_FAST8_MAX INT_LEAST8_MAX
-#define UINT_FAST16_MAX UINT_LEAST16_MAX
-#define INT_FAST16_MAX INT_LEAST16_MAX
-#define UINT_FAST32_MAX UINT_LEAST32_MAX
-#define INT_FAST32_MAX INT_LEAST32_MAX
-#define INT_FAST8_MIN INT_LEAST8_MIN
-#define INT_FAST16_MIN INT_LEAST16_MIN
-#define INT_FAST32_MIN INT_LEAST32_MIN
-#ifdef stdint_int64_defined
- typedef int_least64_t int_fast64_t;
- typedef uint_least64_t uint_fast64_t;
-# define UINT_FAST64_MAX UINT_LEAST64_MAX
-# define INT_FAST64_MAX INT_LEAST64_MAX
-# define INT_FAST64_MIN INT_LEAST64_MIN
-#endif
-
-#undef stdint_int64_defined
-
-/*
- * Whatever piecemeal, per compiler thing we can do about the wchar_t
- * type limits.
- */
-
-#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
-# include <wchar.h>
-# ifndef WCHAR_MIN
-# define WCHAR_MIN 0
-# endif
-# ifndef WCHAR_MAX
-# define WCHAR_MAX ((wchar_t)-1)
-# endif
-#endif
-
-/*
- * Whatever piecemeal, per compiler/platform thing we can do about the
- * (u)intptr_t types and limits.
- */
-
-#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-#ifndef STDINT_H_UINTPTR_T_DEFINED
-# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
-# define stdint_intptr_bits 64
-# elif defined (__WATCOMC__) || defined (__TURBOC__)
-# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
-# define stdint_intptr_bits 16
-# else
-# define stdint_intptr_bits 32
-# endif
-# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
-# define stdint_intptr_bits 32
-# elif defined (__INTEL_COMPILER)
-/* TODO -- what did Intel do about x86-64? */
-# endif
-
-# ifdef stdint_intptr_bits
-# define stdint_intptr_glue3_i(a,b,c) a##b##c
-# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
-# ifndef PRINTF_INTPTR_MODIFIER
-# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
-# endif
-# ifndef PTRDIFF_MAX
-# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef PTRDIFF_MIN
-# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef UINTPTR_MAX
-# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MAX
-# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
-# endif
-# ifndef INTPTR_MIN
-# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
-# endif
-# ifndef INTPTR_C
-# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
-# endif
-# ifndef UINTPTR_C
-# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
-# endif
- typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
- typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
-# else
-/* TODO -- This following is likely wrong for some platforms, and does
- nothing for the definition of uintptr_t. */
- typedef ptrdiff_t intptr_t;
-# endif
-# define STDINT_H_UINTPTR_T_DEFINED
-#endif
-
-/*
- * Assumes sig_atomic_t is signed and we have a 2s complement machine.
- */
-
-#ifndef SIG_ATOMIC_MAX
-# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
-#endif
-
-#endif
-
-#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
-
-/*
- * Please compile with the maximum warning settings to make sure macros are not
- * defined more than once.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define glue3_aux(x,y,z) x ## y ## z
-#define glue3(x,y,z) glue3_aux(x,y,z)
-
-#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0);
-#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0);
-
-#define DECL(us,bits) glue3(DECL,us,) (bits)
-
-#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
-
-int main () {
- DECL(I,8)
- DECL(U,8)
- DECL(I,16)
- DECL(U,16)
- DECL(I,32)
- DECL(U,32)
-#ifdef INT64_MAX
- DECL(I,64)
- DECL(U,64)
-#endif
- intmax_t imax = INTMAX_C(0);
- uintmax_t umax = UINTMAX_C(0);
- char str0[256], str1[256];
-
- sprintf (str0, "%d %x\n", 0, ~0);
-
- sprintf (str1, "%d %x\n", i8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
- sprintf (str1, "%u %x\n", u8, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
- sprintf (str1, "%d %x\n", i16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
- sprintf (str1, "%u %x\n", u16, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
- sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
-#ifdef INT64_MAX
- sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
-#endif
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
- sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
- if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
-
- TESTUMAX(8);
- TESTUMAX(16);
- TESTUMAX(32);
-#ifdef INT64_MAX
- TESTUMAX(64);
-#endif
-
- return EXIT_SUCCESS;
-}
-
-#endif
diff --git a/include/regchannel.h b/include/regchannel.h
deleted file mode 100644
index d4c3e0b59..000000000
--- a/include/regchannel.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- *
- * (C) 2008-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- */
-
-#ifndef REGCHANNEL_H
-#define REGCHANNEL_H
-
-#include "memo.h"
-#include "modes.h"
-#include "extensible.h"
-#include "logger.h"
-#include "modules.h"
-#include "serialize.h"
-#include "bots.h"
-
-typedef Anope::hash_map<ChannelInfo *> registered_channel_map;
-
-extern CoreExport Serialize::Checker<registered_channel_map> RegisteredChannelList;
-
-/* AutoKick data. */
-class CoreExport AutoKick : public Serializable
-{
- public:
- /* Channel this autokick is on */
- Serialize::Reference<ChannelInfo> ci;
-
- Anope::string mask;
- Serialize::Reference<NickCore> nc;
-
- Anope::string reason;
- Anope::string creator;
- time_t addtime;
- time_t last_used;
-
- AutoKick();
- ~AutoKick();
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-};
-
-/* It matters that Base is here before Extensible (it is inherited by Serializable)
- */
-class CoreExport ChannelInfo : public Serializable, public Extensible
-{
- /* channels who reference this one */
- Anope::map<int> references;
- private:
- Serialize::Reference<NickCore> founder; /* Channel founder */
- Serialize::Reference<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
- Serialize::Checker<std::vector<ChanAccess *> > access; /* List of authorized users */
- Serialize::Checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
- Anope::map<int16_t> levels;
-
- public:
- friend class ChanAccess;
- friend class AutoKick;
-
- Anope::string name; /* Channel name */
- Anope::string desc;
-
- time_t time_registered;
- time_t last_used;
-
- Anope::string last_topic; /* The last topic that was set on this channel */
- Anope::string last_topic_setter; /* Setter */
- time_t last_topic_time; /* Time */
-
- Channel::ModeList last_modes; /* The last modes set on this channel */
-
- int16_t bantype;
-
- MemoInfo memos;
-
- Channel *c; /* Pointer to channel, if the channel exists */
-
- /* For BotServ */
- Serialize::Reference<BotInfo> bi; /* Bot used on this channel */
-
- time_t banexpire; /* Time bans expire in */
-
- /** Constructor
- * @param chname The channel name
- */
- ChannelInfo(const Anope::string &chname);
-
- /** Copy constructor
- * @param ci The ChannelInfo to copy settings from
- */
- ChannelInfo(const ChannelInfo &ci);
-
- ~ChannelInfo();
-
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
-
- /** Change the founder of the channek
- * @params nc The new founder
- */
- void SetFounder(NickCore *nc);
-
- /** Get the founder of the channel
- * @return The founder
- */
- NickCore *GetFounder() const;
-
- void SetSuccessor(NickCore *nc);
- NickCore *GetSuccessor() const;
-
- /** Find which bot should send mode/topic/etc changes for this channel
- * @return The bot
- */
- BotInfo *WhoSends() const;
-
- /** Add an entry to the channel access list
- * @param access The entry
- */
- void AddAccess(ChanAccess *access);
-
- /** Get an entry from the channel access list by index
- *
- * @param index The index in the access list vector
- * @return A ChanAccess struct corresponding to the index given, or NULL if outside the bounds
- *
- * Retrieves an entry from the access list that matches the given 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(const User *u, bool updateLastUsed = true);
- AccessGroup AccessFor(const NickCore *nc, bool updateLastUsed = true);
-
- /** Get the size of the accss vector for this channel
- * @return The access vector size
- */
- unsigned GetAccessCount() const;
-
- /** Get the number of access entries for this channel,
- * including those that are on other channels.
- */
- unsigned GetDeepAccessCount() const;
-
- /** Erase an entry from the channel access list
- *
- * @param index The index in the access list vector
- *
- * @return The erased entry
- */
- ChanAccess *EraseAccess(unsigned index);
-
- /** Clear the entire channel access list
- *
- * Clears the entire access list by deleting every item and then clearing the vector.
- */
- void ClearAccess();
-
- /** Add an akick entry to the channel by NickCore
- * @param user The user who added the akick
- * @param akicknc The nickcore being akicked
- * @param reason The reason for the akick
- * @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);
-
- /** Add an akick entry to the channel by reason
- * @param user The user who added the akick
- * @param mask The mask of the akick
- * @param reason The reason for the akick
- * @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);
-
- /** 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) const;
-
- /** Get the size of the akick vector for this channel
- * @return The akick vector size
- */
- unsigned GetAkickCount() const;
-
- /** Erase an entry from the channel akick list
- * @param index The index of the akick
- */
- void EraseAkick(unsigned index);
-
- /** Clear the whole akick list
- */
- void ClearAkick();
-
- /** Get the level entries for the channel.
- * @return The levels for the channel.
- */
- const Anope::map<int16_t> &GetLevelEntries();
-
- /** Get the level for a privilege
- * @param priv The privilege name
- * @return the level
- * @throws CoreException if priv is not a valid privilege
- */
- int16_t GetLevel(const Anope::string &priv) const;
-
- /** Set the level for a privilege
- * @param priv The privilege priv
- * @param level The new level
- */
- void SetLevel(const Anope::string &priv, int16_t level);
-
- /** Remove a privilege from the channel
- * @param priv The privilege
- */
- void RemoveLevel(const Anope::string &priv);
-
- /** Clear all privileges from the channel
- */
- void ClearLevels();
-
- /** Gets a ban mask for the given user based on the bantype
- * of the channel.
- * @param u The user
- * @return A ban mask that affects the user
- */
- Anope::string GetIdealBan(User *u) const;
-
- /** Finds a ChannelInfo
- * @param name channel name to lookup
- * @return the ChannelInfo associated with the channel
- */
- static ChannelInfo* Find(const Anope::string &name);
-
- void AddChannelReference(const Anope::string &what);
- void RemoveChannelReference(const Anope::string &what);
- void GetChannelReferences(std::deque<Anope::string> &chans);
-};
-
-/** Is the user the real founder?
- * @param user The user
- * @param ci The channel
- * @return true or false
- */
-extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
-
-#endif // REGCHANNEL_H
diff --git a/include/regexpr.h b/include/regexpr.h
deleted file mode 100644
index 1ad4bc81e..000000000
--- a/include/regexpr.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for further details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- */
-
-#ifndef REGEXPR_H
-#define REGEXPR_H
-
-#include "services.h"
-#include "anope.h"
-#include "service.h"
-
-class RegexException : public CoreException
-{
- public:
- RegexException(const Anope::string &reason = "") : CoreException(reason) { }
-
- virtual ~RegexException() throw() { }
-};
-
-class CoreExport Regex
-{
- Anope::string expression;
- protected:
- Regex(const Anope::string &expr) : expression(expr) { }
- public:
- virtual ~Regex() { }
- const Anope::string &GetExpression() { return expression; }
- virtual bool Matches(const Anope::string &str) = 0;
-};
-
-class CoreExport RegexProvider : public Service
-{
- public:
- RegexProvider(Module *o, const Anope::string &n) : Service(o, "Regex", n) { }
- virtual Regex *Compile(const Anope::string &) = 0;
-};
-
-#endif // REGEXPR_H
diff --git a/include/serialize.h b/include/serialize.h
index bbc7acba7..8fbeb6615 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -1,335 +1,909 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SERIALIZE_H
-#define SERIALIZE_H
-
-#include <sstream>
+#pragma once
#include "anope.h"
#include "base.h"
+#include "extensible.h"
+#include "event.h"
namespace Serialize
{
- class Data
- {
- public:
- enum Type
- {
- DT_TEXT,
- DT_INT
- };
+ class Object;
+
+ class TypeBase;
+
+ class FieldBase;
+ template<typename> class FieldTypeBase;
+ template<typename, typename> class CommonFieldBase;
+ template<typename, typename> class Field;
+ template<typename, typename> class ObjectField;
+
+ template<typename T, typename> class Type;
+ template<typename T> class Reference;
+
+ // by id
+ extern std::unordered_map<ID, Object *> objects;
+ extern std::vector<FieldBase *> serializableFields;
+
+ extern Object *GetID(ID id);
+
+ template<typename T>
+ inline T GetObject();
+
+ template<typename T>
+ inline std::vector<T> GetObjects(const Anope::string &name);
- virtual ~Data() { }
+ template<typename T>
+ inline std::vector<T> GetObjects();
- virtual std::iostream& operator[](const Anope::string &key) = 0;
- virtual std::set<Anope::string> KeySet() const { throw CoreException("Not supported"); }
- virtual size_t Hash() const { throw CoreException("Not supported"); }
+ template<typename T>
+ inline T New();
- virtual void SetType(const Anope::string &key, Type t) { }
- virtual Type GetType(const Anope::string &key) const { return DT_TEXT; }
+ extern void Clear();
+
+ extern void Unregister(Module *);
+
+ struct Edge
+ {
+ Object *other;
+ FieldBase *field;
+ bool direction;
+
+ Edge(Object *o, FieldBase *f, bool d) : other(o), field(f), direction(d) { }
+
+ bool operator==(const Edge &e) const
+ {
+ return other == e.other && field == e.field && direction == e.direction;
+ }
};
- extern void RegisterTypes();
- extern void CheckTypes();
+ extern std::multimap<Anope::string, Anope::string> child_types;
- class Type;
- template<typename T> class Checker;
- template<typename T> class Reference;
+ extern void SetParent(const Anope::string &child, const Anope::string &parent);
+
+ extern std::vector<Serialize::TypeBase *> GetTypes(const Anope::string &name);
}
-/** A serialziable object. Serializable objects can be serialized into
- * abstract data types (Serialize::Data), and then reconstructed or
- * updated later at any time.
- */
-class CoreExport Serializable : public virtual Base
+class CoreExport Serialize::Object : public Extensible, public virtual Base
{
private:
- /* A list of every serializable item in Anope.
- * Some of these are static and constructed at runtime,
- * so this list must be on the heap, as it is not always
- * constructed before other objects are if it isn't.
- */
- static std::list<Serializable *> *SerializableItems;
- friend class Serialize::Type;
+ friend class Serialize::FieldBase;
+
/* The type of item this object is */
- Serialize::Type *s_type;
- /* Iterator into serializable_items */
- std::list<Serializable *>::iterator s_iter;
- /* The hash of the last serialized form of this object committed to the database */
- size_t last_commit;
- /* The last time this object was committed to the database */
- time_t last_commit_time;
+ TypeBase *s_type;
- protected:
- Serializable(const Anope::string &serialize_type);
- Serializable(const Serializable &);
+ std::map<TypeBase *, std::vector<Edge>> edges;
- Serializable &operator=(const Serializable &);
+ std::vector<Edge> GetRefs(TypeBase *);
public:
- virtual ~Serializable();
+ Object(TypeBase *type);
+ Object(TypeBase *type, ID);
+
+ virtual ~Object();
+
+ virtual void Delete();
- /* Unique ID (per type, not globally) for this object */
- uint64_t id;
+ /* Unique ID for this object */
+ ID id;
- /* Only used by redis, to ignore updates */
- unsigned short redis_ignore;
+ void AddEdge(Object *other, FieldBase *field);
- /** Marks the object as potentially being updated "soon".
+ void RemoveEdge(Object *other, FieldBase *field);
+
+ /**
+ * Get an object of type T that this object references.
*/
- void QueueUpdate();
+ template<typename T>
+ T GetRef()
+ {
+ std::vector<T> t = GetRefs<T>();
+ return !t.empty() ? t[0] : nullptr;
+ }
+
+ /**
+ * Gets all objects of type T that this object references
+ */
+ template<typename T>
+ std::vector<T> GetRefs();
- bool IsCached(Serialize::Data &);
- void UpdateCache(Serialize::Data &);
+ /**
+ * Get the value of a field on this object.
+ */
+ template<
+ typename Type,
+ template<typename, typename> class Field, // Field type being read
+ typename TypeImpl,
+ typename T // type of the Extensible
+ >
+ T Get(Field<TypeImpl, T> Type::*field)
+ {
+ static_assert(std::is_base_of<Object, TypeImpl>::value, "");
+ static_assert(std::is_base_of<Serialize::TypeBase, Type>::value, "");
+
+ Type *t = static_cast<Type *>(s_type);
+ Field<TypeImpl, T>& f = t->*field;
+ return f.GetField(f.Upcast(this));
+ }
- bool IsTSCached();
- void UpdateTS();
+ /**
+ * Get the value of a field on this object. Allows specifying return
+ * type if the return type can't be inferred.
+ */
+ template<typename Ret, typename Field, typename Type>
+ Ret Get(Field Type::*field)
+ {
+ static_assert(std::is_base_of<Serialize::TypeBase, Type>::value, "");
+
+ Type *t = static_cast<Type *>(s_type);
+ Field& f = t->*field;
+ return f.GetField(f.Upcast(this));
+ }
+
+ /**
+ * Set the value of a field on this object
+ */
+ template<
+ typename Type,
+ template<typename, typename> class Field,
+ typename TypeImpl,
+ typename T
+ >
+ void Set(Field<TypeImpl, T> Type::*field, const T& value)
+ {
+ static_assert(std::is_base_of<Object, TypeImpl>::value, "");
+ static_assert(std::is_base_of<Serialize::TypeBase, Type>::value, "");
+
+ Type *t = static_cast<Type *>(s_type);
+ Field<TypeImpl, T>& f = t->*field;
+ f.SetField(f.Upcast(this), value);
+ }
+
+ /**
+ * Set the value of a field on this object
+ */
+ template<typename Field, typename Type, typename T>
+ void Set(Field Type::*field, const T& value)
+ {
+ static_assert(std::is_base_of<Serialize::TypeBase, Type>::value, "");
+
+ Type *t = static_cast<Type *>(s_type);
+ Field& f = t->*field;
+ f.SetField(f.Upcast(this), value);
+ }
/** Get the type of serializable object this is
* @return The serializable object type
*/
- Serialize::Type* GetSerializableType() const { return this->s_type; }
+ TypeBase* GetSerializableType() const { return this->s_type; }
- virtual void Serialize(Serialize::Data &data) const = 0;
+ /** Set the value of a field on this object, by field name
+ */
+ template<typename T>
+ void SetS(const Anope::string &name, const T &what);
- static const std::list<Serializable *> &GetItems();
+ /** Unset a field on this object, by field name
+ */
+ template<typename T>
+ void UnsetS(const Anope::string &name);
+
+ /** Test if a field is set. Only useful with extensible fields,
+ * which can unset (vs set to the default value)
+ */
+ bool HasFieldS(const Anope::string &name);
};
-/* A serializable type. There should be one of these classes for each type
- * of class that inherits from Serialiable. Used for unserializing objects
- * of this type, as it requires a function pointer to a static member function.
- */
-class CoreExport Serialize::Type : public Base
+class CoreExport Serialize::TypeBase : public Service
{
- typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &);
-
- static std::vector<Anope::string> TypeOrder;
- static std::map<Anope::string, Serialize::Type *> Types;
-
- /* The name of this type, should be a class name */
Anope::string name;
- unserialize_func unserialize;
+
/* Owner of this type. Used for placing objects of this type in separate databases
* based on what module, if any, owns it.
*/
Module *owner;
- /* The timesatmp for this type. All objects of this type are as up to date as
- * this timestamp. if curtime == timestamp then we have the most up to date
- * version of every object of this type.
- */
- time_t timestamp;
-
public:
- /* Map of Serializable::id to Serializable objects */
- std::map<uint64_t, Serializable *> objects;
+ static constexpr const char *NAME = "typebase";
+
+ std::set<Object *> objects;
- /** Creates a new serializable type
- * @param n Type name
- * @param f Func to unserialize objects
- * @param owner Owner of this type. Leave NULL for the core.
- */
- Type(const Anope::string &n, unserialize_func f, Module *owner = NULL);
- ~Type();
+ TypeBase(Module *owner, const Anope::string &n);
+ ~TypeBase();
+
+ void Unregister();
/** Gets the name for this type
* @return The name, eg "NickAlias"
*/
const Anope::string &GetName() { return this->name; }
- /** Unserialized an object.
- * @param obj NULL if this object doesn't yet exist. If this isn't NULL, instead
- * update the contents of this object.
- * @param data The data to unserialize
- * @return The unserialized object. If obj != NULL this should be obj.
+ /**
+ * Get all objects of the given type
+ */
+ template<typename T>
+ std::vector<T> List()
+ {
+ std::vector<ID> ids;
+ EventReturn result = EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeList, this, ids);
+ if (result == EVENT_ALLOW)
+ {
+ std::vector<T> o;
+ for (ID id : ids)
+ {
+ Object *s = Require(id);
+ if (s)
+ o.push_back(anope_dynamic_static_cast<T>(s));
+ }
+ return o;
+ }
+
+ return GetObjects<T>();
+ }
+
+ /** Create a new object of this type.
*/
- Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
+ virtual Object *Create() anope_abstract;
- /** Check if this object type has any pending changes and update them.
+ /** Get or otherwise create an object of this type
+ * with the given ID.
*/
- void Check();
+ virtual Object *Require(Serialize::ID) anope_abstract;
- /** Gets the timestamp for the object type. That is, the time we know
- * all objects of this type are updated at least to.
+ /** Find a field on this type
*/
- time_t GetTimestamp() const;
+ FieldBase *GetField(const Anope::string &name);
- /** Bumps object type timestamp to current time
+ /** Get all fields of this type
*/
- void UpdateTimestamp();
+ std::vector<FieldBase *> GetFields();
Module* GetOwner() const { return this->owner; }
- static Serialize::Type *Find(const Anope::string &name);
+ static TypeBase *Find(const Anope::string &name);
+
+ static const std::map<Anope::string, TypeBase *>& GetTypes();
+};
+
+template<typename T, typename Base = Serialize::TypeBase>
+class Serialize::Type : public Base
+{
+ public:
+ Type(Module *module) : Base(module, T::NAME) { }
+ Type(Module *module, const Anope::string &name) : Base(module, name) { }
+
+ Object *Create() override
+ {
+ return new T(this);
+ }
+
+ Object *Require(Serialize::ID id) override
+ {
+ return RequireID(id);
+ }
+
+ T* RequireID(ID id)
+ {
+ Object *s = Serialize::GetID(id);
+ if (s == nullptr)
+ return new T(this, id);
- static const std::vector<Anope::string> &GetTypeOrder();
+ if (s->GetSerializableType() != this)
+ return nullptr;
- static const std::map<Anope::string, Serialize::Type *>& GetTypes();
+ return static_cast<T *>(s);
+ }
};
-/** Should be used to hold lists and other objects of a specific type,
- * but not a specific object. Used for ensuring that any access to
- * this object type is always up to date. These are usually constructed
- * at run time, before main is called, so no types are registered. This
- * is why there are static Serialize::Type* variables in every function.
+/** A reference to a serializable object. Serializable objects may not always
+ * exist in memory at all times, like if they exist in an external database,
+ * so you can't hold pointers to them. Instead, hold a Serialize::Reference
+ * which will properly fetch the object on demand from the underlying database
+ * system.
*/
template<typename T>
-class Serialize::Checker
+class Serialize::Reference
{
- Anope::string name;
- T obj;
- mutable ::Reference<Serialize::Type> type;
+ protected:
+ bool valid = false;
+ TypeBase *type;
+ /* ID of the object which we reference */
+ ID id;
+
+ public:
+ Serialize::Reference<T>& operator=(T* obj)
+ {
+ if (obj != nullptr)
+ {
+ type = obj->GetSerializableType();
+ id = obj->id;
+ valid = true;
+ }
+ else
+ {
+ valid = false;
+ }
+ return *this;
+ }
- inline void Check() const
+ explicit operator bool() const
{
- if (!type)
- type = Serialize::Type::Find(this->name);
- if (type)
- type->Check();
+ return Dereference() != nullptr;
}
+ operator T*() const { return Dereference(); }
+
+ T* operator*() const { return Dereference(); }
+ T* operator->() const { return Dereference(); }
+
+ private:
+ T* Dereference() const
+ {
+ if (!valid)
+ return nullptr;
+
+ Object *targ = GetID(id);
+ if (targ != nullptr && targ->GetSerializableType() == type)
+ return anope_dynamic_static_cast<T*>(targ);
+
+ EventReturn result = EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeDeref, id, type);
+ if (result == EVENT_ALLOW)
+ return anope_dynamic_static_cast<T *>(type->Require(id));
+
+ return nullptr;
+ }
+};
+
+/** A field, associated with a type.
+ */
+class Serialize::FieldBase : public Service
+{
public:
- Checker(const Anope::string &n) : name(n), type(NULL) { }
+ static constexpr const char *NAME = "fieldbase";
+
+ Anope::string serialize_type; // type the field is on
+ Anope::string serialize_name; // field name
+
+ /** For fields which reference other Objects. If true, when
+ * the object the field references gets deleted, this object
+ * gets deleted too.
+ */
+ bool depends;
+
+ FieldBase(Module *, const Anope::string &, const Anope::string &, bool);
+ virtual ~FieldBase();
+ void Unregister();
+
+ /** Serialize value of this field on the given object to string form
+ */
+ virtual Anope::string SerializeToString(Object *s) anope_abstract;
+
+ /** Unserialize value of this field on the given object from string form
+ */
+ virtual void UnserializeFromString(Object *s, const Anope::string &) anope_abstract;
+
+ /** Test if the given object has the given field, only usefil for extensible fields
+ */
+ virtual bool HasFieldS(Object *) anope_abstract;
+
+ /** Unset this field on the given object
+ */
+ virtual void UnsetS(Object *) anope_abstract;
+};
+
+template<typename T>
+class Serialize::FieldTypeBase : public FieldBase
+{
+ public:
+ using FieldBase::FieldBase;
+
+ /** Set this field to the given value on the given object.
+ */
+ virtual void SetFieldS(Object *, const T &) anope_abstract;
+};
+
+/** Base class for serializable fields and serializable object fields.
+ */
+template<
+ typename TypeImpl, // Serializable type
+ typename T // actual type of field
+>
+class Serialize::CommonFieldBase : public FieldTypeBase<T>
+{
+ static_assert(std::is_base_of<Object, TypeImpl>::value, "");
+
+ /** Extensible storage for value of fields. Only used if field
+ * isn't set. Note extensible fields can be "unset", where field
+ * pointers are never unset, but are T().
+ */
+ ExtensibleItem<T> *ext = nullptr;
+
+ /** Field pointer to storage in the TypeImpl object for
+ * this field.
+ */
+ T TypeImpl::*field = nullptr;
+
+ protected:
+ /** Set the value of a field in storage
+ */
+ void Set_(TypeImpl *object, const T &value)
+ {
+ if (field != nullptr)
+ object->*field = value;
+ else if (ext != nullptr)
+ ext->Set(object, value);
+ else
+ throw CoreException("No field or ext");
+ }
+
+ /* Get the value of a field from storage
+ */
+ T* Get_(TypeImpl *object)
+ {
+ if (field != nullptr)
+ return &(object->*field);
+ else if (ext != nullptr)
+ return ext->Get(object);
+ else
+ throw CoreException("No field or ext");
+ }
+
+ /** Unset a field from storage
+ */
+ void Unset_(TypeImpl *object)
+ {
+ if (field != nullptr)
+ object->*field = T();
+ else if (ext != nullptr)
+ ext->Unset(object);
+ else
+ throw CoreException("No field or ext");
+ }
+
+ /** Check is a field is set. Only useful for
+ * extensible storage. Returns true for field storage.
+ */
+ bool HasField_(TypeImpl *object)
+ {
+ if (field != nullptr)
+ return true;
+ else if (ext != nullptr)
+ return ext->HasExt(object);
+ else
+ throw CoreException("No field or ext");
+ }
+
+ public:
+ CommonFieldBase(Serialize::TypeBase *t, const Anope::string &n, bool d)
+ : FieldTypeBase<T>(t->GetOwner(), n, t->GetName(), d)
+ {
+ ext = new ExtensibleItem<T>(t->GetOwner(), t->GetName(), n);
+ }
+
+ CommonFieldBase(Module *creator, const Anope::string &n, bool d)
+ : FieldTypeBase<T>(creator, n, TypeImpl::NAME, d)
+ {
+ ext = new ExtensibleItem<T>(creator, TypeImpl::NAME, n);
+ }
- inline const T* operator->() const
+ CommonFieldBase(Serialize::TypeBase *t,
+ const Anope::string &n,
+ T TypeImpl::*f,
+ bool d)
+ : FieldTypeBase<T>(t->GetOwner(), n, t->GetName(), d)
+ , field(f)
{
- this->Check();
- return &this->obj;
}
- inline T* operator->()
+
+ ~CommonFieldBase()
{
- this->Check();
- return &this->obj;
+ delete ext;
}
- inline const T& operator*() const
+ /** Get the value of this field on the given object
+ */
+ virtual T GetField(TypeImpl *) anope_abstract;
+
+ /** Unset this field on the given object
+ */
+ virtual void UnsetField(TypeImpl *) anope_abstract;
+
+ void UnsetS(Object *s) override
{
- this->Check();
- return this->obj;
+ UnsetField(Upcast(s));
}
- inline T& operator*()
+
+ bool HasFieldS(Object *s) override
{
- this->Check();
- return this->obj;
+ return HasField(Upcast(s));
}
- inline operator const T&() const
+ /** Cast a serializable object of type Object to type TypeImpl,
+ * if appropriate
+ */
+ TypeImpl* Upcast(Object *s)
{
- this->Check();
- return this->obj;
+ if (this->serialize_type != s->GetSerializableType()->GetName())
+ {
+ return nullptr;
+ }
+
+ return anope_dynamic_static_cast<TypeImpl *>(s);
}
- inline operator T&()
+
+ bool HasField(TypeImpl *s)
{
- this->Check();
- return this->obj;
+ EventReturn result = EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeHasField, s, this);
+ if (result != EVENT_CONTINUE)
+ return true;
+
+ return this->HasField_(s);
}
};
-/** Used to hold references to serializable objects. Reference should always be
- * used when holding references to serializable objects for extended periods of time
- * to ensure that the object it refers to it always up to date. This also behaves like
- * Reference in that it will invalidate itself if the object it refers to is
- * destructed.
+/** Class for all fields that aren't to other serializable objects
*/
-template<typename T>
-class Serialize::Reference : public ReferenceBase
+template<typename TypeImpl, typename T>
+class Serialize::Field : public CommonFieldBase<TypeImpl, T>
{
- protected:
- T *ref;
-
public:
- Reference() : ref(NULL)
+ Field(TypeBase *t, const Anope::string &n) : CommonFieldBase<TypeImpl, T>(t, n, false)
{
}
- Reference(T *obj) : ref(obj)
+ Field(Module *creator, const Anope::string &n) : CommonFieldBase<TypeImpl, T>(creator, n, false)
{
- if (obj)
- obj->AddReference(this);
}
- Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref)
+ Field(TypeBase *t, const Anope::string &n, T TypeImpl::*f) : CommonFieldBase<TypeImpl, T>(t, n, f, false)
{
- if (ref && !invalid)
- this->ref->AddReference(this);
}
- ~Reference()
+ T GetField(TypeImpl *s) override
{
- if (ref && !invalid)
- this->ref->DelReference(this);
- }
+ T* t = this->Get_(s);
- inline Reference<T>& operator=(const Reference<T> &other)
- {
- if (this != &other)
+ // If we have a non-default value for this field it is up to date and cached
+ if (t && *t != T())
+ return *t;
+
+ // Query modules
+ Anope::string value;
+ EventReturn result = EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeGet, s, this, value);
+ if (result == EVENT_ALLOW)
{
- if (ref && !invalid)
- this->ref->DelReference(this);
+ // module returned us data, so we unserialize it
+ T t2 = this->Unserialize(value);
- this->ref = other.ref;
- this->invalid = other.invalid;
+ // Cache
+ this->Set_(s, t2);
- if (ref && !invalid)
- this->ref->AddReference(this);
+ return t2;
}
- return *this;
+
+ if (t)
+ return *t;
+
+ return T();
}
- inline operator bool() const
+ void SetFieldS(Object *s, const T &value) override
{
- if (!this->invalid)
- return this->ref != NULL;
- return false;
+ SetField(this->Upcast(s), value);
+ }
+
+ virtual void SetField(TypeImpl *s, const T &value)
+ {
+ Anope::string strvalue = this->Serialize(value);
+ EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeSet, s, this, strvalue);
+
+ this->Set_(s, value);
+ }
+
+ void UnsetField(TypeImpl *s) override
+ {
+ EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeUnset, s, this);
+
+ this->Unset_(s);
}
- inline operator T*() const
+ Anope::string Serialize(const T& t)
{
- if (!this->invalid)
+ try
{
- if (this->ref)
- // This can invalidate me
- this->ref->QueueUpdate();
- if (!this->invalid)
- return this->ref;
+ return stringify(t);
+ }
+ catch (const ConvertException &)
+ {
+ Log(LOG_DEBUG) << "Unable to stringify " << t;
+ return "";
}
- return NULL;
}
- inline T* operator*() const
+ T Unserialize(const Anope::string &str)
{
- if (!this->invalid)
+ if (str.empty())
+ return T();
+
+ try
+ {
+ return convertTo<T>(str);
+ }
+ catch (const ConvertException &)
{
- if (this->ref)
- // This can invalidate me
- this->ref->QueueUpdate();
- if (!this->invalid)
- return this->ref;
+ return T();
}
- return NULL;
}
- inline T* operator->() const
+ Anope::string SerializeToString(Object *s) override
+ {
+ T t = GetField(this->Upcast(s));
+ return this->Serialize(t);
+ }
+
+ void UnserializeFromString(Object *s, const Anope::string &v) override
+ {
+ T t = this->Unserialize(v);
+ SetField(this->Upcast(s), t);
+ }
+
+ void Set(Extensible *obj, const T &value)
+ {
+ TypeImpl *s = anope_dynamic_static_cast<TypeImpl *>(obj);
+ SetField(s, value);
+ }
+
+ void Unset(Extensible *obj)
+ {
+ TypeImpl *s = anope_dynamic_static_cast<TypeImpl *>(obj);
+ this->UnsetField(s);
+ }
+
+ T Get(Extensible *obj)
+ {
+ TypeImpl *s = anope_dynamic_static_cast<TypeImpl *>(obj);
+ return this->GetField(s);
+ }
+
+ bool HasExt(Extensible *obj)
+ {
+ TypeImpl *s = anope_dynamic_static_cast<TypeImpl *>(obj);
+ return this->HasField(s);
+ }
+};
+
+/** Class for all fields that contain a reference to another serializable object.
+ */
+template<typename TypeImpl, typename T>
+class Serialize::ObjectField : public CommonFieldBase<TypeImpl, T>
+{
+ public:
+ ObjectField(TypeBase *t, const Anope::string &n, bool d = false) : CommonFieldBase<TypeImpl, T>(t, n, d)
+ {
+ }
+
+ ObjectField(TypeBase *t, const Anope::string &n, T TypeImpl::*field, bool d = false) : CommonFieldBase<TypeImpl, T>(t, n, field, d)
+ {
+ }
+
+ T GetField(TypeImpl *s)
+ {
+ T *t = this->Get_(s);
+ if (t && *t != nullptr)
+ return *t;
+
+ Anope::string type;
+ ID sid;
+ EventReturn result = EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeGetSerializable, s, this, type, sid);
+ if (result != EVENT_CONTINUE)
+ {
+ Serialize::TypeBase *base = Serialize::TypeBase::Find(type);
+ if (base == nullptr)
+ {
+ Log(LOG_DEBUG_2) << "OnSerializeGetSerializable returned unknown type " << type;
+ return nullptr;
+ }
+
+ T t2 = result == EVENT_ALLOW ? static_cast<T>(base->Require(sid)) : nullptr;
+
+ this->Set_(s, t2);
+
+ return t2;
+ }
+
+ if (t)
+ return *t;
+
+ return T();
+ }
+
+ void SetFieldS(Object *s, const T &value) override
+ {
+ SetField(this->Upcast(s), value);
+ }
+
+ virtual void SetField(TypeImpl *s, T value)
+ {
+ EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeSetSerializable, s, this, value);
+
+ T *old = this->Get_(s);
+ if (old != nullptr && *old != nullptr)
+ s->RemoveEdge(*old, this);
+
+ this->Set_(s, value);
+
+ if (value != nullptr)
+ s->AddEdge(value, this);
+ }
+
+ void UnsetField(TypeImpl *s) override
+ {
+ EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializeUnsetSerializable, s, this);
+
+ this->Unset_(s);
+ }
+
+ Anope::string SerializeToString(Object *s) override
+ {
+ T t = GetField(this->Upcast(s));
+ return this->Serialize(t);
+ }
+
+ void UnserializeFromString(Object *s, const Anope::string &v) override
+ {
+ T t = this->Unserialize(v);
+ SetField(this->Upcast(s), t);
+ }
+
+ Anope::string Serialize(const T& t)
{
- if (!this->invalid)
+ return t ? t->GetSerializableType()->GetName() + ":" + stringify(t->id) : "";
+ }
+
+ T Unserialize(const Anope::string &str)
+ {
+ size_t c = str.rfind(':');
+ if (c == Anope::string::npos)
+ return nullptr;
+
+ Anope::string type = str.substr(0, c);
+ ID id;
+ try
{
- if (this->ref)
- // This can invalidate me
- this->ref->QueueUpdate();
- if (!this->invalid)
- return this->ref;
+ id = convertTo<ID>(str.substr(c + 1));
}
- return NULL;
+ catch (const ConvertException &)
+ {
+ return nullptr;
+ }
+
+ TypeBase *t = TypeBase::Find(type);
+ if (!t)
+ {
+ return nullptr;
+ }
+
+ return anope_dynamic_static_cast<T>(t->Require(id));
}
};
-#endif // SERIALIZE_H
+template<typename T>
+T Serialize::GetObject()
+{
+ std::vector<T> v = GetObjects<T>();
+ return v.empty() ? nullptr : v[0];
+}
+
+template<typename T>
+std::vector<T> Serialize::GetObjects(const Anope::string &name)
+{
+ std::vector<T> objs;
+
+ for (TypeBase *t : GetTypes(name))
+ for (Object *s : t->objects)
+ objs.push_back(anope_dynamic_static_cast<T>(s));
+
+ return objs;
+}
+
+template<typename T>
+std::vector<T> Serialize::GetObjects()
+{
+ const char* const name = std::remove_pointer<T>::type::NAME;
+ return GetObjects<T>(name);
+}
+
+template<typename T>
+T Serialize::New()
+{
+ const char* const name = std::remove_pointer<T>::type::NAME;
+ Serialize::TypeBase *type = TypeBase::Find(name);
+
+ if (type == nullptr)
+ {
+ Log(LOG_DEBUG) << "Serialize::New with unknown type " << name;
+ return nullptr;
+ }
+
+ return static_cast<T>(type->Create());
+}
+
+template<typename T>
+std::vector<T> Serialize::Object::GetRefs()
+{
+ const char* const name = std::remove_pointer<T>::type::NAME;
+ std::vector<Serialize::TypeBase *> types = GetTypes(name);
+ std::vector<T> objs;
+
+ if (types.empty())
+ {
+ Log(LOG_DEBUG) << "GetRefs for unknown type on #" << this->id << " type " << s_type->GetName() << " named " << name;
+ return objs;
+ }
+
+ for (Serialize::TypeBase *t : types)
+ for (const Serialize::Edge &edge : GetRefs(t))
+ if (!edge.direction)
+ objs.push_back(anope_dynamic_static_cast<T>(edge.other));
+
+ return objs;
+}
+
+template<typename T>
+void Serialize::Object::SetS(const Anope::string &name, const T &what)
+{
+ FieldBase *field = s_type->GetField(name);
+ if (field == nullptr)
+ {
+ Log(LOG_DEBUG) << "Set for unknown field " << name << " on " << s_type->GetName();
+ return;
+ }
+
+ FieldTypeBase<T> *fieldt = static_cast<FieldTypeBase<T> *>(field);
+ fieldt->SetFieldS(this, what);
+}
+
+template<typename T>
+void Serialize::Object::UnsetS(const Anope::string &name)
+{
+ FieldBase *field = s_type->GetField(name);
+ if (field == nullptr)
+ {
+ Log(LOG_DEBUG) << "Unset for unknown field " << name << " on " << s_type->GetName();
+ return;
+ }
+
+ FieldTypeBase<T> *fieldt = static_cast<FieldTypeBase<T> *>(field);
+ fieldt->UnsetS(this);
+}
+
+inline bool Serialize::Object::HasFieldS(const Anope::string &name)
+{
+ FieldBase *field = s_type->GetField(name);
+ if (field == nullptr)
+ {
+ Log(LOG_DEBUG) << "HasField for unknown field " << name << " on " << s_type->GetName();
+ return false;
+ }
+
+ FieldTypeBase<void *> *fieldt = static_cast<FieldTypeBase<void *> *>(field);
+ return fieldt->HasFieldS(this);
+}
+
diff --git a/include/servers.h b/include/servers.h
index f06acb156..64a265a85 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SERVERS_H
-#define SERVERS_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -82,6 +89,8 @@ class CoreExport Server : public Extensible
/* Number of users on the server */
unsigned users;
+ void Burst();
+
/** Delete this server with a reason
* @param reason The reason
*/
@@ -174,7 +183,7 @@ class CoreExport Server : public Extensible
* @param source The source of the message
* @param message The message
*/
- void Notice(BotInfo *source, const Anope::string &message);
+ void Notice(ServiceBot *source, const Anope::string &message);
/** Find a server
* @param name The name or SID/numeric
@@ -184,4 +193,3 @@ class CoreExport Server : public Extensible
static Server *Find(const Anope::string &name, bool name_only = false);
};
-#endif // SERVERS_H
diff --git a/include/service.h b/include/service.h
index 9c4d1f172..fd5e2245a 100644
--- a/include/service.h
+++ b/include/service.h
@@ -1,16 +1,24 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2016 Adam <Adam@anope.org>
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SERVICE_H
-#define SERVICE_H
+#pragma once
#include "services.h"
#include "anope.h"
@@ -23,151 +31,145 @@
*/
class CoreExport Service : public virtual Base
{
- static std::map<Anope::string, std::map<Anope::string, Service *> > Services;
- static std::map<Anope::string, std::map<Anope::string, Anope::string> > Aliases;
-
- static Service *FindService(const std::map<Anope::string, Service *> &services, const std::map<Anope::string, Anope::string> *aliases, const Anope::string &n)
- {
- std::map<Anope::string, Service *>::const_iterator it = services.find(n);
- if (it != services.end())
- return it->second;
-
- if (aliases != NULL)
- {
- std::map<Anope::string, Anope::string>::const_iterator it2 = aliases->find(n);
- if (it2 != aliases->end())
- return FindService(services, aliases, it2->second);
- }
-
- return NULL;
- }
+ Module *owner;
+ /* Service type, which should be the class name (eg "Command") */
+ Anope::string type;
+ /* Service name, commands are usually named service/command */
+ Anope::string name;
public:
- static Service *FindService(const Anope::string &t, const Anope::string &n)
- {
- std::map<Anope::string, std::map<Anope::string, Service *> >::const_iterator it = Services.find(t);
- if (it == Services.end())
- return NULL;
+ Service(Module *o, const Anope::string &t, const Anope::string &n);
+
+ Service(Module *o, const Anope::string &t) : Service(o, t, "") { }
- std::map<Anope::string, std::map<Anope::string, Anope::string> >::const_iterator it2 = Aliases.find(t);
- if (it2 != Aliases.end())
- return FindService(it->second, &it2->second, n);
+ virtual ~Service();
- return FindService(it->second, NULL, n);
- }
+ Module *GetOwner() const { return owner; }
- static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
- {
- std::vector<Anope::string> keys;
- std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = Services.find(t);
- if (it != Services.end())
- for (std::map<Anope::string, Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
- keys.push_back(it2->first);
- return keys;
- }
+ const Anope::string &GetType() const { return type; }
- static void AddAlias(const Anope::string &t, const Anope::string &n, const Anope::string &v)
- {
- std::map<Anope::string, Anope::string> &smap = Aliases[t];
- smap[n] = v;
- }
+ const Anope::string &GetName() const { return name; }
+};
- static void DelAlias(const Anope::string &t, const Anope::string &n)
- {
- std::map<Anope::string, Anope::string> &smap = Aliases[t];
- smap.erase(n);
- if (smap.empty())
- Aliases.erase(t);
- }
+class ServiceReferenceBase
+{
+ Anope::string type, name;
- Module *owner;
- /* Service type, which should be the class name (eg "Command") */
- Anope::string type;
- /* Service name, commands are usually named service/command */
- Anope::string name;
+ protected:
+ std::vector<Service *> services;
- Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
- {
- this->Register();
- }
+ public:
- virtual ~Service()
- {
- this->Unregister();
- }
+ ServiceReferenceBase() = default;
- void Register()
+ ServiceReferenceBase(const Anope::string &_type, const Anope::string &_name);
+ ServiceReferenceBase(const Anope::string &_type);
+
+ virtual ~ServiceReferenceBase();
+
+ explicit operator bool() const
{
- std::map<Anope::string, Service *> &smap = Services[this->type];
- if (smap.find(this->name) != smap.end())
- throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
- smap[this->name] = this;
+ return !this->services.empty();
}
- void Unregister()
- {
- std::map<Anope::string, Service *> &smap = Services[this->type];
- smap.erase(this->name);
- if (smap.empty())
- Services.erase(this->type);
- }
+ const Anope::string &GetType() const { return type; }
+ const Anope::string &GetName() const { return name; }
+
+ Service *GetService() const { return services.empty() ? nullptr : services[0]; }
+ const std::vector<Service *> &GetServices() const { return services; }
+ void SetService(Service *service);
+ void SetServices(const std::vector<Service *> &s);
};
-/** Like Reference, but used to refer to Services.
- */
template<typename T>
-class ServiceReference : public Reference<T>
+class ServiceReference : public ServiceReferenceBase
{
- Anope::string type;
- Anope::string name;
+ static_assert(std::is_base_of<Service, T>::value, "");
public:
- ServiceReference() { }
+ ServiceReference() : ServiceReferenceBase(T::NAME) { }
+ ServiceReference(const Anope::string &n) : ServiceReferenceBase(T::NAME, n) { }
- ServiceReference(const Anope::string &t, const Anope::string &n) : type(t), name(n)
+ operator T*() const
{
+ return static_cast<T*>(GetService());
}
- inline void operator=(const Anope::string &n)
+ T* operator->() const
{
- this->name = n;
- this->invalid = true;
+ return static_cast<T*>(GetService());
}
- operator bool() anope_override
+ T* operator*() const
{
- if (this->invalid)
- {
- this->invalid = false;
- this->ref = NULL;
- }
- if (!this->ref)
- {
- /* This really could be dynamic_cast in every case, except for when a module
- * creates its own service type (that other modules must include the header file
- * for), as the core is not compiled with it so there is no RTTI for it.
- */
- this->ref = static_cast<T *>(::Service::FindService(this->type, this->name));
- if (this->ref)
- this->ref->AddReference(this);
- }
- return this->ref;
+ return static_cast<T*>(GetService());
}
};
-class ServiceAlias
+template<typename T>
+class ServiceReferenceList : public ServiceReferenceBase
{
- Anope::string t, f;
+ static_assert(std::is_base_of<Service, T>::value, "");
+
public:
- ServiceAlias(const Anope::string &type, const Anope::string &from, const Anope::string &to) : t(type), f(from)
+ using ServiceReferenceBase::ServiceReferenceBase;
+
+ std::vector<T *> GetServices() const
{
- Service::AddAlias(type, from, to);
+ std::vector<T *> out;
+ std::transform(services.begin(), services.end(), std::back_inserter(out), [](Service *e) { return static_cast<T *>(e); });
+ return out;
}
+};
+
+class ServiceManager
+{
+ std::vector<ServiceReferenceBase *> references; // managed references
+ std::vector<Service *> services; // all registered services
+
+ /* Lookup services for a reference */
+ void Lookup(ServiceReferenceBase *reference);
- ~ServiceAlias()
+ /* Lookup services for all managed references */
+ void LookupAll();
+
+ std::vector<Service *> FindServices(const Anope::string &type);
+
+ static ServiceManager *manager;
+
+ public:
+ Service *FindService(const Anope::string &name);
+ Service *FindService(const Anope::string &type, const Anope::string &name);
+
+ template<typename T>
+ std::vector<T> FindServices()
{
- Service::DelAlias(t, f);
+ static_assert(std::is_base_of<Service, typename std::remove_pointer<T>::type>::value, "");
+ const char *type = std::remove_pointer<T>::type::NAME;
+ std::vector<Service *> s = FindServices(type);
+ std::vector<T> out;
+ std::transform(s.begin(), s.end(), std::back_inserter(out), [](Service *e) { return static_cast<T>(e); });
+ return out;
}
+
+ template<typename T>
+ T FindService(const Anope::string &name)
+ {
+ static_assert(std::is_base_of<Service, typename std::remove_pointer<T>::type>::value, "");
+ const char *type = std::remove_pointer<T>::type::NAME;
+ return static_cast<T>(FindService(type, name));
+ }
+
+ void Register(Service *service);
+
+ void Unregister(Service *service);
+
+ void RegisterReference(ServiceReferenceBase *reference);
+
+ void UnregisterReference(ServiceReferenceBase *reference);
+
+ static void Init();
+ static ServiceManager *Get();
+ static void Destroy();
};
-#endif // SERVICE_H
diff --git a/include/services.h b/include/services.h
index 2fc7280b6..6b5832344 100644
--- a/include/services.h
+++ b/include/services.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SERVICES_H
-#define SERVICES_H
+#pragma once
#include "sysconf.h"
@@ -19,12 +26,10 @@
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
+#include <cstdint>
#include <stdexcept>
#include <string.h>
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
#ifndef _WIN32
#include <unistd.h>
@@ -43,19 +48,13 @@
#include <set>
#include <algorithm>
#include <iterator>
+#include <regex>
+#include <stack>
#include "defs.h"
#define _(x) x
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-# define anope_override override
-# define anope_final final
-#else
-# define anope_override
-# define anope_final
-#endif
-
#ifndef _WIN32
# define DllExport
# define CoreExport
@@ -65,4 +64,10 @@
# include "anope_windows.h"
#endif
-#endif // SERVICES_H
+#ifndef DEBUG_BUILD
+# define NDEBUG
+#endif
+#include <assert.h>
+
+#define anope_abstract = 0
+
diff --git a/include/socketengine.h b/include/socketengine.h
index 36eb253a4..b7a1c6c6e 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SOCKETENGINE_H
-#define SOCKETENGINE_H
+#pragma once
#include "services.h"
#include "sockets.h"
@@ -47,4 +54,3 @@ class CoreExport SocketEngine
static bool IgnoreErrno();
};
-#endif // SOCKETENGINE_H
diff --git a/include/sockets.h b/include/sockets.h
index 89ca79dde..afc335c4f 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2005-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef SOCKETS_H
-#define SOCKETS_H
+#pragma once
#ifndef _WIN32
#include <netinet/in.h>
@@ -286,12 +293,12 @@ class CoreExport BufferedSocket : public virtual Socket
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Gets the new line from the input buffer, if any
*/
@@ -340,12 +347,12 @@ class CoreExport BinarySocket : public virtual Socket
/** Called when there is something to be received for this socket
* @return true on success, false to drop this socket
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Called when the socket is ready to be written to
* @return true on success, false to drop this socket
*/
- bool ProcessWrite() anope_override;
+ bool ProcessWrite() override;
/** Write data to the socket
* @param buffer The data to write
@@ -377,14 +384,14 @@ class CoreExport ListenSocket : public virtual Socket
/** Process what has come in from the connection
* @return false to destroy this socket
*/
- bool ProcessRead();
+ bool ProcessRead() override;
/** Called when a connection is accepted
* @param fd The FD for the new connection
* @param addr The sockaddr for where the connection came from
* @return The new socket
*/
- virtual ClientSocket *OnAccept(int fd, const sockaddrs &addr) = 0;
+ virtual ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_abstract;
};
class CoreExport ConnectionSocket : public virtual Socket
@@ -403,12 +410,12 @@ class CoreExport ConnectionSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called on a successful connect
*/
@@ -438,12 +445,12 @@ class CoreExport ClientSocket : public virtual Socket
* Used to determine whether or not this socket is connected yet.
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
*/
- bool Process() anope_override;
+ bool Process() override;
/** Called when there is an error for this socket
* @return true on success, false to drop this socket
*/
- void ProcessError() anope_override;
+ void ProcessError() override;
/** Called when a client has been accepted() successfully.
*/
@@ -467,7 +474,7 @@ class CoreExport Pipe : public Socket
/** Called when data is to be read, reads the data then calls OnNotify
*/
- bool ProcessRead() anope_override;
+ bool ProcessRead() override;
/** Write data to this pipe
* @param data The data to write
@@ -496,11 +503,10 @@ class CoreExport Pipe : public Socket
/** Called after ProcessRead comes back from Notify(), overload to do something useful
*/
- virtual void OnNotify() = 0;
+ virtual void OnNotify() anope_abstract;
};
extern CoreExport uint32_t TotalRead;
extern CoreExport uint32_t TotalWritten;
extern CoreExport SocketIO NormalSocketIO;
-#endif // SOCKET_H
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 5f0e275c3..2d2ede9de 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -1,47 +1,28 @@
-#ifndef _SYSCONF_H_
-#define _SYSCONF_H_
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2008-2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
#cmakedefine DEBUG_BUILD
#cmakedefine DEFUMASK @DEFUMASK@
-#cmakedefine HAVE_CSTDINT 1
-#cmakedefine HAVE_STDINT_H 1
-#cmakedefine HAVE_STDDEF_H 1
-#cmakedefine HAVE_STRCASECMP 1
-#cmakedefine HAVE_STRICMP 1
-#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_UMASK 1
-#cmakedefine HAVE_EVENTFD 1
-#cmakedefine HAVE_EPOLL 1
-#cmakedefine HAVE_POLL 1
#cmakedefine GETTEXT_FOUND 1
+#cmakedefine Boost_FOUND 1
-#ifdef HAVE_CSTDINT
-# include <cstdint>
-#else
-# ifdef HAVE_STDINT_H
-# include <stdint.h>
-# else
-# include "pstdint.h"
-# endif
-#endif
-#ifdef HAVE_STDDEF_H
-# include <stddef.h>
-#endif
-
-#ifdef _WIN32
-# define popen _popen
-# define pclose _pclose
-# define ftruncate _chsize
-# ifdef MSVCPP
-# define PATH_MAX MAX_PATH
-# endif
-# define MAXPATHLEN MAX_PATH
-# define bzero(buf, size) memset(buf, 0, size)
-# ifdef MSVCPP
-# define strcasecmp stricmp
-# endif
-# define sleep(x) Sleep(x * 1000)
-#endif
-
-#endif
diff --git a/include/threadengine.h b/include/threadengine.h
index 20a35cb09..81b5dcd13 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -1,21 +1,31 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef THREADENGINE_H
-#define THREADENGINE_H
+#pragma once
#include "sockets.h"
#include "extensible.h"
+#include <thread>
+#include <mutex>
+#include <condition_variable>
-class CoreExport Thread : public Pipe, public Extensible
+class CoreExport Thread : public Pipe
{
private:
/* Set to true to tell the thread to finish and we are waiting for it */
@@ -23,7 +33,7 @@ class CoreExport Thread : public Pipe, public Extensible
public:
/* Handle for this thread */
- pthread_t handle;
+ std::thread handle;
/** Threads constructor
*/
@@ -41,10 +51,6 @@ class CoreExport Thread : public Pipe, public Extensible
*/
void SetExitState();
- /** Exit the thread. Note that the thread still must be joined to free resources!
- */
- void Exit();
-
/** Launch the thread
*/
void Start();
@@ -56,65 +62,33 @@ class CoreExport Thread : public Pipe, public Extensible
/** Called when this thread should be joined to
*/
- void OnNotify();
+ void OnNotify() override;
/** Called when the thread is run.
*/
- virtual void Run() = 0;
+ virtual void Run() anope_abstract;
};
-class CoreExport Mutex
+class Mutex
{
protected:
- /* A mutex, used to keep threads in sync */
- pthread_mutex_t mutex;
+ std::mutex m;
public:
- /** Constructor
- */
- Mutex();
-
- /** Destructor
- */
- ~Mutex();
-
- /** Attempt to lock the mutex, will hang until a lock can be achieved
- */
void Lock();
- /** Unlock the mutex, it must be locked first
- */
- void Unlock();
-
- /** Attempt to lock the mutex, will return true on success and false on fail
- * Does not block
- * @return true or false
- */
bool TryLock();
+
+ void Unlock();
};
-class CoreExport Condition : public Mutex
+class Condition : public Mutex
{
- private:
- /* A condition */
- pthread_cond_t cond;
+ std::condition_variable_any cv;
public:
- /** Constructor
- */
- Condition();
-
- /** Destructor
- */
- ~Condition();
-
- /** Called to wakeup the waiter
- */
void Wakeup();
- /** Called to wait for a Wakeup() call
- */
void Wait();
};
-#endif // THREADENGINE_H
diff --git a/include/timers.h b/include/timers.h
index b15d2899f..1425a8fc4 100644
--- a/include/timers.h
+++ b/include/timers.h
@@ -1,16 +1,23 @@
-/* Timer include stuff.
+/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2011-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef TIMERS_H
-#define TIMERS_H
+#pragma once
#include "anope.h"
@@ -95,7 +102,7 @@ class CoreExport Timer
/** Called when the timer ticks
* This should be overridden with something useful
*/
- virtual void Tick(time_t ctime) = 0;
+ virtual void Tick(time_t ctime) anope_abstract;
};
/** This class manages sets of Timers, and triggers them at their defined times.
@@ -128,4 +135,3 @@ class CoreExport TimerManager
static void DeleteTimersFor(Module *m);
};
-#endif // TIMERS_H
diff --git a/include/uplink.h b/include/uplink.h
index 64cc1e08e..0075b5d44 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -1,16 +1,23 @@
/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef UPLINK_H
-#define UPLINK_H
+#pragma once
#include "sockets.h"
#include "protocol.h"
@@ -18,6 +25,21 @@
namespace Uplink
{
extern void Connect();
+ extern void SendMessage(IRCMessage &);
+
+ template<typename... Args>
+ void Send(const MessageSource &source, const Anope::string &command, Args&&... args)
+ {
+ IRCMessage message(source, command, std::forward<Args>(args)...);
+ SendMessage(message);
+ }
+
+ template<typename... Args>
+ void Send(const Anope::string &command, Args&&... args)
+ {
+ IRCMessage message(MessageSource(""), command, std::forward<Args>(args)...);
+ SendMessage(message);
+ }
}
/* This is the socket to our uplink */
@@ -27,27 +49,10 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
bool error;
UplinkSocket();
~UplinkSocket();
- bool ProcessRead() anope_override;
- void OnConnect() anope_override;
- void OnError(const Anope::string &) anope_override;
-
- /* A message sent over the uplink socket */
- class CoreExport Message
- {
- MessageSource source;
- std::stringstream buffer;
-
- public:
- Message();
- Message(const MessageSource &);
- ~Message();
- template<typename T> Message &operator<<(const T &val)
- {
- this->buffer << val;
- return *this;
- }
- };
+ bool ProcessRead() override;
+ void OnConnect() override;
+ void OnError(const Anope::string &) override;
};
+
extern CoreExport UplinkSocket *UplinkSock;
-#endif // UPLINK_H
diff --git a/include/users.h b/include/users.h
index 6f50d0cbd..dacb7045e 100644
--- a/include/users.h
+++ b/include/users.h
@@ -1,35 +1,49 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
- * (C) 2003-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
+ * Copyright (C) 2009-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef USERS_H
-#define USERS_H
+#pragma once
#include "anope.h"
#include "modes.h"
#include "extensible.h"
#include "serialize.h"
#include "commands.h"
-#include "account.h"
#include "sockets.h"
-typedef Anope::hash_map<User *> user_map;
+using user_map = Anope::locale_hash_map<User *>;
+using uid_map = std::unordered_map<Anope::string, User *, Anope::hash, Anope::compare>;
-extern CoreExport user_map UserListByNick, UserListByUID;
+extern CoreExport user_map UserListByNick;
+extern CoreExport uid_map UserListByUID;
extern CoreExport int OperCount;
-extern CoreExport unsigned MaxUserCount;
-extern CoreExport time_t MaxUserTime;
+
+enum class UserType
+{
+ USER,
+ //LOCAL_USER,
+ BOT
+};
/* Online user and channel data. */
-class CoreExport User : public virtual Base, public Extensible, public CommandReply
+class CoreExport User : public virtual Base, public virtual Extensible, public CommandReply
{
/* true if the user was quit or killed */
bool quit;
@@ -46,8 +60,8 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
bool on_access;
/* Map of user modes and the params this user has (if any) */
ModeList modes;
- /* NickCore account the user is currently loggged in as, if they are logged in */
- Serialize::Reference<NickCore> nc;
+ /* NickServ::Account account the user is currently loggged in as, if they are logged in */
+ Serialize::Reference<NickServ::Account> nc;
/* # of invalid password attempts */
unsigned short invalid_pw_count;
@@ -55,7 +69,9 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
time_t invalid_pw_time;
- public: // XXX: exposing a tiny bit too much
+ public:
+ UserType type = UserType::USER;
+
/* User's current nick */
Anope::string nick;
@@ -107,14 +123,14 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param suid The unique identifier of the user.
* @param nc The account the user is identified as, if any
*/
- User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc);
+ User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *nc);
/** Destroy a user.
*/
virtual ~User();
public:
- static User* OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc);
+ static User* OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *nc);
/** Update the nickname of a user record accordingly, should be
* called from ircd protocol.
@@ -186,11 +202,16 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/**
* Send a message (notice or privmsg, depending on settings) to a user
* @param source Sender
- * @param fmt Format of the Message
- * @param ... any number of parameters
+ * @param message Format of the Message
+ * @param args any number of parameters
*/
- void SendMessage(BotInfo *source, const char *fmt, ...);
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override;
+ template<typename... Args>
+ void SendMessage(const MessageSource &source, const char *message, Args&&... args)
+ {
+ const char *translated_message = Language::Translate(this->Account(), message);
+ SendMessage(source, Anope::Format(translated_message, std::forward<Args>(args)...));
+ }
+ void SendMessage(const MessageSource &, const Anope::string &msg) override;
/** Identify the user to a nick.
* updates last_seen, logs the user in,
@@ -198,12 +219,12 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param na the nick to identify to, should be the same as
* the user's current nick
*/
- void Identify(NickAlias *na);
+ void Identify(NickServ::Nick *na);
/** Login the user to an account
* @param core The account
*/
- void Login(NickCore *core);
+ void Login(NickServ::Account *core);
/** Logout the user
*/
@@ -212,7 +233,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/** Get the account the user is logged in using
* @return The account or NULL
*/
- NickCore *Account() const;
+ NickServ::Account *Account() const;
/** Check if the user is identified for their nick
* @param check_nick True to check if the user is identified to the nickname they are on too
@@ -271,34 +292,34 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param um The user mode
* @param Param Optional param for the mode
*/
- void SetMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
+ void SetMode(ServiceBot *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, const Anope::string &name, const Anope::string &param = "");
+ void SetMode(ServiceBot *bi, const Anope::string &name, const Anope::string &param = "");
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
* @param param Optional param for the mode
*/
- void RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
+ void RemoveMode(ServiceBot *bi, UserMode *um, const Anope::string &param = "");
/** Remove a mode from the user
* @param bi The client setting the mode
* @param name The mode name
* @param param Optional param for the mode
*/
- void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "");
+ void RemoveMode(ServiceBot *bi, const Anope::string &name, const Anope::string &param = "");
/** 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(ServiceBot *bi, const char *umodes, ...);
/** Set a string of modes on a user internally
* @param setter who/what is setting the mode
@@ -372,4 +393,12 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
static void QuitUsers();
};
-#endif // USERS_H
+class LocalUser : public User
+{
+ public:
+ using User::User;
+
+ /* Last time this user said something */
+ time_t lastmsg = 0;
+};
+
diff --git a/include/version.cpp b/include/version.cpp
index 017924283..7dc0b3402 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -1,12 +1,20 @@
-/* Build bumper
+/*
+ * Anope IRC Services
*
- * (C) 2003-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2010-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
@@ -28,7 +36,7 @@ static std::string get_git_hash(const std::string &git_dir)
fd.close();
return "";
}
-
+
fd.close();
filebuf = filebuf.substr(5);
diff --git a/include/xline.h b/include/xline.h
index 63d4bb8db..87b64d1da 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -1,64 +1,118 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2016 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2012-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef XLINE_H
-#define XLINE_H
+
+#pragma once
#include "serialize.h"
#include "service.h"
#include "sockets.h"
-/* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
-class CoreExport XLine : public Serializable
+/* An XLine, eg, anything added with operserv/akill, or any of the operserv/sxline commands */
+class CoreExport XLine : public Serialize::Object
{
- void Init();
+ void Recache();
Anope::string nick, user, host, real;
+
+ friend class XLineType;
+
+ Anope::string type, mask, by, reason, id;
+ time_t created = 0, expires = 0;
+
public:
- cidr *c;
- Anope::string mask;
- Regex *regex;
- Anope::string by;
- time_t created;
- time_t expires;
- Anope::string reason;
- XLineManager *manager;
- Anope::string id;
-
- XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = "");
-
- XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = "");
+ static constexpr const char *const NAME = "xline";
+
+ cidr *c = nullptr;
+ std::regex *regex = nullptr;
+
+ using Serialize::Object::Object;
+
~XLine();
+ void SetType(const Anope::string &);
+ Anope::string GetType();
+
+ void SetMask(const Anope::string &);
+ Anope::string GetMask();
+
+ void SetBy(const Anope::string &);
+ Anope::string GetBy();
+
+ void SetReason(const Anope::string &);
+ Anope::string GetReason();
+
+ void SetID(const Anope::string &);
+ Anope::string GetID();
+
+ void SetCreated(const time_t &);
+ time_t GetCreated();
+
+ void SetExpires(const time_t &);
+ time_t GetExpires();
+
const Anope::string &GetNick() const;
const Anope::string &GetUser() const;
const Anope::string &GetHost() const;
const Anope::string &GetReal() const;
- Anope::string GetReason() const;
+ Anope::string GetReasonWithID();
bool HasNickOrReal() const;
- bool IsRegex() const;
+ bool IsRegex();
- void Serialize(Serialize::Data &data) const anope_override;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &data);
+ XLineManager *GetManager();
+};
+
+class XLineType : public Serialize::Type<XLine>
+{
+ public:
+ Serialize::Field<XLine, Anope::string> type;
+ struct Mask : Serialize::Field<XLine, Anope::string>
+ {
+ using Serialize::Field<XLine, Anope::string>::Field;
+
+ void SetField(XLine *s, const Anope::string &value) override;
+ } mask;
+ Serialize::Field<XLine, Anope::string> by, reason, id;
+ Serialize::Field<XLine, time_t> created, expires;
+
+ XLineType(Module *m) : Serialize::Type<XLine>(m)
+ , type(this, "type", &XLine::type)
+ , mask(this, "mask", &XLine::mask)
+ , by(this, "by", &XLine::by)
+ , reason(this, "reason", &XLine::reason)
+ , id(this, "id", &XLine::id)
+ , created(this, "created", &XLine::created)
+ , expires(this, "expires", &XLine::expires)
+ {
+ }
};
/* Managers XLines. There is one XLineManager per type of XLine. */
class CoreExport XLineManager : public Service
{
char type;
- /* List of XLines in this XLineManager */
- Serialize::Checker<std::vector<XLine *> > xlines;
- /* Akills can have the same IDs, sometimes */
- static Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
public:
+ static constexpr const char *NAME = "xlinemanager";
+
/* List of XLine managers we check users against in XLineManager::CheckAll */
- static std::list<XLineManager *> XLineManagers;
+ static std::vector<XLineManager *> XLineManagers;
/** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll
* It is important XLineManagers are registered in the proper order. Eg, if you had one akilling
@@ -95,31 +149,20 @@ class CoreExport XLineManager : public Service
/** The type of xline provided by this service
* @return The type
*/
- const char &Type();
-
- /** Get the number of XLines in this XLineManager
- * @return The number of XLines
- */
- size_t GetCount() const;
+ char Type();
/** Get the XLine vector
* @return The vector
*/
- const std::vector<XLine *> &GetList() const;
+ std::vector<XLine *> GetXLines() const;
+
+ inline unsigned int GetCount() const { return GetXLines().size(); }
/** Add an entry to this XLineManager
* @param x The entry
*/
void AddXLine(XLine *x);
- void RemoveXLine(XLine *);
-
- /** Delete an entry from this XLineManager
- * @param x The entry
- * @return true if the entry was found and deleted, else false
- */
- bool DelXLine(XLine *x);
-
/** Gets an entry by index
* @param index The index
* @return The XLine, or NULL if the index is out of bounds
@@ -156,29 +199,28 @@ class CoreExport XLineManager : public Service
* @param u The user
* @param x The xline
*/
- virtual bool Check(User *u, const XLine *x) = 0;
+ virtual bool Check(User *u, XLine *x) anope_abstract;
/** Called when a user matches a xline in this XLineManager
* @param u The user
* @param x The XLine they match
*/
- virtual void OnMatch(User *u, XLine *x) = 0;
+ virtual void OnMatch(User *u, XLine *x) anope_abstract;
/** Called when an XLine expires
* @param x The xline
*/
- virtual void OnExpire(const XLine *x);
+ virtual void OnExpire(XLine *x);
/** Called to send an XLine to the IRCd
* @param u The user, if we know it
* @param x The xline
*/
- virtual void Send(User *u, XLine *x) = 0;
+ virtual void Send(User *u, XLine *x) anope_abstract;
/** Called to remove an XLine from the IRCd
* @param x The XLine
*/
- virtual void SendDel(XLine *x) = 0;
+ virtual void SendDel(XLine *x) anope_abstract;
};
-#endif // XLINE_H