summaryrefslogtreecommitdiff
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
parent22b80dec657f4353bd6aae69b16459ef2e50f1ba (diff)
downloadweechat-b2183ee3edbfceb66a5705fcfc601c6e72728049.zip
Fixed away after server disconnection (now away is set again when reconnecting) (bug #16359)
-rw-r--r--ChangeLog2
-rw-r--r--src/common/session.c4
-rw-r--r--src/common/session.h3
-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
-rw-r--r--weechat/ChangeLog2
-rw-r--r--weechat/src/common/session.c4
-rw-r--r--weechat/src/common/session.h3
-rw-r--r--weechat/src/irc/irc-recv.c16
-rw-r--r--weechat/src/irc/irc-send.c10
-rw-r--r--weechat/src/irc/irc-server.c4
-rw-r--r--weechat/src/irc/irc.h4
14 files changed, 78 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index e73ffe458..95d3306e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@ WeeChat - Wee Enhanced Environment for Chat
ChangeLog - 2006-08-05
Version 0.2.0 (under dev!):
+ * fixed away after server disconnection (now away is set again when
+ reconnecting) (bug #16359)
* fixed DCC file connection problem (connection from receiver to sender)
* improved DCC speed (up to x5 on LAN) by forking for DCC files and a
new option "dcc_fast_send" (does not wait for ACK) (task #5758)
diff --git a/src/common/session.c b/src/common/session.c
index df26a119f..6d84d4335 100644
--- a/src/common/session.c
+++ b/src/common/session.c
@@ -258,6 +258,7 @@ session_save_servers (FILE *file)
rc = rc && (session_write_buf (file, SESSION_SERV_RECONNECT_START, &(ptr_server->reconnect_start), sizeof (time_t)));
rc = rc && (session_write_int (file, SESSION_SERV_RECONNECT_JOIN, ptr_server->reconnect_join));
rc = rc && (session_write_int (file, SESSION_SERV_IS_AWAY, ptr_server->is_away));
+ rc = rc && (session_write_str (file, SESSION_SERV_AWAY_MESSAGE, ptr_server->away_message));
rc = rc && (session_write_buf (file, SESSION_SERV_AWAY_TIME, &(ptr_server->away_time), sizeof (time_t)));
rc = rc && (session_write_int (file, SESSION_SERV_LAG, ptr_server->lag));
rc = rc && (session_write_buf (file, SESSION_SERV_LAG_CHECK_TIME, &(ptr_server->lag_check_time), sizeof (struct timeval)));
@@ -948,6 +949,9 @@ session_load_server (FILE *file)
case SESSION_SERV_IS_AWAY:
rc = rc && (session_read_int (file, &(session_current_server->is_away)));
break;
+ case SESSION_SERV_AWAY_MESSAGE:
+ rc = rc && (session_read_str (file, &(session_current_server->away_message)));
+ break;
case SESSION_SERV_AWAY_TIME:
rc = rc && (session_read_buf (file, &(session_current_server->away_time), sizeof (time_t)));
break;
diff --git a/src/common/session.h b/src/common/session.h
index 358b2b1ce..604c98405 100644
--- a/src/common/session.h
+++ b/src/common/session.h
@@ -90,7 +90,8 @@ enum t_session_server
SESSION_SERV_CHARSET_DECODE_UTF,
SESSION_SERV_CHARSET_ENCODE,
SESSION_SERV_HOSTNAME,
- SESSION_SERV_NICK_MODES
+ SESSION_SERV_NICK_MODES,
+ SESSION_SERV_AWAY_MESSAGE
};
enum t_session_channel
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 *);
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index e73ffe458..95d3306e5 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -4,6 +4,8 @@ WeeChat - Wee Enhanced Environment for Chat
ChangeLog - 2006-08-05
Version 0.2.0 (under dev!):
+ * fixed away after server disconnection (now away is set again when
+ reconnecting) (bug #16359)
* fixed DCC file connection problem (connection from receiver to sender)
* improved DCC speed (up to x5 on LAN) by forking for DCC files and a
new option "dcc_fast_send" (does not wait for ACK) (task #5758)
diff --git a/weechat/src/common/session.c b/weechat/src/common/session.c
index df26a119f..6d84d4335 100644
--- a/weechat/src/common/session.c
+++ b/weechat/src/common/session.c
@@ -258,6 +258,7 @@ session_save_servers (FILE *file)
rc = rc && (session_write_buf (file, SESSION_SERV_RECONNECT_START, &(ptr_server->reconnect_start), sizeof (time_t)));
rc = rc && (session_write_int (file, SESSION_SERV_RECONNECT_JOIN, ptr_server->reconnect_join));
rc = rc && (session_write_int (file, SESSION_SERV_IS_AWAY, ptr_server->is_away));
+ rc = rc && (session_write_str (file, SESSION_SERV_AWAY_MESSAGE, ptr_server->away_message));
rc = rc && (session_write_buf (file, SESSION_SERV_AWAY_TIME, &(ptr_server->away_time), sizeof (time_t)));
rc = rc && (session_write_int (file, SESSION_SERV_LAG, ptr_server->lag));
rc = rc && (session_write_buf (file, SESSION_SERV_LAG_CHECK_TIME, &(ptr_server->lag_check_time), sizeof (struct timeval)));
@@ -948,6 +949,9 @@ session_load_server (FILE *file)
case SESSION_SERV_IS_AWAY:
rc = rc && (session_read_int (file, &(session_current_server->is_away)));
break;
+ case SESSION_SERV_AWAY_MESSAGE:
+ rc = rc && (session_read_str (file, &(session_current_server->away_message)));
+ break;
case SESSION_SERV_AWAY_TIME:
rc = rc && (session_read_buf (file, &(session_current_server->away_time), sizeof (time_t)));
break;
diff --git a/weechat/src/common/session.h b/weechat/src/common/session.h
index 358b2b1ce..604c98405 100644
--- a/weechat/src/common/session.h
+++ b/weechat/src/common/session.h
@@ -90,7 +90,8 @@ enum t_session_server
SESSION_SERV_CHARSET_DECODE_UTF,
SESSION_SERV_CHARSET_ENCODE,
SESSION_SERV_HOSTNAME,
- SESSION_SERV_NICK_MODES
+ SESSION_SERV_NICK_MODES,
+ SESSION_SERV_AWAY_MESSAGE
};
enum t_session_channel
diff --git a/weechat/src/irc/irc-recv.c b/weechat/src/irc/irc-recv.c
index 225b57f4e..f89c5b288 100644
--- a/weechat/src/irc/irc-recv.c
+++ b/weechat/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/weechat/src/irc/irc-send.c b/weechat/src/irc/irc-send.c
index 785f44369..bd45810c7 100644
--- a/weechat/src/irc/irc-send.c
+++ b/weechat/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/weechat/src/irc/irc-server.c b/weechat/src/irc/irc-server.c
index e67d68798..ff3337868 100644
--- a/weechat/src/irc/irc-server.c
+++ b/weechat/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/weechat/src/irc/irc.h b/weechat/src/irc/irc.h
index 1f20902f3..45f59b16c 100644
--- a/weechat/src/irc/irc.h
+++ b/weechat/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 *);