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