blob: c2874c2c00dfd70b81ced51f0f2901bceacb3bb2 (
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
73
74
75
76
77
|
#pragma once
#include "types.hpp"
#include <string>
#include <odhtdb/Signature.hpp>
namespace dchat
{
class User
{
public:
enum class Type
{
ONLINE_REMOTE_USER,
ONLINE_LOCAL_USER,
OFFLINE,
SYSTEM
};
User(Type type);
virtual ~User(){}
virtual const std::string& getName() const = 0;
virtual bool isOnlineUser() const { return false; }
const Type type;
std::string avatarUrl;
};
class OnlineUser : public User
{
public:
OnlineUser(const std::string &name, Type type);
virtual ~OnlineUser(){}
virtual const std::string& getName() const override;
virtual const odhtdb::Signature::PublicKey& getPublicKey() const = 0;
bool isOnlineUser() const override { return true; }
std::string name;
u32 pingTimestampSec;
};
class OnlineRemoteUser : public OnlineUser
{
public:
OnlineRemoteUser(const std::string &name, const odhtdb::Signature::PublicKey &publicKey);
virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
const odhtdb::Signature::PublicKey publicKey;
};
class OnlineLocalUser : public OnlineUser
{
public:
OnlineLocalUser(const std::string &name, const odhtdb::Signature::KeyPair &keyPair);
virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
const odhtdb::Signature::KeyPair keyPair;
};
class OfflineUser : public User
{
public:
OfflineUser(const std::string &name);
virtual const std::string& getName() const override;
const std::string name;
};
class SystemUser : public User
{
public:
SystemUser();
virtual const std::string& getName() const override;
};
}
|