]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
Add support for cap-notify
authorPatrick Griffis <redacted>
Thu, 28 Jan 2016 21:02:04 +0000 (16:02 -0500)
committerPatrick Griffis <redacted>
Thu, 28 Jan 2016 21:02:04 +0000 (16:02 -0500)
src/common/inbound.c
src/common/inbound.h
src/common/proto-irc.c
src/common/text.c
src/common/textevents.in

index 645cc824abfdd9afe712ba00952e09513c023c00..70aa5b2e64962fd2507fc1edf501933a512b2e73 100644 (file)
@@ -1633,70 +1633,82 @@ inbound_identified (server *serv)       /* 'MODE +e MYSELF' on freenode */
        }
 }
 
-void
-inbound_cap_ack (server *serv, char *nick, char *extensions,
-                                         const message_tags_data *tags_data)
+static void
+inbound_toggle_caps (server *serv, const char *extensions_str, gboolean enable)
 {
-       EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPACK, serv->server_session, nick, extensions,
-                                                                 NULL, NULL, 0, tags_data->timestamp);
+       char **extensions;
+       gsize i;
 
-       if (strstr (extensions, "identify-msg") != NULL)
-       {
-               serv->have_idmsg = TRUE;
-       }
+       extensions = g_strsplit (extensions_str, " ", 0);
 
-       if (strstr (extensions, "multi-prefix") != NULL)
+       for (i = 0; extensions[i]; i++)
        {
-               serv->have_namesx = TRUE;
-       }
+               const char *extension = extensions[i];
 
-       if (strstr (extensions, "away-notify") != NULL)
-       {
-               serv->have_awaynotify = TRUE;
-       }
+               if (!strcmp (extension, "identify-msg"))
+                       serv->have_idmsg = enable;
+               else if (!strcmp (extension, "multi-prefix"))
+                       serv->have_namesx = enable;
+               else if (!strcmp (extension, "account-notify"))
+                       serv->have_accnotify = enable;
+               else if (!strcmp (extension, "extended-join"))
+                       serv->have_extjoin = enable;
+               else if (!strcmp (extension, "userhost-in-names"))
+                       serv->have_uhnames = enable;
+               else if (!strcmp (extension, "server-time")
+                               || !strcmp (extension, "znc.in/server-time")
+                               || !strcmp (extension, "znc.in/server-time-iso"))
+                       serv->have_server_time = enable;
+               else if (!strcmp (extension, "away-notify"))
+                       serv->have_awaynotify = enable;
+               else if (!strcmp (extension, "sasl"))
+               {
+                       serv->have_sasl = enable;
+                       if (enable)
+                       {
+                               serv->sent_saslauth = FALSE;
 
-       if (strstr (extensions, "account-notify") != NULL)
-       {
-               serv->have_accnotify = TRUE;
-       }
-                                       
-       if (strstr (extensions, "extended-join") != NULL)
-       {
-               serv->have_extjoin = TRUE;
+#ifdef USE_OPENSSL
+                               if (serv->loginmethod == LOGIN_SASLEXTERNAL)
+                               {
+                                       serv->sasl_mech = MECH_EXTERNAL;
+                                       tcp_send_len (serv, "AUTHENTICATE EXTERNAL\r\n", 23);
+                               }
+                               else
+                               {
+                                       /* default to most secure, it will fallback if not supported */
+                                       serv->sasl_mech = MECH_AES;
+                                       tcp_send_len (serv, "AUTHENTICATE DH-AES\r\n", 21);
+                               }
+#else
+                               serv->sasl_mech = MECH_PLAIN;
+                               tcp_send_len (serv, "AUTHENTICATE PLAIN\r\n", 20);
+#endif
+                       }
+               }
        }
 
-       if (strstr (extensions, "userhost-in-names") != NULL)
-       {
-               serv->have_uhnames = TRUE;
-       }
+       g_strfreev (extensions);
+}
 
-       if (strstr (extensions, "server-time") != NULL)
-       {
-               serv->have_server_time = TRUE;
-       }
+void
+inbound_cap_ack (server *serv, char *nick, char *extensions,
+                                         const message_tags_data *tags_data)
+{
+       EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPACK, serv->server_session, nick, extensions,
+                                                                 NULL, NULL, 0, tags_data->timestamp);
 
-       if (strstr (extensions, "sasl") != NULL)
-       {
-               serv->have_sasl = TRUE;
-               serv->sent_saslauth = FALSE;
+       inbound_toggle_caps (serv, extensions, TRUE);
+}
 
-#ifdef USE_OPENSSL
-               if (serv->loginmethod == LOGIN_SASLEXTERNAL)
-               {
-                       serv->sasl_mech = MECH_EXTERNAL;
-                       tcp_send_len (serv, "AUTHENTICATE EXTERNAL\r\n", 23);
-               }
-               else
-               {
-                       /* default to most secure, it will fallback if not supported */
-                       serv->sasl_mech = MECH_AES;
-                       tcp_send_len (serv, "AUTHENTICATE DH-AES\r\n", 21);
-               }
-#else
-               serv->sasl_mech = MECH_PLAIN;
-               tcp_send_len (serv, "AUTHENTICATE PLAIN\r\n", 20);
-#endif
-       }
+void
+inbound_cap_del (server *serv, char *nick, char *extensions,
+                                        const message_tags_data *tags_data)
+{
+       EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPDEL, serv->server_session, nick, extensions,
+                                                                 NULL, NULL, 0, tags_data->timestamp);
+
+       inbound_toggle_caps (serv, extensions, FALSE);
 }
 
 static const char * const supported_caps[] = {
@@ -1712,6 +1724,7 @@ static const char * const supported_caps[] = {
        /* IRCv3.2 */
        "server-time"
        "userhost-in-names",
+       "cap-notify",
 
        /* ZNC */
        "znc.in/server-time-iso",
index bbba2e223c3e290fe6abb77da56d1eea4d4254ed..c5d10445820c219bc35dbe22f6757d19c070eab6 100644 (file)
@@ -95,6 +95,8 @@ void inbound_cap_ls (server *serv, char *nick, char *extensions,
 void inbound_cap_nak (server *serv, const message_tags_data *tags_data);
 void inbound_cap_list (server *serv, char *nick, char *extensions,
                                                          const message_tags_data *tags_data);
+void inbound_cap_del (server *serv, char *nick, char *extensions,
+                                                         const message_tags_data *tags_data);
 void inbound_sasl_authenticate (server *serv, char *data);
 int inbound_sasl_error (server *serv);
 void inbound_sasl_supportedmechs (server *serv, char *list);
index d8f15cb59aafdbec6fb080e59553174480121a5f..b737d23b9fcc37edfce19598f9eaf4700f7af510 100644 (file)
@@ -1280,7 +1280,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
                                                                                  word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
                                                                                  tags_data);
                                }
-                               else if (strncasecmp (word[4], "LS", 2) == 0)
+                               else if (strncasecmp (word[4], "LS", 2) == 0 || strncasecmp (word[4], "NEW", 3) == 0)
                                {
                                        inbound_cap_ls (serv, word[1], 
                                                                                 word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
@@ -1296,6 +1296,12 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
                                                                                        word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
                                                                                        tags_data);
                                }
+                               else if (strncasecmp (word[4], "DEL", 3) == 0)
+                               {
+                                       inbound_cap_del (serv, word[1],
+                                                                                       word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
+                                                                                       tags_data);
+                               }
 
                                return;
                }
index cd9ea26e8b56adbc523a4392f6be54e17371d3fa..8cf850ba1c7c5061173f585ca137823f3713169e 100644 (file)
@@ -976,6 +976,11 @@ static char * const pevt_capack_help[] = {
        N_("Acknowledged Capabilities")
 };
 
+static char * const pevt_capdel_help[] = {
+       N_("Server Name"),
+       N_("Removed Capabilities")
+};
+
 static char * const pevt_caplist_help[] = {
        N_("Server Name"),
        N_("Server Capabilities")
index 26e2b3e3391393669373f386e26ca8de1188eac1..e4405ca343161a547b614e3d1cddcd8b81f691ab 100644 (file)
@@ -28,6 +28,12 @@ pevt_capack_help
 %C29*%O$tCapabilities acknowledged: %C29$2%O
 2
 
+Capability Deleted
+XP_TE_CAPDEL
+pevt_capdel_help
+%C29*%O$tCapabilities removed: %C29$2%O
+2
+
 Capability List
 XP_TE_CAPLIST
 pevt_caplist_help