-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsilc-nicklist.c
52 lines (43 loc) · 1.89 KB
/
silc-nicklist.c
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
#include "silc.h"
#include "silcclient.h"
#include "weechat-plugin.h"
#include "silc-plugin.h"
#include "silc-connections.h"
void silc_nicklist_update_internal(SilcChannelUser user, struct t_gui_buffer *channelbuffer, struct t_gui_nick *nick);
struct t_gui_nick *silc_nicklist_add(SilcChannelUser user) {
struct t_gui_nick *nick = NULL;
struct t_gui_buffer *channelbuffer = NULL;
channelbuffer = find_buffer_for_channel(user->channel);
nick = weechat_nicklist_add_nick(channelbuffer, NULL, user->client->nickname, "white", "", "red", 1);
if (nick) {
silc_nicklist_update_internal(user, channelbuffer, nick);
}
return nick;
}
void silc_nicklist_remove(SilcChannelEntry channel_entry, SilcClientEntry user_client) {
struct t_gui_nick *nick = NULL;
struct t_gui_buffer *channelbuffer = NULL;
channelbuffer = find_buffer_for_channel(channel_entry);
nick = weechat_nicklist_search_nick(channelbuffer, NULL, user_client->nickname);
if (nick) {
weechat_nicklist_remove_nick(channelbuffer, nick);
}
}
void silc_nicklist_update(SilcChannelUser user) {
struct t_gui_nick *nick = NULL;
struct t_gui_buffer *channelbuffer = NULL;
channelbuffer = find_buffer_for_channel(user->channel);
nick = weechat_nicklist_search_nick(channelbuffer, NULL, user->client->nickname);
if (nick) {
silc_nicklist_update_internal(user, channelbuffer, nick);
}
}
void silc_nicklist_update_internal(SilcChannelUser user, struct t_gui_buffer *channelbuffer, struct t_gui_nick *nick) {
if (user->mode & SILC_CHANNEL_UMODE_CHANOP) {
weechat_nicklist_nick_set(channelbuffer, nick, "prefix", "@");
}
if (user->channel->founder_key != NULL && user->client->public_key != NULL &&
silc_pkcs_public_key_compare(user->client->public_key, user->channel->founder_key)) {
weechat_nicklist_nick_set(channelbuffer, nick, "color", "red");
}
}