Fixes NB#96049, replaced a logical string
[modest] / src / hildon2 / modest-platform.c
index 5e1e11a..d1c1b8f 100644 (file)
@@ -33,7 +33,7 @@
 #include <modest-runtime.h>
 #include <modest-main-window.h>
 #include <modest-header-view.h>
-#include "modest-maemo-global-settings-dialog.h"
+#include "modest-hildon2-global-settings-dialog.h"
 #include "modest-widget-memory.h"
 #include <modest-hildon-includes.h>
 #include <modest-maemo-utils.h>
@@ -43,8 +43,6 @@
 #include <tny-maemo-conic-device.h>
 #include <tny-simple-list.h>
 #include <tny-folder.h>
-#include <tny-camel-imap-store-account.h>
-#include <tny-camel-pop-store-account.h>
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkmenuitem.h>
 #include <gtk/gtkmain.h>
@@ -59,6 +57,7 @@
 #include <hildon/hildon-sound.h>
 #include <osso-mem.h>
 #include "hildon2/modest-hildon2-details-dialog.h"
+#include <modest-datetime-formatter.h>
 
 #ifdef MODEST_HAVE_MCE
 #include <mce/dbus-names.h>
@@ -520,7 +519,7 @@ modest_platform_get_app_name (void)
        return _("mcen_ap_name");
 }
 
-static void 
+static void
 entry_insert_text (GtkEditable *editable,
                   const gchar *text,
                   gint         length,
@@ -542,15 +541,15 @@ entry_insert_text (GtkEditable *editable,
                if (modest_text_utils_is_forbidden_char (*text, FOLDER_NAME_FORBIDDEN_CHARS)) {
                        /* Show an error */
                        gchar *tmp, *msg;
-                       
-                       tmp = g_strndup (folder_name_forbidden_chars, 
+
+                       tmp = g_strndup (folder_name_forbidden_chars,
                                         FOLDER_NAME_FORBIDDEN_CHARS_LENGTH);
                        msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
-                       hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (data)), 
+                       hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (data)),
                                                         NULL, msg);
                        g_free (msg);
                        g_free (tmp);
-               } else {        
+               } else {
                        /* Write the text in the entry if it's valid */
                        g_signal_handlers_block_by_func (editable,
                                                         (gpointer) entry_insert_text, data);
@@ -573,17 +572,17 @@ entry_changed (GtkEditable *editable,
 
        buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (user_data)->action_area));
        ok_button = GTK_WIDGET (buttons->data);
-       
+
        chars = gtk_editable_get_chars (editable, 0, -1);
        g_return_if_fail (chars != NULL);
 
-       
+
        if (g_utf8_strlen (chars,-1) >= 20)
                hildon_banner_show_information  (gtk_widget_get_parent (GTK_WIDGET (user_data)), NULL,
                                                 _CS("ckdg_ib_maximum_characters_reached"));
        else
                gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars));
-               
+
        /* Free */
        g_list_free (buttons);
        g_free (chars);
@@ -982,7 +981,7 @@ modest_platform_connect_and_wait (GtkWindow *parent_window,
        /* Connect the device */
        if (!device_online) {
                /* Track account connection status changes */
-               data->handler = g_signal_connect (account, "connection-status-changed",                                     
+               data->handler = g_signal_connect (account, "connection-status-changed",
                                                  G_CALLBACK (on_connection_status_changed),
                                                  data);
                /* Try to connect the device */
@@ -1027,8 +1026,7 @@ gboolean
 modest_platform_connect_and_wait_if_network_account (GtkWindow *parent_window, TnyAccount *account)
 {
        if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
-               if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
-                   !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
+               if (!modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account))) {
                        /* This must be a maildir account, which does not require a connection: */
                        return TRUE;
                }
@@ -1066,10 +1064,6 @@ modest_platform_create_sort_dialog       (GtkWindow *parent_window)
 
        dialog = modest_hildon2_sort_dialog_new (parent_window);
 
-       hildon_help_dialog_help_enable (GTK_DIALOG(dialog),
-                                       "applications_email_sort",
-                                       modest_maemo_utils_get_osso_context());
-
        return dialog;
 }
 
@@ -1233,9 +1227,13 @@ modest_platform_on_new_headers_received (TnyList *header_list,
                gboolean first_notification = TRUE;
                gint notif_id;
                gchar *str;
+               ModestDatetimeFormatter *datetime_formatter;
 
                /* constant string, don't free */
-               display_date = modest_text_utils_get_display_date (tny_header_get_date_received (header));
+               datetime_formatter = modest_datetime_formatter_new ();
+               display_date = modest_datetime_formatter_display_datetime (datetime_formatter,
+                                                                          tny_header_get_date_received (header));
+               g_object_unref (datetime_formatter);
 
                display_address = tny_header_dup_from (header);
                modest_text_utils_get_display_address (display_address); /* string is changed in-place */
@@ -1369,27 +1367,14 @@ modest_platform_remove_new_mail_notifications (gboolean only_visuals)
 GtkWidget * 
 modest_platform_get_global_settings_dialog ()
 {
-       return modest_maemo_global_settings_dialog_new ();
+       return modest_hildon2_global_settings_dialog_new ();
 }
 
 void
 modest_platform_show_help (GtkWindow *parent_window, 
                           const gchar *help_id)
 {
-       osso_return_t result;
-       g_return_if_fail (help_id);
-
-       result = hildon_help_show (modest_maemo_utils_get_osso_context(),
-                                  help_id, HILDON_HELP_SHOW_DIALOG);
-       
-       if (result != OSSO_OK) {
-               gchar *error_msg;
-               error_msg = g_strdup_printf ("FIXME The help topic %s could not be found", help_id); 
-               hildon_banner_show_information (GTK_WIDGET (parent_window),
-                                               NULL,
-                                               error_msg);
-               g_free (error_msg);
-       }
+       return;
 }
 
 void 
@@ -1583,24 +1568,17 @@ modest_platform_check_and_wait_for_account_is_online(TnyAccount *account)
        gboolean is_online;
 
        g_return_val_if_fail (account, FALSE);
-       
-       printf ("DEBUG: %s: account id=%s\n", __FUNCTION__, tny_account_get_id (account));
-       
+
        if (!tny_device_is_online (modest_runtime_get_device())) {
                printf ("DEBUG: %s: device is offline.\n", __FUNCTION__);
                return FALSE;
        }
-       
+
        /* The local_folders account never seems to leave TNY_CONNECTION_STATUS_INIT,
         * so we avoid wait unnecessarily: */
-       if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) && 
-               !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account) ) {
-               return TRUE;            
-       }
-               
-       printf ("DEBUG: %s: tny_account_get_connection_status()==%d\n",
-               __FUNCTION__, tny_account_get_connection_status (account));
-       
+       if (!modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)))
+               return TRUE;
+
        /* The POP & IMAP store accounts seem to be TNY_CONNECTION_STATUS_DISCONNECTED, 
         * and that seems to be an OK time to use them. Maybe it's just TNY_CONNECTION_STATUS_INIT that 
         * we want to avoid. */
@@ -1964,11 +1942,8 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
                if (callback) {
                        callback (FALSE, NULL, parent_window, NULL, user_data);
                }
-               return; 
-               
-               /* Original comment: Maybe it is something local. */
-               /* PVH's comment: maybe we should KNOW this in stead of assuming? */
-               
+               return;
+
        } else if (TNY_IS_FOLDER (folder_store)) {
                /* Get the folder's parent account: */
                account = tny_folder_get_account (TNY_FOLDER (folder_store));
@@ -1976,11 +1951,9 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
                /* Use the folder store as an account: */
                account = TNY_ACCOUNT (g_object_ref (folder_store));
        }
+
        if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
-               if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
-                   !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
+               if (!modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account))) {
                        /* No need to connect a local account */
                        if (callback)
                                callback (FALSE, NULL, parent_window, account, user_data);
@@ -1989,17 +1962,17 @@ modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
                }
        }
        modest_platform_connect_and_perform (parent_window, force, account, callback, user_data);
+
  clean:
        if (account)
                g_object_unref (account);
 }
 
 static void
-src_account_connect_performer (gboolean canceled, 
+src_account_connect_performer (gboolean canceled,
                               GError *err,
-                              GtkWindow *parent_window, 
-                              TnyAccount *src_account, 
+                              GtkWindow *parent_window,
+                              TnyAccount *src_account,
                               gpointer user_data)
 {
        DoubleConnectionInfo *info = (DoubleConnectionInfo *) user_data;