summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
Diffstat (limited to 'include/modules')
-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
70 files changed, 3689 insertions, 989 deletions
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;
};
+