X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_who.cpp;h=d6df6de204c097fa8d46df6e96c3a608d2a922c4;hb=850b7a3ace862101a944a9332d72b6bd597c17cc;hp=362e79c03c8e540df8170e0609d9f616790c0c20;hpb=c6e40d36b42a7ebf832c3a57d2816a47ee9c9a76;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 362e79c03..d6df6de20 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -22,6 +22,7 @@ #include "inspircd.h" #include "modules/account.h" +#include "modules/who.h" enum { @@ -33,31 +34,37 @@ enum RPL_WHOSPCRPL = 354 }; -struct WhoData -{ - // The flags for matching users to include. - std::bitset flags; - - // Whether we are matching using a wildcard or a flag. - bool fuzzy_match; +static const char whox_field_order[] = "tcuihsnfdlaor"; +static const char who_field_order[] = "cuhsnf"; - // The text to match against. - std::string matchtext; +struct WhoData : public Who::Request +{ + bool GetFieldIndex(char flag, size_t& out) const CXX11_OVERRIDE + { + if (!whox) + { + const char* pos = strchr(who_field_order, flag); + if (pos == NULL) + return false; - // The WHO/WHOX responses we will send to the source. - std::vector results; + out = pos - who_field_order; + return true; + } - // Whether the source requested a WHOX response. - bool whox; + if (!whox_fields[flag]) + return false; - // The fields to include in the WHOX response. - std::bitset whox_fields; + out = 0; + for (const char* c = whox_field_order; *c && *c != flag; ++c) + { + if (whox_fields[*c]) + ++out; + } - // A user specified label for the WHOX response. - std::string whox_querytype; + return whox_field_order[out]; + } WhoData(const CommandBase::Params& parameters) - : whox(false) { // Find the matchtext and swap the 0 for a * so we can use InspIRCd::Match on it. matchtext = parameters.size() > 2 ? parameters[2] : parameters[0]; @@ -105,6 +112,7 @@ class CommandWho : public SplitCommand ChanModeReference privatemode; UserModeReference hidechansmode; UserModeReference invisiblemode; + Events::ModuleEventProvider whoevprov; /** Determines whether a user can view the users of a channel. */ bool CanView(Channel* chan, User* user) @@ -137,7 +145,7 @@ class CommandWho : public SplitCommand } /** Determines whether WHO flags match a specific channel user. */ - static bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data); + bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data); /** Determines whether WHO flags match a specific user. */ static bool MatchUser(LocalUser* source, User* target, WhoData& data); @@ -160,9 +168,10 @@ class CommandWho : public SplitCommand , privatemode(parent, "private") , hidechansmode(parent, "hidechans") , invisiblemode(parent, "invisible") + , whoevprov(parent, "event/who") { allow_empty_last_param = false; - syntax = "|||||0 [[Aafhilmnoprstu] |||||0]"; + syntax = "|||||0 [[Aafhilmnoprstux][%acdfhilnorstu] |||||0]"; } /** Sends a WHO reply to a user. */ @@ -293,7 +302,7 @@ bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data) long port; while ((port = portrange.GetToken())) { - if (port == lu->GetServerPort()) + if (port == lu->server_sa.port()) { match = true; break; @@ -534,7 +543,7 @@ void CommandWho::SendWhoLine(LocalUser* source, const std::vector& } ModResult res; - FIRST_MOD_RESULT(OnSendWhoLine, res, (source, parameters, user, memb, wholine)); + FIRST_MOD_RESULT_CUSTOM(whoevprov, Who::EventListener, OnWhoLine, res, (data, source, user, memb, wholine)); if (res != MOD_RES_DENY) data.results.push_back(wholine); }