* don't accept certificate when user clicked cancel
[modest] / src / maemo / modest-platform.c
index f80687f..614aa13 100644 (file)
@@ -38,7 +38,6 @@
 #include <modest-hildon-includes.h>
 #include <modest-maemo-utils.h>
 #include <dbus_api/modest-dbus-callbacks.h>
 #include <modest-hildon-includes.h>
 #include <modest-maemo-utils.h>
 #include <dbus_api/modest-dbus-callbacks.h>
-#include <libosso-abook/osso-abook.h>
 #include <maemo/modest-osso-autosave-callbacks.h>
 #include <libosso.h>
 #include <alarmd/alarm_event.h> /* For alarm_event_add(), etc. */
 #include <maemo/modest-osso-autosave-callbacks.h>
 #include <libosso.h>
 #include <alarmd/alarm_event.h> /* For alarm_event_add(), etc. */
 #include <string.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 
 #include <string.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 
+#ifdef MODEST_HAVE_ABOOK
+#include <libosso-abook/osso-abook.h>
+#endif /*MODEST_HAVE_ABOOK*/
+
 
 #define HILDON_OSSO_URI_ACTION "uri-action"
 #define URI_ACTION_COPY "copy:"
 
 #define HILDON_OSSO_URI_ACTION "uri-action"
 #define URI_ACTION_COPY "copy:"
@@ -199,12 +202,16 @@ modest_platform_init (int argc, char *argv[])
                modest_account_mgr_free_account_names (acc_names);
        }
 
                modest_account_mgr_free_account_names (acc_names);
        }
 
+       
+#ifdef MODEST_HAVE_ABOOK
        /* initialize the addressbook */
        if (!osso_abook_init (&argc, &argv, osso_context)) {
                g_printerr ("modest: failed to initialized addressbook\n");
                return FALSE;
        }
        /* initialize the addressbook */
        if (!osso_abook_init (&argc, &argv, osso_context)) {
                g_printerr ("modest: failed to initialized addressbook\n");
                return FALSE;
        }
-               
+#endif /*MODEST_HAVE_ABOOK*/
+
+
        return TRUE;
 }
 
        return TRUE;
 }
 
@@ -607,7 +614,7 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
 
        sort_key = hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_priority"));
        sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
 
        sort_key = hildon_sort_dialog_add_sort_key (dialog, _("mcen_li_sort_priority"));
        sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
-       sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY;
+       sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY_MASK;
        priority_sort_id = sort_key;
 
        sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
        priority_sort_id = sort_key;
 
        sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
@@ -621,7 +628,7 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
                if (current_sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
                        gpointer flags_sort_type_pointer;
                        flags_sort_type_pointer = g_object_get_data (G_OBJECT (cols->data), MODEST_HEADER_VIEW_FLAG_SORT);
                if (current_sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
                        gpointer flags_sort_type_pointer;
                        flags_sort_type_pointer = g_object_get_data (G_OBJECT (cols->data), MODEST_HEADER_VIEW_FLAG_SORT);
-                       if (GPOINTER_TO_INT (flags_sort_type_pointer) == TNY_HEADER_FLAG_PRIORITY)
+                       if (GPOINTER_TO_INT (flags_sort_type_pointer) == TNY_HEADER_FLAG_PRIORITY_MASK)
                                hildon_sort_dialog_set_sort_key (dialog, priority_sort_id);
                        else
                                hildon_sort_dialog_set_sort_key (dialog, attachments_sort_id);
                                hildon_sort_dialog_set_sort_key (dialog, priority_sort_id);
                        else
                                hildon_sort_dialog_set_sort_key (dialog, attachments_sort_id);
@@ -929,28 +936,18 @@ modest_platform_run_information_dialog (GtkWindow *parent_window,
 
 
 
 
 
 
-typedef struct _UtilIdleData {
+typedef struct _ConnectAndWaitData {
        GMutex *mutex;
        GMainLoop *wait_loop;
        gboolean has_callback;
        gulong handler;
        GMutex *mutex;
        GMainLoop *wait_loop;
        gboolean has_callback;
        gulong handler;
-} UtilIdleData;
+} ConnectAndWaitData;
 
 
 static void
 
 
 static void
-check_connection_status_and_quit (TnyAccount *account,
-                                 UtilIdleData *data) 
+quit_wait_loop (TnyAccount *account,
+               ConnectAndWaitData *data) 
 {
 {
-       TnyConnectionStatus conn_status;
-                       
-       conn_status = tny_account_get_connection_status (account);
-       if (conn_status == TNY_CONNECTION_STATUS_RECONNECTING ||
-           conn_status == TNY_CONNECTION_STATUS_DISCONNECTED)
-               return;
-
-       /* Remove the handler */
-       g_signal_handler_disconnect (account, data->handler);
-
        /* Set the has_callback to TRUE (means that the callback was
           executed and wake up every code waiting for cond to be
           TRUE */
        /* Set the has_callback to TRUE (means that the callback was
           executed and wake up every code waiting for cond to be
           TRUE */
@@ -966,8 +963,21 @@ on_connection_status_changed (TnyAccount *account,
                              TnyConnectionStatus status,
                              gpointer user_data)
 {
                              TnyConnectionStatus status,
                              gpointer user_data)
 {
-       check_connection_status_and_quit (account, 
-                                         (UtilIdleData *) user_data);
+       TnyConnectionStatus conn_status;
+       ConnectAndWaitData *data;
+                       
+       /* Ignore if reconnecting or disconnected */
+       conn_status = tny_account_get_connection_status (account);
+       if (conn_status == TNY_CONNECTION_STATUS_RECONNECTING ||
+           conn_status == TNY_CONNECTION_STATUS_DISCONNECTED)
+               return;
+
+       /* Remove the handler */
+       data = (ConnectAndWaitData *) user_data;
+       g_signal_handler_disconnect (account, data->handler);
+
+       /* Quit from wait loop */
+       quit_wait_loop (account, (ConnectAndWaitData *) user_data);
 }
 
 static void
 }
 
 static void
@@ -976,15 +986,15 @@ on_tny_camel_account_set_online_cb (TnyCamelAccount *account,
                                    GError *err, 
                                    gpointer user_data)
 {
                                    GError *err, 
                                    gpointer user_data)
 {
-       check_connection_status_and_quit (TNY_ACCOUNT (account), 
-                                         (UtilIdleData *) user_data);
+       /* Quit from wait loop */
+       quit_wait_loop (TNY_ACCOUNT (account), (ConnectAndWaitData *) user_data);
 }
 
 gboolean 
 modest_platform_connect_and_wait (GtkWindow *parent_window, 
                                  TnyAccount *account)
 {
 }
 
 gboolean 
 modest_platform_connect_and_wait (GtkWindow *parent_window, 
                                  TnyAccount *account)
 {
-       UtilIdleData *data = NULL;
+       ConnectAndWaitData *data = NULL;
        gboolean device_online;
        TnyDevice *device;
        TnyConnectionStatus conn_status;
        gboolean device_online;
        TnyDevice *device;
        TnyConnectionStatus conn_status;
@@ -1006,7 +1016,7 @@ modest_platform_connect_and_wait (GtkWindow *parent_window,
                return TRUE;
 
        /* Create the helper */
                return TRUE;
 
        /* Create the helper */
-       data = g_slice_new0 (UtilIdleData);
+       data = g_slice_new0 (ConnectAndWaitData);
        data->mutex = g_mutex_new ();
        data->has_callback = FALSE;
 
        data->mutex = g_mutex_new ();
        data->has_callback = FALSE;
 
@@ -1046,7 +1056,7 @@ modest_platform_connect_and_wait (GtkWindow *parent_window,
                        g_signal_handler_disconnect (account, data->handler);
                g_mutex_free (data->mutex);
                g_main_loop_unref (data->wait_loop);
                        g_signal_handler_disconnect (account, data->handler);
                g_mutex_free (data->mutex);
                g_main_loop_unref (data->wait_loop);
-               g_slice_free (UtilIdleData, data);
+               g_slice_free (ConnectAndWaitData, data);
        }
 
        conn_status = tny_account_get_connection_status (account);
        }
 
        conn_status = tny_account_get_connection_status (account);
@@ -1622,7 +1632,7 @@ on_cert_dialog_response (GtkDialog *dialog, gint response_id,  const gchar* cert
 
 
 gboolean
 
 
 gboolean
-modest_platform_run_certificate_conformation_dialog (const gchar* server_name,
+modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
                                                     const gchar *certificate)
 {
        GtkWidget *note;
                                                     const gchar *certificate)
 {
        GtkWidget *note;
@@ -1652,7 +1662,7 @@ modest_platform_run_certificate_conformation_dialog (const gchar* server_name,
        on_destroy_dialog (GTK_DIALOG(note));
        g_free (question);
        
        on_destroy_dialog (GTK_DIALOG(note));
        g_free (question);
        
-       return response;
+       return response == GTK_RESPONSE_OK;
 }
        
 
 }