InspIRCd  3.0
clientprotocolevent.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2018 Sadie Powell <[email protected]>
5  * Copyright (C) 2018 Attila Molnar <[email protected]>
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 
33 {
34  Join()
35  : ClientProtocol::Event(ServerInstance->GetRFCEvents().join, *this)
36  {
37  }
38 
39  Join(Membership* 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 
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 };
ClientProtocol::Event::SetMessageList
void SetMessageList(const MessageList &msglist)
Definition: clientprotocol.h:505
Modes::ChangeList::getlist
const List & getlist() const
Definition: modechange.h:119
ClientProtocol::Messages::Mode
Definition: clientprotocolmsg.h:225
Modes::ChangeList
Definition: modechange.h:52
ClientProtocol::Event
Definition: clientprotocol.h:462
ClientProtocol::Events::Mode
Definition: clientprotocolevent.h:52
Channel
Definition: channels.h:40
User
Definition: users.h:233
ClientProtocol::Events::Join
Definition: clientprotocolevent.h:32
Membership
Definition: membership.h:35
ClientProtocol::Messages::Join
Definition: clientprotocolmsg.h:105