diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2015-01-04 13:57:11 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2015-01-04 13:57:11 +0100 |
| commit | fbe3c5fbe1327fd81e2eb8fe30a75c4cf5d7b35c (patch) | |
| tree | 02c7bd3f23e18ffcd2d75257ab215e87ead72c96 /ClientInfo.hpp | |
| parent | a92aea252411f86657081587633a88083a3b14a9 (diff) | |
| download | manager-fbe3c5fbe1327fd81e2eb8fe30a75c4cf5d7b35c.tar.gz manager-fbe3c5fbe1327fd81e2eb8fe30a75c4cf5d7b35c.zip | |
Cleanup completed. New Interface based system.
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)") : ""); } }; |
