diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2004-09-12 17:22:45 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2004-09-12 17:22:45 +0000 |
commit | 0e47caf091dae7b4c214bab7e7398a32a07a657f (patch) | |
tree | f430a57aa5025a199c88762cd145c2518bcab930 | |
parent | 6100af949b683d3a092ca17c8e2487beece9e754 (diff) | |
download | weechat-0e47caf091dae7b4c214bab7e7398a32a07a657f.zip |
Away now announced in channels, and config option "look_display_away" added to enable/disable this feature
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/common/weeconfig.c | 5 | ||||
-rw-r--r-- | src/common/weeconfig.h | 1 | ||||
-rw-r--r-- | src/irc/irc-send.c | 89 | ||||
-rw-r--r-- | src/irc/irc.h | 4 | ||||
-rw-r--r-- | weechat/ChangeLog | 4 | ||||
-rw-r--r-- | weechat/src/common/weeconfig.c | 5 | ||||
-rw-r--r-- | weechat/src/common/weeconfig.h | 1 | ||||
-rw-r--r-- | weechat/src/irc/irc-send.c | 89 | ||||
-rw-r--r-- | weechat/src/irc/irc.h | 4 |
10 files changed, 190 insertions, 16 deletions
@@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2004-09-08 +ChangeLog - 2004-09-12 Version 0.0.8 (under dev!): + * Away now announced in channels, and config option "look_display_away" added + to enable/disable this feature * Fixed crash when resizing terminal to very small size * "-MORE-" message is now erased when switching to another buffer * DCC window with Alt-D diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index b912d9a38..2416333a8 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -73,6 +73,7 @@ int cfg_look_nickmode; int cfg_look_nickmode_empty; char *cfg_look_no_nickname; char *cfg_look_completor; +int cfg_look_display_away; int cfg_look_infobar; char *cfg_look_infobar_timestamp; int cfg_look_infobar_delay_highlight; @@ -140,6 +141,10 @@ t_config_option weechat_options_look[] = N_("the string inserted after nick completion"), OPTION_TYPE_STRING, 0, 0, 0, ":", NULL, NULL, &cfg_look_completor, config_change_noop }, + { "look_display_away", N_("display message to all channels when away"), + N_("display message to all channels when (un)marking as away"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_display_away, NULL, config_change_noop }, { "look_infobar", N_("enable info bar"), N_("enable info bar"), OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h index 36ffb49eb..4f39b29c3 100644 --- a/src/common/weeconfig.h +++ b/src/common/weeconfig.h @@ -88,6 +88,7 @@ extern int cfg_look_nickmode; extern int cfg_look_nickmode_empty; extern char *cfg_look_no_nickname; extern char *cfg_look_completor; +extern int cfg_look_display_away; extern int cfg_look_infobar; extern char *cfg_look_infobar_timestamp; extern int cfg_look_infobar_delay_highlight; diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index d33bb275c..c55aacb36 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -89,6 +89,8 @@ irc_cmd_send_away (t_irc_server *server, char *arguments) { char *pos; t_irc_server *ptr_server; + time_t elapsed; + char buffer[4096]; if (arguments && (strncmp (arguments, "-all", 4) == 0)) { @@ -104,18 +106,62 @@ irc_cmd_send_away (t_irc_server *server, char *arguments) if (ptr_server->is_connected) { if (pos) + { + ptr_server->is_away = 1; + ptr_server->away_time = time (NULL); server_sendf (ptr_server, "AWAY :%s\r\n", pos); + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), "is away: %s", pos); + irc_send_me_all_channels (ptr_server, buffer); + } + } else + { server_sendf (ptr_server, "AWAY\r\n"); + ptr_server->is_away = 0; + elapsed = time (NULL) - ptr_server->away_time; + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), + "is back (gone %.2ld:%.2ld:%.2ld)", + elapsed / 3600, + (elapsed / 60) % 60, + elapsed % 60); + irc_send_me_all_channels (ptr_server, buffer); + } + } } } } else { if (arguments) + { + server->is_away = 1; + server->away_time = time (NULL); server_sendf (server, "AWAY :%s\r\n", arguments); + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), "is away: %s", arguments); + irc_send_me_all_channels (server, buffer); + } + } else + { server_sendf (server, "AWAY\r\n"); + server->is_away = 0; + elapsed = time (NULL) - server->away_time; + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), + "is back (gone %.2ld:%.2ld:%.2ld)", + elapsed / 3600, + (elapsed / 60) % 60, + elapsed % 60); + irc_send_me_all_channels (server, buffer); + } + } } return 0; } @@ -382,6 +428,41 @@ irc_cmd_send_lusers (t_irc_server *server, char *arguments) } /* + * irc_send_me: send a ctcp action to a channel + */ + +int +irc_send_me (t_irc_server *server, t_irc_channel *channel, char *arguments) +{ + server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n", + channel->name, arguments); + irc_display_prefix (channel->buffer, PREFIX_ACTION_ME); + gui_printf_color (channel->buffer, + COLOR_WIN_CHAT_NICK, "%s", server->nick); + gui_printf_color (channel->buffer, + COLOR_WIN_CHAT, " %s\n", arguments); + return 0; +} + +/* + * irc_send_me_all_channels: send a ctcp action to all channels of a server + */ + +int +irc_send_me_all_channels (t_irc_server *server, char *arguments) +{ + t_irc_channel *ptr_channel; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->type == CHAT_CHANNEL) + irc_send_me (server, ptr_channel, arguments); + } + return 0; +} + +/* * irc_cmd_send_me: send a ctcp action to the current channel */ @@ -395,13 +476,7 @@ irc_cmd_send_me (t_irc_server *server, char *arguments) WEECHAT_ERROR, "me"); return -1; } - server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n", - CHANNEL(gui_current_window->buffer)->name, arguments); - irc_display_prefix (gui_current_window->buffer, PREFIX_ACTION_ME); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT_NICK, "%s", server->nick); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT, " %s\n", arguments); + irc_send_me (server, CHANNEL(gui_current_window->buffer), arguments); return 0; } diff --git a/src/irc/irc.h b/src/irc/irc.h index 3d22fe5fb..9ce6238f1 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -21,6 +21,7 @@ #ifndef __WEECHAT_IRC_H #define __WEECHAT_IRC_H 1 +#include <time.h> #include "../gui/gui.h" /* prefixes for chat window */ @@ -132,6 +133,7 @@ struct t_irc_server int is_connected; /* 1 if WeeChat is connected to server */ int sock4; /* socket for server */ int is_away; /* 1 is user is marker as away */ + time_t away_time; /* time() when user marking as away */ int server_read; /* pipe for reading server data */ int server_write; /* pipe for sending data to server */ t_gui_buffer *buffer; /* GUI buffer allocated for server */ @@ -279,6 +281,8 @@ extern int irc_cmd_send_kill (t_irc_server *, char *); extern int irc_cmd_send_links (t_irc_server *, char *); extern int irc_cmd_send_list (t_irc_server *, char *); extern int irc_cmd_send_lusers (t_irc_server *, char *); +extern int irc_send_me (t_irc_server *, t_irc_channel *, char *); +extern int irc_send_me_all_channels (t_irc_server *, char *); extern int irc_cmd_send_me (t_irc_server *, char *); extern int irc_cmd_send_mode (t_irc_server *, char *); extern int irc_cmd_send_motd (t_irc_server *, char *); diff --git a/weechat/ChangeLog b/weechat/ChangeLog index a10929beb..46b37d770 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2004-09-08 +ChangeLog - 2004-09-12 Version 0.0.8 (under dev!): + * Away now announced in channels, and config option "look_display_away" added + to enable/disable this feature * Fixed crash when resizing terminal to very small size * "-MORE-" message is now erased when switching to another buffer * DCC window with Alt-D diff --git a/weechat/src/common/weeconfig.c b/weechat/src/common/weeconfig.c index b912d9a38..2416333a8 100644 --- a/weechat/src/common/weeconfig.c +++ b/weechat/src/common/weeconfig.c @@ -73,6 +73,7 @@ int cfg_look_nickmode; int cfg_look_nickmode_empty; char *cfg_look_no_nickname; char *cfg_look_completor; +int cfg_look_display_away; int cfg_look_infobar; char *cfg_look_infobar_timestamp; int cfg_look_infobar_delay_highlight; @@ -140,6 +141,10 @@ t_config_option weechat_options_look[] = N_("the string inserted after nick completion"), OPTION_TYPE_STRING, 0, 0, 0, ":", NULL, NULL, &cfg_look_completor, config_change_noop }, + { "look_display_away", N_("display message to all channels when away"), + N_("display message to all channels when (un)marking as away"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_look_display_away, NULL, config_change_noop }, { "look_infobar", N_("enable info bar"), N_("enable info bar"), OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, diff --git a/weechat/src/common/weeconfig.h b/weechat/src/common/weeconfig.h index 36ffb49eb..4f39b29c3 100644 --- a/weechat/src/common/weeconfig.h +++ b/weechat/src/common/weeconfig.h @@ -88,6 +88,7 @@ extern int cfg_look_nickmode; extern int cfg_look_nickmode_empty; extern char *cfg_look_no_nickname; extern char *cfg_look_completor; +extern int cfg_look_display_away; extern int cfg_look_infobar; extern char *cfg_look_infobar_timestamp; extern int cfg_look_infobar_delay_highlight; diff --git a/weechat/src/irc/irc-send.c b/weechat/src/irc/irc-send.c index d33bb275c..c55aacb36 100644 --- a/weechat/src/irc/irc-send.c +++ b/weechat/src/irc/irc-send.c @@ -89,6 +89,8 @@ irc_cmd_send_away (t_irc_server *server, char *arguments) { char *pos; t_irc_server *ptr_server; + time_t elapsed; + char buffer[4096]; if (arguments && (strncmp (arguments, "-all", 4) == 0)) { @@ -104,18 +106,62 @@ irc_cmd_send_away (t_irc_server *server, char *arguments) if (ptr_server->is_connected) { if (pos) + { + ptr_server->is_away = 1; + ptr_server->away_time = time (NULL); server_sendf (ptr_server, "AWAY :%s\r\n", pos); + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), "is away: %s", pos); + irc_send_me_all_channels (ptr_server, buffer); + } + } else + { server_sendf (ptr_server, "AWAY\r\n"); + ptr_server->is_away = 0; + elapsed = time (NULL) - ptr_server->away_time; + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), + "is back (gone %.2ld:%.2ld:%.2ld)", + elapsed / 3600, + (elapsed / 60) % 60, + elapsed % 60); + irc_send_me_all_channels (ptr_server, buffer); + } + } } } } else { if (arguments) + { + server->is_away = 1; + server->away_time = time (NULL); server_sendf (server, "AWAY :%s\r\n", arguments); + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), "is away: %s", arguments); + irc_send_me_all_channels (server, buffer); + } + } else + { server_sendf (server, "AWAY\r\n"); + server->is_away = 0; + elapsed = time (NULL) - server->away_time; + if (cfg_look_display_away) + { + snprintf (buffer, sizeof (buffer), + "is back (gone %.2ld:%.2ld:%.2ld)", + elapsed / 3600, + (elapsed / 60) % 60, + elapsed % 60); + irc_send_me_all_channels (server, buffer); + } + } } return 0; } @@ -382,6 +428,41 @@ irc_cmd_send_lusers (t_irc_server *server, char *arguments) } /* + * irc_send_me: send a ctcp action to a channel + */ + +int +irc_send_me (t_irc_server *server, t_irc_channel *channel, char *arguments) +{ + server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n", + channel->name, arguments); + irc_display_prefix (channel->buffer, PREFIX_ACTION_ME); + gui_printf_color (channel->buffer, + COLOR_WIN_CHAT_NICK, "%s", server->nick); + gui_printf_color (channel->buffer, + COLOR_WIN_CHAT, " %s\n", arguments); + return 0; +} + +/* + * irc_send_me_all_channels: send a ctcp action to all channels of a server + */ + +int +irc_send_me_all_channels (t_irc_server *server, char *arguments) +{ + t_irc_channel *ptr_channel; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->type == CHAT_CHANNEL) + irc_send_me (server, ptr_channel, arguments); + } + return 0; +} + +/* * irc_cmd_send_me: send a ctcp action to the current channel */ @@ -395,13 +476,7 @@ irc_cmd_send_me (t_irc_server *server, char *arguments) WEECHAT_ERROR, "me"); return -1; } - server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n", - CHANNEL(gui_current_window->buffer)->name, arguments); - irc_display_prefix (gui_current_window->buffer, PREFIX_ACTION_ME); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT_NICK, "%s", server->nick); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT, " %s\n", arguments); + irc_send_me (server, CHANNEL(gui_current_window->buffer), arguments); return 0; } diff --git a/weechat/src/irc/irc.h b/weechat/src/irc/irc.h index 3d22fe5fb..9ce6238f1 100644 --- a/weechat/src/irc/irc.h +++ b/weechat/src/irc/irc.h @@ -21,6 +21,7 @@ #ifndef __WEECHAT_IRC_H #define __WEECHAT_IRC_H 1 +#include <time.h> #include "../gui/gui.h" /* prefixes for chat window */ @@ -132,6 +133,7 @@ struct t_irc_server int is_connected; /* 1 if WeeChat is connected to server */ int sock4; /* socket for server */ int is_away; /* 1 is user is marker as away */ + time_t away_time; /* time() when user marking as away */ int server_read; /* pipe for reading server data */ int server_write; /* pipe for sending data to server */ t_gui_buffer *buffer; /* GUI buffer allocated for server */ @@ -279,6 +281,8 @@ extern int irc_cmd_send_kill (t_irc_server *, char *); extern int irc_cmd_send_links (t_irc_server *, char *); extern int irc_cmd_send_list (t_irc_server *, char *); extern int irc_cmd_send_lusers (t_irc_server *, char *); +extern int irc_send_me (t_irc_server *, t_irc_channel *, char *); +extern int irc_send_me_all_channels (t_irc_server *, char *); extern int irc_cmd_send_me (t_irc_server *, char *); extern int irc_cmd_send_mode (t_irc_server *, char *); extern int irc_cmd_send_motd (t_irc_server *, char *); |