summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2018-04-08 01:24:48 -0300
committerdequis <dx@dxzone.com.ar>2018-04-08 01:24:48 -0300
commitaf5ee997e7544eb59ed509ef8fb79ec449756e90 (patch)
tree4c52026a5632c18be0663ce9e37cef0fbf70276f
parentb2b1ac670879ed49ebf87acc4e33212a21e8df66 (diff)
downloadirssi-af5ee997e7544eb59ed509ef8fb79ec449756e90.zip
Add "server cap req" signal, emitted before requesting caps
-rw-r--r--docs/signals.txt1
-rw-r--r--src/irc/core/irc-cap.c14
2 files changed, 12 insertions, 3 deletions
diff --git a/docs/signals.txt b/docs/signals.txt
index 84d4518f..97ce6c69 100644
--- a/docs/signals.txt
+++ b/docs/signals.txt
@@ -133,6 +133,7 @@ irc-cap.c
"server cap ack "<cmd>, SERVER_REC
"server cap nak "<cmd>, SERVER_REC
"server cap end", SERVER_REC
+ "server cap req", SERVER_REC, char *caps
sasl.c
"server sasl failure", SERVER_REC, char *reason
diff --git a/src/irc/core/irc-cap.c b/src/irc/core/irc-cap.c
index 1a60d99b..bcaeb10d 100644
--- a/src/irc/core/irc-cap.c
+++ b/src/irc/core/irc-cap.c
@@ -48,11 +48,17 @@ int cap_toggle (IRC_SERVER_REC *server, char *cap, int enable)
if (!g_hash_table_lookup_extended(server->cap_supported, cap, NULL, NULL))
return FALSE;
+ signal_emit("server cap req", 2, server, cap);
irc_send_cmdv(server, "CAP REQ %s", cap);
return TRUE;
}
else if (!enable && gslist_find_string(server->cap_active, cap)) {
- irc_send_cmdv(server, "CAP REQ -%s", cap);
+ char *negcap = g_strdup_printf("-%s", cap);
+
+ signal_emit("server cap req", 2, server, negcap);
+ irc_send_cmdv(server, "CAP REQ %s", negcap);
+
+ g_free(negcap);
return TRUE;
}
@@ -194,10 +200,12 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
server->cap_queue = NULL;
/* If the server doesn't support any cap we requested close the negotiation here */
- if (avail_caps > 0)
+ if (avail_caps > 0) {
+ signal_emit("server cap req", 2, server, cmd->str + sizeof("CAP REQ :") - 1);
irc_send_cmd_now(server, cmd->str);
- else
+ } else {
cap_finish_negotiation(server);
+ }
g_string_free(cmd, TRUE);
}