This commit is contained in:
Jari Matilainen 2016-06-16 12:42:56 +00:00 committed by GitHub
commit e69ad779c8
11 changed files with 305 additions and 88 deletions

View file

@ -7,6 +7,7 @@
LIST: Displays the list of configured channels. LIST: Displays the list of configured channels.
ADD: Adds a channel to your configuration. ADD: Adds a channel to your configuration.
MODIFY: Modifies a channel in your configuration.
REMOVE: Removes a channel from your configuration. REMOVE: Removes a channel from your configuration.
-auto: Automatically join the channel. -auto: Automatically join the channel.
@ -25,6 +26,9 @@
Adds, removes or displays the configuration of channels; this method is Adds, removes or displays the configuration of channels; this method is
used to automate and simplify your workflow. used to automate and simplify your workflow.
/CHANNEL ADD modifies a channel if it already exists in the configuration.
/CHANNEL MODIFY only modifies existing channels.
You can use the ADDALLCHANS command, which is a default alias, to add all You can use the ADDALLCHANS command, which is a default alias, to add all
the channels you are present on into the configuration. the channels you are present on into the configuration.
@ -36,6 +40,7 @@
/CHANNEL ADD -auto #basementcat Quakenet secret_lair /CHANNEL ADD -auto #basementcat Quakenet secret_lair
/CHANNEL ADD -auto -bots '*!@*.irssi.org *!bot@irssi.org' -botcmd 'msg $0 op WzerTrzq' #hideout Freenode /CHANNEL ADD -auto -bots '*!@*.irssi.org *!bot@irssi.org' -botcmd 'msg $0 op WzerTrzq' #hideout Freenode
/CHANNEL ADD -auto -bots 'Q!TheQBot@CServe.quakenet.org' -botcmd '^MSG Q op #irssi' #irssi Quakenet /CHANNEL ADD -auto -bots 'Q!TheQBot@CServe.quakenet.org' -botcmd '^MSG Q op #irssi' #irssi Quakenet
/CHANNEL MODIFY -noauto #irssi Freenode
/CHANNEL REMOVE #hideout Freenode /CHANNEL REMOVE #hideout Freenode
%9Special Example:%9 %9Special Example:%9

View file

@ -7,6 +7,7 @@
LIST: Displays the list of configured networks. LIST: Displays the list of configured networks.
ADD: Adds a network to your configuration. ADD: Adds a network to your configuration.
MODIFY: Modifies a network in your configuration.
REMOVE: Removes a network from your configuration. REMOVE: Removes a network from your configuration.
-nick: Specifies the nickname to use. -nick: Specifies the nickname to use.
@ -47,8 +48,8 @@
Displays, adds, modifies or removes the network configuration of IRC Displays, adds, modifies or removes the network configuration of IRC
networks. networks.
When using the ADD parameter on a network that already exists, the /NETWORK ADD modifies a network if it already exists in the configuration.
configuration will be merged with each other. /NETWORK MODIFY only modifies existing channels.
We recommend using 'WAIT 2000' between the automated commands in order to We recommend using 'WAIT 2000' between the automated commands in order to
prevent you from being kicked from the network due to flooding commands. prevent you from being kicked from the network due to flooding commands.
@ -59,6 +60,7 @@
/NETWORK ADD -usermode +iw -nick mike -realname 'The one and only mike!' -host staff.irssi.org Freenode /NETWORK ADD -usermode +iw -nick mike -realname 'The one and only mike!' -host staff.irssi.org Freenode
/NETWORK ADD -autosendcmd '^MSG NickServ identify WzerT8zq' Freenode /NETWORK ADD -autosendcmd '^MSG NickServ identify WzerT8zq' Freenode
/NETWORK ADD -autosendcmd '^MSG Q@CServe.quakenet.org AUTH mike WzerT8zq; WAIT 2000; OPER mike WzerT8zq; WAIT 2000; MODE mike +kXP' Quakenet /NETWORK ADD -autosendcmd '^MSG Q@CServe.quakenet.org AUTH mike WzerT8zq; WAIT 2000; OPER mike WzerT8zq; WAIT 2000; MODE mike +kXP' Quakenet
/NETWORK MODIFY -usermode +gi EFnet
/NETWORK REMOVE Freenode /NETWORK REMOVE Freenode
%9See also:%9 CHANNEL, CONNECT, SERVER %9See also:%9 CHANNEL, CONNECT, SERVER

View file

@ -8,6 +8,7 @@
LIST: Displays the list of servers you are connected to. LIST: Displays the list of servers you are connected to.
CONNECT: Connects to the given server. CONNECT: Connects to the given server.
ADD: Adds a server to your configuration. ADD: Adds a server to your configuration.
MODIFY: Modifies a server in your configuration.
REMOVE: Removes a server from your configuration. REMOVE: Removes a server from your configuration.
PURGE: Purges the commands queued to be sent to the server. PURGE: Purges the commands queued to be sent to the server.
@ -45,8 +46,8 @@
Displays, adds, modifies or removes the network configuration of IRC Displays, adds, modifies or removes the network configuration of IRC
servers. servers.
When using the ADD parameter on a server that already exists, the /SERVER ADD modifies a server if it already exists in the configuration.
configuration will be merged with each other. /SERVER MODIFY only modified existing servers.
When using the command without any of the given parameters, it will When using the command without any of the given parameters, it will
connect to the specified server; the server in the active window will be connect to the specified server; the server in the active window will be
@ -62,6 +63,7 @@
/SERVER CONNECT +chat.freenode.net /SERVER CONNECT +chat.freenode.net
/SERVER ADD -network Freenode -noautosendcmd orwell.freenode.net /SERVER ADD -network Freenode -noautosendcmd orwell.freenode.net
/SERVER ADD -! -auto -host staff.irssi.org -port 6667 -4 -network Freenode -noproxy orwell.freenode.net /SERVER ADD -! -auto -host staff.irssi.org -port 6667 -4 -network Freenode -noproxy orwell.freenode.net
/SERVER MODIFY -network Freenode -noauto orwell.freenode.net
/SERVER REMOVE orwell.freenode.net 6667 Freenode /SERVER REMOVE orwell.freenode.net 6667 Freenode
/SERVER PURGE /SERVER PURGE
/SERVER PURGE orwell.freenode.net /SERVER PURGE orwell.freenode.net

View file

@ -248,6 +248,21 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
} }
} }
static CHANNEL_SETUP_REC *channel_setup_fill_rec(CHANNEL_SETUP_REC *rec, GHashTable *optlist)
{
char *botarg, *botcmdarg;
botarg = g_hash_table_lookup(optlist, "bots");
botcmdarg = g_hash_table_lookup(optlist, "botcmd");
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);
return rec;
}
/* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>] /* SYNTAX: CHANNEL ADD [-auto | -noauto] [-bots <masks>] [-botcmd <command>]
<channel> <network> [<password>] */ <channel> <network> [<password>] */
static void cmd_channel_add(const char *data) static void cmd_channel_add(const char *data)
@ -255,7 +270,7 @@ static void cmd_channel_add(const char *data)
GHashTable *optlist; GHashTable *optlist;
CHATNET_REC *chatnetrec; CHATNET_REC *chatnetrec;
CHANNEL_SETUP_REC *rec; CHANNEL_SETUP_REC *rec;
char *botarg, *botcmdarg, *chatnet, *channel, *password; char *chatnet, *channel, *password;
void *free_arg; void *free_arg;
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS, if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS,
@ -273,9 +288,6 @@ static void cmd_channel_add(const char *data)
return; return;
} }
botarg = g_hash_table_lookup(optlist, "bots");
botcmdarg = g_hash_table_lookup(optlist, "botcmd");
rec = channel_setup_find(channel, chatnet); rec = channel_setup_find(channel, chatnet);
if (rec == NULL) { if (rec == NULL) {
rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup(); rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup();
@ -286,14 +298,10 @@ static void cmd_channel_add(const char *data)
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd); if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
if (*password != '\0') g_free_and_null(rec->password); 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); if (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
signal_emit("channel add fill", 2, rec, optlist); rec = channel_setup_fill_rec(rec, optlist);
channel_setup_create(rec); channel_setup_create(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_CHANSETUP_ADDED, channel, chatnet); TXT_CHANSETUP_ADDED, channel, chatnet);
@ -301,6 +309,49 @@ static void cmd_channel_add(const char *data)
cmd_params_free(free_arg); 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 *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;
}
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 (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
rec = channel_setup_fill_rec(rec, optlist);
channel_setup_create(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_CHANSETUP_MODIFIED, channel, chatnet);
}
cmd_params_free(free_arg);
}
/* SYNTAX: CHANNEL REMOVE <channel> <network> */ /* SYNTAX: CHANNEL REMOVE <channel> <network> */
static void cmd_channel_remove(const char *data) static void cmd_channel_remove(const char *data)
{ {
@ -618,6 +669,7 @@ void fe_channels_init(void)
command_bind("join", NULL, (SIGNAL_FUNC) cmd_join); command_bind("join", NULL, (SIGNAL_FUNC) cmd_join);
command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel); command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel);
command_bind("channel modify", NULL, (SIGNAL_FUNC) cmd_channel_modify);
command_bind("channel add", NULL, (SIGNAL_FUNC) cmd_channel_add); command_bind("channel add", NULL, (SIGNAL_FUNC) cmd_channel_add);
command_bind("channel remove", NULL, (SIGNAL_FUNC) cmd_channel_remove); command_bind("channel remove", NULL, (SIGNAL_FUNC) cmd_channel_remove);
command_bind("channel list", NULL, (SIGNAL_FUNC) cmd_channel_list); command_bind("channel list", NULL, (SIGNAL_FUNC) cmd_channel_list);
@ -625,6 +677,7 @@ void fe_channels_init(void)
command_bind("cycle", NULL, (SIGNAL_FUNC) cmd_cycle); command_bind("cycle", NULL, (SIGNAL_FUNC) cmd_cycle);
command_set_options("channel add", "auto noauto -bots -botcmd"); 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("names", "count ops halfops voices normal");
command_set_options("join", "invite window"); command_set_options("join", "invite window");
} }
@ -639,6 +692,7 @@ void fe_channels_deinit(void)
command_unbind("join", (SIGNAL_FUNC) cmd_join); command_unbind("join", (SIGNAL_FUNC) cmd_join);
command_unbind("channel", (SIGNAL_FUNC) cmd_channel); command_unbind("channel", (SIGNAL_FUNC) cmd_channel);
command_unbind("channel modify", (SIGNAL_FUNC) cmd_channel_modify);
command_unbind("channel add", (SIGNAL_FUNC) cmd_channel_add); command_unbind("channel add", (SIGNAL_FUNC) cmd_channel_add);
command_unbind("channel remove", (SIGNAL_FUNC) cmd_channel_remove); command_unbind("channel remove", (SIGNAL_FUNC) cmd_channel_remove);
command_unbind("channel list", (SIGNAL_FUNC) cmd_channel_list); command_unbind("channel list", (SIGNAL_FUNC) cmd_channel_list);

View file

@ -104,43 +104,10 @@ static SERVER_SETUP_REC *create_server_setup(GHashTable *optlist)
return server; return server;
} }
static void cmd_server_add(const char *data)
static SERVER_SETUP_REC *server_setup_fill_rec(SERVER_SETUP_REC *rec, GHashTable *optlist)
{ {
GHashTable *optlist; char *value;
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 add", &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) {
rec = create_server_setup(optlist);
if (rec == NULL) {
cmd_params_free(free_arg);
return;
}
rec->address = g_strdup(addr);
rec->port = 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")) if (g_hash_table_lookup(optlist, "6"))
rec->family = AF_INET6; rec->family = AF_INET6;
@ -189,15 +156,57 @@ static void cmd_server_add(const char *data)
if (g_hash_table_lookup(optlist, "proxy")) rec->no_proxy = FALSE; if (g_hash_table_lookup(optlist, "proxy")) rec->no_proxy = FALSE;
if (g_hash_table_lookup(optlist, "noproxy")) rec->no_proxy = TRUE; 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"); value = g_hash_table_lookup(optlist, "host");
if (value != NULL && *value != '\0') { if (value != NULL && *value != '\0') {
rec->own_host = g_strdup(value); rec->own_host = g_strdup(value);
rec->own_ip4 = rec->own_ip6 = NULL; rec->own_ip4 = rec->own_ip6 = NULL;
} }
signal_emit("server add fill", 2, rec, optlist); return rec;
}
static void cmd_server_add(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 add", &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) {
rec = create_server_setup(optlist);
if (rec == NULL) {
cmd_params_free(free_arg);
return;
}
rec->address = g_strdup(addr);
rec->port = 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 (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
rec = server_setup_fill_rec(rec, optlist);
signal_emit("server add fill", 2, rec, optlist);
server_setup_add(rec); server_setup_add(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
TXT_SETUPSERVER_ADDED, addr, port); TXT_SETUPSERVER_ADDED, addr, port);
@ -205,6 +214,49 @@ static void cmd_server_add(const char *data)
cmd_params_free(free_arg); 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 (*password != '\0' && g_strcmp0(password, "-") != 0) rec->password = g_strdup(password);
rec = server_setup_fill_rec(rec, optlist);
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>] */ /* SYNTAX: SERVER REMOVE <address> [<port>] [<network>] */
static void cmd_server_remove(const char *data) static void cmd_server_remove(const char *data)
{ {
@ -387,11 +439,13 @@ void fe_server_init(void)
{ {
command_bind("server", NULL, (SIGNAL_FUNC) cmd_server); command_bind("server", NULL, (SIGNAL_FUNC) cmd_server);
command_bind("server connect", NULL, (SIGNAL_FUNC) cmd_server_connect); command_bind("server connect", NULL, (SIGNAL_FUNC) cmd_server_connect);
command_bind("server modify", NULL, (SIGNAL_FUNC) cmd_server_modify);
command_bind("server add", NULL, (SIGNAL_FUNC) cmd_server_add); command_bind("server add", NULL, (SIGNAL_FUNC) cmd_server_add);
command_bind("server remove", NULL, (SIGNAL_FUNC) cmd_server_remove); command_bind("server remove", NULL, (SIGNAL_FUNC) cmd_server_remove);
command_bind_first("server", NULL, (SIGNAL_FUNC) server_command); command_bind_first("server", NULL, (SIGNAL_FUNC) server_command);
command_bind_first("disconnect", 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 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 looking", (SIGNAL_FUNC) sig_server_looking);
signal_add("server connecting", (SIGNAL_FUNC) sig_server_connecting); signal_add("server connecting", (SIGNAL_FUNC) sig_server_connecting);
@ -411,6 +465,7 @@ void fe_server_deinit(void)
{ {
command_unbind("server", (SIGNAL_FUNC) cmd_server); command_unbind("server", (SIGNAL_FUNC) cmd_server);
command_unbind("server connect", (SIGNAL_FUNC) cmd_server_connect); command_unbind("server connect", (SIGNAL_FUNC) cmd_server_connect);
command_unbind("server modify", (SIGNAL_FUNC) cmd_server_modify);
command_unbind("server add", (SIGNAL_FUNC) cmd_server_add); command_unbind("server add", (SIGNAL_FUNC) cmd_server_add);
command_unbind("server remove", (SIGNAL_FUNC) cmd_server_remove); command_unbind("server remove", (SIGNAL_FUNC) cmd_server_remove);
command_unbind("server", (SIGNAL_FUNC) server_command); command_unbind("server", (SIGNAL_FUNC) server_command);

View file

@ -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_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 } }, { "server_reconnect_not_found", "Reconnection tag {server $0} not found", 1, { 0 } },
{ "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } }, { "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_removed", "Server {server $0} removed", 2, { 0, 1 } },
{ "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } }, { "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } },
{ "your_nick", "Your nickname is {nick $0}", 1, { 0 } }, { "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 } }, { "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_not_found", "Channel {channel $0} not found", 2, { 0, 0 } },
{ "chansetup_added", "Channel {channel $0} saved", 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_removed", "Channel {channel $0} removed", 2, { 0, 0 } },
{ "chansetup_header", "%#Channel Network Password Settings", 0 }, { "chansetup_header", "%#Channel Network Password Settings", 0 },
{ "chansetup_line", "%#{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } }, { "chansetup_line", "%#{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } },

View file

@ -64,6 +64,7 @@ enum {
TXT_RECONNECT_REMOVED, TXT_RECONNECT_REMOVED,
TXT_RECONNECT_NOT_FOUND, TXT_RECONNECT_NOT_FOUND,
TXT_SETUPSERVER_ADDED, TXT_SETUPSERVER_ADDED,
TXT_SETUPSERVER_MODIFIED,
TXT_SETUPSERVER_REMOVED, TXT_SETUPSERVER_REMOVED,
TXT_SETUPSERVER_NOT_FOUND, TXT_SETUPSERVER_NOT_FOUND,
TXT_YOUR_NICK, TXT_YOUR_NICK,
@ -95,6 +96,7 @@ enum {
TXT_CHANLIST_LINE, TXT_CHANLIST_LINE,
TXT_CHANSETUP_NOT_FOUND, TXT_CHANSETUP_NOT_FOUND,
TXT_CHANSETUP_ADDED, TXT_CHANSETUP_ADDED,
TXT_CHANSETUP_MODIFIED,
TXT_CHANSETUP_REMOVED, TXT_CHANSETUP_REMOVED,
TXT_CHANSETUP_HEADER, TXT_CHANSETUP_HEADER,
TXT_CHANSETUP_LINE, TXT_CHANSETUP_LINE,

View file

@ -86,6 +86,42 @@ static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec,
if (value != NULL && *value != '\0') rec->max_query_chans = atoi(value); if (value != NULL && *value != '\0') rec->max_query_chans = atoi(value);
} }
/* SYNTAX: SERVER MODIFY [-4 | -6] [-ssl] [-ssl_cert <cert>] [-ssl_pkey <pkey>] [-ssl_pass <password>]
[-ssl_verify] [-ssl_cafile <cafile>] [-ssl_capath <capath>]
[-ssl_ciphers <list>]
[-auto | -noauto] [-network <network>] [-host <hostname>]
[-cmdspeed <ms>] [-cmdmax <count>] [-port <port>]
<address> [<port> [<password>]] */
/* NOTE: -network replaces the old -ircnet flag. */
static void sig_server_modify_fill(IRC_SERVER_SETUP_REC *rec,
GHashTable *optlist)
{
IRC_CHATNET_REC *ircnet;
char *value;
value = g_hash_table_lookup(optlist, "network");
/* For backwards compatibility, also allow the old name 'ircnet'.
But of course only if -network was not given. */
if (!value)
value = g_hash_table_lookup(optlist, "ircnet");
if (value != NULL) {
g_free_and_null(rec->chatnet);
if (*value != '\0') {
ircnet = ircnet_find(value);
rec->chatnet = ircnet != NULL ?
g_strdup(ircnet->name) : g_strdup(value);
}
}
value = g_hash_table_lookup(optlist, "cmdspeed");
if (value != NULL && *value != '\0') rec->cmd_queue_speed = atoi(value);
value = g_hash_table_lookup(optlist, "cmdmax");
if (value != NULL && *value != '\0') rec->max_cmds_at_once = atoi(value);
value = g_hash_table_lookup(optlist, "querychans");
if (value != NULL && *value != '\0') rec->max_query_chans = atoi(value);
}
/* SYNTAX: SERVER LIST */ /* SYNTAX: SERVER LIST */
static void cmd_server_list(const char *data) static void cmd_server_list(const char *data)
{ {
@ -148,13 +184,16 @@ static void cmd_server_list(const char *data)
void fe_irc_server_init(void) void fe_irc_server_init(void)
{ {
signal_add("server add fill", (SIGNAL_FUNC) sig_server_add_fill); signal_add("server add fill", (SIGNAL_FUNC) sig_server_add_fill);
signal_add("server modify fill", (SIGNAL_FUNC) sig_server_modify_fill);
command_bind("server list", NULL, (SIGNAL_FUNC) cmd_server_list); command_bind("server list", NULL, (SIGNAL_FUNC) cmd_server_list);
command_set_options("server add", "-ircnet -network -cmdspeed -cmdmax -querychans"); command_set_options("server add", "-ircnet -network -cmdspeed -cmdmax -querychans");
command_set_options("server modify", "-ircnet -network -cmdspeed -cmdmax -querychans");
} }
void fe_irc_server_deinit(void) void fe_irc_server_deinit(void)
{ {
signal_remove("server add fill", (SIGNAL_FUNC) sig_server_add_fill); signal_remove("server add fill", (SIGNAL_FUNC) sig_server_add_fill);
signal_remove("server modify fill", (SIGNAL_FUNC) sig_server_modify_fill);
command_unbind("server list", (SIGNAL_FUNC) cmd_server_list); command_unbind("server list", (SIGNAL_FUNC) cmd_server_list);
} }

View file

@ -88,43 +88,9 @@ static void cmd_network_list(void)
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NETWORK_FOOTER); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NETWORK_FOOTER);
} }
/* SYNTAX: NETWORK ADD [-nick <nick>] [-user <user>] [-realname <name>] static IRC_CHATNET_REC *network_setup_fill_rec(IRC_CHATNET_REC *rec, GHashTable *optlist)
[-host <host>] [-usermode <mode>] [-autosendcmd <cmd>]
[-querychans <count>] [-whois <count>] [-msgs <count>]
[-kicks <count>] [-modes <count>] [-cmdspeed <ms>]
[-cmdmax <count>] [-sasl_mechanism <mechanism>]
[-sasl_username <username>] [-sasl_password <password>]
<name> */
static void cmd_network_add(const char *data)
{ {
GHashTable *optlist; char *value;
char *name, *value;
void *free_arg;
IRC_CHATNET_REC *rec;
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
"network add", &optlist, &name))
return;
if (*name == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
rec = ircnet_find(name);
if (rec == NULL) {
rec = g_new0(IRC_CHATNET_REC, 1);
rec->name = g_strdup(name);
} else {
if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick);
if (g_hash_table_lookup(optlist, "user")) g_free_and_null(rec->username);
if (g_hash_table_lookup(optlist, "realname")) g_free_and_null(rec->realname);
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, "usermode")) g_free_and_null(rec->usermode);
if (g_hash_table_lookup(optlist, "autosendcmd")) g_free_and_null(rec->autosendcmd);
if (g_hash_table_lookup(optlist, "sasl_mechanism")) g_free_and_null(rec->sasl_mechanism);
if (g_hash_table_lookup(optlist, "sasl_username")) g_free_and_null(rec->sasl_username);
if (g_hash_table_lookup(optlist, "sasl_password")) g_free_and_null(rec->sasl_password);
}
value = g_hash_table_lookup(optlist, "kicks"); value = g_hash_table_lookup(optlist, "kicks");
if (value != NULL) rec->max_kicks = atoi(value); if (value != NULL) rec->max_kicks = atoi(value);
@ -155,6 +121,12 @@ static void cmd_network_add(const char *data)
rec->own_ip4 = rec->own_ip6 = NULL; rec->own_ip4 = rec->own_ip6 = NULL;
} }
if (g_hash_table_lookup(optlist, "usermode")) g_free_and_null(rec->usermode);
if (g_hash_table_lookup(optlist, "autosendcmd")) g_free_and_null(rec->autosendcmd);
if (g_hash_table_lookup(optlist, "sasl_mechanism")) g_free_and_null(rec->sasl_mechanism);
if (g_hash_table_lookup(optlist, "sasl_username")) g_free_and_null(rec->sasl_username);
if (g_hash_table_lookup(optlist, "sasl_password")) g_free_and_null(rec->sasl_password);
value = g_hash_table_lookup(optlist, "usermode"); value = g_hash_table_lookup(optlist, "usermode");
if (value != NULL && *value != '\0') rec->usermode = g_strdup(value); if (value != NULL && *value != '\0') rec->usermode = g_strdup(value);
value = g_hash_table_lookup(optlist, "autosendcmd"); value = g_hash_table_lookup(optlist, "autosendcmd");
@ -168,12 +140,90 @@ static void cmd_network_add(const char *data)
value = g_hash_table_lookup(optlist, "sasl_password"); value = g_hash_table_lookup(optlist, "sasl_password");
if (value != NULL && *value != '\0') rec->sasl_password = g_strdup(value); if (value != NULL && *value != '\0') rec->sasl_password = g_strdup(value);
return rec;
}
/* SYNTAX: NETWORK ADD [-nick <nick>] [-user <user>] [-realname <name>]
[-host <host>] [-usermode <mode>] [-autosendcmd <cmd>]
[-querychans <count>] [-whois <count>] [-msgs <count>]
[-kicks <count>] [-modes <count>] [-cmdspeed <ms>]
[-cmdmax <count>] [-sasl_mechanism <mechanism>]
[-sasl_username <username>] [-sasl_password <password>]
<name> */
static void cmd_network_add(const char *data)
{
GHashTable *optlist;
char *name;
void *free_arg;
IRC_CHATNET_REC *rec;
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
"network add", &optlist, &name))
return;
if (*name == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
rec = ircnet_find(name);
if (rec == NULL) {
rec = g_new0(IRC_CHATNET_REC, 1);
rec->name = g_strdup(name);
} else {
if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick);
if (g_hash_table_lookup(optlist, "user")) g_free_and_null(rec->username);
if (g_hash_table_lookup(optlist, "realname")) g_free_and_null(rec->realname);
if (g_hash_table_lookup(optlist, "host")) {
g_free_and_null(rec->own_host);
rec->own_ip4 = rec->own_ip6 = NULL;
}
}
rec = network_setup_fill_rec(rec, optlist);
ircnet_create(rec); ircnet_create(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_ADDED, name); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_ADDED, name);
cmd_params_free(free_arg); cmd_params_free(free_arg);
} }
/* SYNTAX: NETWORK MODIFY [-nick <nick>] [-user <user>] [-realname <name>]
[-host <host>] [-usermode <mode>] [-autosendcmd <cmd>]
[-querychans <count>] [-whois <count>] [-msgs <count>]
[-kicks <count>] [-modes <count>] [-cmdspeed <ms>]
[-cmdmax <count>] [-sasl_mechanism <mechanism>]
[-sasl_username <username>] [-sasl_password <password>]
<name> */
static void cmd_network_modify(const char *data)
{
GHashTable *optlist;
char *name;
void *free_arg;
IRC_CHATNET_REC *rec;
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
"network modify", &optlist, &name))
return;
if (*name == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
rec = ircnet_find(name);
if (rec == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_NOT_FOUND, name);
} else {
if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick);
if (g_hash_table_lookup(optlist, "user")) g_free_and_null(rec->username);
if (g_hash_table_lookup(optlist, "realname")) g_free_and_null(rec->realname);
if (g_hash_table_lookup(optlist, "host")) {
g_free_and_null(rec->own_host);
rec->own_ip4 = rec->own_ip6 = NULL;
}
rec = network_setup_fill_rec(rec, optlist);
ircnet_create(rec);
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_MODIFIED, name);
}
cmd_params_free(free_arg);
}
/* SYNTAX: NETWORK REMOVE <network> */ /* SYNTAX: NETWORK REMOVE <network> */
static void cmd_network_remove(const char *data) static void cmd_network_remove(const char *data)
{ {
@ -205,11 +255,14 @@ void fe_ircnet_init(void)
command_bind("ircnet", NULL, (SIGNAL_FUNC) cmd_network); command_bind("ircnet", NULL, (SIGNAL_FUNC) cmd_network);
command_bind("network", NULL, (SIGNAL_FUNC) cmd_network); command_bind("network", NULL, (SIGNAL_FUNC) cmd_network);
command_bind("network list", NULL, (SIGNAL_FUNC) cmd_network_list); command_bind("network list", NULL, (SIGNAL_FUNC) cmd_network_list);
command_bind("network modify", NULL, (SIGNAL_FUNC) cmd_network_modify);
command_bind("network add", NULL, (SIGNAL_FUNC) cmd_network_add); command_bind("network add", NULL, (SIGNAL_FUNC) cmd_network_add);
command_bind("network remove", NULL, (SIGNAL_FUNC) cmd_network_remove); command_bind("network remove", NULL, (SIGNAL_FUNC) cmd_network_remove);
command_set_options("network add", "-kicks -msgs -modes -whois -cmdspeed " command_set_options("network add", "-kicks -msgs -modes -whois -cmdspeed "
"-cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode -sasl_mechanism -sasl_username -sasl_password"); "-cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode -sasl_mechanism -sasl_username -sasl_password");
command_set_options("network modify", "-kicks -msgs -modes -whois -cmdspeed "
"-cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode -sasl_mechanism -sasl_username -sasl_password");
} }
void fe_ircnet_deinit(void) void fe_ircnet_deinit(void)
@ -217,6 +270,7 @@ void fe_ircnet_deinit(void)
command_unbind("ircnet", (SIGNAL_FUNC) cmd_network); command_unbind("ircnet", (SIGNAL_FUNC) cmd_network);
command_unbind("network", (SIGNAL_FUNC) cmd_network); command_unbind("network", (SIGNAL_FUNC) cmd_network);
command_unbind("network list", (SIGNAL_FUNC) cmd_network_list); command_unbind("network list", (SIGNAL_FUNC) cmd_network_list);
command_unbind("network modify", (SIGNAL_FUNC) cmd_network_modify);
command_unbind("network add", (SIGNAL_FUNC) cmd_network_add); command_unbind("network add", (SIGNAL_FUNC) cmd_network_add);
command_unbind("network remove", (SIGNAL_FUNC) cmd_network_remove); command_unbind("network remove", (SIGNAL_FUNC) cmd_network_remove);
} }

View file

@ -36,6 +36,7 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "netsplits_line", "%#$[9]0 $[10]1 $[20]2 $3", 4, { 0, 0, 0, 0 } }, { "netsplits_line", "%#$[9]0 $[10]1 $[20]2 $3", 4, { 0, 0, 0, 0 } },
{ "netsplits_footer", "", 0 }, { "netsplits_footer", "", 0 },
{ "network_added", "Network $0 saved", 1, { 0 } }, { "network_added", "Network $0 saved", 1, { 0 } },
{ "network_modified", "Network $0 saved", 1, { 0 } },
{ "network_removed", "Network $0 removed", 1, { 0 } }, { "network_removed", "Network $0 removed", 1, { 0 } },
{ "network_not_found", "Network $0 not found", 1, { 0 } }, { "network_not_found", "Network $0 not found", 1, { 0 } },
{ "network_header", "%#Networks:", 0 }, { "network_header", "%#Networks:", 0 },

View file

@ -14,6 +14,7 @@ enum {
IRCTXT_NETSPLITS_LINE, IRCTXT_NETSPLITS_LINE,
IRCTXT_NETSPLITS_FOOTER, IRCTXT_NETSPLITS_FOOTER,
IRCTXT_NETWORK_ADDED, IRCTXT_NETWORK_ADDED,
IRCTXT_NETWORK_MODIFIED,
IRCTXT_NETWORK_REMOVED, IRCTXT_NETWORK_REMOVED,
IRCTXT_NETWORK_NOT_FOUND, IRCTXT_NETWORK_NOT_FOUND,
IRCTXT_NETWORK_HEADER, IRCTXT_NETWORK_HEADER,