* Fixes NB#78357, new mail sound is played now with IMAP IDLE events
[modest] / src / gnome / modest-platform.c
index 03baeba..dc4c4c8 100644 (file)
 #include <libgnomevfs/gnome-vfs-mime.h>
 #include <libgnomeui/gnome-icon-lookup.h>
 #include <tny-gnome-device.h>
+#include <tny-camel-imap-store-account.h>
+#include <tny-camel-pop-store-account.h>
 
 #include "modest-platform.h"
 #include "modest-mail-operation-queue.h"
 #include "modest-runtime.h"
+
 #include "gnome/modest-gnome-global-settings-dialog.h"
 
 gboolean
@@ -110,7 +113,7 @@ modest_platform_show_uri_popup (const gchar *uri)
 }
 
 GdkPixbuf*
-modest_platform_get_icon (const gchar *name)
+modest_platform_get_icon (const gchar *name, guint icon_size)
 {
        GError *err = NULL;
        GdkPixbuf* pixbuf;
@@ -178,15 +181,60 @@ gint
 modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
                                         const gchar *msg)
 {
-       /* TODO implement confirmation dialog */
-       return GTK_RESPONSE_CANCEL;
+       gint response;
+       GtkWidget *dialog;
+
+       dialog = gtk_message_dialog_new (parent_window,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_MESSAGE_QUESTION,
+                                        GTK_BUTTONS_OK_CANCEL,
+                                        msg);
+
+       response = gtk_dialog_run (GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+       
+       return response;
+}
+
+gint
+modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window,
+                                                     const gchar *message,
+                                                     const gchar *button_accept,
+                                                     const gchar *button_cancel)
+{
+       gint response;
+       GtkWidget *dialog;
+
+       dialog = gtk_dialog_new_with_buttons (message,
+                                             parent_window,
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             button_accept,
+                                             GTK_RESPONSE_ACCEPT,
+                                             button_cancel,
+                                             GTK_RESPONSE_CANCEL,
+                                             NULL);
+
+       response = gtk_dialog_run (GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+       
+       return response;
 }
 
 void
 modest_platform_run_information_dialog (GtkWindow *parent_window,
                                        const gchar *message)
 {
-       /* TODO: implement a information dialog */
+       GtkWidget *dialog;
+
+       dialog = gtk_message_dialog_new (parent_window,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_MESSAGE_INFO,
+                                        GTK_BUTTONS_OK,
+                                        message);
+
+       gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (dialog);
+       
 }
 
 gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account)
@@ -203,6 +251,56 @@ gboolean modest_platform_connect_and_wait_if_network_account (GtkWindow *parent_
        return TRUE;
 }
 
+
+void
+modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, 
+                                              TnyFolderStore *folder_store, 
+                                              ModestConnectedPerformer callback, 
+                                              gpointer user_data)
+{
+       TnyAccount *account = NULL;
+       
+       if (!folder_store) {
+               /* We promise to instantly perform the callback, so ... */
+               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? */
+               
+       } else if (TNY_IS_FOLDER (folder_store)) {
+               /* Get the folder's parent account: */
+               account = tny_folder_get_account(TNY_FOLDER (folder_store));
+       } else if (TNY_IS_ACCOUNT (folder_store)) {
+               /* Use the folder store as an account: */
+               account = TNY_ACCOUNT (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)) {
+                       
+                       /* This IS a local account like a maildir account, which does not require 
+                        * a connection. (original comment had a vague assumption in its language
+                        * usage. There's no assuming needed, this IS what it IS: a local account), */
+                       /* We promise to instantly perform the callback, so ... */
+                       if (callback) {
+                               callback (FALSE, NULL, parent_window, account, user_data);
+                       }
+                       
+                       return;
+               }
+       }
+       modest_platform_connect_and_perform (parent_window, account, callback, user_data);
+       return;
+}
+
+
 gboolean modest_platform_set_update_interval (guint minutes)
 {
        /* TODO. */
@@ -224,7 +322,8 @@ modest_platform_get_global_settings_dialog ()
 
 
 void 
-modest_platform_on_new_headers_received (TnyList *header_list)
+modest_platform_on_new_headers_received (TnyList *header_list,
+                                        gboolean show_visual)
 {
        /* TODO: implement this */
        g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n");
@@ -246,6 +345,15 @@ modest_platform_information_banner (GtkWidget *widget,
        g_message ("NOT IMPLEMENTED");;
 }
 
+void
+modest_platform_information_banner_with_timeout (GtkWidget *widget,
+                                                const gchar *icon_name,
+                                                const gchar *text,
+                                                gint timeout)
+{
+       g_message ("NOT IMPLEMENTED");;
+}
+
 GtkWidget *
 modest_platform_animation_banner (GtkWidget *widget,
                                  const gchar *icon_name,
@@ -314,7 +422,7 @@ modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_wi
 
 
 void 
-modest_platform_remove_new_mail_notifications (void)
+modest_platform_remove_new_mail_notifications (gboolean only_visuals)
 {
        g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
 }
@@ -350,3 +458,20 @@ modest_platform_show_addressbook (GtkWindow *parent_window)
        g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
 }
 
+GtkWidget *
+modest_platform_get_account_settings_dialog (ModestAccountSettings *settings)
+{
+       GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                                   GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+                                                   "NOT IMPLEMENTED");
+       return dialog;
+}
+
+GtkWidget *
+modest_platform_get_account_settings_wizard ()
+{
+       GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                                   GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+                                                   "NOT IMPLEMENTED");
+       return dialog;
+}