mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 06:51:08 +01:00
cap: allow modules to return client-specific responses for capability inquiries
This commit is contained in:
parent
1aee992256
commit
38ffccf8c3
3 changed files with 9 additions and 9 deletions
|
@ -56,8 +56,8 @@ extern struct CapabilityIndex *cli_capindex;
|
|||
#define CLICAP_FLAGS_REQACK 0x002
|
||||
|
||||
struct ClientCapability {
|
||||
int (*visible)(void); /* whether or not to display the capability. set to NULL or true return value = displayed */
|
||||
const char *(*data)(void); /* any custom data for the capability. set to NULL or return NULL = no data */
|
||||
int (*visible)(struct Client *); /* whether or not to display the capability. set to NULL or true return value = displayed */
|
||||
const char *(*data)(struct Client *); /* any custom data for the capability. set to NULL or return NULL = no data */
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ DECLARE_MODULE_AV1(cap, NULL, NULL, cap_clist, NULL, NULL, "$Revision: 676 $");
|
|||
#define HasCapabilityFlag(c, f) (c->ownerdata != NULL && (((struct ClientCapability *)c->ownerdata)->flags & (f)) == f)
|
||||
|
||||
static inline int
|
||||
clicap_visible(const struct CapabilityEntry *cap)
|
||||
clicap_visible(struct Client *client_p, const struct CapabilityEntry *cap)
|
||||
{
|
||||
struct ClientCapability *clicap;
|
||||
|
||||
|
@ -75,7 +75,7 @@ clicap_visible(const struct CapabilityEntry *cap)
|
|||
if (clicap->visible == NULL)
|
||||
return 1;
|
||||
|
||||
return clicap->visible();
|
||||
return clicap->visible(client_p);
|
||||
}
|
||||
|
||||
/* clicap_find()
|
||||
|
@ -188,12 +188,12 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!clicap_visible(entry))
|
||||
if (!clicap_visible(source_p, entry))
|
||||
continue;
|
||||
|
||||
caplen = strlen(entry->cap);
|
||||
if (!flags && (source_p->flags & FLAGS_CLICAP_DATA) && clicap != NULL && clicap->data != NULL)
|
||||
data = clicap->data();
|
||||
data = clicap->data(source_p);
|
||||
|
||||
if (data != NULL)
|
||||
caplen += strlen(data) + 1;
|
||||
|
@ -374,7 +374,7 @@ cap_req(struct Client *source_p, const char *arg)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!clicap_visible(cap))
|
||||
if (!clicap_visible(source_p, cap))
|
||||
{
|
||||
finished = 0;
|
||||
break;
|
||||
|
|
|
@ -81,7 +81,7 @@ mapi_hfn_list_av1 sasl_hfnlist[] = {
|
|||
};
|
||||
|
||||
static int
|
||||
sasl_visible(void)
|
||||
sasl_visible(struct Client *client_p)
|
||||
{
|
||||
struct Client *agent_p = NULL;
|
||||
|
||||
|
@ -92,7 +92,7 @@ sasl_visible(void)
|
|||
}
|
||||
|
||||
static const char *
|
||||
sasl_data(void)
|
||||
sasl_data(struct Client *client_p)
|
||||
{
|
||||
return *mechlist_buf != 0 ? mechlist_buf : NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue