summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-02-01 21:57:43 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-02-01 21:57:43 +0100
commit333ad2c98198b4b5c0c98a2b5d09e60c90d311f7 (patch)
treef37b774c0dd2c4ee0dd2a28d732f2ff88fcf8d81 /degesch.c
parenta850ee45f189dc4afd935f967ee7e5fa4168a2d9 (diff)
downloadxK-333ad2c98198b4b5c0c98a2b5d09e60c90d311f7.tar.gz
xK-333ad2c98198b4b5c0c98a2b5d09e60c90d311f7.tar.xz
xK-333ad2c98198b4b5c0c98a2b5d09e60c90d311f7.zip
degesch: allow changing the list of used CAPs
Bump liberty.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index 93d9316..0a1cb6e 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1802,6 +1802,12 @@ static struct config_schema g_config_server[] =
.comment = "Password to connect to the server, if any",
.type = CONFIG_ITEM_STRING,
.validate = config_validate_nonjunk_string },
+ // XXX: if we add support for new capabilities, the value stays unchanged
+ { .name = "capabilities",
+ .comment = "Capabilities to use if supported by server",
+ .type = CONFIG_ITEM_STRING_ARRAY,
+ .validate = config_validate_nonjunk_string,
+ .default_ = "\"multi-prefix,invite-notify,server-time,echo-message\"" },
{ .name = "tls",
.comment = "Whether to use TLS",
@@ -5470,22 +5476,25 @@ irc_handle_cap (struct server *s, const struct irc_message *msg)
log_server_status (s, s->buffer,
"#s: #S", "Capabilities supported", args);
- struct str_vector chosen;
- str_vector_init (&chosen);
+ struct str_vector chosen; str_vector_init (&chosen);
+ struct str_vector use; str_vector_init (&use);
+
+ cstr_split_ignore_empty
+ (get_config_string (s->config, "capabilities"), ',', &use);
// Filter server capabilities for ones we can make use of
for (size_t i = 0; i < v.len; i++)
{
const char *cap = v.vector[i];
- if (!strcasecmp_ascii (cap, "multi-prefix")
- || !strcasecmp_ascii (cap, "invite-notify")
- || !strcasecmp_ascii (cap, "server-time")
- || !strcasecmp_ascii (cap, "echo-message"))
- str_vector_add (&chosen, cap);
+ for (size_t k = 0; k < use.len; k++)
+ if (!strcasecmp_ascii (use.vector[k], cap))
+ str_vector_add (&chosen, cap);
}
char *chosen_str = join_str_vector (&chosen, ' ');
str_vector_free (&chosen);
+ str_vector_free (&use);
+
irc_send (s, "CAP REQ :%s", chosen_str);
log_server_status (s, s->buffer,
"#s: #S", "Capabilities requested", chosen_str);