X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fclientprotocol.h;h=decb2fcf496a69693513a6c71f5c63deca023cf4;hb=b4a174ee9c32d62ea6bf010e837e8c5b1c3d36a3;hp=a3efcf98484f7c8cb32f8b411423d9932c7f075a;hpb=c6e40d36b42a7ebf832c3a57d2816a47ee9c9a76;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/clientprotocol.h b/include/clientprotocol.h index a3efcf984..decb2fcf4 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -1,7 +1,8 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2016 Attila Molnar + * Copyright (C) 2018-2020 Sadie Powell + * Copyright (C) 2018 Attila Molnar * * 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 @@ -238,15 +239,17 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource } Param(int, const char* s) - : owned(true) + : ptr(NULL) + , owned(true) { new(str) std::string(s); } Param(int, const std::string& s) - : owned(true) + : ptr(NULL) + , owned(true) { - new(str) std::string(s); + new(str) std::string(s); } Param(const Param& other) @@ -360,7 +363,7 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource /** Add a parameter to the parameter list. * @param str String to add. - * The string will NOT be copied, it must remain alive until ClearParams() is called or until the object is destroyed. + * The string will NOT be copied, it must remain alive until ClearParams() is called or until the object is destroyed. */ void PushParamRef(const std::string& str) { params.push_back(str); } @@ -467,7 +470,7 @@ class ClientProtocol::Event public: /** Constructor. - * @param protoevent Protocol event provider the event is an instance of. + * @param protoeventprov Protocol event provider the event is an instance of. */ Event(EventProvider& protoeventprov) : event(&protoeventprov) @@ -478,8 +481,8 @@ class ClientProtocol::Event } /** Constructor. - * @param protoevent Protocol event provider the event is an instance of. - * @param msg Message to include in this event by default. + * @param protoeventprov Protocol event provider the event is an instance of. + * @param msg Message to include in this event by default. */ Event(EventProvider& protoeventprov, ClientProtocol::Message& msg) : event(&protoeventprov) @@ -515,6 +518,16 @@ class ClientProtocol::Event void GetMessagesForUser(LocalUser* user, MessageList& messagelist); }; +class ClientProtocol::MessageTagEvent + : public Events::ModuleEventProvider +{ + public: + MessageTagEvent(Module* mod) + : ModuleEventProvider(mod, "event/messagetag") + { + } +}; + /** Base class for message tag providers. * All message tags belong to a message tag provider. Message tag providers can populate messages * with tags before the message is sent and they have the job of determining whether a user should @@ -537,19 +550,19 @@ class ClientProtocol::MessageTagProvider : public Events::ModuleEventListener * The default implementation does nothing. * @param msg Message to be populated with tags. */ - virtual void OnClientProtocolPopulateTags(ClientProtocol::Message& msg) + virtual void OnPopulateTags(ClientProtocol::Message& msg) { } /** Called for each tag that the server receives from a client in a message. * @param user User that sent the tag. * @param tagname Name of the tag. - * @param value Value of the tag, empty string if the tag has no value. May be modified. + * @param tagvalue Value of the tag, empty string if the tag has no value. May be modified. * @return MOD_RES_ALLOW to accept the tag with the value in 'value', MOD_RES_DENY to reject the tag and act as if it wasn't sent, * MOD_RES_PASSTHRU to make no decision. If no hooks accept a tag, the tag is rejected. * The default implementation returns MOD_RES_PASSTHRU. */ - virtual ModResult OnClientProtocolProcessTag(LocalUser* user, const std::string& tagname, std::string& tagvalue) + virtual ModResult OnProcessTag(User* user, const std::string& tagname, std::string& tagvalue) { return MOD_RES_PASSTHRU; } @@ -667,7 +680,8 @@ struct ClientProtocol::RFCEvents */ class CoreExport ClientProtocol::Serializer : public DataProvider { - Events::ModuleEventProvider evprov; + private: + ClientProtocol::MessageTagEvent evprov; /** Make a white list containing which tags a user should get. * @param user User in question. @@ -688,7 +702,7 @@ class CoreExport ClientProtocol::Serializer : public DataProvider * @param tagname Name of the tag. * @param tagvalue Tag value, may be empty. * @param tags TagMap to place the tag into, if it gets accepted. - * @return True if no error occured, false if the tag name is invalid or if this tag already exists. + * @return True if no error occurred, false if the tag name is invalid or if this tag already exists. */ bool HandleTag(LocalUser* user, const std::string& tagname, std::string& tagvalue, TagMap& tags) const;