Replace MMC hardcoded paths with the ones retrieving path from env
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 2 Dec 2008 14:18:37 +0000 (14:18 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 2 Dec 2008 14:18:37 +0000 (14:18 +0000)
pmo-trunk-r6485

src/modest-defs.h
src/modest-tny-account-store.c
src/modest-tny-account.c

index 4927cbb..602d351 100644 (file)
 
 #define MODEST_MMC_ACCOUNT_ID             "mcc"
 
 
 #define MODEST_MMC_ACCOUNT_ID             "mcc"
 
-/* FIXME: get these from the environment */
 /* Without the trailing / because gnome-vfs reports mounted 
  * volume URIs without the trailing, and we want to match them: */
 /* Without the trailing / because gnome-vfs reports mounted 
  * volume URIs without the trailing, and we want to match them: */
-#define MODEST_MCC1_VOLUMEPATH   "/media/mmc1" 
-#define MODEST_MCC1_VOLUMEPATH_URI "file://" MODEST_MCC1_VOLUMEPATH
+#define MODEST_MMC1_VOLUMEPATH_ENV       "MMC_MOUNTPOINT" 
+#define MODEST_MMC1_VOLUMEPATH_URI_PREFIX "file://"
 
 /* configuration key definitions for modest */
 #define MODEST_CONF_NAMESPACE          "/apps/modest"
 
 /* configuration key definitions for modest */
 #define MODEST_CONF_NAMESPACE          "/apps/modest"
index d674e75..e7c9886 100644 (file)
@@ -335,8 +335,8 @@ add_mmc_account(ModestTnyAccountStore *self, gboolean emit_insert_signal)
        g_return_if_fail (priv->session);
        
        TnyAccount *mmc_account = modest_tny_account_new_for_local_folders (priv->account_mgr, 
        g_return_if_fail (priv->session);
        
        TnyAccount *mmc_account = modest_tny_account_new_for_local_folders (priv->account_mgr, 
-                                                                       priv->session, 
-                                                                       MODEST_MCC1_VOLUMEPATH);
+                                                                           priv->session, 
+                                                                           g_getenv (MODEST_MMC1_VOLUMEPATH_ENV));
 
        /* Add to the list of store accounts */
        tny_list_append (priv->store_accounts, G_OBJECT (mmc_account));
 
        /* Add to the list of store accounts */
        tny_list_append (priv->store_accounts, G_OBJECT (mmc_account));
@@ -358,6 +358,7 @@ on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor,
 {
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
 {
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
+       gchar *volume_path_uri;
  
        gchar *uri = NULL;
 
  
        gchar *uri = NULL;
 
@@ -367,10 +368,14 @@ on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor,
        /* Check whether this was the external MMC1 card: */
        uri = gnome_vfs_volume_get_activation_uri (volume);
 
        /* Check whether this was the external MMC1 card: */
        uri = gnome_vfs_volume_get_activation_uri (volume);
 
-       if (uri && (!strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI))) {
+       volume_path_uri = g_strconcat (MODEST_MMC1_VOLUMEPATH_URI_PREFIX,
+                                      g_getenv (MODEST_MMC1_VOLUMEPATH_ENV),
+                                      NULL);
+       if (uri && (!strcmp (uri, volume_path_uri))) {
                add_mmc_account (self, TRUE /* emit the insert signal. */);
        }
                add_mmc_account (self, TRUE /* emit the insert signal. */);
        }
-       
+
+       g_free (volume_path_uri);       
        g_free (uri);
 }
 
        g_free (uri);
 }
 
@@ -382,13 +387,17 @@ on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor,
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
        gchar *uri = NULL;
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
        gchar *uri = NULL;
+       gchar *volume_path_uri;
 
        self = MODEST_TNY_ACCOUNT_STORE(user_data);
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
        
        /* Check whether this was the external MMC1 card: */
        uri = gnome_vfs_volume_get_activation_uri (volume);
 
        self = MODEST_TNY_ACCOUNT_STORE(user_data);
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
        
        /* Check whether this was the external MMC1 card: */
        uri = gnome_vfs_volume_get_activation_uri (volume);
-       if (uri && (strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI) == 0)) {
+       volume_path_uri = g_strconcat (MODEST_MMC1_VOLUMEPATH_URI_PREFIX,
+                                      g_getenv (MODEST_MMC1_VOLUMEPATH_ENV),
+                                      NULL);
+       if (uri && (strcmp (uri, volume_path_uri) == 0)) {
                TnyAccount *mmc_account = NULL;
                gboolean found = FALSE;
                TnyIterator *iter = NULL;
                TnyAccount *mmc_account = NULL;
                gboolean found = FALSE;
                TnyIterator *iter = NULL;
@@ -422,6 +431,7 @@ on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor,
                                   __FUNCTION__);
                }
        }
                                   __FUNCTION__);
                }
        }
+       g_free (volume_path_uri);
        g_free (uri);
 }
 
        g_free (uri);
 }
 
@@ -851,7 +861,7 @@ volume_path_is_mounted (const gchar* path)
         * GnomeVFSVolume even if the drive is not mounted: */
        /*
        GnomeVFSVolume *volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, 
         * GnomeVFSVolume even if the drive is not mounted: */
        /*
        GnomeVFSVolume *volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, 
-               MODEST_MCC1_VOLUMEPATH);
+                                g_getenv (MODEST_MMC1_VOLUMEPATH_ENV));
        if (volume) {
                gnome_vfs_volume_unref(volume);
        }
        if (volume) {
                gnome_vfs_volume_unref(volume);
        }
@@ -951,7 +961,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr,
                add_connection_specific_transport_accounts (MODEST_TNY_ACCOUNT_STORE(obj));
        
        /* This is a singleton, so it does not need to be unrefed. */
                add_connection_specific_transport_accounts (MODEST_TNY_ACCOUNT_STORE(obj));
        
        /* This is a singleton, so it does not need to be unrefed. */
-       if (volume_path_is_mounted (MODEST_MCC1_VOLUMEPATH)) {
+       if (volume_path_is_mounted (g_getenv (MODEST_MMC1_VOLUMEPATH_ENV))) {
                /* It is mounted: */
                add_mmc_account (MODEST_TNY_ACCOUNT_STORE (obj), FALSE /* don't emit the insert signal. */); 
        }
                /* It is mounted: */
                add_mmc_account (MODEST_TNY_ACCOUNT_STORE (obj), FALSE /* don't emit the insert signal. */); 
        }
index cfa79f4..57a58e7 100644 (file)
@@ -637,11 +637,13 @@ on_modest_file_system_info (HildonFileSystemInfoHandle *handle,
 void modest_tny_account_get_mmc_account_name (TnyStoreAccount* self, ModestTnyAccountGetMmcAccountNameCallback callback, gpointer user_data)
 {
 #ifndef MODEST_TOOLKIT_GTK
 void modest_tny_account_get_mmc_account_name (TnyStoreAccount* self, ModestTnyAccountGetMmcAccountNameCallback callback, gpointer user_data)
 {
 #ifndef MODEST_TOOLKIT_GTK
-       /* Just use the hard-coded path for the single memory card,
+       /* Just use the path for the single memory card,
         * rather than try to figure out the path to the specific card by 
         * looking at the maildir URI:
         */
         * rather than try to figure out the path to the specific card by 
         * looking at the maildir URI:
         */
-       const gchar *uri_real = MODEST_MCC1_VOLUMEPATH_URI;
+       gchar *uri_real = g_strconcat (MODEST_MMC1_VOLUMEPATH_URI_PREFIX,
+                                      g_getenv (MODEST_MMC1_VOLUMEPATH_ENV),
+                                      NULL);
 
        /*
        gchar* uri = tny_account_get_url_string (TNY_ACCOUNT (self));
 
        /*
        gchar* uri = tny_account_get_url_string (TNY_ACCOUNT (self));
@@ -671,7 +673,7 @@ void modest_tny_account_get_mmc_account_name (TnyStoreAccount* self, ModestTnyAc
                hildon_file_system_info_async_new(uri_real, 
                        on_modest_file_system_info, callback_data /* user_data */);
 
                hildon_file_system_info_async_new(uri_real, 
                        on_modest_file_system_info, callback_data /* user_data */);
 
-               /* g_free (uri_real); */
+               g_free (uri_real);
        }
 
        /* g_free (uri); */
        }
 
        /* g_free (uri); */
@@ -730,7 +732,7 @@ modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySess
         * via a derived TnyCamelStoreAccount ? */
        const gboolean is_mmc = 
                location_filepath && 
         * via a derived TnyCamelStoreAccount ? */
        const gboolean is_mmc = 
                location_filepath && 
-               (strcmp (location_filepath, MODEST_MCC1_VOLUMEPATH) == 0);
+               (strcmp (location_filepath, g_getenv (MODEST_MMC1_VOLUMEPATH_ENV)) == 0);
                
        /* The name of memory card locations will be updated asynchronously.
         * This is just a default: */
                
        /* The name of memory card locations will be updated asynchronously.
         * This is just a default: */