From 46283d0da3ca90d9516fb33c7299dd12ee86cacb Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Mon, 13 Apr 2009 17:10:39 +0000 Subject: [PATCH] Changes to fix NB#110512 * Add detection and dependency on libtime * Store last updated in utc, and properly adapt it for display * Fix am/pm calculation pmo-trunk-r8750 --- configure.ac | 10 ++++++++++ debian/control.maemo-fremantle | 2 +- src/Makefile.am | 2 ++ src/maemo/modest-main-window.c | 13 +++++++++++++ src/modest-datetime-formatter.c | 7 +++++-- src/modest-mail-operation.c | 13 ++++++++++++- src/widgets/modest-account-view.c | 13 +++++++++++++ 7 files changed, 56 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index bd6f20b..0b4cb9e 100644 --- a/configure.ac +++ b/configure.ac @@ -507,6 +507,15 @@ if test "x$with_platform" == "xmaemo"; then fi fi +AC_CHECK_HEADERS([clockd/libtime.h], have_libtime=true, have_libtime=false) + +if test "x$have_libtime" == "xtrue"; then + AC_DEFINE_UNQUOTED(MODEST_USE_LIBTIME, 1, ["use libtime API"]) + MODEST_LIBTIME_LIBS=-ltime +else + MODEST_LIBTIME_LIBS= +fi +AC_SUBST(MODEST_LIBTIME_LIBS) # # if we don't have an addressbook, use the dummy one @@ -655,6 +664,7 @@ echo "MozEmbed support : $use_mozembed" if [ $gtk_html_found = "true" ]; then echo "GtkHTML version : $gtk_html_version" fi +echo "Libtime : $have_libtime" echo "CFLAGS : $CFLAGS" echo "Debug version : $with_debug" diff --git a/debian/control.maemo-fremantle b/debian/control.maemo-fremantle index 43e54dc..2023177 100644 --- a/debian/control.maemo-fremantle +++ b/debian/control.maemo-fremantle @@ -4,7 +4,7 @@ Priority: optional Maintainer: Dirk-Jan C. Binnema Build-Depends: debhelper (>= 4.0.0), cdbs, gnome-common, gtkhtml3.14-dev, libconic0-dev, libhildon1-dev, libdbus-1-dev, libdbus-glib-1-dev, libebook-dev, osso-af-settings, libedataserver-dev, libhildonnotify-dev, libgconf2-dev, - libglib2.0-dev, libosso-abook-dev, libosso-gnomevfs2-dev, libhildonmime-dev, libprofile-dev, libtinymail-1.0-0-dev, libtinymail-camel-1.0-0-dev, + libglib2.0-dev, libosso-abook-dev, libosso-gnomevfs2-dev, libhildonmime-dev, libprofile-dev, libtime-dev, libtinymail-1.0-0-dev, libtinymail-camel-1.0-0-dev, libtinymail-maemo-1.0-0-dev, libtinymailui-1.0-0-dev, libtinymail-gnomevfs-1.0-0-dev, libtinymailui-gtk-1.0-0-dev, wpeditor0, wpeditor-dev, modest-providers-data, libalarm-dev, gtk-doc-tools, libhildonnotify-dev, libnotify-dev, microb-engine-dev, mce-dev, maemo-launcher-dev, profile-data-dev diff --git a/src/Makefile.am b/src/Makefile.am index db86a97..cd710fd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -175,6 +175,7 @@ libmodest_la_LIBADD = \ $(MODEST_HILDON_HELP_LIBS) \ $(MODEST_HILDON_NOTIFY_LIBS) \ $(MODEST_OGS_LIBS) \ + $(MODEST_LIBTIME_LIBS) \ ${easysetupmaybe} \ widgets/libmodest-widgets.la \ $(MODEST_TOOLKIT_DIR)/libmodest-ui.la @@ -205,6 +206,7 @@ modest_LDADD = \ $(MODEST_HILDON_HELP_LIBS) \ $(MODEST_HILDON_NOTIFY_LIBS) \ $(MODEST_OGS_LIBS) \ + $(MODEST_LIBTIME_LIBS) \ ${easysetupmaybe} \ libmodest.la) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 25f744e..ce89897 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -64,6 +64,9 @@ #include "maemo/modest-osso-state-saving.h" #include "modest-text-utils.h" #include "modest-signal-mgr.h" +#ifdef MODEST_USE_LIBTIME +#include +#endif #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions" @@ -2028,6 +2031,16 @@ create_details_widget (GtkWidget *styled_widget, TnyAccount *account) last_updated = modest_account_mgr_get_last_updated (modest_runtime_get_account_mgr (), tny_account_get_id (account)); +#ifdef MODEST_USE_LIBTIME + /* If we use libtime, we are storing the time in UTC so we have to convert to currently + * selected time */ + time_t now; + struct tm *localtime_tm; + time (&now); + localtime_tm = localtime (&now); + last_updated -= time_get_utc_offset (localtime_tm->tm_zone); +#endif + if (last_updated > 0) last_updated_string = modest_text_utils_get_display_date(last_updated); else diff --git a/src/modest-datetime-formatter.c b/src/modest-datetime-formatter.c index 7aa9b24..630022b 100644 --- a/src/modest-datetime-formatter.c +++ b/src/modest-datetime-formatter.c @@ -256,11 +256,14 @@ modest_datetime_formatter_format_time (ModestDatetimeFormatter *self, ModestDatetimeFormatterPrivate *priv; const gchar *format_string = NULL; gboolean is_pm; + struct tm localtime_tm = {0, }; + time_t date_copy; g_return_val_if_fail (MODEST_IS_DATETIME_FORMATTER (self), NULL); priv = MODEST_DATETIME_FORMATTER_GET_PRIVATE (self); - - is_pm = (date / (60 * 60 * 12)) % 2; + date_copy = date; + localtime_r (&date_copy, &localtime_tm); + is_pm = (localtime_tm.tm_hour/12) % 2; switch (priv->current_format) { case DATETIME_FORMAT_12H: diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 05c5c48..c9986db 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -63,6 +63,9 @@ #include #include "modest-utils.h" #include "modest-debug.h" +#ifdef MODEST_USE_LIBTIME +#include +#endif #define KB 1024 @@ -1570,6 +1573,7 @@ inbox_refreshed_cb (TnyFolder *inbox, ModestAccountRetrieveType retrieve_type; TnyList *new_headers = NULL; gboolean headers_only, ignore_limit; + time_t time_to_store; info = (UpdateAccountInfo *) user_data; priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op); @@ -1600,7 +1604,14 @@ inbox_refreshed_cb (TnyFolder *inbox, } /* Set the last updated as the current time */ - modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL)); +#ifdef MODEST_USE_LIBTIME + struct tm utc_tm; + time_get_utc (&utc_tm); + time_to_store = time_mktime (&utc_tm, "GMT"); +#else + time_to_store = time (NULL); +#endif + modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time_to_store); /* Get the message max size */ max_size = modest_conf_get_int (modest_runtime_get_conf (), diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index a990788..88e5739 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -47,6 +47,9 @@ #ifdef MODEST_TOOLKIT_HILDON2 #include #endif +#ifdef MODEST_USE_LIBTIME +#include +#endif /* 'private'/'protected' functions */ static void modest_account_view_class_init (ModestAccountViewClass *klass); @@ -208,6 +211,16 @@ get_last_updated_string(ModestAccountView *self, ModestAccountMgr* account_mgr, server_settings = modest_account_settings_get_store_settings (settings); store_account_name = modest_server_account_settings_get_account_name (server_settings); last_updated = modest_account_mgr_get_last_updated (account_mgr, store_account_name); + +#ifdef MODEST_USE_LIBTIME + /* If we use libtime, we are storing the time in UTC so we have to convert to currently + * selected time */ + time_t now; + struct tm *localtime_tm; + time (&now); + localtime_tm = localtime (&now); + last_updated -= time_get_utc_offset (localtime_tm->tm_zone); +#endif g_object_unref (server_settings); account_name = modest_account_settings_get_account_name (settings); if (!modest_account_mgr_account_is_busy(account_mgr, account_name)) { -- 1.7.9.5