diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-19 17:06:52 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-19 18:16:11 +0800 |
commit | 92af7e9f7c5f114963299fcf53b48b4ed86a2f7b (patch) | |
tree | 24fc4607cd492d777c2e1ee4a5f77a6381059fd8 /libempathy-gtk | |
parent | 2d1ca4e5b9f7fdff7b1ea2d4fc31828d7dbbbae8 (diff) | |
download | gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar.gz gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar.bz2 gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar.lz gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar.xz gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.tar.zst gsoc2013-empathy-92af7e9f7c5f114963299fcf53b48b4ed86a2f7b.zip |
Port all timestamps from time_t to gint64 (#648188)
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat-text-view.c | 43 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat-text-view.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-widget.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-location-manager.c | 17 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-boxes.c | 2 |
7 files changed, 37 insertions, 45 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c index b58fbc239..b04d3e9d2 100644 --- a/libempathy-gtk/empathy-chat-text-view.c +++ b/libempathy-gtk/empathy-chat-text-view.c @@ -48,7 +48,7 @@ #include <libempathy/empathy-debug.h> /* Number of seconds between timestamps when using normal mode, 5 minutes. */ -#define TIMESTAMP_INTERVAL 300 +#define TIMESTAMP_INTERVAL (5 * G_TIME_SPAN_MINUTE) #define MAX_LINES 800 #define MAX_SCROLL_TIME 0.4 /* seconds */ @@ -65,7 +65,7 @@ typedef struct { gboolean find_wrapped; gboolean find_last_direction; EmpathyContact *last_contact; - time_t last_timestamp; + gint64 last_timestamp; gboolean allow_scrolling; guint notify_system_fonts_id; GSettings *gsettings_desktop; @@ -398,7 +398,7 @@ chat_text_view_maybe_trim_buffer (EmpathyChatTextView *view) static void chat_text_view_append_timestamp (EmpathyChatTextView *view, - time_t timestamp, + gint64 timestamp, gboolean show_date) { EmpathyChatTextViewPriv *priv = GET_PRIV (view); @@ -410,17 +410,16 @@ chat_text_view_append_timestamp (EmpathyChatTextView *view, /* Append date if needed */ if (show_date) { - GDate *date; - gchar buf[256]; + GDateTime *date; - date = g_date_new (); - g_date_set_time_t (date, timestamp); + date = g_date_time_new_from_unix_utc (timestamp); /* Translators: timestamp displayed between conversations in * chat windows (strftime format string) */ - g_date_strftime (buf, 256, _("%A %B %d %Y"), date); - g_string_append (str, buf); + tmp = g_date_time_format (date, _("%A %B %d %Y")); + g_string_append (str, tmp); g_string_append (str, ", "); - g_date_free (date); + g_date_time_unref (date); + g_free (tmp); } /* Append time */ @@ -444,32 +443,32 @@ chat_text_view_append_timestamp (EmpathyChatTextView *view, static void chat_text_maybe_append_date_and_time (EmpathyChatTextView *view, - time_t timestamp) + gint64 timestamp) { EmpathyChatTextViewPriv *priv = GET_PRIV (view); - GDate *date, *last_date; + GDateTime *date, *last_date; gboolean append_date = FALSE; gboolean append_time = FALSE; + GTimeSpan delta; /* Get the date from last message */ - last_date = g_date_new (); - g_date_set_time_t (last_date, priv->last_timestamp); + last_date = g_date_time_new_from_unix_utc (priv->last_timestamp); /* Get the date of the message we are appending */ - date = g_date_new (); - g_date_set_time_t (date, timestamp); + date = g_date_time_new_from_unix_utc (timestamp); + delta = g_date_time_difference (last_date, date); /* If last message was from another day we append date and time */ - if (g_date_compare (date, last_date) > 0) { + if (delta >= G_TIME_SPAN_DAY) { append_date = TRUE; append_time = TRUE; } - g_date_free (last_date); - g_date_free (date); + g_date_time_unref (last_date); + g_date_time_unref (date); /* If last message is 'old' append the time */ - if (timestamp - priv->last_timestamp >= TIMESTAMP_INTERVAL) { + if (delta >= TIMESTAMP_INTERVAL) { append_time = TRUE; } @@ -725,7 +724,7 @@ chat_text_view_append_message (EmpathyChatView *view, EmpathyChatTextView *text_view = EMPATHY_CHAT_TEXT_VIEW (view); EmpathyChatTextViewPriv *priv = GET_PRIV (text_view); gboolean bottom; - time_t timestamp; + gint64 timestamp; g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view)); g_return_if_fail (EMPATHY_IS_MESSAGE (msg)); @@ -1320,7 +1319,7 @@ empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view) return priv->last_contact; } -time_t +gint64 empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view) { EmpathyChatTextViewPriv *priv = GET_PRIV (view); diff --git a/libempathy-gtk/empathy-chat-text-view.h b/libempathy-gtk/empathy-chat-text-view.h index 7ee7ba8a2..12edbcc64 100644 --- a/libempathy-gtk/empathy-chat-text-view.h +++ b/libempathy-gtk/empathy-chat-text-view.h @@ -70,7 +70,7 @@ struct _EmpathyChatTextViewClass { GType empathy_chat_text_view_get_type (void) G_GNUC_CONST; EmpathyContact * empathy_chat_text_view_get_last_contact (EmpathyChatTextView *view); -time_t empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view); +gint64 empathy_chat_text_view_get_last_timestamp (EmpathyChatTextView *view); void empathy_chat_text_view_set_only_if_date (EmpathyChatTextView *view, gboolean only_if_date); void empathy_chat_text_view_append_body (EmpathyChatTextView *view, diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 15b8ed39b..acf206ad3 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -877,13 +877,11 @@ contact_widget_location_update (EmpathyContactWidget *information) gchar *user_date; gchar *text; gint64 stamp; - time_t time_; gchar *tmp; stamp = g_value_get_int64 (value); - time_ = stamp; - user_date = empathy_time_to_string_relative (time_); + user_date = empathy_time_to_string_relative (stamp); tmp = g_strdup_printf ("<b>%s</b>", _("Location")); /* translators: format is "Location, $date" */ @@ -936,7 +934,7 @@ contact_widget_location_update (EmpathyContactWidget *information) } else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64) { - time_t time_; + gint64 time_; time_ = g_value_get_int64 (value); svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC")); diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c index ebad685be..dc45191a6 100644 --- a/libempathy-gtk/empathy-individual-widget.c +++ b/libempathy-gtk/empathy-individual-widget.c @@ -622,13 +622,11 @@ location_update (EmpathyIndividualWidget *self) gchar *user_date; gchar *text; gint64 stamp; - time_t time_; gchar *tmp; stamp = g_value_get_int64 (value); - time_ = stamp; - user_date = empathy_time_to_string_relative (time_); + user_date = empathy_time_to_string_relative (stamp); tmp = g_strdup_printf ("<b>%s</b>", _("Location")); /* translators: format is "Location, $date" */ @@ -678,7 +676,7 @@ location_update (EmpathyIndividualWidget *self) } else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64) { - time_t time_; + gint64 time_; time_ = g_value_get_int64 (value); svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC")); diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c index 1c09c358c..1925d4371 100644 --- a/libempathy-gtk/empathy-location-manager.c +++ b/libempathy-gtk/empathy-location-manager.c @@ -39,6 +39,7 @@ #include "libempathy/empathy-gsettings.h" #include "libempathy/empathy-location.h" #include "libempathy/empathy-utils.h" +#include "libempathy/empathy-time.h" #define DEBUG_FLAG EMPATHY_DEBUG_LOCATION #include "libempathy/empathy-debug.h" @@ -322,16 +323,12 @@ static void update_timestamp (EmpathyLocationManager *self) { EmpathyLocationManagerPriv *priv= GET_PRIV (self); - GValue *new_value; - gint64 stamp64; - time_t timestamp; - - timestamp = time (NULL); - stamp64 = (gint64) timestamp; - new_value = tp_g_value_slice_new_int64 (stamp64); - g_hash_table_insert (priv->location, g_strdup (EMPATHY_LOCATION_TIMESTAMP), - new_value); - DEBUG ("\t - Timestamp: %" G_GINT64_FORMAT, stamp64); + gint64 timestamp; + + timestamp = empathy_time_get_current (); + tp_asv_set_int64 (priv->location, EMPATHY_LOCATION_TIMESTAMP, timestamp); + + DEBUG ("\t - Timestamp: %" G_GINT64_FORMAT, timestamp); } static void diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index e7e4cbd37..659bbac87 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -56,7 +56,7 @@ typedef struct { EmpathyAdiumData *data; EmpathySmileyManager *smiley_manager; EmpathyContact *last_contact; - time_t last_timestamp; + gint64 last_timestamp; gboolean last_is_backlog; guint pages_loading; GList *message_queue; @@ -327,7 +327,7 @@ theme_adium_append_html (EmpathyThemeAdium *theme, const gchar *contact_id, const gchar *service_name, const gchar *message_classes, - time_t timestamp, + gint64 timestamp, gboolean is_backlog) { GString *string; @@ -445,7 +445,7 @@ theme_adium_append_message (EmpathyChatView *view, const gchar *contact_id; EmpathyAvatar *avatar; const gchar *avatar_filename = NULL; - time_t timestamp; + gint64 timestamp; gchar *html = NULL; gsize len = 0; const gchar *func; diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c index bf97f3f97..c0377b6ae 100644 --- a/libempathy-gtk/empathy-theme-boxes.c +++ b/libempathy-gtk/empathy-theme-boxes.c @@ -196,7 +196,7 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme, GtkTextChildAnchor *anchor; GtkWidget *box; gchar *str; - time_t time_; + gint64 time_; gchar *tmp; GtkTextIter start; gboolean color_set; |