summaryrefslogtreecommitdiffstats
path: root/ClientInfo.hpp
blob: f3def0e8799574625975cf6ba86a1a36c336c912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once

#include <QString>

enum ClientInterface {
    Clonk = 1,
    IRC = 1 << 1
};

class ClientInfo
{

public:
    ClientInterface interface = Clonk;
    QString nick = "";

    int CUID = 0;
    QString pcName = "";
    bool activated = false;

    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 (!nick.isEmpty() ? nick + (interface == Clonk ? " (" + pcName + ")" : " (IRC)") : "");
    }
};