summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-08-05 18:44:55 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-08-05 18:44:55 +0000
commitb2183ee3edbfceb66a5705fcfc601c6e72728049 (patch)
treecb763631df4039edbcb25777294dd80a3d7fd961 /src/irc
parent22b80dec657f4353bd6aae69b16459ef2e50f1ba (diff)
downloadweechat-b2183ee3edbfceb66a5705fcfc601c6e72728049.zip
Fixed away after server disconnection (now away is set again when reconnecting) (bug #16359)
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc-recv.c16
-rw-r--r--src/irc/irc-send.c10
-rw-r--r--src/irc/irc-server.c4
-rw-r--r--src/irc/irc.h4
4 files changed, 31 insertions, 3 deletions
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index 225b57f4e..f89c5b288 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -2857,7 +2857,8 @@ irc_cmd_recv_001 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos;
char **commands, **ptr;
- t_irc_channel *ptr_channel;
+ t_irc_channel *ptr_channel;
+ char *away_msg;
pos = strchr (arguments, ' ');
if (pos)
@@ -2876,7 +2877,7 @@ irc_cmd_recv_001 (t_irc_server *server, char *host, char *nick, char *arguments)
gui_status_draw (server->buffer, 1);
gui_input_draw (server->buffer, 1);
- /* execute command once connected */
+ /* execute command when connected */
if (server->command && server->command[0])
{
/* splitting command on ';' which can be escaped with '\;' */
@@ -2916,6 +2917,17 @@ irc_cmd_recv_001 (t_irc_server *server, char *host, char *nick, char *arguments)
if (server->autojoin && server->autojoin[0])
return irc_cmd_send_join (server, NULL, server->autojoin);
}
+
+ /* set away message if user was away (before disconnection for example) */
+ if (server->away_message && server->away_message[0])
+ {
+ away_msg = strdup (server->away_message);
+ if (away_msg)
+ {
+ irc_send_away (server, away_msg);
+ free (away_msg);
+ }
+ }
return 0;
}
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index 785f44369..bd45810c7 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -244,6 +244,11 @@ irc_send_away (t_irc_server *server, char *arguments)
if (arguments)
{
server->is_away = 1;
+ if (server->away_message)
+ free (server->away_message);
+ server->away_message = (char *) malloc (strlen (arguments) + 1);
+ if (server->away_message)
+ strcpy (server->away_message, arguments);
server->away_time = time (NULL);
server_sendf (server, "AWAY :%s\r\n", arguments);
if (cfg_irc_display_away != CFG_IRC_DISPLAY_AWAY_OFF)
@@ -272,6 +277,11 @@ irc_send_away (t_irc_server *server, char *arguments)
{
server_sendf (server, "AWAY\r\n");
server->is_away = 0;
+ if (server->away_message)
+ {
+ free (server->away_message);
+ server->away_message = NULL;
+ }
if (server->away_time != 0)
{
time_now = time (NULL);
diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c
index e67d68798..ff3337868 100644
--- a/src/irc/irc-server.c
+++ b/src/irc/irc-server.c
@@ -108,6 +108,7 @@ server_init (t_irc_server *server)
server->reconnect_start = 0;
server->reconnect_join = 0;
server->is_away = 0;
+ server->away_message = NULL;
server->away_time = 0;
server->lag = 0;
server->lag_check_time.tv_sec = 0;
@@ -323,6 +324,8 @@ server_destroy (t_irc_server *server)
free (server->nick);
if (server->nick_modes)
free (server->nick_modes);
+ if (server->away_message)
+ free (server->away_message);
if (server->channels)
channel_free_all (server);
}
@@ -1980,6 +1983,7 @@ server_print_log (t_irc_server *server)
weechat_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start);
weechat_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join);
weechat_log_printf (" is_away . . . . . . : %d\n", server->is_away);
+ weechat_log_printf (" away_message. . . . : '%s'\n", server->away_message);
weechat_log_printf (" away_time . . . . . : %ld\n", server->away_time);
weechat_log_printf (" lag . . . . . . . . : %d\n", server->lag);
weechat_log_printf (" lag_check_time. . . : tv_sec:%d, tv_usec:%d\n",
diff --git a/src/irc/irc.h b/src/irc/irc.h
index 1f20902f3..45f59b16c 100644
--- a/src/irc/irc.h
+++ b/src/irc/irc.h
@@ -184,7 +184,8 @@ struct t_irc_server
char *nick_modes; /* nick modes */
time_t reconnect_start; /* this time + delay = reconnect time */
int reconnect_join; /* 1 if channels opened to rejoin */
- int is_away; /* 1 is user is marker as away */
+ int is_away; /* 1 is user is marked as away */
+ char *away_message; /* away message, NULL if not away */
time_t away_time; /* time() when user marking as away */
int lag; /* lag (in milliseconds) */
struct timeval lag_check_time; /* last time lag was checked (ping sent) */
@@ -468,6 +469,7 @@ extern void irc_login (t_irc_server *);
extern int irc_cmd_send_admin (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ame (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_amsg (t_irc_server *, t_irc_channel *, char *);
+extern void irc_send_away (t_irc_server *, char *);
extern int irc_cmd_send_away (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ban (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ctcp (t_irc_server *, t_irc_channel *, char *);