InspIRCd  3.0
protocol.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2008 Robin Burchell <[email protected]>
5  * Copyright (C) 2008 Craig Edwards <[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 #include "hashcomp.h"
24 
25 class User;
26 
28 {
29  public:
34  virtual void SendMetaData(const std::string& key, const std::string& data) = 0;
35 };
36 
37 class CoreExport ProtocolInterface
38 {
39  public:
40  typedef ProtocolServer Server;
41 
42  class ServerInfo
43  {
44  public:
45  std::string servername;
46  std::string parentname;
47  std::string description;
48  unsigned int usercount;
49  unsigned int opercount;
50  unsigned int latencyms;
51  };
52 
53  typedef std::vector<ServerInfo> ServerList;
54 
55  virtual ~ProtocolInterface() { }
56 
67  virtual bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source = NULL) { return false; }
68 
77  virtual void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source = NULL, User* omit = NULL) { }
78 
84  virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
85 
91  virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
92 
97  virtual void SendMetaData(const std::string& key, const std::string& data) { }
98 
103  virtual void SendSNONotice(char snomask, const std::string& text) { }
104 
111  virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { }
112 
118  virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
119 
125  void SendChannelNotice(Channel* target, char status, const std::string &text)
126  {
127  SendMessage(target, status, text, MSG_NOTICE);
128  }
129 
134  void SendUserNotice(User* target, const std::string &text)
135  {
136  SendMessage(target, text, MSG_NOTICE);
137  }
138 
143  virtual void GetServerList(ServerList& sl) { }
144 };
ProtocolInterface::SendEncapsulatedData
virtual bool SendEncapsulatedData(const std::string &targetmask, const std::string &cmd, const CommandBase::Params &params, User *source=NULL)
Definition: protocol.h:67
ProtocolInterface::SendSNONotice
virtual void SendSNONotice(char snomask, const std::string &text)
Definition: protocol.h:103
ProtocolInterface::SendUserNotice
void SendUserNotice(User *target, const std::string &text)
Definition: protocol.h:134
ProtocolServer::SendMetaData
virtual void SendMetaData(const std::string &key, const std::string &data)=0
ProtocolInterface::SendChannelNotice
void SendChannelNotice(Channel *target, char status, const std::string &text)
Definition: protocol.h:125
ProtocolInterface::SendMetaData
virtual void SendMetaData(User *user, const std::string &key, const std::string &data)
Definition: protocol.h:91
ProtocolInterface::SendMessage
virtual void SendMessage(User *target, const std::string &text, MessageType type=MSG_PRIVMSG)
Definition: protocol.h:118
ProtocolInterface
Definition: protocol.h:37
ProtocolInterface::GetServerList
virtual void GetServerList(ServerList &sl)
Definition: protocol.h:143
ProtocolServer
Definition: protocol.h:27
Channel
Definition: channels.h:37
ProtocolInterface::SendMessage
virtual void SendMessage(Channel *target, char status, const std::string &text, MessageType type=MSG_PRIVMSG)
Definition: protocol.h:111
ProtocolInterface::SendMetaData
virtual void SendMetaData(Channel *chan, const std::string &key, const std::string &data)
Definition: protocol.h:84
ProtocolInterface::SendMetaData
virtual void SendMetaData(const std::string &key, const std::string &data)
Definition: protocol.h:97
User
Definition: users.h:224
ProtocolInterface::ServerInfo
Definition: protocol.h:42
ProtocolInterface::BroadcastEncap
virtual void BroadcastEncap(const std::string &cmd, const CommandBase::Params &params, User *source=NULL, User *omit=NULL)
Definition: protocol.h:77
CommandBase::Params
Definition: ctables.h:114