1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

xfer: add option xfer.file.auto_accept_nicks (patch #7962)

This commit is contained in:
Andrew Potter
2013-03-25 09:05:36 +01:00
committed by Sebastien Helleu
parent 1871a774f3
commit fe512fdd33
21 changed files with 179 additions and 16 deletions
+9
View File
@@ -61,6 +61,7 @@ struct t_config_option *xfer_config_file_auto_rename;
struct t_config_option *xfer_config_file_auto_resume;
struct t_config_option *xfer_config_file_auto_accept_files;
struct t_config_option *xfer_config_file_auto_accept_chats;
struct t_config_option *xfer_config_file_auto_accept_nicks;
@@ -304,6 +305,14 @@ xfer_config_init ()
"auto_accept_chats", "boolean",
N_("automatically accept chat requests (use carefully!)"),
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_accept_nicks = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_accept_nicks", "string",
N_("comma-separated list of nicks for which the incoming files and "
"chats are automatically accepted; format is \"server.nick\" (for a "
"specific server) or \"nick\" (for all servers); example: "
"\"freenode.FlashCode,andrew\""),
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
+1
View File
@@ -49,6 +49,7 @@ extern struct t_config_option *xfer_config_file_auto_rename;
extern struct t_config_option *xfer_config_file_auto_resume;
extern struct t_config_option *xfer_config_file_auto_accept_files;
extern struct t_config_option *xfer_config_file_auto_accept_chats;
extern struct t_config_option *xfer_config_file_auto_accept_nicks;
extern int xfer_config_init ();
extern int xfer_config_read ();
+60 -4
View File
@@ -519,6 +519,53 @@ xfer_alloc ()
return new_xfer;
}
/*
* Checks if the given server/nick is auto-accepted.
*
* Returns:
* 1: nick auto-accepted
* 0: nick not auto-accepted
*/
int
xfer_nick_auto_accepted (const char *server, const char *nick)
{
int rc, num_nicks, i;
char **nicks, *pos;
rc = 0;
nicks = weechat_string_split (weechat_config_string (xfer_config_file_auto_accept_nicks),
",", 0, 0, &num_nicks);
if (nicks)
{
for (i = 0; i < num_nicks; i++)
{
pos = strchr (nicks[i], '.');
if (pos)
{
if ((weechat_strncasecmp (server, nicks[i], pos - nicks[i]) == 0)
&& (weechat_strcasecmp (nick, pos + 1) == 0))
{
rc = 1;
break;
}
}
else
{
if (weechat_strcasecmp (nick, nicks[i]) == 0)
{
rc = 1;
break;
}
}
}
weechat_string_free_split (nicks);
}
return rc;
}
/*
* Adds a xfer to list.
*
@@ -678,13 +725,22 @@ xfer_new (const char *plugin_name, const char *plugin_id,
}
}
if ( ( (type == XFER_TYPE_FILE_RECV)
&& (weechat_config_boolean (xfer_config_file_auto_accept_files)) )
|| ( (type == XFER_TYPE_CHAT_RECV)
&& (weechat_config_boolean (xfer_config_file_auto_accept_chats)) ) )
/*
* auto-accept file/chat if nick is auto-accepted, or if file/chat is
* auto-accepted
*/
if (xfer_nick_auto_accepted (new_xfer->plugin_id, new_xfer->remote_nick)
|| ((type == XFER_TYPE_FILE_RECV)
&& weechat_config_boolean (xfer_config_file_auto_accept_files))
|| ((type == XFER_TYPE_CHAT_RECV)
&& weechat_config_boolean (xfer_config_file_auto_accept_chats)))
{
xfer_network_accept (new_xfer);
}
else
{
xfer_buffer_refresh (WEECHAT_HOTLIST_PRIVATE);
}
return new_xfer;
}