diff options
author | LemonBoy <thatlemon@gmail.com> | 2017-10-21 17:11:43 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-01-07 12:36:19 +0100 |
commit | f4d811ddf51ce03e90e0417a6c25baeb9aa48353 (patch) | |
tree | 842bc019456b8cf7535bb9754cf9e01231fdc4ad /src/irc | |
parent | 8c87766132b7dbb75d8a49548ff7c97037ea983b (diff) | |
download | irssi-f4d811ddf51ce03e90e0417a6c25baeb9aa48353.zip |
Handle CAP {ADD,DEL} from cap-notify
This is the last piece of the puzzle.
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/irc-cap.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/irc/core/irc-cap.c b/src/irc/core/irc-cap.c index 602a7b06..2378d640 100644 --- a/src/irc/core/irc-cap.c +++ b/src/irc/core/irc-cap.c @@ -135,6 +135,8 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add return; } + g_warning("%s -> %s", evt, list); + /* Strip the trailing whitespaces before splitting the string, some servers send responses with * superfluous whitespaces that g_strsplit the interprets as tokens */ caps = g_strsplit(g_strchomp(list), " ", -1); @@ -158,11 +160,11 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add key, val)) { /* The specification doesn't say anything about * duplicated values, let's just warn the user */ - g_warning("Duplicate value"); + g_warning("Duplicate value %s", key); } } else { - g_warning("Invalid CAP key/value pair"); + g_warning("Invalid CAP %s key/value pair", evt); } } @@ -236,6 +238,36 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add for (i = 0; i < caps_length; i++) cap_emit_signal(server, "nak", caps[i]); } + else if (!strcmp(evt, "NEW")) { + for (i = 0; i < caps_length; i++) { + char *key, *val; + + if (parse_cap_name(caps[i], &key, &val)) { + g_hash_table_insert(server->cap_supported, + key, val); + } + else { + g_warning("Invalid CAP %s key/value pair", evt); + } + cap_emit_signal(server, "new", key); + } + } + else if (!strcmp(evt, "DEL")) { + for (i = 0; i < caps_length; i++) { + char *key, *val; + + if (parse_cap_name(caps[i], &key, &val)) { + g_hash_table_remove(server->cap_supported, key); + } + else { + g_warning("Invalid CAP %s key/value pair", evt); + } + cap_emit_signal(server, "delete", key); + /* The server removed this CAP, remove it from the list + * of the active ones if we had requested it */ + server->cap_active = gslist_remove_string(server->cap_active, key); + } + } else { g_warning("Unhandled CAP subcommand %s", evt); } |