Mercurial > pidgin.yaz
diff libpurple/log.c @ 15519:b15cc37605c4
In Pidgin, display a full date on the timestamp of the first message to
cross the boundary into a new day. Sean and various users want this. I
think I'm finally going to admit it's a decent idea.
I've also refactored plenty of code related to the conversation-timestamp
and log-timestamp signals. This breaks API compatibility, but I'm pretty
sure the only plugin that uses those signals is the Message Timestamps
plugin that we ship. The changes eliminate duplicated code between the
core/UI and the plugin.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 03 Feb 2007 20:28:41 +0000 |
parents | da62cc01dd56 |
children | f61ad08739fc |
line wrap: on
line diff
--- a/libpurple/log.c Sat Feb 03 18:46:49 2007 +0000 +++ b/libpurple/log.c Sat Feb 03 20:28:41 2007 +0000 @@ -595,9 +595,9 @@ gaim_signal_register(handle, "log-timestamp", #if SIZEOF_TIME_T == 4 - gaim_marshal_POINTER__POINTER_INT, + gaim_marshal_POINTER__POINTER_INT_BOOLEAN, #elif SIZEOF_TIME_T == 8 - gaim_marshal_POINTER__POINTER_INT64, + gaim_marshal_POINTER__POINTER_INT64_BOOLEAN, #else #error Unknown size of time_t #endif @@ -605,12 +605,13 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_LOG), #if SIZEOF_TIME_T == 4 - gaim_value_new(GAIM_TYPE_INT)); + gaim_value_new(GAIM_TYPE_INT), #elif SIZEOF_TIME_T == 8 - gaim_value_new(GAIM_TYPE_INT64)); + gaim_value_new(GAIM_TYPE_INT64), #else # error Unknown size of time_t #endif + gaim_value_new(GAIM_TYPE_BOOLEAN)); gaim_prefs_connect_callback(NULL, "/core/logging/format", logger_pref_cb, NULL); @@ -633,17 +634,20 @@ static char *log_get_timestamp(GaimLog *log, time_t when) { + gboolean show_date; char *date; struct tm tm; + show_date = (log->type == GAIM_LOG_SYSTEM) || (time(NULL) > when + 20*60); + date = gaim_signal_emit_return_1(gaim_log_get_handle(), "log-timestamp", - log, when); + log, when, show_date); if (date != NULL) return date; tm = *(localtime(&when)); - if (log->type == GAIM_LOG_SYSTEM || time(NULL) > when + 20*60) + if (show_date) return g_strdup(gaim_date_format_long(&tm)); else return g_strdup(gaim_time_format(&tm));