diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/chat-commands.c | 29 | ||||
-rw-r--r-- | src/core/servers.c | 2 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index 9b033779..11e04a1e 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -32,8 +32,10 @@ #include "channels.h" #include "queries.h" #include "window-item-def.h" +#include "rawlog.h" -static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr) +static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr, + char **rawlog_file) { CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; @@ -89,6 +91,8 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr) if (g_hash_table_lookup(optlist, "noproxy") != NULL) g_free_and_null(conn->proxy); + *rawlog_file = g_strdup(g_hash_table_lookup(optlist, "rawlog")); + host = g_hash_table_lookup(optlist, "host"); if (host != NULL && *host != '\0') { IPADDR ip4, ip6; @@ -106,12 +110,19 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr) static void cmd_connect(const char *data) { SERVER_CONNECT_REC *conn; + SERVER_REC *server; + char *rawlog_file; - conn = get_server_connect(data, NULL); + conn = get_server_connect(data, NULL, &rawlog_file); if (conn != NULL) { - CHAT_PROTOCOL(conn)->server_connect(conn); + server = CHAT_PROTOCOL(conn)->server_connect(conn); server_connect_unref(conn); + + if (server != NULL && rawlog_file != NULL) + rawlog_open(server->rawlog, rawlog_file); } + + g_free(rawlog_file); } static RECONNECT_REC *find_reconnect_server(int chat_type, @@ -200,18 +211,24 @@ static void sig_default_command_server(const char *data, SERVER_REC *server, static void cmd_server_connect(const char *data, SERVER_REC *server) { SERVER_CONNECT_REC *conn; + char *rawlog_file; int plus_addr; g_return_if_fail(data != NULL); /* create connection record */ - conn = get_server_connect(data, &plus_addr); + conn = get_server_connect(data, &plus_addr, &rawlog_file); if (conn != NULL) { if (!plus_addr) update_reconnection(conn, server); - CHAT_PROTOCOL(conn)->server_connect(conn); + server = CHAT_PROTOCOL(conn)->server_connect(conn); server_connect_unref(conn); + + if (server != NULL && rawlog_file != NULL) + rawlog_open(server->rawlog, rawlog_file); } + + g_free(rawlog_file); } /* SYNTAX: DISCONNECT *|<tag> [<message>] */ @@ -400,7 +417,7 @@ void chat_commands_init(void) signal_add("default command server", (SIGNAL_FUNC) sig_default_command_server); - command_set_options("connect", "4 6 !! +host noproxy"); + command_set_options("connect", "4 6 !! +host noproxy -rawlog"); command_set_options("join", "invite"); } diff --git a/src/core/servers.c b/src/core/servers.c index b455f553..e5aac01e 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -136,7 +136,6 @@ static char *server_create_tag(SERVER_CONNECT_REC *conn) void server_connect_finished(SERVER_REC *server) { server->connect_time = time(NULL); - server->rawlog = rawlog_create(); servers = g_slist_append(servers, server); signal_emit("server connected", 1, server); @@ -296,6 +295,7 @@ int server_start_connect(SERVER_REC *server) g_input_add(server->connect_pipe[0], G_INPUT_READ, (GInputFunction) server_connect_callback_readpipe, server); + server->rawlog = rawlog_create(); lookup_servers = g_slist_append(lookup_servers, server); |