-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuser.hh
70 lines (58 loc) · 2.17 KB
/
user.hh
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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <memory>
#include <string>
#include <optional>
namespace weechat
{
class account;
class channel;
class user
{
private:
struct profile
{
char *avatar_hash = nullptr;
char *status_text = nullptr;
char *status = nullptr;
std::optional<std::string> idle;
char *display_name = nullptr;
char *email = nullptr;
char *role = nullptr;
char *affiliation = nullptr;
char *pgp_id = nullptr;
int omemo = 0;
};
private:
char *name = nullptr;
bool updated = false;
public:
char *id = nullptr;
bool is_away = false;
struct profile profile;
public:
user(weechat::account *account, weechat::channel *channel, const char *id, const char *display_name);
static std::string get_colour(const char *name);
static std::string get_colour_for_nicklist(const char *name);
std::string get_colour();
std::string get_colour_for_nicklist();
static std::string as_prefix_raw(const char *name);
static std::string as_prefix(const char *name);
std::string as_prefix_raw();
std::string as_prefix();
static std::string as_prefix_raw(weechat::account *account, const char *id) {
auto found = search(account, id);
return found ? found->as_prefix_raw() : "";
}
static std::string as_prefix(weechat::account *account, const char *id) {
auto found = search(account, id);
return found ? found->as_prefix() : "";
}
static weechat::user *bot_search(weechat::account *account, const char *pgp_id);
static weechat::user *search(weechat::account *account, const char *id);
void nicklist_add(weechat::account *account, weechat::channel *channel);
void nicklist_remove(weechat::account *account, weechat::channel *channel);
};
}