-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathchannel.hh
166 lines (133 loc) · 4.87 KB
/
channel.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// 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 <ctime>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <optional>
#define CHANNEL_MEMBERS_SPEAKING_LIMIT 128
namespace weechat
{
class account;
class user;
class channel
{
public:
enum class chat_type { MUC, PM };
enum class transport { PLAIN, OMEMO, PGP, OTR, OX };
static const char *transport_name(enum transport transport)
{
switch (transport)
{
case transport::PLAIN:
return "PLAINTEXT";
case transport::OMEMO:
return "OMEMO";
case transport::PGP:
return "PGP";
case transport::OTR:
return "OTR";
default:
return NULL;
}
}
struct typing
{
weechat::user *user;
std::string name;
time_t ts;
};
struct member
{
char *id;
char *role;
char *affiliation;
};
struct topic
{
char *value = nullptr;
char *creator = nullptr;
time_t last_set = 0;
};
struct unread
{
char *id;
char *thread;
};
private:
topic topic;
/* mpim */
char *creator = nullptr;
double last_read = 0.0;
int unread_count = 0;
int unread_count_display = 0;
struct t_hook *typing_hook_timer = nullptr;
struct t_hook *self_typing_hook_timer = nullptr;
public:
std::vector<weechat::channel::unread> unreads;
public:
std::string id;
std::string name;
enum chat_type type;
enum transport transport = weechat::channel::transport::PLAIN;
struct {
int enabled;
struct t_hashtable *devicelist_requests;
struct t_hashtable *bundle_requests;
} omemo;
struct {
int enabled = 1;
std::unordered_set<std::string> ids;
} pgp;
struct {
int enabled = 0;
} otr;
struct t_weelist *members_speaking[2] = { nullptr };
std::vector<typing> self_typings;
std::vector<typing> typings;
std::unordered_map<std::string, member> members;
public:
struct t_gui_buffer *buffer;
public:
channel(weechat::account& account, enum chat_type type, const char *id, const char *name);
~channel();
void set_transport(enum weechat::channel::transport transport, int force);
struct t_gui_buffer *search_buffer(weechat::channel::chat_type type,
const char *name);
struct t_gui_buffer *create_buffer(weechat::channel::chat_type type,
const char *name);
void add_nicklist_groups();
void member_speaking_add_to_list(const char *nick, int highlight);
void member_speaking_add(const char *nick, int highlight);
void member_speaking_rename(const char *old_nick, const char *new_nick);
void member_speaking_rename_if_present(const char *nick);
static int typing_cb(const void *pointer, void *data, int remaining_calls);
typing *typing_search(weechat::user *user);
int add_typing(weechat::user *user);
static int self_typing_cb(const void *pointer, void *data, int remaining_calls);
typing *self_typing_search(weechat::user *user);
int add_self_typing(weechat::user *user);
static int hotlist_update_cb(const void *pointer, void *data,
const char *signal, const char *type_data,
void *signal_data);
void free(channel *channel);
void free_all();
void update_topic(const char* title, const char* creator, int last_set);
void update_name(const char* name);
void update_purpose(const char* purpose, const char* creator, int last_set);
member *add_member(const char *id, const char *client);
member *member_search(const char *id);
member *remove_member(const char *id, const char *reason);
int send_message(std::string to, std::string body,
std::optional<std::string> oob = {});
int send_message(const char *to, const char *body);
void send_reads();
void send_typing(weechat::user *user);
void send_paused(weechat::user *user);
void fetch_mam(const char *id, time_t *start, time_t *end, const char *after);
weechat::account& account;
};
}