mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/IRCNET ADD -usermode option added.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2206 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
be8778052e
commit
4c6237256f
@ -143,6 +143,8 @@ static void server_setup_fill(SERVER_CONNECT_REC *conn,
|
||||
conn->own_ip6 = g_new(IPADDR, 1);
|
||||
memcpy(conn->own_ip6, source_host_ip6, sizeof(IPADDR));
|
||||
}
|
||||
|
||||
signal_emit("server setup fill connect", 1, conn);
|
||||
}
|
||||
|
||||
static void server_setup_fill_server(SERVER_CONNECT_REC *conn,
|
||||
@ -242,7 +244,6 @@ create_addr_conn(int chat_type, const char *address, int port,
|
||||
conn->nick = g_strdup(nick);
|
||||
}
|
||||
|
||||
signal_emit("server setup fill connect", 1, conn);
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,8 @@ static void cmd_ircnet_list(void)
|
||||
g_string_sprintfa(str, "host: %s, ", rec->own_host);
|
||||
if (rec->autosendcmd != NULL)
|
||||
g_string_sprintfa(str, "autosendcmd: %s, ", rec->autosendcmd);
|
||||
if (rec->usermode != NULL)
|
||||
g_string_sprintfa(str, "usermode: %s, ", rec->usermode);
|
||||
|
||||
if (rec->cmd_queue_speed > 0)
|
||||
g_string_sprintfa(str, "cmdspeed: %d, ", rec->cmd_queue_speed);
|
||||
@ -108,6 +110,7 @@ static void cmd_ircnet_add(const char *data)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -140,6 +143,8 @@ static void cmd_ircnet_add(const char *data)
|
||||
rec->own_ip4 = rec->own_ip6 = NULL;
|
||||
}
|
||||
|
||||
value = g_hash_table_lookup(optlist, "usermode");
|
||||
if (value != NULL && *value != '\0') rec->usermode = g_strdup(value);
|
||||
value = g_hash_table_lookup(optlist, "autosendcmd");
|
||||
if (value != NULL && *value != '\0') rec->autosendcmd = g_strdup(value);
|
||||
|
||||
@ -180,7 +185,7 @@ void fe_ircnet_init(void)
|
||||
command_bind("ircnet add", NULL, (SIGNAL_FUNC) cmd_ircnet_add);
|
||||
command_bind("ircnet remove", NULL, (SIGNAL_FUNC) cmd_ircnet_remove);
|
||||
|
||||
command_set_options("ircnet add", "-kicks -msgs -modes -whois -cmdspeed -cmdmax -nick -user -realname -host -autosendcmd -querychans");
|
||||
command_set_options("ircnet add", "-kicks -msgs -modes -whois -cmdspeed -cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode");
|
||||
}
|
||||
|
||||
void fe_ircnet_deinit(void)
|
||||
|
@ -38,6 +38,8 @@ static void sig_chatnet_read(IRC_CHATNET_REC *rec, CONFIG_NODE *node)
|
||||
if (!IS_IRC_CHATNET(rec))
|
||||
return;
|
||||
|
||||
rec->usermode = g_strdup(config_node_get_str(node, "usermode", NULL));
|
||||
|
||||
rec->max_cmds_at_once = config_node_get_int(node, "cmdmax", 0);
|
||||
rec->cmd_queue_speed = config_node_get_int(node, "cmdspeed", 0);
|
||||
rec->max_query_chans = config_node_get_int(node, "max_query_chans", 0);
|
||||
@ -53,6 +55,9 @@ static void sig_chatnet_saved(IRC_CHATNET_REC *rec, CONFIG_NODE *node)
|
||||
if (!IS_IRC_CHATNET(rec))
|
||||
return;
|
||||
|
||||
if (rec->usermode != NULL)
|
||||
iconfig_node_set_str(node, "usermode", rec->usermode);
|
||||
|
||||
if (rec->max_cmds_at_once > 0)
|
||||
iconfig_node_set_int(node, "cmdmax", rec->max_cmds_at_once);
|
||||
if (rec->cmd_queue_speed > 0)
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
struct _IRC_CHATNET_REC {
|
||||
#include "chatnet-rec.h"
|
||||
|
||||
char *usermode;
|
||||
|
||||
int max_cmds_at_once;
|
||||
int cmd_queue_speed;
|
||||
int max_query_chans; /* when syncing, max. number of channels to
|
||||
|
@ -62,34 +62,6 @@ static void sig_server_reconnect_save_status(IRC_SERVER_CONNECT_REC *conn,
|
||||
conn->usermode = g_strdup(server->wanted_usermode);
|
||||
}
|
||||
|
||||
static int sig_set_user_mode(IRC_SERVER_REC *server)
|
||||
{
|
||||
const char *mode;
|
||||
char *newmode, *args;
|
||||
|
||||
if (g_slist_find(servers, server) == NULL)
|
||||
return 0; /* got disconnected */
|
||||
|
||||
mode = server->connrec->usermode;
|
||||
if (mode == NULL) return 0;
|
||||
|
||||
newmode = server->usermode == NULL ? NULL :
|
||||
modes_join(server->usermode, mode, FALSE);
|
||||
|
||||
if (server->usermode == NULL) {
|
||||
/* server didn't set user mode, just set the new one */
|
||||
irc_send_cmdv(server, "MODE %s %s", server->nick, mode);
|
||||
} else if (strcmp(newmode, server->usermode) != 0) {
|
||||
args = g_strdup_printf("%s -%s+%s", server->nick,
|
||||
server->usermode, mode);
|
||||
signal_emit("command mode", 3, server, args, NULL);
|
||||
g_free(args);
|
||||
}
|
||||
|
||||
g_free_not_null(newmode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sig_connected(IRC_SERVER_REC *server)
|
||||
{
|
||||
if (!IS_IRC_SERVER(server) || !server->connrec->reconnection)
|
||||
@ -97,10 +69,6 @@ static void sig_connected(IRC_SERVER_REC *server)
|
||||
|
||||
if (server->connrec->away_reason != NULL)
|
||||
signal_emit("command away", 2, server->connrec->away_reason, server, NULL);
|
||||
if (server->connrec->usermode != NULL) {
|
||||
/* wait a second and then send the user mode */
|
||||
g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server);
|
||||
}
|
||||
}
|
||||
|
||||
static void event_nick_collision(IRC_SERVER_REC *server, const char *data)
|
||||
|
@ -51,6 +51,7 @@ static void sig_server_setup_fill_connect(IRC_SERVER_CONNECT_REC *conn)
|
||||
return;
|
||||
|
||||
conn->alternate_nick = g_strdup(settings_get_str("alternate_nick"));
|
||||
conn->usermode = g_strdup(settings_get_str("usermode"));
|
||||
}
|
||||
|
||||
static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
|
||||
@ -60,7 +61,11 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
|
||||
return;
|
||||
g_return_if_fail(IS_IRCNET(ircnet));
|
||||
|
||||
if (ircnet->nick) g_free_and_null(conn->alternate_nick);
|
||||
if (ircnet->nick != NULL) g_free_and_null(conn->alternate_nick);
|
||||
if (ircnet->usermode != NULL) {
|
||||
g_free_and_null(conn->usermode);
|
||||
conn->usermode = g_strdup(ircnet->usermode);
|
||||
}
|
||||
|
||||
if (ircnet->max_kicks > 0) conn->max_kicks = ircnet->max_kicks;
|
||||
if (ircnet->max_msgs > 0) conn->max_msgs = ircnet->max_msgs;
|
||||
|
@ -407,16 +407,32 @@ char *irc_server_get_channels(IRC_SERVER_REC *server)
|
||||
static int sig_set_user_mode(IRC_SERVER_REC *server)
|
||||
{
|
||||
const char *mode;
|
||||
char *newmode;
|
||||
char *newmode, *args;
|
||||
|
||||
if (g_slist_find(servers, server) == NULL)
|
||||
return 0; /* got disconnected */
|
||||
|
||||
mode = settings_get_str("usermode");
|
||||
mode = server->connrec->usermode;
|
||||
newmode = server->usermode == NULL ? NULL :
|
||||
modes_join(server->usermode, mode, FALSE);
|
||||
if (server->usermode == NULL || strcmp(newmode, server->usermode) != 0)
|
||||
|
||||
if (server->usermode == NULL) {
|
||||
/* server didn't set user mode, just set the new one */
|
||||
irc_send_cmdv(server, "MODE %s %s", server->nick, mode);
|
||||
} else if (strcmp(newmode, server->usermode) != 0) {
|
||||
if (server->connrec->reconnection) {
|
||||
/* when reconnecting, we want to set exactly the
|
||||
same mode we had before reconnect */
|
||||
args = g_strdup_printf("%s -%s+%s", server->nick,
|
||||
server->usermode, mode);
|
||||
} else {
|
||||
/* allow using modes the server gave us */
|
||||
args = g_strdup_printf("%s -%s", server->nick, mode);
|
||||
}
|
||||
signal_emit("command mode", 3, server, args, NULL);
|
||||
g_free(args);
|
||||
}
|
||||
|
||||
g_free_not_null(newmode);
|
||||
return 0;
|
||||
}
|
||||
@ -424,7 +440,6 @@ static int sig_set_user_mode(IRC_SERVER_REC *server)
|
||||
static void event_connected(IRC_SERVER_REC *server, const char *data, const char *from)
|
||||
{
|
||||
char *params, *nick;
|
||||
const char *mode;
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
@ -447,11 +462,9 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char
|
||||
server->connected = 1;
|
||||
server->real_connect_time = time(NULL);
|
||||
|
||||
if (!server->connrec->reconnection) {
|
||||
if (server->connrec->usermode != NULL) {
|
||||
/* wait a second and then send the user mode */
|
||||
mode = settings_get_str("usermode");
|
||||
if (*mode != '\0')
|
||||
g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server);
|
||||
g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server);
|
||||
}
|
||||
|
||||
signal_emit("event connected", 1, server);
|
||||
|
Loading…
Reference in New Issue
Block a user