+static void
+recreate_all_accounts (ModestTnyAccountStore *self)
+{
+ ModestTnyAccountStorePrivate *priv =
+ MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+ if (priv->store_accounts_outboxes) {
+ account_list_free (priv->store_accounts_outboxes);
+ priv->store_accounts_outboxes = NULL;
+ }
+
+ if (priv->store_accounts) {
+ account_list_free (priv->store_accounts);
+ priv->store_accounts = NULL;
+ get_server_accounts (TNY_ACCOUNT_STORE(self),
+ NULL, TNY_ACCOUNT_TYPE_STORE);
+ }
+
+ if (priv->transport_accounts) {
+ account_list_free (priv->transport_accounts);
+ priv->transport_accounts = NULL;
+ get_server_accounts (TNY_ACCOUNT_STORE(self), NULL,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ }
+}
+
+static void
+on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor,
+ GnomeVFSVolume *volume, gpointer user_data)
+{
+ ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+
+ /* Check whether this was the external MMC1 card: */
+ gchar *uri = gnome_vfs_volume_get_activation_uri (volume);
+ if (uri && (strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI) == 0)) {
+ printf ("DEBUG: %s: MMC1 card mounted.\n", __FUNCTION__);
+
+ /* TODO: Just add an account and emit (and respond to)
+ * TnyAccountStore::accountinserted signal?
+ */
+ recreate_all_accounts (self);
+
+ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
+ NULL);
+ }
+
+ g_free (uri);
+}
+
+static void
+on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor,
+ GnomeVFSVolume *volume, gpointer user_data)
+{
+ ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+
+ /* Check whether this was the external MMC1 card: */
+ gchar *uri = gnome_vfs_volume_get_activation_uri (volume);
+ if (uri && (strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI) == 0)) {
+ printf ("DEBUG: %s: MMC1 card unmounted.\n", __FUNCTION__);
+
+ /* TODO: Just add an account and emit (and respond to)
+ * TnyAccountStore::accountinserted signal?
+ */
+ recreate_all_accounts (self);
+
+ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
+ NULL);
+ }
+
+ g_free (uri);
+}