mirror of
https://github.com/irssi/irssi.git
synced 2026-08-23 10:32:31 +02:00
MODIFY works only on existing channels/servers/networks now, ADD can still add/modify
This commit is contained in:
parent
0afdfe7cae
commit
a7353b6b3a
8 changed files with 279 additions and 18 deletions
|
|
@ -248,8 +248,6 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||
|
||||
/* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
|
||||
<channel> <network> [<password>] */
|
||||
/* SYNTAX: CHANNEL MODIFY [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
|
||||
<channel> <network> [<password>] */
|
||||
static void cmd_channel_add(const char *data)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
|
|
@ -292,8 +290,6 @@ static void cmd_channel_add(const char *data)
|
|||
if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg);
|
||||
if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
|
||||
|
||||
signal_emit("channel add fill", 2, rec, optlist);
|
||||
|
||||
channel_setup_create(rec);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_CHANSETUP_ADDED, channel, chatnet);
|
||||
|
|
@ -301,6 +297,55 @@ static void cmd_channel_add(const char *data)
|
|||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
/* SYNTAX: CHANNEL MODIFY [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
|
||||
<channel> <network> [<password>] */
|
||||
static void cmd_channel_modify(const char *data)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
CHATNET_REC *chatnetrec;
|
||||
CHANNEL_SETUP_REC *rec;
|
||||
char *botarg, *botcmdarg, *chatnet, *channel, *password;
|
||||
void *free_arg;
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS,
|
||||
"channel modify", &optlist, &channel, &chatnet, &password))
|
||||
return;
|
||||
|
||||
if (*chatnet == '\0' || *channel == '\0')
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
||||
chatnetrec = chatnet_find(chatnet);
|
||||
if (chatnetrec == NULL) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_UNKNOWN_CHATNET, chatnet);
|
||||
cmd_params_free(free_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
botarg = g_hash_table_lookup(optlist, "bots");
|
||||
botcmdarg = g_hash_table_lookup(optlist, "botcmd");
|
||||
|
||||
rec = channel_setup_find(channel, chatnet);
|
||||
if (rec == NULL) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_NOT_FOUND, channel, chatnet);
|
||||
} else {
|
||||
if (g_hash_table_lookup(optlist, "bots")) g_free_and_null(rec->botmasks);
|
||||
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
|
||||
if (*password != '\0') g_free_and_null(rec->password);
|
||||
if (g_hash_table_lookup(optlist, "auto")) rec->autojoin = TRUE;
|
||||
if (g_hash_table_lookup(optlist, "noauto")) rec->autojoin = FALSE;
|
||||
if (botarg != NULL && *botarg != '\0') rec->botmasks = g_strdup(botarg);
|
||||
if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg);
|
||||
if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
|
||||
|
||||
channel_setup_create(rec);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_CHANSETUP_MODIFIED, channel, chatnet);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
/* SYNTAX: CHANNEL REMOVE <channel> <network> */
|
||||
static void cmd_channel_remove(const char *data)
|
||||
{
|
||||
|
|
@ -623,7 +668,7 @@ void fe_channels_init(void)
|
|||
|
||||
command_bind("join", NULL, (SIGNAL_FUNC) cmd_join);
|
||||
command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel);
|
||||
command_bind("channel modify", NULL, (SIGNAL_FUNC) cmd_channel_add);
|
||||
command_bind("channel modify", NULL, (SIGNAL_FUNC) cmd_channel_modify);
|
||||
command_bind("channel add", NULL, (SIGNAL_FUNC) cmd_channel_add);
|
||||
command_bind("channel remove", NULL, (SIGNAL_FUNC) cmd_channel_remove);
|
||||
command_bind("channel list", NULL, (SIGNAL_FUNC) cmd_channel_list);
|
||||
|
|
@ -631,6 +676,7 @@ void fe_channels_init(void)
|
|||
command_bind("cycle", NULL, (SIGNAL_FUNC) cmd_cycle);
|
||||
|
||||
command_set_options("channel add", "auto noauto -bots -botcmd");
|
||||
command_set_options("channel modify", "auto noauto -bots -botcmd");
|
||||
command_set_options("names", "count ops halfops voices normal");
|
||||
command_set_options("join", "invite window");
|
||||
}
|
||||
|
|
@ -645,7 +691,7 @@ void fe_channels_deinit(void)
|
|||
|
||||
command_unbind("join", (SIGNAL_FUNC) cmd_join);
|
||||
command_unbind("channel", (SIGNAL_FUNC) cmd_channel);
|
||||
command_unbind("channel modify", (SIGNAL_FUNC) cmd_channel_add);
|
||||
command_unbind("channel modify", (SIGNAL_FUNC) cmd_channel_modify);
|
||||
command_unbind("channel add", (SIGNAL_FUNC) cmd_channel_add);
|
||||
command_unbind("channel remove", (SIGNAL_FUNC) cmd_channel_remove);
|
||||
command_unbind("channel list", (SIGNAL_FUNC) cmd_channel_list);
|
||||
|
|
|
|||
|
|
@ -205,6 +205,101 @@ static void cmd_server_add(const char *data)
|
|||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static void cmd_server_modify(const char *data)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
SERVER_SETUP_REC *rec;
|
||||
char *addr, *portstr, *password, *value, *chatnet;
|
||||
void *free_arg;
|
||||
int port;
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS,
|
||||
"server modify", &optlist, &addr, &portstr, &password))
|
||||
return;
|
||||
|
||||
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
port = *portstr == '\0' ? DEFAULT_SERVER_ADD_PORT : atoi(portstr);
|
||||
|
||||
chatnet = g_hash_table_lookup(optlist, "network");
|
||||
|
||||
rec = server_setup_find(addr, port, chatnet);
|
||||
|
||||
if (rec == NULL) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_NOT_FOUND, addr, port);
|
||||
} else {
|
||||
value = g_hash_table_lookup(optlist, "port");
|
||||
if (value != NULL && *value != '\0') rec->port = atoi(value);
|
||||
|
||||
if (*password != '\0') g_free_and_null(rec->password);
|
||||
if (g_hash_table_lookup(optlist, "host")) {
|
||||
g_free_and_null(rec->own_host);
|
||||
rec->own_ip4 = rec->own_ip6 = NULL;
|
||||
}
|
||||
|
||||
if (g_hash_table_lookup(optlist, "6"))
|
||||
rec->family = AF_INET6;
|
||||
else if (g_hash_table_lookup(optlist, "4"))
|
||||
rec->family = AF_INET;
|
||||
|
||||
if (g_hash_table_lookup(optlist, "ssl"))
|
||||
rec->use_ssl = TRUE;
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_cert");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_cert = g_strdup(value);
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_pkey");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_pkey = g_strdup(value);
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_pass");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_pass = g_strdup(value);
|
||||
|
||||
if (g_hash_table_lookup(optlist, "ssl_verify"))
|
||||
rec->ssl_verify = TRUE;
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_cafile");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_cafile = g_strdup(value);
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_capath");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_capath = g_strdup(value);
|
||||
|
||||
value = g_hash_table_lookup(optlist, "ssl_ciphers");
|
||||
if (value != NULL && *value != '\0')
|
||||
rec->ssl_ciphers = g_strdup(value);
|
||||
|
||||
if ((rec->ssl_cafile != NULL && rec->ssl_cafile[0] != '\0')
|
||||
|| (rec->ssl_capath != NULL && rec->ssl_capath[0] != '\0'))
|
||||
rec->ssl_verify = TRUE;
|
||||
|
||||
if ((rec->ssl_cert != NULL && rec->ssl_cert[0] != '\0') || rec->ssl_verify == TRUE)
|
||||
rec->use_ssl = TRUE;
|
||||
|
||||
if (g_hash_table_lookup(optlist, "auto")) rec->autoconnect = TRUE;
|
||||
if (g_hash_table_lookup(optlist, "noauto")) rec->autoconnect = FALSE;
|
||||
if (g_hash_table_lookup(optlist, "proxy")) rec->no_proxy = FALSE;
|
||||
if (g_hash_table_lookup(optlist, "noproxy")) rec->no_proxy = TRUE;
|
||||
|
||||
if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
|
||||
value = g_hash_table_lookup(optlist, "host");
|
||||
if (value != NULL && *value != '\0') {
|
||||
rec->own_host = g_strdup(value);
|
||||
rec->own_ip4 = rec->own_ip6 = NULL;
|
||||
}
|
||||
|
||||
signal_emit("server modify fill", 2, rec, optlist);
|
||||
|
||||
server_setup_add(rec);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_SETUPSERVER_MODIFIED, addr, port);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
/* SYNTAX: SERVER REMOVE <address> [<port>] [<network>] */
|
||||
static void cmd_server_remove(const char *data)
|
||||
{
|
||||
|
|
@ -387,12 +482,13 @@ void fe_server_init(void)
|
|||
{
|
||||
command_bind("server", NULL, (SIGNAL_FUNC) cmd_server);
|
||||
command_bind("server connect", NULL, (SIGNAL_FUNC) cmd_server_connect);
|
||||
command_bind("server modify", NULL, (SIGNAL_FUNC) cmd_server_add);
|
||||
command_bind("server modify", NULL, (SIGNAL_FUNC) cmd_server_modify);
|
||||
command_bind("server add", NULL, (SIGNAL_FUNC) cmd_server_add);
|
||||
command_bind("server remove", NULL, (SIGNAL_FUNC) cmd_server_remove);
|
||||
command_bind_first("server", NULL, (SIGNAL_FUNC) server_command);
|
||||
command_bind_first("disconnect", NULL, (SIGNAL_FUNC) server_command);
|
||||
command_set_options("server add", "4 6 !! ssl +ssl_cert +ssl_pkey +ssl_pass ssl_verify +ssl_cafile +ssl_capath +ssl_ciphers auto noauto proxy noproxy -host -port noautosendcmd");
|
||||
command_set_options("server modify", "4 6 !! ssl +ssl_cert +ssl_pkey +ssl_pass ssl_verify +ssl_cafile +ssl_capath +ssl_ciphers auto noauto proxy noproxy -host -port noautosendcmd");
|
||||
|
||||
signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
|
||||
signal_add("server connecting", (SIGNAL_FUNC) sig_server_connecting);
|
||||
|
|
@ -412,7 +508,7 @@ void fe_server_deinit(void)
|
|||
{
|
||||
command_unbind("server", (SIGNAL_FUNC) cmd_server);
|
||||
command_unbind("server connect", (SIGNAL_FUNC) cmd_server_connect);
|
||||
command_unbind("server modify", (SIGNAL_FUNC) cmd_server_add);
|
||||
command_unbind("server modify", (SIGNAL_FUNC) cmd_server_modify);
|
||||
command_unbind("server add", (SIGNAL_FUNC) cmd_server_add);
|
||||
command_unbind("server remove", (SIGNAL_FUNC) cmd_server_remove);
|
||||
command_unbind("server", (SIGNAL_FUNC) server_command);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||
{ "server_reconnect_removed", "Removed reconnection to server {server $0} port {hilight $1}", 3, { 0, 1, 0 } },
|
||||
{ "server_reconnect_not_found", "Reconnection tag {server $0} not found", 1, { 0 } },
|
||||
{ "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } },
|
||||
{ "setupserver_modified", "Server {server $0} saved", 2, { 0, 1 } },
|
||||
{ "setupserver_removed", "Server {server $0} removed", 2, { 0, 1 } },
|
||||
{ "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } },
|
||||
{ "your_nick", "Your nickname is {nick $0}", 1, { 0 } },
|
||||
|
|
@ -119,6 +120,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||
{ "chanlist_line", "%#{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_not_found", "Channel {channel $0} not found", 2, { 0, 0 } },
|
||||
{ "chansetup_added", "Channel {channel $0} saved", 2, { 0, 0 } },
|
||||
{ "chansetup_modified", "Channel {channel $0} saved", 2, { 0, 0 } },
|
||||
{ "chansetup_removed", "Channel {channel $0} removed", 2, { 0, 0 } },
|
||||
{ "chansetup_header", "%#Channel Network Password Settings", 0 },
|
||||
{ "chansetup_line", "%#{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } },
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ enum {
|
|||
TXT_RECONNECT_REMOVED,
|
||||
TXT_RECONNECT_NOT_FOUND,
|
||||
TXT_SETUPSERVER_ADDED,
|
||||
TXT_SETUPSERVER_MODIFIED,
|
||||
TXT_SETUPSERVER_REMOVED,
|
||||
TXT_SETUPSERVER_NOT_FOUND,
|
||||
TXT_YOUR_NICK,
|
||||
|
|
@ -95,6 +96,7 @@ enum {
|
|||
TXT_CHANLIST_LINE,
|
||||
TXT_CHANSETUP_NOT_FOUND,
|
||||
TXT_CHANSETUP_ADDED,
|
||||
TXT_CHANSETUP_MODIFIED,
|
||||
TXT_CHANSETUP_REMOVED,
|
||||
TXT_CHANSETUP_HEADER,
|
||||
TXT_CHANSETUP_LINE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue