From fbe3c5fbe1327fd81e2eb8fe30a75c4cf5d7b35c Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sun, 4 Jan 2015 13:57:11 +0100 Subject: Cleanup completed. New Interface based system. --- ClientInfo.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'ClientInfo.hpp') diff --git a/ClientInfo.hpp b/ClientInfo.hpp index 61e1b34..f3def0e 100644 --- a/ClientInfo.hpp +++ b/ClientInfo.hpp @@ -2,14 +2,60 @@ #include -struct ClientInfo +enum ClientInterface { + Clonk = 1, + IRC = 1 << 1 +}; + +class ClientInfo { - int CUID = 0; + +public: + ClientInterface interface = Clonk; QString nick = ""; + + int CUID = 0; QString pcName = ""; bool activated = false; - bool operator==(const ClientInfo& other) + + QString target = ""; + + static inline ClientInfo ircClient(QString nick, QString target = "") + { + ClientInfo ret; + ret.interface = IRC; + ret.nick = nick; + if(target.isEmpty()) + { + target = nick; + } + ret.target = target; + return ret; + } + + static inline ClientInfo clonkClient(QString nick, QString pcName, int CUID, bool activated = false) + { + ClientInfo ret; + ret.interface = Clonk; + ret.nick = nick; + ret.nick = pcName; + ret.CUID = CUID; + ret.activated = activated; + return ret; + } + + inline bool operator==(const ClientInfo& other) + { + return other.interface == interface && other.nick == nick && (interface == Clonk ? other.pcName == pcName && other.CUID == CUID : true); + } + + inline bool operator!=(const ClientInfo& other) + { + return !operator==(other); + } + + inline QString toString() const { - return other.nick == nick && other.pcName == pcName && other.CUID == CUID; + return (!nick.isEmpty() ? nick + (interface == Clonk ? " (" + pcName + ")" : " (IRC)") : ""); } }; -- cgit v1.2.3-54-g00ecf