Add a cap_change hook

This commit is contained in:
Ed Kellett 2020-04-26 22:34:00 +01:00
parent d0dc83b60a
commit 71f10f833f
3 changed files with 19 additions and 0 deletions

View File

@ -45,6 +45,7 @@ extern int h_conf_read_start;
extern int h_conf_read_end;
extern int h_outbound_msgbuf;
extern int h_rehash;
extern int h_cap_change;
void init_hook(void);
int register_hook(const char *name);
@ -146,6 +147,14 @@ typedef struct
unsigned int oldsnomask;
} hook_data_umode_changed;
typedef struct
{
struct Client *client;
int oldcaps;
int add;
int del;
} hook_data_cap_change;
enum message_type {
MESSAGE_TYPE_NOTICE,
MESSAGE_TYPE_PRIVMSG,

View File

@ -71,6 +71,7 @@ int h_conf_read_start;
int h_conf_read_end;
int h_outbound_msgbuf;
int h_rehash;
int h_cap_change;
void
init_hook(void)
@ -95,6 +96,7 @@ init_hook(void)
h_conf_read_end = register_hook("conf_read_end");
h_outbound_msgbuf = register_hook("outbound_msgbuf");
h_rehash = register_hook("rehash");
h_cap_change = register_hook("cap_change");
}
/* grow_hooktable()

View File

@ -312,6 +312,7 @@ cap_req(struct Client *source_p, const char *arg)
int i = 0;
int capadd = 0, capdel = 0;
int finished = 0, negate;
hook_data_cap_change hdata;
if(!IsRegistered(source_p))
source_p->flags |= FLAGS_CLICAP;
@ -399,8 +400,15 @@ cap_req(struct Client *source_p, const char *arg)
sendto_one(source_p, "%s%s%s", buf_prefix, str_final, buf_list[0]);
}
hdata.client = source_p;
hdata.oldcaps = source_p->localClient->caps;
hdata.add = capadd;
hdata.del = capdel;
source_p->localClient->caps |= capadd;
source_p->localClient->caps &= ~capdel;
call_hook(h_cap_change, &hdata);
}
static struct clicap_cmd