2021-06-30 06:26:06 +00:00
|
|
|
// 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/.
|
|
|
|
|
2022-01-11 21:38:52 +00:00
|
|
|
#pragma once
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
#include <memory>
|
2022-03-28 21:57:58 +00:00
|
|
|
#include <string>
|
2022-10-22 22:37:38 +00:00
|
|
|
#include <optional>
|
2022-03-28 21:57:58 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
namespace weechat
|
2021-06-30 06:26:06 +00:00
|
|
|
{
|
2022-05-26 14:57:08 +00:00
|
|
|
class account;
|
|
|
|
class channel;
|
2022-01-11 21:38:52 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
class user
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct profile
|
|
|
|
{
|
|
|
|
char *avatar_hash = nullptr;
|
|
|
|
char *status_text = nullptr;
|
|
|
|
char *status = nullptr;
|
2022-10-22 22:37:38 +00:00
|
|
|
std::optional<std::string> idle;
|
2022-05-26 14:57:08 +00:00
|
|
|
char *display_name = nullptr;
|
|
|
|
char *email = nullptr;
|
|
|
|
char *role = nullptr;
|
|
|
|
char *affiliation = nullptr;
|
|
|
|
char *pgp_id = nullptr;
|
|
|
|
int omemo = 0;
|
|
|
|
};
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
private:
|
|
|
|
char *name = nullptr;
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
bool updated = false;
|
2021-07-01 22:08:12 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
public:
|
|
|
|
char *id = nullptr;
|
|
|
|
bool is_away = false;
|
|
|
|
struct profile profile;
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
public:
|
|
|
|
user(weechat::account *account, const char *id, const char *display_name);
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
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();
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
static std::string as_prefix_raw(weechat::account *account, const char *id) {
|
|
|
|
auto found = std::unique_ptr<user>(search(account, id));
|
|
|
|
return found ? found->as_prefix_raw() : "";
|
|
|
|
}
|
|
|
|
static std::string as_prefix(weechat::account *account, const char *id) {
|
|
|
|
auto found = std::unique_ptr<user>(search(account, id));
|
|
|
|
return found ? found->as_prefix() : "";
|
|
|
|
}
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
static weechat::user *bot_search(weechat::account *account, const char *pgp_id);
|
|
|
|
static weechat::user *search(weechat::account *account, const char *id);
|
2021-06-30 06:26:06 +00:00
|
|
|
|
2022-05-26 14:57:08 +00:00
|
|
|
void nicklist_add(weechat::account *account, weechat::channel *channel);
|
|
|
|
void nicklist_remove(weechat::account *account, weechat::channel *channel);
|
|
|
|
};
|
|
|
|
}
|