* src/modest-tny-account-store.c
[modest] / src / modest-tny-account-store.c
index 4ec859e..e46ca55 100644 (file)
@@ -850,6 +850,58 @@ modest_tny_account_store_finalize (GObject *obj)
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
+gboolean volume_path_is_mounted (const gchar* path)
+{
+       g_return_val_if_fail (path, FALSE);
+
+       gboolean result = FALSE;
+       gchar * path_as_uri = g_filename_to_uri (path, NULL, NULL);
+       g_return_val_if_fail (path_as_uri, FALSE);
+
+       /* Get the monitor singleton: */
+       GnomeVFSVolumeMonitor *monitor = gnome_vfs_get_volume_monitor();
+
+       /* This seems like a simpler way to do this, but it returns a   
+        * GnomeVFSVolume even if the drive is not mounted: */
+       /*
+       GnomeVFSVolume *volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, 
+               MODEST_MCC1_VOLUMEPATH);
+       if (volume) {
+               gnome_vfs_volume_unref(volume);
+       }
+       */
+
+       /* Get the mounted volumes from the monitor: */
+       GList *list = gnome_vfs_volume_monitor_get_mounted_volumes (monitor);
+       GList *iter = list;
+       for (iter = list; iter; iter = g_list_next (iter)) {
+               GnomeVFSVolume *volume = (GnomeVFSVolume*)iter->data;
+               if (volume) {
+                       /*
+                       char *display_name = 
+                               gnome_vfs_volume_get_display_name (volume);
+                       printf ("volume display name=%s\n", display_name);
+                       g_free (display_name);
+                       */
+                       
+                       char *uri = 
+                               gnome_vfs_volume_get_activation_uri (volume);
+                       /* printf ("  uri=%s\n", uri); */
+                       if (uri && (strcmp (uri, path_as_uri) == 0))
+                               result = TRUE;
+
+                       g_free (uri);
+
+                       gnome_vfs_volume_unref (volume);
+               }
+       }
+
+       g_list_free (list);
+
+       g_free (path_as_uri);
+
+       return result;
+}
 
 ModestTnyAccountStore*
 modest_tny_account_store_new (ModestAccountMgr *account_mgr, 
@@ -905,17 +957,9 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr,
        /* Create the memory card account if the card is mounted: */
        
        /* This is a singleton, so it does not need to be unrefed. */
-       GnomeVFSVolumeMonitor* monitor = gnome_vfs_get_volume_monitor();
-       GnomeVFSVolume *volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, 
-               MODEST_MCC1_VOLUMEPATH);
-       if (volume) {
+       if (volume_path_is_mounted (MODEST_MCC1_VOLUMEPATH)) {
                /* It is mounted: */
-               
-               /* TODO: Reneable this. Apaprently it causes a hang: */
-               #if 0
                add_mmc_account (MODEST_TNY_ACCOUNT_STORE (obj), FALSE /* don't emit the insert signal. */); 
-               #endif
-               gnome_vfs_volume_unref(volume);
        }
        
        return MODEST_TNY_ACCOUNT_STORE(obj);
@@ -1369,6 +1413,12 @@ get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *
        
        /*  Get the connection-specific transport acccount, if any: */
        ModestAccountMgr *account_manager = modest_runtime_get_account_mgr ();
+
+        /* Check if this account has connection-specific SMTP enabled */
+        if (!modest_account_mgr_get_use_connection_specific_smtp (account_manager, account_name)) {
+                return NULL;
+        }
+
        gchar* server_account_name = modest_account_mgr_get_connection_specific_smtp (account_manager, 
                account_name, connection_name);