Clean up handling CAP LS
This commit is contained in:
parent
5c534ac344
commit
4e061a43b3
@ -1699,20 +1699,37 @@ inbound_cap_ack (server *serv, char *nick, char *extensions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * const supported_caps[] = {
|
||||||
|
"identify-msg",
|
||||||
|
|
||||||
|
/* IRCv3.1 */
|
||||||
|
"multi-prefix",
|
||||||
|
"away-notify",
|
||||||
|
"account-notify",
|
||||||
|
"extended-join",
|
||||||
|
/* "sasl", Handled manually */
|
||||||
|
|
||||||
|
/* IRCv3.2 */
|
||||||
|
"server-time"
|
||||||
|
"userhost-in-names",
|
||||||
|
|
||||||
|
/* ZNC */
|
||||||
|
"znc.in/server-time-iso",
|
||||||
|
"znc.in/server-time",
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
inbound_cap_ls (server *serv, char *nick, char *extensions_str,
|
inbound_cap_ls (server *serv, char *nick, char *extensions_str,
|
||||||
const message_tags_data *tags_data)
|
const message_tags_data *tags_data)
|
||||||
{
|
{
|
||||||
char buffer[256]; /* buffer for requesting capabilities and emitting the signal */
|
char buffer[256]; /* buffer for requesting capabilities and emitting the signal */
|
||||||
guint32 want_cap; /* format the CAP REQ string based on previous capabilities being requested or not */
|
gboolean want_cap = FALSE; /* format the CAP REQ string based on previous capabilities being requested or not */
|
||||||
guint32 want_sasl; /* CAP END shouldn't be sent when SASL is requested, it needs further responses */
|
gboolean want_sasl = FALSE; /* CAP END shouldn't be sent when SASL is requested, it needs further responses */
|
||||||
char **extensions;
|
char **extensions;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPLIST, serv->server_session, nick,
|
EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPLIST, serv->server_session, nick,
|
||||||
extensions_str, NULL, NULL, 0, tags_data->timestamp);
|
extensions_str, NULL, NULL, 0, tags_data->timestamp);
|
||||||
want_cap = 0;
|
|
||||||
want_sasl = 0;
|
|
||||||
|
|
||||||
extensions = g_strsplit (extensions_str, " ", 0);
|
extensions = g_strsplit (extensions_str, " ", 0);
|
||||||
|
|
||||||
@ -1721,66 +1738,27 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
|
|||||||
for (i=0; extensions[i]; i++)
|
for (i=0; extensions[i]; i++)
|
||||||
{
|
{
|
||||||
const char *extension = extensions[i];
|
const char *extension = extensions[i];
|
||||||
|
gsize x;
|
||||||
if (!strcmp (extension, "identify-msg"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "identify-msg ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "multi-prefix"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "multi-prefix ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "away-notify"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "away-notify ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "account-notify"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "account-notify ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "extended-join"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "extended-join ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "userhost-in-names"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "userhost-in-names ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* bouncers can prefix a name space to the extension so we should use.
|
|
||||||
* znc <= 1.0 uses "znc.in/server-time" and newer use "znc.in/server-time-iso".
|
|
||||||
*/
|
|
||||||
if (!strcmp (extension, "znc.in/server-time-iso"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "znc.in/server-time-iso ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (!strcmp (extension, "znc.in/server-time"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "znc.in/server-time ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
if (prefs.hex_irc_cap_server_time
|
|
||||||
&& !strcmp (extension, "server-time"))
|
|
||||||
{
|
|
||||||
strcat (buffer, "server-time ");
|
|
||||||
want_cap = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if the SASL password is set AND auth mode is set to SASL, request SASL auth */
|
/* if the SASL password is set AND auth mode is set to SASL, request SASL auth */
|
||||||
if (!strcmp (extension, "sasl")
|
if (!g_strcmp0 (extension, "sasl") &&
|
||||||
&& ((serv->loginmethod == LOGIN_SASL && strlen (serv->password) != 0)
|
((serv->loginmethod == LOGIN_SASL && strlen (serv->password) != 0)
|
||||||
|| (serv->loginmethod == LOGIN_SASLEXTERNAL && serv->have_cert)))
|
|| (serv->loginmethod == LOGIN_SASLEXTERNAL && serv->have_cert)))
|
||||||
{
|
{
|
||||||
strcat (buffer, "sasl ");
|
want_cap = TRUE;
|
||||||
want_cap = 1;
|
want_sasl = TRUE;
|
||||||
want_sasl = 1;
|
g_strlcat (buffer, "sasl ", sizeof(buffer));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (x = 0; x < G_N_ELEMENTS(supported_caps); ++x)
|
||||||
|
{
|
||||||
|
if (!g_strcmp0 (extension, supported_caps[x]))
|
||||||
|
{
|
||||||
|
g_strlcat (buffer, extension, sizeof(buffer));
|
||||||
|
g_strlcat (buffer, " ", sizeof(buffer));
|
||||||
|
want_cap = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user