summaryrefslogtreecommitdiff
path: root/src/irc/irc-send.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-01-08 01:22:25 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-01-08 01:22:25 +0000
commitb1f83dce8a9979aad72ccc5b2f34455488cc6c6e (patch)
treec4fa83a298c271b1530a7a51c1f5e9fff453b518 /src/irc/irc-send.c
parentdd39ac243273052609e5f3ee6a5217f07e06402d (diff)
downloadweechat-b1f83dce8a9979aad72ccc5b2f34455488cc6c6e.zip
Removed "irc_default_msg_away" setting, for RFC 2812 conformity (/away command
wihtout argument only removes away status)
Diffstat (limited to 'src/irc/irc-send.c')
-rw-r--r--src/irc/irc-send.c95
1 files changed, 44 insertions, 51 deletions
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index f6b6ce4b8..ca225d59c 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -195,8 +195,7 @@ irc_cmd_send_amsg (t_irc_server *server, char *arguments)
int
irc_cmd_send_away (t_irc_server *server, char *arguments)
{
- char *pos, *ptr_away_msg;
- char *ptr_away_default_msg = "away";
+ char *pos;
t_irc_server *ptr_server;
t_gui_window *ptr_window;
time_t elapsed;
@@ -217,37 +216,14 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
{
if (ptr_server->is_connected)
{
- if (ptr_server->is_away && (!pos))
- {
- server_sendf (ptr_server, "AWAY\r\n");
- ptr_server->is_away = 0;
- if (server->away_time != 0)
- {
- elapsed = time (NULL) - ptr_server->away_time;
- ptr_server->away_time = 0;
- if (cfg_irc_display_away)
- {
- snprintf (buffer, sizeof (buffer),
- "is back (gone %.2ld:%.2ld:%.2ld)",
- (long int)(elapsed / 3600),
- (long int)((elapsed / 60) % 60),
- (long int)(elapsed % 60));
- irc_send_me_all_channels (ptr_server, buffer);
- }
- }
- server_set_away (ptr_server, ptr_server->nick, 0);
- }
- else
+ if (pos)
{
ptr_server->is_away = 1;
ptr_server->away_time = time (NULL);
- ptr_away_msg = (pos) ? pos :
- ((cfg_irc_default_msg_away && cfg_irc_default_msg_away[0]) ?
- cfg_irc_default_msg_away : ptr_away_default_msg);
- server_sendf (ptr_server, "AWAY :%s\r\n", ptr_away_msg);
+ server_sendf (ptr_server, "AWAY :%s\r\n", pos);
if (cfg_irc_display_away)
{
- string = (char *)gui_color_decode ((unsigned char *)ptr_away_msg, 1);
+ string = (char *)gui_color_decode ((unsigned char *)pos, 1);
snprintf (buffer, sizeof (buffer), "is away: %s", (string) ? string : "");
irc_send_me_all_channels (ptr_server, buffer);
if (string)
@@ -262,12 +238,51 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
ptr_window->buffer->last_line;
}
}
+ else
+ {
+ server_sendf (ptr_server, "AWAY\r\n");
+ ptr_server->is_away = 0;
+ if (server->away_time != 0)
+ {
+ elapsed = time (NULL) - ptr_server->away_time;
+ ptr_server->away_time = 0;
+ if (cfg_irc_display_away)
+ {
+ snprintf (buffer, sizeof (buffer),
+ "is back (gone %.2ld:%.2ld:%.2ld)",
+ (long int)(elapsed / 3600),
+ (long int)((elapsed / 60) % 60),
+ (long int)(elapsed % 60));
+ irc_send_me_all_channels (ptr_server, buffer);
+ }
+ }
+ server_set_away (ptr_server, ptr_server->nick, 0);
+ }
}
}
}
else
{
- if (server->is_away && (!arguments))
+ if (arguments)
+ {
+ server->is_away = 1;
+ server->away_time = time (NULL);
+ server_sendf (server, "AWAY :%s\r\n", arguments);
+ if (cfg_irc_display_away)
+ {
+ snprintf (buffer, sizeof (buffer), "is away: %s", arguments);
+ irc_send_me_all_channels (server, buffer);
+ }
+ server_set_away (server, server->nick, 1);
+ for (ptr_window = gui_windows; ptr_window;
+ ptr_window = ptr_window->next_window)
+ {
+ if (SERVER(ptr_window->buffer) == server)
+ ptr_window->buffer->last_read_line =
+ ptr_window->buffer->last_line;
+ }
+ }
+ else
{
server_sendf (server, "AWAY\r\n");
server->is_away = 0;
@@ -287,28 +302,6 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
}
server_set_away (server, server->nick, 0);
}
- else
- {
- server->is_away = 1;
- server->away_time = time (NULL);
- ptr_away_msg = (arguments) ? arguments :
- ((cfg_irc_default_msg_away && cfg_irc_default_msg_away[0]) ?
- cfg_irc_default_msg_away : ptr_away_default_msg);
- server_sendf (server, "AWAY :%s\r\n", ptr_away_msg);
- if (cfg_irc_display_away)
- {
- snprintf (buffer, sizeof (buffer), "is away: %s", ptr_away_msg);
- irc_send_me_all_channels (server, buffer);
- }
- server_set_away (server, server->nick, 1);
- for (ptr_window = gui_windows; ptr_window;
- ptr_window = ptr_window->next_window)
- {
- if (SERVER(ptr_window->buffer) == server)
- ptr_window->buffer->last_read_line =
- ptr_window->buffer->last_line;
- }
- }
}
gui_draw_buffer_status (gui_current_window->buffer, 1);
gui_add_hotlist = 1;