]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/clientprotocolevent.h
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / include / clientprotocolevent.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2018 Attila Molnar <attilamolnar@hush.com>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #pragma once
22
23 namespace ClientProtocol
24 {
25         namespace Events
26         {
27                 struct Join;
28                 class Mode;
29         }
30 }
31
32 struct ClientProtocol::Events::Join : public ClientProtocol::Messages::Join, public ClientProtocol::Event
33 {
34         Join()
35                 : ClientProtocol::Event(ServerInstance->GetRFCEvents().join, *this)
36         {
37         }
38
39         Join(Membership* Memb)
40                 : ClientProtocol::Messages::Join(Memb)
41                 , ClientProtocol::Event(ServerInstance->GetRFCEvents().join, *this)
42         {
43         }
44
45         Join(Membership* Memb, const std::string& Sourcestr)
46                 : ClientProtocol::Messages::Join(Memb, Sourcestr)
47                 , ClientProtocol::Event(ServerInstance->GetRFCEvents().join, *this)
48         {
49         }
50 };
51
52 class ClientProtocol::Events::Mode : public ClientProtocol::Event
53 {
54         std::list<ClientProtocol::Messages::Mode> modelist;
55         std::vector<Message*> modemsgplist;
56         const Modes::ChangeList& modechanges;
57
58  public:
59         static void BuildMessages(User* source, Channel* Chantarget, User* Usertarget, const Modes::ChangeList& changelist, std::list<ClientProtocol::Messages::Mode>& modelist, std::vector<Message*>& modemsgplist)
60         {
61                 // Build as many MODEs as necessary
62                 for (Modes::ChangeList::List::const_iterator i = changelist.getlist().begin(); i != changelist.getlist().end(); i = modelist.back().GetEndIterator())
63                 {
64                         modelist.push_back(ClientProtocol::Messages::Mode(source, Chantarget, Usertarget, changelist, i));
65                         modemsgplist.push_back(&modelist.back());
66                 }
67         }
68
69         Mode(User* source, Channel* Chantarget, User* Usertarget, const Modes::ChangeList& changelist)
70                 : ClientProtocol::Event(ServerInstance->GetRFCEvents().mode)
71                 , modechanges(changelist)
72         {
73                 BuildMessages(source, Chantarget, Usertarget, changelist, modelist, modemsgplist);
74                 SetMessageList(modemsgplist);
75         }
76
77         const Modes::ChangeList& GetChangeList() const { return modechanges; }
78         const std::list<ClientProtocol::Messages::Mode>& GetMessages() const { return modelist; }
79 };