From 8dcb59fd0b19f1d50254d4299b1c7fe9a0399c02 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 14 Oct 2006 08:33:13 +0000 Subject: [PATCH] Added date in plugin function get_buffer_data() --- ChangeLog | 3 +- doc/de/weechat.de.xml | 10 ++++- doc/en/weechat.en.xml | 10 ++++- doc/fr/weechat.fr.xml | 10 ++++- src/common/session.c | 6 ++- src/common/session.h | 3 +- src/gui/gui-buffer.c | 3 +- src/gui/gui-buffer.h | 1 + src/gui/gui-common.c | 50 ++++++++++++------------- src/gui/gui.h | 2 +- src/plugins/plugins-interface.c | 1 + src/plugins/weechat-plugin.h | 5 ++- weechat/ChangeLog | 3 +- weechat/doc/de/weechat.de.xml | 10 ++++- weechat/doc/en/weechat.en.xml | 10 ++++- weechat/doc/fr/weechat.fr.xml | 10 ++++- weechat/src/common/session.c | 6 ++- weechat/src/common/session.h | 3 +- weechat/src/gui/gui-buffer.c | 3 +- weechat/src/gui/gui-buffer.h | 1 + weechat/src/gui/gui-common.c | 50 ++++++++++++------------- weechat/src/gui/gui.h | 2 +- weechat/src/plugins/plugins-interface.c | 1 + weechat/src/plugins/weechat-plugin.h | 5 ++- 24 files changed, 138 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ff111468..f64607a04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,11 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2006-10-12 +ChangeLog - 2006-10-14 Version 0.2.2 (under dev!): + * added date in plugin function get_buffer_data() * fixed some portability bugs (patch #5271) * fixed iconv detection for BSD (patch #5456) * fixed typo in configure.in (bash specific test) (patch #5450) diff --git a/doc/de/weechat.de.xml b/doc/de/weechat.de.xml index 3b1b8e5fb..c9405cceb 100644 --- a/doc/de/weechat.de.xml +++ b/doc/de/weechat.de.xml @@ -4076,6 +4076,11 @@ else + + time_t + date + Datum/Zeit + char * nick @@ -4108,13 +4113,16 @@ else Example: t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/doc/en/weechat.en.xml b/doc/en/weechat.en.xml index 4f7b88b9f..2901b9bd1 100644 --- a/doc/en/weechat.en.xml +++ b/doc/en/weechat.en.xml @@ -4110,6 +4110,11 @@ else + + time_t + date + date and time + char * nick @@ -4142,13 +4147,16 @@ else Example: t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/doc/fr/weechat.fr.xml b/doc/fr/weechat.fr.xml index fe7ab6a80..b6c85fc0c 100644 --- a/doc/fr/weechat.fr.xml +++ b/doc/fr/weechat.fr.xml @@ -4207,6 +4207,11 @@ else + + time_t + date + date et heure + char * nick @@ -4242,13 +4247,16 @@ else Exemple : t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "pseudo: %s, données: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, pseudo: %s, données: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/src/common/session.c b/src/common/session.c index e885326a3..5f9872e1b 100644 --- a/src/common/session.c +++ b/src/common/session.c @@ -377,6 +377,7 @@ session_save_line (FILE *file, t_gui_line *line) rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_start_message)); rc = rc && (session_write_int (file, SESSION_LINE_OFS_START_MESSAGE, line->ofs_start_message)); rc = rc && (session_write_str (file, SESSION_LINE_NICK, line->nick)); + rc = rc && (session_write_buf (file, SESSION_LINE_NICK, &(line->date), sizeof (time_t))); rc = rc && (session_write_id (file, SESSION_LINE_END)); return rc; } @@ -1524,7 +1525,7 @@ session_load_line (FILE *file) } /* allocate line */ - line = gui_buffer_line_new (session_current_buffer); + line = gui_buffer_line_new (session_current_buffer, time (NULL)); if (!line) { session_crash (file, _("can't create new line")); @@ -1573,6 +1574,9 @@ session_load_line (FILE *file) case SESSION_LINE_NICK: rc = rc && (session_read_str (file, &(line->nick))); break; + case SESSION_LINE_DATE: + rc = rc && (session_read_buf (file, &(line->date), sizeof (time_t))); + break; default: weechat_log_printf (_("session: warning: ignoring value from " "line (object id: %d)\n"), diff --git a/src/common/session.h b/src/common/session.h index 343e40db2..64d9e8b4a 100644 --- a/src/common/session.h +++ b/src/common/session.h @@ -179,7 +179,8 @@ enum t_session_line SESSION_LINE_DATA, SESSION_LINE_OFS_AFTER_DATE, SESSION_LINE_OFS_START_MESSAGE, - SESSION_LINE_NICK + SESSION_LINE_NICK, + SESSION_LINE_DATE }; enum t_session_uptime diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index bb91d329c..2d2503847 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -551,7 +551,7 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another) */ t_gui_line * -gui_buffer_line_new (t_gui_buffer *buffer) +gui_buffer_line_new (t_gui_buffer *buffer, time_t date) { t_gui_line *new_line, *ptr_line; @@ -562,6 +562,7 @@ gui_buffer_line_new (t_gui_buffer *buffer) new_line->log_write = 1; new_line->line_with_message = 0; new_line->line_with_highlight = 0; + new_line->date = date; new_line->nick = NULL; new_line->data = NULL; new_line->ofs_after_date = -1; diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 518ae1045..4e2acb2d1 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -62,6 +62,7 @@ struct t_gui_line int log_write; /* = 1 if line will be written to log */ int line_with_message; /* line contains a message from a user? */ int line_with_highlight; /* line contains highlight */ + time_t date; /* date/time of line */ char *nick; /* nickname for line (may be NULL) */ char *data; /* line content */ int ofs_after_date; /* offset to first char after date */ diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index edf0541b2..71337adca 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -108,7 +108,7 @@ gui_word_real_pos (t_gui_window *window, char *string, int pos) */ void -gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message) +gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *message) { char *pos; int length; @@ -117,7 +117,7 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message) if (buffer->line_complete) { buffer->line_complete = 0; - if (!gui_buffer_line_new (buffer)) + if (!gui_buffer_line_new (buffer, date)) return; } @@ -220,14 +220,12 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic static char buf[8192]; char text_time[1024]; char text_time_char[2]; - time_t time_seconds; + time_t date; struct tm *local_time; int time_first_digit, time_last_digit; char *buf2, *pos; int i; va_list argptr; - static time_t seconds; - struct tm *date_tmp; if (gui_init_ok) { @@ -271,19 +269,16 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic if (gui_init_ok) { - seconds = time (NULL); - date_tmp = localtime (&seconds); - pos = buf2; while (pos) { + date = time (NULL); if ((!buffer->last_line) || (buffer->line_complete)) { if (display_time && cfg_look_buffer_timestamp && cfg_look_buffer_timestamp[0]) { - time_seconds = time (NULL); - local_time = localtime (&time_seconds); + local_time = localtime (&date); strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time); time_first_digit = -1; @@ -307,41 +302,46 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic text_time_char[0] = text_time[i]; if (time_first_digit < 0) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { if ((i < time_first_digit) || (i > time_last_digit)) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_DARK)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { if (isdigit (text_time[i])) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } } } i++; } - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, GUI_COLOR(COLOR_WIN_CHAT)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT)); } - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, " "); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, NULL, " "); } - gui_add_to_line (buffer, type, nick, pos); + gui_add_to_line (buffer, type, date, nick, pos); pos = strchr (pos, '\n'); if (pos) { diff --git a/src/gui/gui.h b/src/gui/gui.h index ac9f5343c..6891013a0 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -89,7 +89,7 @@ extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *); extern void gui_buffer_clear (t_gui_buffer *); extern void gui_buffer_clear_all (); extern void gui_buffer_free (t_gui_buffer *, int); -extern t_gui_line *gui_buffer_line_new (t_gui_buffer *); +extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t); extern void gui_buffer_merge_servers (t_gui_window *); extern void gui_buffer_split_server (t_gui_window *); extern void gui_buffer_switch_previous (t_gui_window *); diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c index ccf6ea9b5..a45ec7480 100644 --- a/src/plugins/plugins-interface.c +++ b/src/plugins/plugins-interface.c @@ -1294,6 +1294,7 @@ weechat_plugin_get_buffer_data (t_weechat_plugin *plugin, char *server, char *ch new_buffer_line = (t_plugin_buffer_line *) malloc (sizeof (t_plugin_buffer_line)); if (new_buffer_line) { + new_buffer_line->date = ptr_line->date; new_buffer_line->nick = (ptr_line->nick) ? strdup (ptr_line->nick) : NULL; new_buffer_line->data = (ptr_line->data) ? (char *) gui_color_decode ((unsigned char *)(ptr_line->data + ptr_line->ofs_start_message), 0) : NULL; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 582bbeea6..3658a2c4b 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -174,8 +174,9 @@ typedef struct t_plugin_buffer_line t_plugin_buffer_line; struct t_plugin_buffer_line { - char *nick; /* nick */ - char *data; /* line data */ + time_t date; /* date */ + char *nick; /* nick */ + char *data; /* line data */ t_plugin_buffer_line *prev_line; /* link to previous line */ t_plugin_buffer_line *next_line; /* link to next line */ }; diff --git a/weechat/ChangeLog b/weechat/ChangeLog index 7ff111468..f64607a04 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,11 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2006-10-12 +ChangeLog - 2006-10-14 Version 0.2.2 (under dev!): + * added date in plugin function get_buffer_data() * fixed some portability bugs (patch #5271) * fixed iconv detection for BSD (patch #5456) * fixed typo in configure.in (bash specific test) (patch #5450) diff --git a/weechat/doc/de/weechat.de.xml b/weechat/doc/de/weechat.de.xml index 3b1b8e5fb..c9405cceb 100644 --- a/weechat/doc/de/weechat.de.xml +++ b/weechat/doc/de/weechat.de.xml @@ -4076,6 +4076,11 @@ else + + time_t + date + Datum/Zeit + char * nick @@ -4108,13 +4113,16 @@ else Example: t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/weechat/doc/en/weechat.en.xml b/weechat/doc/en/weechat.en.xml index 4f7b88b9f..2901b9bd1 100644 --- a/weechat/doc/en/weechat.en.xml +++ b/weechat/doc/en/weechat.en.xml @@ -4110,6 +4110,11 @@ else + + time_t + date + date and time + char * nick @@ -4142,13 +4147,16 @@ else Example: t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/weechat/doc/fr/weechat.fr.xml b/weechat/doc/fr/weechat.fr.xml index fe7ab6a80..b6c85fc0c 100644 --- a/weechat/doc/fr/weechat.fr.xml +++ b/weechat/doc/fr/weechat.fr.xml @@ -4207,6 +4207,11 @@ else + + time_t + date + date et heure + char * nick @@ -4242,13 +4247,16 @@ else Exemple : t_plugin_buffer_line *buffer_line, *ptr_line; +char text_time[256]; buffer_line = plugin->get_buffer_data (plugin); if (buffer_line) { for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line) { - plugin->print (plugin, NULL, NULL, "pseudo: %s, données: %s", ptr_line->nick, ptr_line->data); + strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date))); + plugin->print (plugin, NULL, NULL, "date: %s, pseudo: %s, données: %s", + text_time, ptr_line->nick, ptr_line->data); } plugin->free_buffer_data (plugin, buffer_line); } diff --git a/weechat/src/common/session.c b/weechat/src/common/session.c index e885326a3..5f9872e1b 100644 --- a/weechat/src/common/session.c +++ b/weechat/src/common/session.c @@ -377,6 +377,7 @@ session_save_line (FILE *file, t_gui_line *line) rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_start_message)); rc = rc && (session_write_int (file, SESSION_LINE_OFS_START_MESSAGE, line->ofs_start_message)); rc = rc && (session_write_str (file, SESSION_LINE_NICK, line->nick)); + rc = rc && (session_write_buf (file, SESSION_LINE_NICK, &(line->date), sizeof (time_t))); rc = rc && (session_write_id (file, SESSION_LINE_END)); return rc; } @@ -1524,7 +1525,7 @@ session_load_line (FILE *file) } /* allocate line */ - line = gui_buffer_line_new (session_current_buffer); + line = gui_buffer_line_new (session_current_buffer, time (NULL)); if (!line) { session_crash (file, _("can't create new line")); @@ -1573,6 +1574,9 @@ session_load_line (FILE *file) case SESSION_LINE_NICK: rc = rc && (session_read_str (file, &(line->nick))); break; + case SESSION_LINE_DATE: + rc = rc && (session_read_buf (file, &(line->date), sizeof (time_t))); + break; default: weechat_log_printf (_("session: warning: ignoring value from " "line (object id: %d)\n"), diff --git a/weechat/src/common/session.h b/weechat/src/common/session.h index 343e40db2..64d9e8b4a 100644 --- a/weechat/src/common/session.h +++ b/weechat/src/common/session.h @@ -179,7 +179,8 @@ enum t_session_line SESSION_LINE_DATA, SESSION_LINE_OFS_AFTER_DATE, SESSION_LINE_OFS_START_MESSAGE, - SESSION_LINE_NICK + SESSION_LINE_NICK, + SESSION_LINE_DATE }; enum t_session_uptime diff --git a/weechat/src/gui/gui-buffer.c b/weechat/src/gui/gui-buffer.c index bb91d329c..2d2503847 100644 --- a/weechat/src/gui/gui-buffer.c +++ b/weechat/src/gui/gui-buffer.c @@ -551,7 +551,7 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another) */ t_gui_line * -gui_buffer_line_new (t_gui_buffer *buffer) +gui_buffer_line_new (t_gui_buffer *buffer, time_t date) { t_gui_line *new_line, *ptr_line; @@ -562,6 +562,7 @@ gui_buffer_line_new (t_gui_buffer *buffer) new_line->log_write = 1; new_line->line_with_message = 0; new_line->line_with_highlight = 0; + new_line->date = date; new_line->nick = NULL; new_line->data = NULL; new_line->ofs_after_date = -1; diff --git a/weechat/src/gui/gui-buffer.h b/weechat/src/gui/gui-buffer.h index 518ae1045..4e2acb2d1 100644 --- a/weechat/src/gui/gui-buffer.h +++ b/weechat/src/gui/gui-buffer.h @@ -62,6 +62,7 @@ struct t_gui_line int log_write; /* = 1 if line will be written to log */ int line_with_message; /* line contains a message from a user? */ int line_with_highlight; /* line contains highlight */ + time_t date; /* date/time of line */ char *nick; /* nickname for line (may be NULL) */ char *data; /* line content */ int ofs_after_date; /* offset to first char after date */ diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c index edf0541b2..71337adca 100644 --- a/weechat/src/gui/gui-common.c +++ b/weechat/src/gui/gui-common.c @@ -108,7 +108,7 @@ gui_word_real_pos (t_gui_window *window, char *string, int pos) */ void -gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message) +gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *message) { char *pos; int length; @@ -117,7 +117,7 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message) if (buffer->line_complete) { buffer->line_complete = 0; - if (!gui_buffer_line_new (buffer)) + if (!gui_buffer_line_new (buffer, date)) return; } @@ -220,14 +220,12 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic static char buf[8192]; char text_time[1024]; char text_time_char[2]; - time_t time_seconds; + time_t date; struct tm *local_time; int time_first_digit, time_last_digit; char *buf2, *pos; int i; va_list argptr; - static time_t seconds; - struct tm *date_tmp; if (gui_init_ok) { @@ -271,19 +269,16 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic if (gui_init_ok) { - seconds = time (NULL); - date_tmp = localtime (&seconds); - pos = buf2; while (pos) { + date = time (NULL); if ((!buffer->last_line) || (buffer->line_complete)) { if (display_time && cfg_look_buffer_timestamp && cfg_look_buffer_timestamp[0]) { - time_seconds = time (NULL); - local_time = localtime (&time_seconds); + local_time = localtime (&date); strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time); time_first_digit = -1; @@ -307,41 +302,46 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic text_time_char[0] = text_time[i]; if (time_first_digit < 0) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { if ((i < time_first_digit) || (i > time_last_digit)) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_DARK)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { if (isdigit (text_time[i])) { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } else { - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, - GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP)); - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, text_time_char); } } } i++; } - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, GUI_COLOR(COLOR_WIN_CHAT)); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, + NULL, GUI_COLOR(COLOR_WIN_CHAT)); } - gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, " "); + gui_add_to_line (buffer, MSG_TYPE_TIME, date, NULL, " "); } - gui_add_to_line (buffer, type, nick, pos); + gui_add_to_line (buffer, type, date, nick, pos); pos = strchr (pos, '\n'); if (pos) { diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h index ac9f5343c..6891013a0 100644 --- a/weechat/src/gui/gui.h +++ b/weechat/src/gui/gui.h @@ -89,7 +89,7 @@ extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *); extern void gui_buffer_clear (t_gui_buffer *); extern void gui_buffer_clear_all (); extern void gui_buffer_free (t_gui_buffer *, int); -extern t_gui_line *gui_buffer_line_new (t_gui_buffer *); +extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t); extern void gui_buffer_merge_servers (t_gui_window *); extern void gui_buffer_split_server (t_gui_window *); extern void gui_buffer_switch_previous (t_gui_window *); diff --git a/weechat/src/plugins/plugins-interface.c b/weechat/src/plugins/plugins-interface.c index ccf6ea9b5..a45ec7480 100644 --- a/weechat/src/plugins/plugins-interface.c +++ b/weechat/src/plugins/plugins-interface.c @@ -1294,6 +1294,7 @@ weechat_plugin_get_buffer_data (t_weechat_plugin *plugin, char *server, char *ch new_buffer_line = (t_plugin_buffer_line *) malloc (sizeof (t_plugin_buffer_line)); if (new_buffer_line) { + new_buffer_line->date = ptr_line->date; new_buffer_line->nick = (ptr_line->nick) ? strdup (ptr_line->nick) : NULL; new_buffer_line->data = (ptr_line->data) ? (char *) gui_color_decode ((unsigned char *)(ptr_line->data + ptr_line->ofs_start_message), 0) : NULL; diff --git a/weechat/src/plugins/weechat-plugin.h b/weechat/src/plugins/weechat-plugin.h index 582bbeea6..3658a2c4b 100644 --- a/weechat/src/plugins/weechat-plugin.h +++ b/weechat/src/plugins/weechat-plugin.h @@ -174,8 +174,9 @@ typedef struct t_plugin_buffer_line t_plugin_buffer_line; struct t_plugin_buffer_line { - char *nick; /* nick */ - char *data; /* line data */ + time_t date; /* date */ + char *nick; /* nick */ + char *data; /* line data */ t_plugin_buffer_line *prev_line; /* link to previous line */ t_plugin_buffer_line *next_line; /* link to next line */ };