mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
/UPGRADE was broken, changed again the server connection code.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2821 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
09505d628c
commit
4aa0b9111e
@ -118,7 +118,7 @@ static void cmd_connect(const char *data)
|
||||
|
||||
conn = get_server_connect(data, NULL, &rawlog_file);
|
||||
if (conn != NULL) {
|
||||
server = CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server = server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
|
||||
if (server != NULL && rawlog_file != NULL)
|
||||
@ -224,7 +224,7 @@ static void cmd_server_connect(const char *data, SERVER_REC *server)
|
||||
if (conn != NULL) {
|
||||
if (!plus_addr)
|
||||
update_reconnection(conn, server);
|
||||
server = CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server = server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
|
||||
if (server != NULL && rawlog_file != NULL)
|
||||
|
@ -17,7 +17,8 @@ struct _CHAT_PROTOCOL_REC {
|
||||
SERVER_CONNECT_REC *(*create_server_connect) (void);
|
||||
void (*destroy_server_connect) (SERVER_CONNECT_REC *);
|
||||
|
||||
SERVER_REC *(*server_connect) (SERVER_CONNECT_REC *);
|
||||
SERVER_REC *(*server_init_connect) (SERVER_CONNECT_REC *);
|
||||
void (*server_connect) (SERVER_REC *);
|
||||
CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *,
|
||||
const char *, int);
|
||||
QUERY_REC *(*query_create) (const char *, const char *, int);
|
||||
|
@ -29,6 +29,5 @@ GIOChannel *connect_handle; /* connect using this handle */
|
||||
unsigned int reconnection:1; /* we're trying to reconnect */
|
||||
unsigned int no_autojoin_channels:1; /* don't autojoin any channels */
|
||||
unsigned int unix_socket:1; /* Connect using named unix socket */
|
||||
unsigned int session_reconnect:1; /* Connected to this server with /UPGRADE */
|
||||
char *channels;
|
||||
char *away_reason;
|
||||
|
@ -99,7 +99,7 @@ static int server_reconnect_timeout(void)
|
||||
conn = rec->conn;
|
||||
server_connect_ref(conn);
|
||||
server_reconnect_destroy(rec);
|
||||
CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
}
|
||||
}
|
||||
@ -329,7 +329,7 @@ static void reconnect_all(void)
|
||||
while (list != NULL) {
|
||||
conn = list->data;
|
||||
|
||||
CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
list = g_slist_remove(list, conn);
|
||||
}
|
||||
@ -351,7 +351,7 @@ static void cmd_reconnect(const char *data, SERVER_REC *server)
|
||||
signal_emit("command disconnect", 2, "* Reconnecting", server);
|
||||
|
||||
conn->reconnection = TRUE;
|
||||
CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
return;
|
||||
}
|
||||
@ -383,7 +383,7 @@ static void cmd_reconnect(const char *data, SERVER_REC *server)
|
||||
conn = rec->conn;
|
||||
server_connect_ref(conn);
|
||||
server_reconnect_destroy(rec);
|
||||
CHAT_PROTOCOL(conn)->server_connect(conn);
|
||||
server_connect(conn);
|
||||
server_connect_unref(conn);
|
||||
}
|
||||
|
||||
|
@ -264,6 +264,18 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
||||
g_free(iprec.errorstr);
|
||||
}
|
||||
|
||||
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
|
||||
{
|
||||
CHAT_PROTOCOL_REC *proto;
|
||||
SERVER_REC *server;
|
||||
|
||||
proto = CHAT_PROTOCOL(conn);
|
||||
server = proto->server_init_connect(conn);
|
||||
proto->server_connect(server);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
/* initializes server record but doesn't start connecting */
|
||||
void server_connect_init(SERVER_REC *server)
|
||||
{
|
||||
@ -305,16 +317,8 @@ int server_start_connect(SERVER_REC *server)
|
||||
if (!server->connrec->unix_socket && server->connrec->port <= 0)
|
||||
return FALSE;
|
||||
|
||||
server_connect_init(server);
|
||||
server->rawlog = rawlog_create();
|
||||
|
||||
if (server->connrec->session_reconnect) {
|
||||
/* /UPGRADE connection - the session_connect is meant
|
||||
for us only once, move it into server->session_connect */
|
||||
server->connrec->session_reconnect = FALSE;
|
||||
server->session_reconnect = TRUE;
|
||||
}
|
||||
|
||||
if (server->connrec->connect_handle != NULL) {
|
||||
/* already connected */
|
||||
GIOChannel *handle = server->connrec->connect_handle;
|
||||
|
@ -53,6 +53,8 @@ int server_start_connect(SERVER_REC *server);
|
||||
void server_connect_ref(SERVER_CONNECT_REC *conn);
|
||||
void server_connect_unref(SERVER_CONNECT_REC *conn);
|
||||
|
||||
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn);
|
||||
|
||||
/* initializes server record but doesn't start connecting */
|
||||
void server_connect_init(SERVER_REC *server);
|
||||
/* Connection to server finished, fill the rest of the fields */
|
||||
|
@ -277,10 +277,12 @@ static void session_restore_server(CONFIG_NODE *node)
|
||||
if (conn != NULL) {
|
||||
conn->reconnection = TRUE;
|
||||
conn->connect_handle = g_io_channel_unix_new(handle);
|
||||
conn->session_reconnect = TRUE;
|
||||
|
||||
server = proto->server_connect(conn);
|
||||
server = proto->server_init_connect(conn);
|
||||
server->session_reconnect = TRUE;
|
||||
signal_emit("session restore server", 2, server, node);
|
||||
|
||||
proto->server_connect(server);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@ void irc_core_init(void)
|
||||
rec->create_server_connect = create_server_connect;
|
||||
rec->destroy_server_connect = destroy_server_connect;
|
||||
|
||||
rec->server_connect = (SERVER_REC *(*) (SERVER_CONNECT_REC *))
|
||||
irc_server_connect;
|
||||
rec->server_init_connect = irc_server_init_connect;
|
||||
rec->server_connect = irc_server_connect;
|
||||
rec->channel_create =
|
||||
(CHANNEL_REC *(*) (SERVER_REC *, const char *,
|
||||
const char *, int))
|
||||
|
@ -150,8 +150,9 @@ static void server_init(IRC_SERVER_REC *server)
|
||||
server->cmdcount = 0;
|
||||
}
|
||||
|
||||
IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn)
|
||||
SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn)
|
||||
{
|
||||
IRC_SERVER_CONNECT_REC *ircconn;
|
||||
IRC_SERVER_REC *server;
|
||||
|
||||
g_return_val_if_fail(IS_IRC_SERVER_CONNECT(conn), NULL);
|
||||
@ -161,34 +162,39 @@ IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn)
|
||||
server = g_new0(IRC_SERVER_REC, 1);
|
||||
server->chat_type = IRC_PROTOCOL;
|
||||
|
||||
server->connrec = conn;
|
||||
server_connect_ref(SERVER_CONNECT(conn));
|
||||
ircconn = (IRC_SERVER_CONNECT_REC *) conn;
|
||||
server->connrec = ircconn;
|
||||
server_connect_ref(conn);
|
||||
|
||||
if (server->connrec->port <= 0)
|
||||
server->connrec->port = 6667;
|
||||
|
||||
server->cmd_queue_speed = conn->cmd_queue_speed > 0 ?
|
||||
conn->cmd_queue_speed : settings_get_int("cmd_queue_speed");
|
||||
server->max_cmds_at_once = conn->max_cmds_at_once > 0 ?
|
||||
conn->max_cmds_at_once : settings_get_int("cmds_max_at_once");
|
||||
server->max_query_chans = conn->max_query_chans > 0 ?
|
||||
conn->max_query_chans : DEFAULT_MAX_QUERY_CHANS;
|
||||
server->cmd_queue_speed = ircconn->cmd_queue_speed > 0 ?
|
||||
ircconn->cmd_queue_speed : settings_get_int("cmd_queue_speed");
|
||||
server->max_cmds_at_once = ircconn->max_cmds_at_once > 0 ?
|
||||
ircconn->max_cmds_at_once : settings_get_int("cmds_max_at_once");
|
||||
server->max_query_chans = ircconn->max_query_chans > 0 ?
|
||||
ircconn->max_query_chans : DEFAULT_MAX_QUERY_CHANS;
|
||||
|
||||
server->max_kicks_in_cmd = conn->max_kicks > 0 ?
|
||||
conn->max_kicks : DEFAULT_MAX_KICKS;
|
||||
server->max_modes_in_cmd = conn->max_modes > 0 ?
|
||||
conn->max_modes : DEFAULT_MAX_MODES;
|
||||
server->max_whois_in_cmd = conn->max_whois > 0 ?
|
||||
conn->max_whois : DEFAULT_MAX_WHOIS;
|
||||
server->max_msgs_in_cmd = conn->max_msgs > 0 ?
|
||||
conn->max_msgs : DEFAULT_MAX_MSGS;
|
||||
server->max_kicks_in_cmd = ircconn->max_kicks > 0 ?
|
||||
ircconn->max_kicks : DEFAULT_MAX_KICKS;
|
||||
server->max_modes_in_cmd = ircconn->max_modes > 0 ?
|
||||
ircconn->max_modes : DEFAULT_MAX_MODES;
|
||||
server->max_whois_in_cmd = ircconn->max_whois > 0 ?
|
||||
ircconn->max_whois : DEFAULT_MAX_WHOIS;
|
||||
server->max_msgs_in_cmd = ircconn->max_msgs > 0 ?
|
||||
ircconn->max_msgs : DEFAULT_MAX_MSGS;
|
||||
|
||||
if (!server_start_connect((SERVER_REC *) server)) {
|
||||
server_connect_unref(SERVER_CONNECT(conn));
|
||||
server_connect_init((SERVER_REC *) server);
|
||||
return (SERVER_REC *) server;
|
||||
}
|
||||
|
||||
void irc_server_connect(SERVER_REC *server)
|
||||
{
|
||||
if (!server_start_connect(server)) {
|
||||
server_connect_unref(server->connrec);
|
||||
g_free(server);
|
||||
return NULL;
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
||||
/* Returns TRUE if `command' is sent to `target' */
|
||||
|
@ -97,7 +97,8 @@ struct _IRC_SERVER_REC {
|
||||
void *chanqueries;
|
||||
};
|
||||
|
||||
IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn);
|
||||
SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn);
|
||||
void irc_server_connect(SERVER_REC *server);
|
||||
|
||||
/* Purge server output, either all or for specified target */
|
||||
void irc_server_purge_output(IRC_SERVER_REC *server, const char *target);
|
||||
|
@ -129,9 +129,3 @@ CODE:
|
||||
RETVAL = (char *) server_redirect_peek_signal(server, event, args, &redirection);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_
|
||||
|
||||
Irssi::Irc::Server
|
||||
irc_server_connect(conn)
|
||||
Irssi::Irc::Connect conn
|
||||
|
Loading…
Reference in New Issue
Block a user