Changes to fix NB#110512
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 13 Apr 2009 17:10:39 +0000 (17:10 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 13 Apr 2009 17:10:39 +0000 (17:10 +0000)
* 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
debian/control.maemo-fremantle
src/Makefile.am
src/maemo/modest-main-window.c
src/modest-datetime-formatter.c
src/modest-mail-operation.c
src/widgets/modest-account-view.c

index bd6f20b..0b4cb9e 100644 (file)
@@ -507,6 +507,15 @@ if test "x$with_platform" == "xmaemo"; then
    fi
 fi
 
    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
 
 #
 # 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
 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"
 
 echo "CFLAGS           : $CFLAGS"
 echo "Debug version    : $with_debug"
index 43e54dc..2023177 100644 (file)
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
 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,
 Maintainer: Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
 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
  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
index db86a97..cd710fd 100644 (file)
@@ -175,6 +175,7 @@ libmodest_la_LIBADD =                                               \
        $(MODEST_HILDON_HELP_LIBS)                      \
        $(MODEST_HILDON_NOTIFY_LIBS)                    \
        $(MODEST_OGS_LIBS)                              \
        $(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
        ${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_HILDON_HELP_LIBS)                      \
        $(MODEST_HILDON_NOTIFY_LIBS)                    \
        $(MODEST_OGS_LIBS)                              \
+       $(MODEST_LIBTIME_LIBS)                          \
        ${easysetupmaybe}                               \
        libmodest.la)
 
        ${easysetupmaybe}                               \
        libmodest.la)
 
index 25f744e..ce89897 100644 (file)
@@ -64,6 +64,9 @@
 #include "maemo/modest-osso-state-saving.h"
 #include "modest-text-utils.h"
 #include "modest-signal-mgr.h"
 #include "maemo/modest-osso-state-saving.h"
 #include "modest-text-utils.h"
 #include "modest-signal-mgr.h"
+#ifdef MODEST_USE_LIBTIME
+#include <clockd/libtime.h>
+#endif
 
 #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions"
 
 
 #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));
 
                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
                if (last_updated > 0) 
                        last_updated_string = modest_text_utils_get_display_date(last_updated);
                else
index 7aa9b24..630022b 100644 (file)
@@ -256,11 +256,14 @@ modest_datetime_formatter_format_time (ModestDatetimeFormatter *self,
        ModestDatetimeFormatterPrivate *priv;
        const gchar *format_string = NULL;
        gboolean is_pm;
        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);
 
        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:
 
        switch (priv->current_format) {
        case DATETIME_FORMAT_12H:
index 05c5c48..c9986db 100644 (file)
@@ -63,6 +63,9 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include "modest-utils.h"
 #include "modest-debug.h"
 #include <libgnomevfs/gnome-vfs.h>
 #include "modest-utils.h"
 #include "modest-debug.h"
+#ifdef MODEST_USE_LIBTIME
+#include <clockd/libtime.h>
+#endif
 
 #define KB 1024
 
 
 #define KB 1024
 
@@ -1570,6 +1573,7 @@ inbox_refreshed_cb (TnyFolder *inbox,
        ModestAccountRetrieveType retrieve_type;
        TnyList *new_headers = NULL;
        gboolean headers_only, ignore_limit;
        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);
 
        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 */
        }
 
        /* 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 (),
 
        /* Get the message max size */
        max_size  = modest_conf_get_int (modest_runtime_get_conf (),
index a990788..88e5739 100644 (file)
@@ -47,6 +47,9 @@
 #ifdef MODEST_TOOLKIT_HILDON2
 #include <hildon/hildon-defines.h>
 #endif
 #ifdef MODEST_TOOLKIT_HILDON2
 #include <hildon/hildon-defines.h>
 #endif
+#ifdef MODEST_USE_LIBTIME
+#include <clockd/libtime.h>
+#endif
 
 /* 'private'/'protected' functions */
 static void modest_account_view_class_init    (ModestAccountViewClass *klass);
 
 /* '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);
        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)) {
        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)) {