diff options
Diffstat (limited to 'ClientInfo.hpp')
| -rw-r--r-- | ClientInfo.hpp | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/ClientInfo.hpp b/ClientInfo.hpp index 61e1b34..f3def0e 100644 --- a/ClientInfo.hpp +++ b/ClientInfo.hpp @@ -2,14 +2,60 @@ #include <QString> -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)") : ""); } }; |
