diff options
author | Timo Sirainen <cras@irssi.org> | 2001-11-20 01:29:23 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-11-20 01:29:23 +0000 |
commit | bb3592f5c7a2c75effc38bc136bab2a9d175299f (patch) | |
tree | 3f80c187fcef9d4766ba46399f75da78ea9386f2 /src/irc/core/irc-session.c | |
parent | 333f6a3bab94de48db1c66cd014d9b4b8f11381c (diff) | |
download | irssi-bb3592f5c7a2c75effc38bc136bab2a9d175299f.zip |
/UPGRADE: server command queue is now flushed to make sure everything
gets sent to server. Channels are now stored in in config blocks
instead of just in one string, this way we can restore the topic and
key. Away status in server is also restored.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2113 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/core/irc-session.c')
-rw-r--r-- | src/irc/core/irc-session.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c index dcb7d5d3..4831a75f 100644 --- a/src/irc/core/irc-session.c +++ b/src/irc/core/irc-session.c @@ -20,6 +20,7 @@ #include "module.h" #include "signals.h" +#include "net-sendbuffer.h" #include "lib-config/iconfig.h" #include "irc-servers.h" @@ -28,18 +29,29 @@ static void sig_session_save_server(IRC_SERVER_REC *server, CONFIG_REC *config, CONFIG_NODE *node) { - char *chans; + GSList *tmp; if (!IS_IRC_SERVER(server)) return; + /* send all non-redirected commands to server immediately */ + for (tmp = server->cmdqueue; tmp != NULL; tmp = tmp->next->next) { + const char *cmd = tmp->data; + void *redirect = tmp->next->data; + + if (redirect == NULL) { + if (net_sendbuffer_send(server->handle, cmd, + strlen(cmd)) == -1) + break; + } + } + net_sendbuffer_flush(server->handle); + config_node_set_str(config, node, "real_address", server->real_address); config_node_set_str(config, node, "userhost", server->userhost); config_node_set_str(config, node, "usermode", server->usermode); - - chans = irc_server_get_channels(server); - config_node_set_str(config, node, "channels", chans); - g_free(chans); + config_node_set_bool(config, node, "usermode_away", server->usermode_away); + config_node_set_str(config, node, "away_reason", server->away_reason); } static void sig_session_restore_server(IRC_SERVER_REC *server, @@ -52,11 +64,21 @@ static void sig_session_restore_server(IRC_SERVER_REC *server, server->real_address = g_strdup(config_node_get_str(node, "real_address", NULL)); server->userhost = g_strdup(config_node_get_str(node, "userhost", NULL)); server->usermode = g_strdup(config_node_get_str(node, "usermode", NULL)); + server->usermode_away = config_node_get_bool(node, "usermode_away", FALSE); + server->away_reason = g_strdup(config_node_get_str(node, "away_reason", NULL)); + /* FIXME: remove before .99 */ g_free_not_null(server->connrec->channels); server->connrec->channels = g_strdup(config_node_get_str(node, "channels", NULL)); } +static void session_restore_channel(IRC_CHANNEL_REC *channel) +{ + signal_emit("event join", 4, channel->server, channel->name, + channel->server->nick, channel->server->userhost); + irc_send_cmdv(channel->server, "NAMES %s", channel->name); +} + static void sig_connected(IRC_SERVER_REC *server) { GSList *tmp; @@ -70,15 +92,12 @@ static void sig_connected(IRC_SERVER_REC *server) signal_emit("event 001", 3, server, str, server->real_address); g_free(str); - /* send join events for each channel and ask names list for them */ for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { - CHANNEL_REC *rec = tmp->data; + IRC_CHANNEL_REC *rec = tmp->data; - rec->session_rejoin = TRUE; - signal_emit("event join", 4, server, rec->name, - server->nick, server->userhost); - irc_send_cmdv(server, "TOPIC %s", rec->name); - irc_send_cmdv(server, "NAMES %s", rec->name); + rec->session_rejoin = TRUE; /* FIXME: remove after .99 */ + if (rec->session_rejoin) + session_restore_channel(rec); } } |