summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-11-14 15:01:21 +0000
committerPeter Powell <petpow@saberuk.com>2018-11-15 19:24:47 +0000
commit6adca3e0997781eae4adb02f19a2f8c312512ae1 (patch)
treedb7b860b6f5a78975b84d079b8671c3252eaa793 /include
parent19c0cfa3e5c3b71521c29d9bcf98f45b7ce13a09 (diff)
Fix the OnSendWhoLine event being completely broken with WHOX.
Diffstat (limited to 'include')
-rw-r--r--include/modules.h12
-rw-r--r--include/modules/who.h80
2 files changed, 81 insertions, 11 deletions
diff --git a/include/modules.h b/include/modules.h
index 8acf9089d..b4f13c6b7 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -226,7 +226,7 @@ enum Implementation
I_OnPostOper, I_OnPostCommand, I_OnPostJoin,
I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
I_OnUserMessage, I_OnPassCompare, I_OnNamesListItem, I_OnNumeric,
- I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_OnSetUserIP,
+ I_OnPreRehash, I_OnModuleRehash, I_OnChangeIdent, I_OnSetUserIP,
I_OnServiceAdd, I_OnServiceDel, I_OnUserWrite,
I_END
};
@@ -916,16 +916,6 @@ class CoreExport Module : public classbase, public usecountbase
virtual ModResult OnNumeric(User* user, const Numeric::Numeric& numeric);
- /** Called whenever a result from /WHO is about to be returned
- * @param source The user running the /WHO query
- * @param params The parameters to the /WHO query
- * @param user The user that this line of the query is about
- * @param memb The member shown in this line, NULL if no channel is in this line
- * @param numeric Numeric to send; modifiable.
- * @return MOD_RES_PASSTHRU to allow the line to be displayed, MOD_RES_DENY to hide it
- */
- virtual ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric);
-
/** Called whenever a local user's IP is set for the first time, or when a local user's IP changes due to
* a module like m_cgiirc changing it.
* @param user The user whose IP is being set
diff --git a/include/modules/who.h b/include/modules/who.h
new file mode 100644
index 000000000..4fcbe5f91
--- /dev/null
+++ b/include/modules/who.h
@@ -0,0 +1,80 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
+ *
+ * This file is part of InspIRCd. InspIRCd 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "event.h"
+
+namespace Who
+{
+ class EventListener;
+ class Request;
+}
+
+class Who::EventListener : public Events::ModuleEventListener
+{
+ public:
+ EventListener(Module* mod)
+ : ModuleEventListener(mod, "event/who")
+ {
+ }
+
+ /** Called when a result from WHO is about to be queued.
+ * @param request Details about the WHO request which caused this response.
+ * @param source The user who initiated this WHO request.
+ * @param user The user that this line of the WHO request is about.
+ * @param memb The channel membership of the user or NULL if not targeted at a channel.
+ * @param numeric The numeric which will be sent in response to the request.
+ * @return MOD_RES_ALLOW to explicitly allow the response, MOD_RES_DENY to explicitly deny the
+ * response, or MOD_RES_PASSTHRU to let another module handle the event.
+ */
+ virtual ModResult OnWhoLine(const Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) = 0;
+};
+
+class Who::Request
+{
+ public:
+ /** The flags for matching users to include. */
+ std::bitset<UCHAR_MAX> flags;
+
+ /** Whether we are matching using a wildcard or a flag. */
+ bool fuzzy_match;
+
+ /** The text to match against. */
+ std::string matchtext;
+
+ /** The WHO/WHOX responses we will send to the source. */
+ std::vector<Numeric::Numeric> results;
+
+ /** Whether the source requested a WHOX response. */
+ bool whox;
+
+ /** The fields to include in the WHOX response. */
+ std::bitset<UCHAR_MAX> whox_fields;
+
+ /** A user specified label for the WHOX response. */
+ std::string whox_querytype;
+
+ protected:
+ Request()
+ : fuzzy_match(false)
+ , whox(false)
+ {
+ }
+};