From acaa1ca87c20110b228946d5678643aa6f3a9862 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 14 Aug 2007 09:53:22 +0000 Subject: [PATCH] 2007-08-14 Murray Cumming * src/modest-tny-account-store.c: Added the add_mmc_account() function to save some copy/pasting. (modest_tny_account_store_new): If the memory card is mounted, create an account for it at the start, instead of waiting for the user to unmount it and mount it. pmo-trunk-r2979 --- ChangeLog2 | 8 +++ .../modest-easysetup-provider-combo-box.c | 2 +- src/modest-tny-account-store.c | 60 ++++++++++++++------ 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index e95165b..980cbc9 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,11 @@ +2007-08-14 Murray Cumming + + * src/modest-tny-account-store.c: Added the add_mmc_account() + function to save some copy/pasting. + (modest_tny_account_store_new): If the memory card is mounted, + create an account for it at the start, instead of waiting for the + user to unmount it and mount it. + 2007-08-13 Murray Cumming * src/widgets/modest-account-view.c: (on_account_changed): diff --git a/src/maemo/easysetup/modest-easysetup-provider-combo-box.c b/src/maemo/easysetup/modest-easysetup-provider-combo-box.c index a7871ca..d4fcdca 100644 --- a/src/maemo/easysetup/modest-easysetup-provider-combo-box.c +++ b/src/maemo/easysetup/modest-easysetup-provider-combo-box.c @@ -144,7 +144,7 @@ easysetup_provider_combo_box_new (void) void easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPresets *presets, GSList * list_country_id) { - /* If the list is empty then use mmc=0 to get the providers for all countries: */ + /* If the list is empty then use mcc=0 to get the providers for all countries: */ GSList *list = list_country_id; GSList *fake_list = NULL; if (!list_country_id) { diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index ecec23b..18f08ad 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -290,6 +290,7 @@ modest_tny_account_store_instance_init (ModestTnyAccountStore *obj) /* Respond to volume mounts and unmounts, such * as the insertion/removal of the memory card: */ + /* This is a singleton, so it does not need to be unrefed. */ monitor = gnome_vfs_get_volume_monitor(); priv->volume_mounted_handler = g_signal_connect (G_OBJECT(monitor), @@ -324,6 +325,32 @@ foreach_account_append_to_list (gpointer data, /********************************************************************/ /* Control the state of the MMC local account */ /********************************************************************/ + +/** Only call this if the memory card is really mounted. + */ +static void +add_mmc_account(ModestTnyAccountStore *self, gboolean emit_insert_signal) +{ + ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self); + g_return_if_fail (priv->session); + + TnyAccount *mmc_account = modest_tny_account_new_for_local_folders (priv->account_mgr, + priv->session, + MODEST_MCC1_VOLUMEPATH); + + /* Add to the list of store accounts */ + tny_list_append (priv->store_accounts, G_OBJECT (mmc_account)); + + if (emit_insert_signal) { + g_signal_emit (G_OBJECT (self), + signals [ACCOUNT_INSERTED_SIGNAL], + 0, mmc_account); + } + + /* Free */ + g_object_unref (mmc_account); +} + static void on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor, GnomeVFSVolume *volume, @@ -341,21 +368,9 @@ on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor, uri = gnome_vfs_volume_get_activation_uri (volume); if (uri && (!strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI))) { - TnyAccount *mmc_account; - - mmc_account = modest_tny_account_new_for_local_folders (priv->account_mgr, - priv->session, - MODEST_MCC1_VOLUMEPATH); - - /* Add to the list of store accounts */ - tny_list_append (priv->store_accounts, G_OBJECT (mmc_account)); - - g_signal_emit (G_OBJECT (self), - signals [ACCOUNT_INSERTED_SIGNAL], - 0, mmc_account); - /* Free */ - g_object_unref (mmc_account); + add_mmc_account (self, TRUE /* emit the insert signal. */); } + g_free (uri); } @@ -881,11 +896,24 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, tny_list_append (priv->store_accounts, G_OBJECT(local_account)); g_object_unref (local_account); - /* Add the other remote accounts. Do this before adding the + /* Add the other remote accounts. Do this after adding the local account, because we need to add our outboxes to the global OUTBOX hosted in the local account */ add_existing_accounts (MODEST_TNY_ACCOUNT_STORE (obj)); - + + + /* 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) { + /* It is mounted: */ + add_mmc_account (MODEST_TNY_ACCOUNT_STORE (obj), FALSE /* don't emit the insert signal. */); + gnome_vfs_volume_unref(volume); + } + return MODEST_TNY_ACCOUNT_STORE(obj); } -- 1.7.9.5