aboutsummaryrefslogtreecommitdiff
path: root/src/User.cpp
blob: aabfd0b6f26fa52c023b2e0751b3928b41c211bd (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
62
63
64
65
66
67
68
69
70
71
72
#include "../include/User.hpp"

namespace dchat
{
    const static std::string SYSTEM_USER_NAME = "System";
    
    User::User(Type _type) : 
        type(_type)
    {
        
    }
    
    OnlineUser::OnlineUser(const std::string &_name, Type type) : 
        User(type),
        name(_name),
        pingTimestampSec(0)
    {
        
    }
    
    const std::string& OnlineUser::getName() const
    {
        return name;
    }

    OnlineRemoteUser::OnlineRemoteUser(const std::string &name, const odhtdb::Signature::PublicKey &_publicKey) : 
        OnlineUser(name, Type::ONLINE_REMOTE_USER),
        publicKey(_publicKey)
    {
        
    }
    
    const odhtdb::Signature::PublicKey& OnlineRemoteUser::getPublicKey() const
    {
        return publicKey;
    }

    OnlineLocalUser::OnlineLocalUser(const std::string &name, const odhtdb::Signature::KeyPair &_keyPair) : 
        OnlineUser(name, Type::ONLINE_LOCAL_USER),
        keyPair(_keyPair)
    {
        
    }
    
    const odhtdb::Signature::PublicKey& OnlineLocalUser::getPublicKey() const
    {
        return keyPair.getPublicKey();
    }
    
    OfflineUser::OfflineUser(const std::string &_name) : 
        User(Type::OFFLINE),
        name(_name)
    {
        
    }
    
    const std::string& OfflineUser::getName() const
    {
        return name;
    }
    
    SystemUser::SystemUser() : 
        User(Type::SYSTEM)
    {
        
    }
    
    const std::string& SystemUser::getName() const
    {
        return SYSTEM_USER_NAME;
    }
}