From 61d586b1a3ad689669f6dcdc285b0d021ca814bd Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Fri, 19 Jul 2013 13:55:02 +0200 Subject: Clean up the protocol interface --- include/protocol.h | 55 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'include/protocol.h') diff --git a/include/protocol.h b/include/protocol.h index eedca50ec..6af0ed21c 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -26,23 +26,22 @@ class User; typedef std::vector parameterlist; -class ProtoServer -{ - public: - std::string servername; - std::string parentname; - std::string gecos; - unsigned int usercount; - unsigned int opercount; - unsigned int latencyms; -}; - -typedef std::list ProtoServerList; - class ProtocolInterface { public: - ProtocolInterface() { } + class ServerInfo + { + public: + std::string servername; + std::string parentname; + std::string gecos; + unsigned int usercount; + unsigned int opercount; + unsigned int latencyms; + }; + + typedef std::vector ServerList; + virtual ~ProtocolInterface() { } /** Send an ENCAP message to one or more linked servers. @@ -92,31 +91,39 @@ class ProtocolInterface * @param target The channel to message. * @param status The status character (e.g. %) required to recieve. * @param text The message to send. + * @param type The message type (MSG_PRIVMSG or MSG_NOTICE) */ - virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text) { } + virtual void SendMessage(Channel* target, char status, const std::string& text, MessageType type = MSG_PRIVMSG) { } - /** Send a notice to a channel. - * @param target The channel to message. - * @param status The status character (e.g. %) required to recieve. + /** Send a message to a user. + * @param target The user to message. * @param text The message to send. + * @param type The message type (MSG_PRIVMSG or MSG_NOTICE) */ - virtual void SendChannelNotice(Channel* target, char status, const std::string &text) { } + virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { } - /** Send a message to a user. - * @param target The user to message. + /** Send a notice to a channel. + * @param target The channel to message. + * @param status The status character (e.g. %) required to recieve. * @param text The message to send. */ - virtual void SendUserPrivmsg(User* target, const std::string &text) { } + void SendChannelNotice(Channel* target, char status, const std::string &text) + { + SendMessage(target, status, text, MSG_NOTICE); + } /** Send a notice to a user. * @param target The user to message. * @param text The message to send. */ - virtual void SendUserNotice(User* target, const std::string &text) { } + void SendUserNotice(User* target, const std::string &text) + { + SendMessage(target, text, MSG_NOTICE); + } /** Fill a list of servers and information about them. * @param sl The list of servers to fill. * XXX: document me properly, this is shit. */ - virtual void GetServerList(ProtoServerList &sl) { } + virtual void GetServerList(ServerList& sl) { } }; -- cgit v1.2.3