* unbreak dape's gnome-desktop port
[modest] / src / gnome / modest-platform.c
index 03baeba..24aed2e 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
@@ -203,6 +206,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. */