1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

irc: add modifier "irc_cap_sync_req" (closes #1767)

This commit is contained in:
Sébastien Helleu
2023-05-15 20:10:28 +02:00
parent d857c91a59
commit 8d35e67dd6
7 changed files with 85 additions and 12 deletions
+1
View File
@@ -41,6 +41,7 @@ New features::
* alias: use lower case for default aliases, rename all aliases to lower case on upgrade (issue #1872)
* irc: rename "ssl" options to "tls", connect with TLS and port 6697 by default
* irc: add support of capabilities "batch" and "draft/multiline" (issue #1292, issue #1923)
* irc: add modifier "irc_cap_sync_req" (issue #1767)
* irc: add support of "LINELEN" in message 005 (max message length in bytes) (issue #1927)
* irc: add command `/rules` (issue #1864)
* irc: add command `/knock` (issue #7)
+5
View File
@@ -12343,6 +12343,11 @@ List of modifiers used by WeeChat and plugins:
| New content of messages (number can be different), an empty string discards
all messages in the batch.
| [[hook_modifier_irc_cap_sync_req]] irc_cap_sync_req | 4.0.0
| Server name + "," + supported capabilities on server (separated by spaces)
| Capabilities to request (separated by spaces).
| New content of capabilities to request (separated by spaces).
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
| Server name
| Content of message received from IRC server (before charset decoding). +
+6
View File
@@ -12606,6 +12606,12 @@ Liste des modificateurs utilisés par WeeChat et les extensions :
| Nouveau contenu des messages (le nombre peut être différent), une chaîne vide
annule tous les messages du batch.
| [[hook_modifier_irc_cap_sync_req]] irc_cap_sync_req | 4.0.0
| Nom de serveur + "," + capacités supportées par le serveur (séparées par
des espaces)
| Capacités à demander (séparées par des espaces).
| Nouveau contenu des capacités à demander (séparées par des espaces).
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
| Nom de serveur
| Contenu du message reçu du serveur IRC (avant décodage du jeu de caractères). +
+6
View File
@@ -12885,6 +12885,12 @@ List of modifiers used by WeeChat and plugins:
| New content of messages (number can be different), an empty string discards
all messages in the batch.
// TRANSLATION MISSING
| [[hook_modifier_irc_cap_sync_req]] irc_cap_sync_req | 4.0.0
| Server name + "," + supported capabilities on server (separated by spaces)
| Capabilities to request (separated by spaces).
| New content of capabilities to request (separated by spaces).
// TRANSLATION MISSING
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
| Nome server
+6
View File
@@ -12471,6 +12471,12 @@ WeeChat とプラグインが使う修飾子のリスト:
| New content of messages (number can be different), an empty string discards
all messages in the batch.
// TRANSLATION MISSING
| [[hook_modifier_irc_cap_sync_req]] irc_cap_sync_req | 4.0.0
| Server name + "," + supported capabilities on server (separated by spaces)
| Capabilities to request (separated by spaces).
| New content of capabilities to request (separated by spaces).
// TRANSLATION MISSING
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
| サーバ名
+6
View File
@@ -11938,6 +11938,12 @@ struct t_hook *weechat_hook_modifier (const char *modifier,
| New content of messages (number can be different), an empty string discards
all messages in the batch.
// TRANSLATION MISSING
| [[hook_modifier_irc_cap_sync_req]] irc_cap_sync_req | 4.0.0
| Server name + "," + supported capabilities on server (separated by spaces)
| Capabilities to request (separated by spaces).
| New content of capabilities to request (separated by spaces).
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
| Име сервера
| Садржај поруке примљене са IRC сервера (пре декодирања скупа карактера). +
+55 -12
View File
@@ -793,6 +793,49 @@ irc_protocol_cap_to_enable (const char *capabilities, int sasl_requested)
return weechat_string_dyn_free (str_caps, 0);
}
/*
* Requests capabilities for IRC server after synchronization.
*/
void
irc_protocol_cap_sync_req (struct t_irc_server *server,
const char *caps_server,
const char *caps_req)
{
char modifier_data[4096], *new_caps_req;
const char *ptr_caps_req;
snprintf (modifier_data, sizeof (modifier_data),
"%s,%s",
server->name,
(caps_server) ? caps_server : "");
new_caps_req = weechat_hook_modifier_exec ("irc_cap_sync_req",
modifier_data,
caps_req);
/* no changes in new caps requested */
if (new_caps_req && (strcmp (caps_req, new_caps_req) == 0))
{
free (new_caps_req);
new_caps_req = NULL;
}
/* caps not dropped? */
if (!new_caps_req || new_caps_req[0])
{
ptr_caps_req = (new_caps_req) ? new_caps_req : caps_req;
weechat_printf (
server->buffer,
_("%s%s: client capability, requesting: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
ptr_caps_req);
irc_server_sendf (server, 0, NULL, "CAP REQ :%s", ptr_caps_req);
}
if (new_caps_req)
free (new_caps_req);
}
/*
* Synchronizes requested capabilities for IRC server.
*/
@@ -800,11 +843,14 @@ irc_protocol_cap_to_enable (const char *capabilities, int sasl_requested)
void
irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
{
char **caps_server, *caps_to_enable, **list_caps_to_enable, **cap_req;
const char *ptr_cap_option;
char *str_caps_server, **caps_server, *caps_to_enable;
char **list_caps_to_enable, **cap_req;
const char *ptr_caps_server, *ptr_cap_option;
int sasl_requested, sasl_to_do, sasl_fail;
int i, num_caps_server;
str_caps_server = NULL;
sasl_requested = (sasl) ? irc_server_sasl_enabled (server) : 0;
sasl_to_do = 0;
@@ -827,8 +873,11 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
NULL);
if (list_caps_to_enable)
{
ptr_caps_server = weechat_hashtable_get_string (server->cap_ls, "keys");
str_caps_server = (ptr_caps_server) ?
weechat_string_replace (ptr_caps_server, ",", " ") : NULL;
caps_server = weechat_string_split (
weechat_hashtable_get_string (server->cap_ls, "keys"),
(ptr_caps_server) ? ptr_caps_server : "",
",",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -856,15 +905,7 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
weechat_string_free_split (caps_server);
}
if (*cap_req[0])
{
weechat_printf (
server->buffer,
_("%s%s: client capability, requesting: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*cap_req);
irc_server_sendf (server, 0, NULL, "CAP REQ :%s", *cap_req);
}
irc_protocol_cap_sync_req (server, str_caps_server, *cap_req);
if (sasl)
{
@@ -894,6 +935,8 @@ irc_protocol_cap_sync (struct t_irc_server *server, int sasl)
weechat_string_free_split (list_caps_to_enable);
}
if (str_caps_server)
free (str_caps_server);
if (caps_to_enable)
free (caps_to_enable);
if (cap_req)