From f29e1cf383529a1a29f02b0669d973f5ee0b7a66 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 28 May 2014 12:07:29 -0400 Subject: Move most of the core pseudoclient logic to modules --- include/access.h | 169 ----- include/account.h | 279 -------- include/anope.h | 10 +- include/bots.h | 10 +- include/channels.h | 17 +- include/commands.h | 12 +- include/config.h | 2 - include/defs.h | 26 +- include/event.h | 70 +- include/language.h | 4 +- include/lists.h | 8 +- include/logger.h | 6 +- include/mail.h | 4 +- include/memo.h | 53 -- include/messages.h | 68 +- include/modes.h | 6 +- include/module.h | 9 +- include/modules/botserv.h | 22 + include/modules/bs_badwords.h | 4 +- include/modules/bs_info.h | 2 +- include/modules/bs_kick.h | 4 +- include/modules/chanserv.h | 595 ++++++++++++++++- include/modules/cs_access.h | 2 +- include/modules/cs_akick.h | 34 +- include/modules/cs_drop.h | 2 +- include/modules/cs_info.h | 2 +- include/modules/cs_mode.h | 4 +- include/modules/cs_set.h | 2 +- include/modules/dns.h | 42 +- include/modules/fantasy.h | 4 +- include/modules/hs_del.h | 2 +- include/modules/memoserv.h | 58 +- include/modules/nickserv.h | 288 +++++++- include/modules/ns_cert.h | 16 +- include/modules/ns_drop.h | 2 +- include/modules/ns_group.h | 2 +- include/modules/ns_info.h | 2 +- include/modules/ns_set.h | 2 +- include/modules/os_ignore.h | 2 +- include/modules/os_news.h | 6 +- include/modules/os_session.h | 2 +- include/modules/redis.h | 2 +- include/modules/sasl.h | 20 +- include/modules/ssl.h | 2 +- include/modules/suspend.h | 8 +- include/modules/xmlrpc.h | 2 +- include/opertype.h | 5 +- include/protocol.h | 4 +- include/regchannel.h | 246 ------- include/users.h | 19 +- include/version.cpp | 2 +- modules/bs_autoassign.cpp | 4 +- modules/commands/bs_assign.cpp | 18 +- modules/commands/bs_badwords.cpp | 28 +- modules/commands/bs_bot.cpp | 10 +- modules/commands/bs_control.cpp | 4 +- modules/commands/bs_info.cpp | 17 +- modules/commands/bs_kick.cpp | 68 +- modules/commands/bs_set.cpp | 6 +- modules/commands/cs_access.cpp | 155 ++--- modules/commands/cs_akick.cpp | 202 ++++-- modules/commands/cs_ban.cpp | 8 +- modules/commands/cs_clone.cpp | 24 +- modules/commands/cs_drop.cpp | 2 +- modules/commands/cs_enforce.cpp | 20 +- modules/commands/cs_entrymsg.cpp | 18 +- modules/commands/cs_flags.cpp | 46 +- modules/commands/cs_getkey.cpp | 2 +- modules/commands/cs_info.cpp | 4 +- modules/commands/cs_invite.cpp | 2 +- modules/commands/cs_kick.cpp | 8 +- modules/commands/cs_list.cpp | 17 +- modules/commands/cs_log.cpp | 12 +- modules/commands/cs_mode.cpp | 48 +- modules/commands/cs_register.cpp | 8 +- modules/commands/cs_seen.cpp | 15 +- modules/commands/cs_set.cpp | 60 +- modules/commands/cs_set_misc.cpp | 8 +- modules/commands/cs_status.cpp | 11 +- modules/commands/cs_suspend.cpp | 14 +- modules/commands/cs_sync.cpp | 4 +- modules/commands/cs_topic.cpp | 16 +- modules/commands/cs_unban.cpp | 6 +- modules/commands/cs_updown.cpp | 4 +- modules/commands/cs_xop.cpp | 66 +- modules/commands/greet.cpp | 14 +- modules/commands/help.cpp | 6 +- modules/commands/hs_del.cpp | 6 +- modules/commands/hs_group.cpp | 12 +- modules/commands/hs_list.cpp | 4 +- modules/commands/hs_off.cpp | 2 +- modules/commands/hs_on.cpp | 2 +- modules/commands/hs_request.cpp | 20 +- modules/commands/hs_set.cpp | 10 +- modules/commands/ms_cancel.cpp | 36 +- modules/commands/ms_check.cpp | 33 +- modules/commands/ms_del.cpp | 18 +- modules/commands/ms_ignore.cpp | 10 +- modules/commands/ms_info.cpp | 20 +- modules/commands/ms_list.cpp | 18 +- modules/commands/ms_read.cpp | 28 +- modules/commands/ms_rsend.cpp | 12 +- modules/commands/ms_sendall.cpp | 4 +- modules/commands/ms_set.cpp | 26 +- modules/commands/ms_staff.cpp | 4 +- modules/commands/ns_access.cpp | 12 +- modules/commands/ns_ajoin.cpp | 26 +- modules/commands/ns_alist.cpp | 14 +- modules/commands/ns_cert.cpp | 34 +- modules/commands/ns_drop.cpp | 2 +- modules/commands/ns_getemail.cpp | 6 +- modules/commands/ns_getpass.cpp | 4 +- modules/commands/ns_group.cpp | 55 +- modules/commands/ns_identify.cpp | 22 +- modules/commands/ns_info.cpp | 6 +- modules/commands/ns_list.cpp | 20 +- modules/commands/ns_recover.cpp | 39 +- modules/commands/ns_register.cpp | 24 +- modules/commands/ns_resetpass.cpp | 12 +- modules/commands/ns_set.cpp | 56 +- modules/commands/ns_set_misc.cpp | 12 +- modules/commands/ns_status.cpp | 2 +- modules/commands/ns_suspend.cpp | 16 +- modules/commands/ns_update.cpp | 2 +- modules/commands/os_akill.cpp | 2 +- modules/commands/os_config.cpp | 2 +- modules/commands/os_defcon.cpp | 10 +- modules/commands/os_dns.cpp | 14 +- modules/commands/os_forbid.cpp | 10 +- modules/commands/os_ignore.cpp | 6 +- modules/commands/os_info.cpp | 16 +- modules/commands/os_logsearch.cpp | 2 +- modules/commands/os_mode.cpp | 2 +- modules/commands/os_module.cpp | 2 +- modules/commands/os_news.cpp | 2 +- modules/commands/os_oline.cpp | 2 +- modules/commands/os_oper.cpp | 16 +- modules/commands/os_session.cpp | 6 +- modules/commands/os_set.cpp | 2 +- modules/commands/os_stats.cpp | 6 +- modules/cs_statusupdate.cpp | 12 +- modules/database/db_flatfile.cpp | 4 +- modules/database/db_old.cpp | 93 ++- modules/database/db_redis.cpp | 10 +- modules/database/db_sql_live.cpp | 2 +- modules/encryption/enc_bcrypt.cpp | 7 +- modules/encryption/enc_md5.cpp | 8 +- modules/encryption/enc_none.cpp | 6 +- modules/encryption/enc_old.cpp | 6 +- modules/encryption/enc_sha1.cpp | 6 +- modules/encryption/enc_sha256.cpp | 6 +- modules/extra/m_ldap.cpp | 6 +- modules/extra/m_ldap_authentication.cpp | 8 +- modules/extra/m_ldap_oper.cpp | 4 +- modules/extra/m_mysql.cpp | 4 +- modules/extra/m_sql_authentication.cpp | 4 +- modules/extra/m_sql_oper.cpp | 4 +- modules/extra/m_sqlite.cpp | 2 +- modules/extra/m_ssl_openssl.cpp | 8 +- modules/extra/stats/cs_fantasy_stats.cpp | 2 +- modules/extra/stats/m_chanstats.cpp | 20 +- modules/fantasy.cpp | 14 +- modules/m_dns.cpp | 42 +- modules/m_httpd.cpp | 2 +- modules/m_rewrite.cpp | 4 +- modules/m_sasl.cpp | 8 +- modules/m_xmlrpc_main.cpp | 20 +- modules/ns_maxemail.cpp | 6 +- modules/protocol/bahamut.cpp | 8 +- modules/protocol/charybdis.cpp | 14 +- modules/protocol/hybrid.cpp | 6 +- modules/protocol/inspircd20.cpp | 20 +- modules/protocol/ngircd.cpp | 8 +- modules/protocol/plexus.cpp | 12 +- modules/protocol/ratbox.cpp | 4 +- modules/protocol/unreal.cpp | 26 +- modules/pseudoclients/botserv.cpp | 235 ------- modules/pseudoclients/botserv/CMakeLists.txt | 1 + modules/pseudoclients/botserv/botserv.cpp | 237 +++++++ modules/pseudoclients/chanserv.cpp | 525 --------------- modules/pseudoclients/chanserv/CMakeLists.txt | 1 + modules/pseudoclients/chanserv/channel.cpp | 605 +++++++++++++++++ modules/pseudoclients/chanserv/channel.h | 41 ++ modules/pseudoclients/chanserv/chanserv.cpp | 736 +++++++++++++++++++++ modules/pseudoclients/global.cpp | 2 +- modules/pseudoclients/hostserv.cpp | 18 +- modules/pseudoclients/memoserv.cpp | 246 ------- modules/pseudoclients/memoserv/CMakeLists.txt | 1 + modules/pseudoclients/memoserv/memo.cpp | 58 ++ modules/pseudoclients/memoserv/memo.h | 11 + modules/pseudoclients/memoserv/memoinfo.cpp | 33 + modules/pseudoclients/memoserv/memoinfo.h | 10 + modules/pseudoclients/memoserv/memoserv.cpp | 291 ++++++++ modules/pseudoclients/nickserv.cpp | 594 ----------------- modules/pseudoclients/nickserv/CMakeLists.txt | 1 + modules/pseudoclients/nickserv/account.cpp | 264 ++++++++ modules/pseudoclients/nickserv/account.h | 22 + modules/pseudoclients/nickserv/identifyrequest.cpp | 51 ++ modules/pseudoclients/nickserv/identifyrequest.h | 13 + modules/pseudoclients/nickserv/nick.cpp | 198 ++++++ modules/pseudoclients/nickserv/nick.h | 18 + modules/pseudoclients/nickserv/nickserv.cpp | 666 +++++++++++++++++++ modules/pseudoclients/operserv.cpp | 2 +- modules/webcpanel/pages/chanserv/access.cpp | 29 +- modules/webcpanel/pages/chanserv/access.h | 2 +- modules/webcpanel/pages/chanserv/akick.cpp | 19 +- modules/webcpanel/pages/chanserv/akick.h | 2 +- modules/webcpanel/pages/chanserv/drop.cpp | 6 +- modules/webcpanel/pages/chanserv/drop.h | 2 +- modules/webcpanel/pages/chanserv/info.cpp | 2 +- modules/webcpanel/pages/chanserv/info.h | 2 +- modules/webcpanel/pages/chanserv/modes.cpp | 6 +- modules/webcpanel/pages/chanserv/modes.h | 2 +- modules/webcpanel/pages/chanserv/set.cpp | 4 +- modules/webcpanel/pages/chanserv/set.h | 2 +- modules/webcpanel/pages/chanserv/utils.cpp | 8 +- modules/webcpanel/pages/chanserv/utils.h | 2 +- modules/webcpanel/pages/hostserv/request.cpp | 4 +- modules/webcpanel/pages/hostserv/request.h | 2 +- modules/webcpanel/pages/index.cpp | 21 +- modules/webcpanel/pages/logout.cpp | 2 +- modules/webcpanel/pages/logout.h | 2 +- modules/webcpanel/pages/memoserv/memos.cpp | 60 +- modules/webcpanel/pages/memoserv/memos.h | 2 +- modules/webcpanel/pages/nickserv/access.cpp | 2 +- modules/webcpanel/pages/nickserv/access.h | 2 +- modules/webcpanel/pages/nickserv/alist.cpp | 12 +- modules/webcpanel/pages/nickserv/alist.h | 2 +- modules/webcpanel/pages/nickserv/cert.cpp | 2 +- modules/webcpanel/pages/nickserv/cert.h | 2 +- modules/webcpanel/pages/nickserv/info.cpp | 4 +- modules/webcpanel/pages/nickserv/info.h | 2 +- modules/webcpanel/pages/operserv/akill.cpp | 2 +- modules/webcpanel/pages/operserv/akill.h | 2 +- modules/webcpanel/static_fileserver.cpp | 2 +- modules/webcpanel/template_fileserver.cpp | 8 +- modules/webcpanel/webcpanel.cpp | 6 +- modules/webcpanel/webcpanel.h | 10 +- src/access.cpp | 441 ------------ src/account.cpp | 80 --- src/bots.cpp | 18 +- src/channels.cpp | 63 +- src/command.cpp | 23 +- src/config.cpp | 61 +- src/event.cpp | 1 - src/hashcomp.cpp | 2 +- src/init.cpp | 2 +- src/language.cpp | 7 +- src/logger.cpp | 12 +- src/mail.cpp | 9 +- src/memos.cpp | 133 ---- src/messages.cpp | 15 +- src/misc.cpp | 12 +- src/modes.cpp | 41 +- src/module.cpp | 4 +- src/modulemanager.cpp | 17 +- src/nickalias.cpp | 217 ------ src/nickcore.cpp | 266 -------- src/process.cpp | 5 +- src/protocol.cpp | 6 +- src/regchannel.cpp | 689 ------------------- src/serialize.cpp | 8 +- src/servers.cpp | 12 +- src/socket_transport.cpp | 4 +- src/socketengines/socketengine_epoll.cpp | 6 +- src/socketengines/socketengine_kqueue.cpp | 4 +- src/socketengines/socketengine_poll.cpp | 2 +- src/socketengines/socketengine_select.cpp | 2 +- src/sockets.cpp | 2 +- src/tools/anopesmtp.cpp | 2 +- src/uplink.cpp | 1 + src/users.cpp | 73 +- src/win32/anope_windows.h | 4 +- src/win32/dir/dir.cpp | 2 +- src/win32/dir/dir.h | 2 +- src/win32/pipe/pipe.cpp | 2 +- src/win32/resource.h | 2 +- src/win32/sigaction/sigaction.cpp | 5 +- src/win32/sigaction/sigaction.h | 10 +- src/win32/socket.cpp | 2 +- src/win32/windows.cpp | 6 +- 281 files changed, 5910 insertions(+), 5748 deletions(-) delete mode 100644 include/access.h delete mode 100644 include/account.h delete mode 100644 include/memo.h create mode 100644 include/modules/botserv.h delete mode 100644 include/regchannel.h delete mode 100644 modules/pseudoclients/botserv.cpp create mode 100644 modules/pseudoclients/botserv/CMakeLists.txt create mode 100644 modules/pseudoclients/botserv/botserv.cpp delete mode 100644 modules/pseudoclients/chanserv.cpp create mode 100644 modules/pseudoclients/chanserv/CMakeLists.txt create mode 100644 modules/pseudoclients/chanserv/channel.cpp create mode 100644 modules/pseudoclients/chanserv/channel.h create mode 100644 modules/pseudoclients/chanserv/chanserv.cpp delete mode 100644 modules/pseudoclients/memoserv.cpp create mode 100644 modules/pseudoclients/memoserv/CMakeLists.txt create mode 100644 modules/pseudoclients/memoserv/memo.cpp create mode 100644 modules/pseudoclients/memoserv/memo.h create mode 100644 modules/pseudoclients/memoserv/memoinfo.cpp create mode 100644 modules/pseudoclients/memoserv/memoinfo.h create mode 100644 modules/pseudoclients/memoserv/memoserv.cpp delete mode 100644 modules/pseudoclients/nickserv.cpp create mode 100644 modules/pseudoclients/nickserv/CMakeLists.txt create mode 100644 modules/pseudoclients/nickserv/account.cpp create mode 100644 modules/pseudoclients/nickserv/account.h create mode 100644 modules/pseudoclients/nickserv/identifyrequest.cpp create mode 100644 modules/pseudoclients/nickserv/identifyrequest.h create mode 100644 modules/pseudoclients/nickserv/nick.cpp create mode 100644 modules/pseudoclients/nickserv/nick.h create mode 100644 modules/pseudoclients/nickserv/nickserv.cpp delete mode 100644 src/access.cpp delete mode 100644 src/account.cpp delete mode 100644 src/memos.cpp delete mode 100644 src/nickalias.cpp delete mode 100644 src/nickcore.cpp delete mode 100644 src/regchannel.cpp diff --git a/include/access.h b/include/access.h deleted file mode 100644 index 292e95228..000000000 --- a/include/access.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * - * (C) 2003-2014 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. - * - */ - -#pragma once - -#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 Privileges; - public: - static void AddPrivilege(Privilege p); - static void RemovePrivilege(Privilege &p); - static Privilege *FindPrivilege(const Anope::string &name); - static std::vector &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 Providers; - public: - static const std::list& GetProviders(); -}; - -/* Represents one entry of an access list on a channel. */ -class CoreExport ChanAccess : public Serializable -{ - public: - typedef std::multimap Set; - /* shows the 'path' taken to determine if an access entry matches a user - * .first are access entries checked - * .second are access entries which match - */ - typedef std::pair Path; - - /* The provider that created this access entry */ - AccessProvider *provider; - /* Channel this access entry is on */ - Serialize::Reference ci; - /* account this access entry is for, if any */ - Serialize::Reference nc; - Anope::string mask; - Anope::string creator; - time_t last_seen; - time_t created; - - ChanAccess(AccessProvider *p); - virtual ~ChanAccess(); - - void Serialize(Serialize::Data &data) const override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &); - - /** Check if this access entry matches the given user or account - * @param u The user - * @param nc The account - * @param p The path to the access object which matches will be put here - */ - virtual bool Matches(const User *u, const NickCore *nc, Path &p) 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 std::vector -{ - public: - /* Channel these access entries are on */ - const ChannelInfo *ci; - /* Path from these entries to other entries that they depend on */ - ChanAccess::Path path; - /* 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; -}; - diff --git a/include/account.h b/include/account.h deleted file mode 100644 index 381047ac4..000000000 --- a/include/account.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - * - * (C) 2003-2014 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. - * - */ - -#pragma once - -#include "extensible.h" -#include "serialize.h" -#include "anope.h" -#include "memo.h" -#include "base.h" - -typedef Anope::hash_map nickalias_map; -typedef Anope::hash_map nickcore_map; - -extern CoreExport Serialize::Checker NickAliasList; -extern CoreExport Serialize::Checker 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 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 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 > 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 access; - MemoInfo memos; - std::map last_modes; - - /* Nicknames registered that are grouped to this account. - * for n in aliases, n->nc == this. - */ - Serialize::Checker > 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 users; - - /** Constructor - * @param display The display nick - */ - NickCore(const Anope::string &nickdisplay); - ~NickCore(); - - void Serialize(Serialize::Data &data) const override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &); - - /** Changes the display for this account - * @param na The new display, must be grouped to this account. - */ - 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 &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 holds; - bool dispatched; - bool success; - - static std::set 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); -}; diff --git a/include/anope.h b/include/anope.h index bb20299e4..845a2b1fb 100644 --- a/include/anope.h +++ b/include/anope.h @@ -441,13 +441,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 @@ -502,21 +502,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, const 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, const 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, const 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 diff --git a/include/bots.h b/include/bots.h index 353be89cb..9a2c5d237 100644 --- a/include/bots.h +++ b/include/bots.h @@ -15,7 +15,7 @@ #include "commands.h" -typedef Anope::map botinfo_map; +typedef Anope::hash_map botinfo_map; extern CoreExport Serialize::Checker BotListByNick, BotListByUID; @@ -23,7 +23,7 @@ extern CoreExport Serialize::Checker BotListByNick, BotListByUID; class CoreExport BotInfo : public User, public Serializable { /* Channels this bot is assigned to */ - Serialize::Checker > channels; + Serialize::Checker > channels; public: time_t created; /* Last time this bot said something (via privmsg) */ @@ -68,19 +68,19 @@ class CoreExport BotInfo : public User, public Serializable /** Return the channels this bot is assigned to */ - const std::set &GetChannels() const; + const std::set &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 */ diff --git a/include/channels.h b/include/channels.h index e676bb924..3deadce5b 100644 --- a/include/channels.h +++ b/include/channels.h @@ -42,7 +42,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 ci; + Serialize::Reference ci; /* When the channel was created */ time_t creation_time; /* If the channel has just been created in a netjoin */ @@ -163,7 +163,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 ¶m = "", bool enforce_mlock = true); + void SetMode(User *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** * Set a mode on a channel @@ -172,7 +172,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 ¶m = "", bool enforce_mlock = true); + void SetMode(User *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Remove a mode from a channel * @param bi The client setting the modes @@ -180,7 +180,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 ¶m = "", bool enforce_mlock = true); + void RemoveMode(User *bi, ChannelMode *cm, const Anope::string ¶m = "", bool enforce_mlock = true); /** * Remove a mode from a channel @@ -189,7 +189,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 ¶m = "", bool enforce_mlock = true); + void RemoveMode(User *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Get a modes parameter for the channel * @param name The mode @@ -203,7 +203,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 @@ -223,8 +223,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 @@ -232,7 +233,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. diff --git a/include/commands.h b/include/commands.h index 2be64d00d..ac79267ae 100644 --- a/include/commands.h +++ b/include/commands.h @@ -45,7 +45,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 */ @@ -57,7 +57,7 @@ class CoreExport CommandSource Reference u; public: /* The account executing the command */ - Reference nc; + Reference nc; /* Where the reply should go */ CommandReply *reply; /* Channel the command was executed on (fantasy) */ @@ -69,13 +69,13 @@ class CoreExport CommandSource /* 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, BotInfo *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); void Reply(const char *message, ...); void Reply(const Anope::string &message); diff --git a/include/config.h b/include/config.h index 903c41120..3d0133409 100644 --- a/include/config.h +++ b/include/config.h @@ -12,8 +12,6 @@ #pragma once -#include "account.h" -#include "regchannel.h" #include "users.h" #include "opertype.h" #include diff --git a/include/defs.h b/include/defs.h index b53e512d6..4c1e9ce91 100644 --- a/include/defs.h +++ b/include/defs.h @@ -11,13 +11,16 @@ */ -class AccessGroup; class AutoKick; class BotInfo; -class ChanAccess; class Channel; -class ChannelInfo; class ChannelStatus; +namespace ChanServ +{ + class AccessGroup; + class ChanAccess; + class Channel; +} struct ChanUserContainer; class ClientSocket; class Command; @@ -25,16 +28,24 @@ class CommandSource; namespace Configuration { struct Conf; } class ConnectionSocket; class Entry; -class IdentifyRequest; class InfoFormatter; class IRCDProto; class ListenSocket; class Log; -class Memo; +class LogInfo; +namespace NickServ +{ + class Account; + class Nick; + class IdentifyRequest; +} +namespace MemoServ +{ + class Memo; + struct MemoInfo; +} class MessageSource; class Module; -class NickAlias; -class NickCore; class OperType; class ReferenceBase; class Regex; @@ -47,7 +58,6 @@ class XLine; class XLineManager; struct BadWord; struct Exception; -struct MemoInfo; struct ModeLock; struct Oper; namespace SASL { struct Message; } diff --git a/include/event.h b/include/event.h index aab854750..83d5a79e1 100644 --- a/include/event.h +++ b/include/event.h @@ -147,8 +147,9 @@ namespace Event * @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 void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_abstract; + virtual EventReturn OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) anope_abstract; }; extern CoreExport EventHandlers OnPreUserKicked; @@ -173,7 +174,7 @@ namespace Event * @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) anope_abstract; + virtual EventReturn OnPreBotAssign(User *sender, ChanServ::Channel *ci, BotInfo *bi) anope_abstract; }; extern CoreExport EventHandlers OnPreBotAssign; @@ -181,7 +182,7 @@ namespace Event { /** Called when a bot is assigned ot a channel */ - virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) anope_abstract; + virtual void OnBotAssign(User *sender, ChanServ::Channel *ci, BotInfo *bi) anope_abstract; }; extern CoreExport EventHandlers OnBotAssign; @@ -192,7 +193,7 @@ namespace Event * @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) anope_abstract; + virtual EventReturn OnBotUnAssign(User *sender, ChanServ::Channel *ci) anope_abstract; }; extern CoreExport EventHandlers OnBotUnAssign; @@ -297,19 +298,6 @@ namespace Event }; extern CoreExport EventHandlers OnDelBot; - struct CoreExport BotKick : Events - { - /** 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) anope_abstract; - }; - extern CoreExport EventHandlers OnBotKick; - struct CoreExport PrePartChannel : Events { /** Called before a user parts a channel @@ -492,7 +480,7 @@ namespace Event * @param source The source of the command * @param access The access entry that was removed */ - virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) anope_abstract; + virtual void OnAccessDel(ChanServ::Channel *ci, CommandSource &source, ChanServ::ChanAccess *access) anope_abstract; }; extern CoreExport EventHandlers OnAccessDel; @@ -503,7 +491,7 @@ namespace Event * @param source The source of the command * @param access The access changed */ - virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) anope_abstract; + virtual void OnAccessAdd(ChanServ::Channel *ci, CommandSource &source, ChanServ::ChanAccess *access) anope_abstract; }; extern CoreExport EventHandlers OnAccessAdd; @@ -513,7 +501,7 @@ namespace Event * @param ci The channel * @param u The user who cleared the access */ - virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) anope_abstract; + virtual void OnAccessClear(ChanServ::Channel *ci, CommandSource &source) anope_abstract; }; extern CoreExport EventHandlers OnAccessClear; @@ -522,7 +510,7 @@ namespace Event /** Called when a channel is registered * @param ci The channel */ - virtual void OnChanRegistered(ChannelInfo *ci) anope_abstract; + virtual void OnChanRegistered(ChanServ::Channel *ci) anope_abstract; }; extern CoreExport EventHandlers OnChanRegistered; @@ -532,7 +520,7 @@ namespace Event /** Called when a channel is being created, for any reason * @param ci The channel */ - virtual void OnCreateChan(ChannelInfo *ci) anope_abstract; + virtual void OnCreateChan(ChanServ::Channel *ci) anope_abstract; }; extern CoreExport EventHandlers OnCreateChan; @@ -541,7 +529,7 @@ namespace Event /** Called when a channel is being deleted, for any reason * @param ci The channel */ - virtual void OnDelChan(ChannelInfo *ci) anope_abstract; + virtual void OnDelChan(ChanServ::Channel *ci) anope_abstract; }; extern CoreExport EventHandlers OnDelChan; @@ -586,7 +574,7 @@ namespace Event * @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) anope_abstract; + virtual EventReturn OnCheckPriv(const ChanServ::ChanAccess *access, const Anope::string &priv) anope_abstract; }; extern CoreExport EventHandlers OnCheckPriv; @@ -597,7 +585,7 @@ namespace Event * @param priv The privilege * @return MOD_ALLOW to allow, MOD_STOP to stop */ - virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) anope_abstract; + virtual EventReturn OnGroupCheckPriv(const ChanServ::AccessGroup *group, const Anope::string &priv) anope_abstract; }; extern CoreExport EventHandlers OnGroupCheckPriv; @@ -633,7 +621,7 @@ namespace Event /** Called on delnick() * @ param na pointer to the nickalias */ - virtual void OnDelNick(NickAlias *na) anope_abstract; + virtual void OnDelNick(NickServ::Nick *na) anope_abstract; }; extern CoreExport EventHandlers OnDelNick; @@ -642,35 +630,35 @@ namespace Event /** Called when a nickcore is created * @param nc The nickcore */ - virtual void OnNickCoreCreate(NickCore *nc) anope_abstract; + virtual void OnNickCoreCreate(NickServ::Account *nc) anope_abstract; }; extern CoreExport EventHandlers OnNickCoreCreate; struct CoreExport DelCore : Events { /** Called on delcore() - * @param nc pointer to the NickCore + * @param nc pointer to the NickServ::Account */ - virtual void OnDelCore(NickCore *nc) anope_abstract; + virtual void OnDelCore(NickServ::Account *nc) anope_abstract; }; extern CoreExport EventHandlers OnDelCore; struct CoreExport ChangeCoreDisplay : Events { /** Called on change_core_display() - * @param nc pointer to the NickCore + * @param nc pointer to the NickServ::Account * @param newdisplay the new display */ - virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_abstract; + virtual void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) anope_abstract; }; extern CoreExport EventHandlers OnChangeCoreDisplay; struct CoreExport NickClearAccess : Events { - /** called from NickCore::ClearAccess() - * @param nc pointer to the NickCore + /** called from NickServ::Account::ClearAccess() + * @param nc pointer to the NickServ::Account */ - virtual void OnNickClearAccess(NickCore *nc) anope_abstract; + virtual void OnNickClearAccess(NickServ::Account *nc) anope_abstract; }; extern CoreExport EventHandlers OnNickClearAccess; @@ -680,17 +668,17 @@ namespace Event * @param nc The nick * @param entry The entry */ - virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) anope_abstract; + virtual void OnNickAddAccess(NickServ::Account *nc, const Anope::string &entry) anope_abstract; }; extern CoreExport EventHandlers OnNickAddAccess; struct CoreExport NickEraseAccess : Events { - /** Called from NickCore::EraseAccess() - * @param nc pointer to the NickCore + /** Called from NickServ::Account::EraseAccess() + * @param nc pointer to the NickServ::Account * @param entry The access mask */ - virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) anope_abstract; + virtual void OnNickEraseAccess(NickServ::Account *nc, const Anope::string &entry) anope_abstract; }; extern CoreExport EventHandlers OnNickEraseAccess; @@ -702,7 +690,7 @@ namespace Event * @param u The user trying to identify, if applicable. * @param req The login request */ - virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) anope_abstract; + virtual void OnCheckAuthentication(User *u, NickServ::IdentifyRequest *req) anope_abstract; }; extern CoreExport EventHandlers OnCheckAuthentication; @@ -741,7 +729,7 @@ namespace Event /** Called when a vhost is set * @param na The nickalias of the vhost */ - virtual void OnSetVhost(NickAlias *na) anope_abstract; + virtual void OnSetVhost(NickServ::Nick *na) anope_abstract; }; extern CoreExport EventHandlers OnSetVhost; @@ -943,7 +931,7 @@ namespace Event * @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) anope_abstract; + virtual void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) anope_abstract; }; extern CoreExport EventHandlers OnSetCorrectModes; diff --git a/include/language.h b/include/language.h index 041f90b11..55726b8d6 100644 --- a/include/language.h +++ b/include/language.h @@ -24,7 +24,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 Domains; @@ -52,7 +52,7 @@ namespace Language * @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(const NickServ::Account *nc, const char *string); /** Translatesa string to the given language. * @param lang The language to translate to diff --git a/include/lists.h b/include/lists.h index 36e5ae30d..c40d97e7d 100644 --- a/include/lists.h +++ b/include/lists.h @@ -66,11 +66,11 @@ class CoreExport ListFormatter public: typedef std::map ListEntry; private: - NickCore *nc; + NickServ::Account *nc; std::vector columns; std::vector entries; public: - ListFormatter(NickCore *nc); + ListFormatter(NickServ::Account *nc); ListFormatter &AddColumn(const Anope::string &name); void AddEntry(const ListEntry &entry); bool IsEmpty() const; @@ -81,11 +81,11 @@ class CoreExport ListFormatter */ class CoreExport InfoFormatter { - NickCore *nc; + NickServ::Account *nc; std::vector > replies; unsigned longest; public: - InfoFormatter(NickCore *nc); + InfoFormatter(NickServ::Account *nc); void Process(std::vector &); Anope::string &operator[](const Anope::string &key); void AddOption(const Anope::string &opt); diff --git a/include/logger.h b/include/logger.h index 73180e66e..8ed316e94 100644 --- a/include/logger.h +++ b/include/logger.h @@ -57,7 +57,7 @@ class CoreExport Log /* 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 +65,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; + const ChanServ::Channel *ci; /* For LOG_SERVER */ Server *s; /* For LOG_MODULE */ @@ -78,7 +78,7 @@ class CoreExport Log Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *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 = ""); diff --git a/include/mail.h b/include/mail.h index 2f59b5000..7ef5a265e 100644 --- a/include/mail.h +++ b/include/mail.h @@ -19,8 +19,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, BotInfo *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 */ diff --git a/include/memo.h b/include/memo.h deleted file mode 100644 index 103f00ca1..000000000 --- a/include/memo.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * (C) 2003-2014 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. - * - */ - -#pragma once - -#include "anope.h" -#include "serialize.h" - -class CoreExport Memo : public Serializable -{ - public: - bool unread; - bool receipt; - Memo(); - ~Memo(); - - void Serialize(Serialize::Data &data) const override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &); - - Anope::string owner; - /* When it was sent */ - time_t time; - 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 > memos; - std::vector 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); -}; - diff --git a/include/messages.h b/include/messages.h index 070fcb84f..58d32aaf5 100644 --- a/include/messages.h +++ b/include/messages.h @@ -23,21 +23,21 @@ 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 ¶ms) 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 ¶ms) override; }; - + struct CoreExport Error : IRCDMessage { Error(Module *creator, const Anope::string &mname = "ERROR") : IRCDMessage(creator, mname, 1) { } - + void Run(MessageSource &source, const std::vector ¶ms) override; }; @@ -47,15 +47,15 @@ namespace Message void Run(MessageSource &source, const std::vector ¶ms) 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 ¶ms) override; - + typedef std::pair SJoinUser; - + /** Handle a SJOIN. * @param source The source of the SJOIN * @param chan The channel the users are joining to @@ -65,18 +65,18 @@ namespace Message */ static void SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list &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 ¶ms) override; }; - + struct CoreExport Kill : IRCDMessage { Kill(Module *creator, const Anope::string &mname = "KILL") : IRCDMessage(creator, mname, 2) { } - + void Run(MessageSource &source, const std::vector ¶ms) override; }; @@ -86,14 +86,14 @@ namespace Message void Run(MessageSource &source, const std::vector ¶ms) override; }; - + struct CoreExport MOTD : IRCDMessage { MOTD(Module *creator, const Anope::string &mname = "MOTD") : IRCDMessage(creator, mname, 1) { } - + void Run(MessageSource &source, const std::vector ¶ms) override; }; - + struct CoreExport Notice : IRCDMessage { Notice(Module *creator, const Anope::string &mname = "NOTICE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } @@ -104,70 +104,70 @@ namespace Message 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 ¶ms) 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 ¶ms) 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 ¶ms) 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 ¶ms) override; }; - + struct CoreExport SQuit : IRCDMessage { SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - + void Run(MessageSource &source, const std::vector ¶ms) 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 ¶ms) 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 ¶ms) 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 ¶ms) 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 ¶ms) override; }; - + struct