* more changes to the account management; now the following should work again:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 1 Aug 2007 13:27:11 +0000 (13:27 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 1 Aug 2007 13:27:11 +0000 (13:27 +0000)
  - changing account names (updates modest-account-view, and modest-folder-view)
  - expand root folders
  - change modest-account-mgr to only emit change signals once per 500ms
  - modest-account-mgr changes notification now only give the "parent account",
    not the server account, and not for every single key
  - accounts are changed, not recreated

pmo-trunk-r2888

src/modest-account-mgr-priv.h
src/modest-account-mgr.c
src/modest-account-mgr.h
src/modest-tny-account-store.c
src/modest-tny-account.c
src/modest-tny-account.h
src/modest-tny-folder.c
src/widgets/modest-folder-view.c

index 54beffb..18a2981 100644 (file)
@@ -54,6 +54,9 @@ struct _ModestAccountMgrPrivate {
        gulong key_changed_handler_uid;
        GSList* busy_accounts;
 
        gulong key_changed_handler_uid;
        GSList* busy_accounts;
 
+       GSList* change_queue; /* list with all accounts that are changed */
+       guint timeout;
+       
        GHashTable *notification_id_accounts;
 };
 
        GHashTable *notification_id_accounts;
 };
 
index 75fa3b8..c62feb9 100644 (file)
@@ -52,43 +52,109 @@ enum {
 static GObjectClass *parent_class = NULL;
 static guint signals[LAST_SIGNAL] = {0};
 
 static GObjectClass *parent_class = NULL;
 static guint signals[LAST_SIGNAL] = {0};
 
-/* /\* We signal key changes in batches, every X seconds: *\/ */
-/* static gboolean */
-/* on_timeout_notify_changes (gpointer data) */
-/* { */
-/*     ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data); */
-/*     ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
+/* is the account already in the queue? */
+static gboolean
+in_change_queue (GSList *change_queue, const gchar *account)
+{
+       GSList *cursor = change_queue;
+       while (cursor) {
+               const gchar *acc = cursor->data;
+               if (acc && strcmp (acc, account) == 0)
+                       return TRUE;
+               cursor = g_slist_next (cursor);
+       }
+       return FALSE;
+}
+
+static GSList*
+add_to_change_queue (GSList *change_queue, const gchar *account_name)
+{
+       g_return_val_if_fail (account_name, change_queue);      
+       return g_slist_prepend (change_queue, g_strdup (account_name));
+}
+
+
+/* we don't need to track specific accounts, as in our UI case
+ * it's impossible to change two accounts within .5 seconds.
+ * still, we might want to allow that later, and then this func
+ * will come in handy */
+#if 0
+static GSList*
+remove_from_queue (GSList *change_queue, const gchar *account)
+{
+       GSList *cursor = change_queue;
+       while (cursor) {
+               const gchar *acc = cursor->data;
+               if (acc && strcmp (acc, account) == 0) {
+                       g_free (acc);
+                       return g_slist_delete_link (change_queue, cursor);
+               }
+               cursor = g_slist_next (cursor);
+       }
+       return change_queue;
+}
+#endif
+
+static gboolean
+on_timeout_notify_changes (gpointer data)
+{
+       ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data);
+       ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
                
                
-/*     /\* TODO: Also store the account names, and notify one list for each account, */
-/*      * if anything uses the account names. *\/ */
+       GSList *cursor = priv->change_queue;
+       while (cursor) {
+               const gchar *account = cursor->data;
+               if (account)
+                       g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, 
+                                      account);
+               cursor = g_slist_next (cursor);
+       }
        
        
-/*     if (priv->changed_conf_keys) { */
-/*             gchar *default_account =  */
-/*                             modest_account_mgr_get_default_account (self); */
-               
-/*             /\* printf ("DEBUG: %s: priv->changed_conf_key length=%d\n",  */
-/*                     __FUNCTION__, g_slist_length (priv->changed_conf_keys)); *\/ */
-/*             g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, */
-/*                              default_account, priv->changed_conf_keys, FALSE); */
-                       
-/*             g_free (default_account); */
-               
-/*             g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); */
-/*             g_slist_free (priv->changed_conf_keys); */
-/*             priv->changed_conf_keys = NULL; */
-/*     } */
+       /* free our queue */
+       g_slist_foreach (priv->change_queue, (GFunc)g_free, NULL);
+       g_slist_free (priv->change_queue);
+       priv->change_queue = NULL;
+       priv->timeout = 0; /* hmmm */
        
        
-/*     return TRUE; /\* Call this again later. *\/ */
-/* } */
+       return FALSE; /* don't call me again */
+}
+
+
+/* little hack to retrieve the account name from a server account name,
+ * by relying on the convention for that. Note: this changes the
+ * string in-place
+ *
+ * server accounts look like fooID_transport or fooID_store
+ * FIXME: make the suffixes more explicit in the account setup
+ */
+static void
+get_account_name_from_server_account (gchar *server_account_name)
+{
+       static const gchar *t = "ID_transport";
+       static const gchar *s = "ID_store";
+       const guint len_t = strlen (t);
+       const guint len_s = strlen (s);
+       
+       guint len_a = strlen (server_account_name);
+               
+       if (g_str_has_suffix (server_account_name, t)) 
+               server_account_name [len_a - len_t] = '\0';
+       else if (g_str_has_suffix (server_account_name, s)) 
+               server_account_name [len_a - len_s] = '\0';
+}
+
+
 
 static void
 on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
               ModestConfNotificationId id, gpointer user_data)
 {
        ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
 
 static void
 on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
               ModestConfNotificationId id, gpointer user_data)
 {
        ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
+       ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+
        gboolean is_account_key;
        gboolean is_server_account;
        gboolean is_account_key;
        gboolean is_server_account;
-       gchar* account = NULL;
+       gchar* account_name = NULL;
 
        /* there is only one not-really-account key which will still emit
         * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
 
        /* there is only one not-really-account key which will still emit
         * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
@@ -100,7 +166,7 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
                        return;
                } else {
                        g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, 
                        return;
                } else {
                        g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, 
-                                      default_account, key, FALSE);
+                                      default_account);
                        g_free(default_account);
                        return;
                }       
                        g_free(default_account);
                        return;
                }       
@@ -108,20 +174,25 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
        
        is_account_key = FALSE;
        is_server_account = FALSE;
        
        is_account_key = FALSE;
        is_server_account = FALSE;
-       account = _modest_account_mgr_account_from_key (key, &is_account_key,
-                                                       &is_server_account);
+       account_name = _modest_account_mgr_account_from_key (key, &is_account_key,
+                                                            &is_server_account);
 
        /* if this is not an account-related key change, ignore */
 
        /* if this is not an account-related key change, ignore */
-       if (!account)
+       if (!account_name)
                return;
 
                return;
 
+       /* ignore server account changes */
+       if (is_server_account)
+               /* change in place: retrieve the parent account name */
+               get_account_name_from_server_account (account_name);
+
        /* account was removed. Do not emit an account removed signal
           because it was already being done in the remove_account
           method. Do not notify also the removal of the server
           account keys for the same reason */
        if ((is_account_key || is_server_account) &&
            event == MODEST_CONF_EVENT_KEY_UNSET) {
        /* account was removed. Do not emit an account removed signal
           because it was already being done in the remove_account
           method. Do not notify also the removal of the server
           account keys for the same reason */
        if ((is_account_key || is_server_account) &&
            event == MODEST_CONF_EVENT_KEY_UNSET) {
-               g_free (account);
+               g_free (account_name);
                return;
        }
 
                return;
        }
 
@@ -130,20 +201,24 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
        if (is_server_account)
                enabled = TRUE;
        else
        if (is_server_account)
                enabled = TRUE;
        else
-               enabled = modest_account_mgr_get_enabled (self, account);
+               enabled = modest_account_mgr_get_enabled (self, account_name);
 
        /* Notify is server account was changed, default account was changed
         * or when enabled/disabled changes:
         */
 
        /* Notify is server account was changed, default account was changed
         * or when enabled/disabled changes:
         */
-       if (enabled ||
-           g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) ||
+       if (!is_server_account)
+       if (enabled || g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) ||
            strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
            strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
-               g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, 
-                              account, key, is_server_account);
-               /* Store the key for later notification in our timeout callback.
-                * Notifying for every key change would cause unnecessary work: */
+               if (!in_change_queue (priv->change_queue, account_name)) {
+                       priv->change_queue = add_to_change_queue (priv->change_queue,
+                                                                 account_name);
+                       /* hmm, small race when this object is destroyed within
+                        * 500ms of the last change, and there are multiple timeouts... */
+                       priv->timeout = g_timeout_add (500, (GSourceFunc)on_timeout_notify_changes,
+                                                      self);
+               }   
        }
        }
-       g_free (account);
+       g_free (account_name);
 }
 
 
 }
 
 
@@ -204,8 +279,8 @@ modest_account_mgr_base_init (gpointer g_class)
                                      G_SIGNAL_RUN_FIRST,
                                      G_STRUCT_OFFSET(ModestAccountMgrClass,account_changed),
                                      NULL, NULL,
                                      G_SIGNAL_RUN_FIRST,
                                      G_STRUCT_OFFSET(ModestAccountMgrClass,account_changed),
                                      NULL, NULL,
-                                     modest_marshal_VOID__STRING_STRING_BOOLEAN,
-                                     G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+                                     g_cclosure_marshal_VOID__STRING,
+                                     G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
                signals[ACCOUNT_BUSY_SIGNAL] =
                        g_signal_new ("account_busy_changed",
 
                signals[ACCOUNT_BUSY_SIGNAL] =
                        g_signal_new ("account_busy_changed",
@@ -240,9 +315,11 @@ modest_account_mgr_init (ModestAccountMgr * obj)
        ModestAccountMgrPrivate *priv =
                MODEST_ACCOUNT_MGR_GET_PRIVATE (obj);
 
        ModestAccountMgrPrivate *priv =
                MODEST_ACCOUNT_MGR_GET_PRIVATE (obj);
 
-       priv->modest_conf = NULL;
+       priv->modest_conf   = NULL;
        priv->busy_accounts = NULL;
        priv->busy_accounts = NULL;
-
+       priv->change_queue  = NULL;
+       priv->timeout       = 0;
+       
        priv->notification_id_accounts = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
 }
 
        priv->notification_id_accounts = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
 }
 
@@ -268,14 +345,11 @@ modest_account_mgr_finalize (GObject * obj)
                g_object_unref (G_OBJECT(priv->modest_conf));
                priv->modest_conf = NULL;
        }
                g_object_unref (G_OBJECT(priv->modest_conf));
                priv->modest_conf = NULL;
        }
-       
-/*     if (priv->timeout) */
-/*             g_source_remove (priv->timeout); */
-               
-/*     if (priv->changed_conf_keys) { */
-/*             g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); */
-/*             g_slist_free (priv->changed_conf_keys); */
-/*     } */
+
+       if (priv->timeout)
+               g_source_remove (priv->timeout);
+       priv->timeout = 0;
+
 
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
index ae33f39..acbef4a 100644 (file)
@@ -66,8 +66,6 @@ struct _ModestAccountMgrClass {
 
        void (* account_changed)   (ModestAccountMgr *obj, 
                                    const gchar* account,
 
        void (* account_changed)   (ModestAccountMgr *obj, 
                                    const gchar* account,
-                                   const gchar* key, 
-                                   gboolean server_account,
                                    gpointer user_data);
 
        void (* account_busy_changed)   (ModestAccountMgr *obj, 
                                    gpointer user_data);
 
        void (* account_busy_changed)   (ModestAccountMgr *obj, 
index 7c90a39..d9d6f97 100644 (file)
@@ -474,33 +474,21 @@ update_tny_account_for_account (ModestTnyAccountStore *self, ModestAccountMgr *a
 
 static void
 on_account_changed (ModestAccountMgr *acc_mgr, 
 
 static void
 on_account_changed (ModestAccountMgr *acc_mgr, 
-                   const gchar *account_name,
-                   const gchar *key, 
-                   gboolean server_account, 
+                   const gchar *account_name, 
                    gpointer user_data)
 {
                    gpointer user_data)
 {
-       printf ("DEBUG: modest: %s\n", __FUNCTION__);
-       
        ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
        ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
-       
+
+       g_debug ("DEBUG: modest: %s\n", __FUNCTION__);
+
        /* Ignore the change if it's a change in the last_updated value */
        /* Ignore the change if it's a change in the last_updated value */
-       if (key && g_str_has_suffix ((const gchar *) key, MODEST_ACCOUNT_LAST_UPDATED))
-               return;
+//     if (key && g_str_has_suffix ((const gchar *) key, MODEST_ACCOUNT_LAST_UPDATED))
+//             return;
        
        
-       if (!server_account && FALSE) { /* FIXME FALSE: turned off for now */
-               if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_STORE))
-                       g_warning ("%s: failed to update store account for %s", __FUNCTION__, account_name);
-               if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_TRANSPORT))
-                       g_warning ("%s: failed to update transport account for %s", __FUNCTION__, account_name);
-       }
-
-       /* TODO: This doesn't actually work, because
-        * a) The account name is not sent correctly per key:
-        * b) We should test the end of the key, not the whole keym
-        * c) We don't seem to be getting all keys here.
-        * Instead, we just forget the password for all accounts when we create them,
-        * for now.
-        */
+       if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_STORE))
+               g_warning ("%s: failed to update store account for %s", __FUNCTION__, account_name);
+       if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_TRANSPORT))
+               g_warning ("%s: failed to update transport account for %s", __FUNCTION__, account_name);
 }
 
 static void 
 }
 
 static void 
@@ -1608,6 +1596,7 @@ insert_account (ModestTnyAccountStore *self,
                tny_folder_store_get_folders (TNY_FOLDER_STORE (account_outbox),
                                              folders, NULL, NULL);
                g_assert (tny_list_get_length (folders) == 1);
                tny_folder_store_get_folders (TNY_FOLDER_STORE (account_outbox),
                                              folders, NULL, NULL);
                g_assert (tny_list_get_length (folders) == 1);
+               
                iter_folders = tny_list_create_iterator (folders);
                per_account_outbox = TNY_FOLDER (tny_iterator_get_current (iter_folders));
                g_object_unref (iter_folders);
                iter_folders = tny_list_create_iterator (folders);
                per_account_outbox = TNY_FOLDER (tny_iterator_get_current (iter_folders));
                g_object_unref (iter_folders);
index 4e18eff..382f0d1 100644 (file)
@@ -464,7 +464,7 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
 }
 
 
 }
 
 
-
+#if 0
 gboolean
 modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
                                                    ModestAccountMgr *account_mgr,
 gboolean
 modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
                                                    ModestAccountMgr *account_mgr,
@@ -535,7 +535,7 @@ modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
        modest_account_mgr_free_server_account_data (account_mgr, account_data);
        return TRUE;
 }
        modest_account_mgr_free_server_account_data (account_mgr, account_data);
        return TRUE;
 }
-
+#endif
 
 
 
 
 
 
index 8cbcc72..0a1b428 100644 (file)
@@ -124,6 +124,7 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
                                                 TnySessionCamel *session,
                                                 const gchar* server_account_name);
 
                                                 TnySessionCamel *session,
                                                 const gchar* server_account_name);
 
+#if 0
 /**
  * modest_tny_account_new_from_server_account_name:
  * @tny_account: a valid tny account
 /**
  * modest_tny_account_new_from_server_account_name:
  * @tny_account: a valid tny account
@@ -137,7 +138,7 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
 gboolean modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
                                                             ModestAccountMgr *account_mgr,
                                                             const gchar *server_account_name);
 gboolean modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
                                                             ModestAccountMgr *account_mgr,
                                                             const gchar *server_account_name);
-
+#endif
 
 /**
  * modest_tny_account_get_special_folder:
 
 /**
  * modest_tny_account_get_special_folder:
index fd35b01..a5973b1 100644 (file)
@@ -163,10 +163,11 @@ modest_tny_folder_get_rules   (TnyFolder *folder)
                }
                g_object_unref (G_OBJECT(account));
 
                }
                g_object_unref (G_OBJECT(account));
 
-               /* Neither INBOX not ROOT folders should me moveable */
+               /* Neither INBOX nor ROOT, nor ARCHIVE folders should me moveable */
                folder_type = modest_tny_folder_guess_folder_type (folder);
                if ((folder_type ==  TNY_FOLDER_TYPE_INBOX) ||
                folder_type = modest_tny_folder_guess_folder_type (folder);
                if ((folder_type ==  TNY_FOLDER_TYPE_INBOX) ||
-                   (folder_type == TNY_FOLDER_TYPE_ROOT)) {
+                   (folder_type == TNY_FOLDER_TYPE_ROOT) ||
+                   (folder_type == TNY_FOLDER_TYPE_ARCHIVE)) {
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_DELETABLE;
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE;
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_RENAMEABLE;
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_DELETABLE;
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE;
                        rules |= MODEST_FOLDER_RULES_FOLDER_NON_RENAMEABLE;
@@ -175,6 +176,7 @@ modest_tny_folder_get_rules   (TnyFolder *folder)
        return rules;
 }
 
        return rules;
 }
 
+       
 
 gboolean
 modest_tny_folder_is_local_folder   (TnyFolder *folder)
 
 gboolean
 modest_tny_folder_is_local_folder   (TnyFolder *folder)
@@ -187,21 +189,27 @@ modest_tny_folder_is_local_folder   (TnyFolder *folder)
         * We should do something more sophisticated if we 
         * ever use TnyMergeFolder for anything else.
         */
         * We should do something more sophisticated if we 
         * ever use TnyMergeFolder for anything else.
         */
-       if (TNY_IS_MERGE_FOLDER (folder))
+       if (TNY_IS_MERGE_FOLDER (folder)) {
                return TRUE;
                return TRUE;
-
+       }
+       
        TnyAccount* account = tny_folder_get_account ((TnyFolder*)folder);
        TnyAccount* account = tny_folder_get_account ((TnyFolder*)folder);
-       if (!account)
+       if (!account) {
+               g_warning ("folder without account");
                return FALSE;
                return FALSE;
+       }
        
        /* Outbox is a special case, using a derived TnyAccount: */
        if (MODEST_IS_TNY_OUTBOX_ACCOUNT (account)) {
        
        /* Outbox is a special case, using a derived TnyAccount: */
        if (MODEST_IS_TNY_OUTBOX_ACCOUNT (account)) {
+               //g_warning ("BUG: should not be reached");
+               /* should be handled with the MERGE_FOLDER above*/
                g_object_unref (G_OBJECT(account));
                return TRUE;
        }
 
        const gchar* account_id = tny_account_get_id (account);
        if (!account_id) {
                g_object_unref (G_OBJECT(account));
                return TRUE;
        }
 
        const gchar* account_id = tny_account_get_id (account);
        if (!account_id) {
+               g_warning ("BUG: account without account id");
                g_object_unref (G_OBJECT(account));
                return FALSE;
        }
                g_object_unref (G_OBJECT(account));
                return FALSE;
        }
index 0353cd8..478a892 100644 (file)
@@ -124,6 +124,8 @@ static gboolean     on_drag_motion         (GtkWidget      *widget,
                                            guint           time,
                                            gpointer        user_data);
 
                                            guint           time,
                                            gpointer        user_data);
 
+static void expand_root_items (ModestFolderView *self);
+
 static gint         expand_row_timeout     (gpointer data);
 
 static void         setup_drag_and_drop    (GtkTreeView *self);
 static gint         expand_row_timeout     (gpointer data);
 
 static void         setup_drag_and_drop    (GtkTreeView *self);
@@ -420,8 +422,7 @@ text_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer *renderer,
                         * added to the model, not when the account is 
                         * changed later, so get the name from the account
                         * instance: */
                         * added to the model, not when the account is 
                         * changed later, so get the name from the account
                         * instance: */
-                       item_name = g_strdup (tny_account_get_name (
-                               TNY_ACCOUNT (instance)));
+                       item_name = g_strdup (tny_account_get_name (TNY_ACCOUNT (instance)));
                        item_weight = 800;
                } else {
                        item_name = g_strdup (fname);
                        item_weight = 800;
                } else {
                        item_name = g_strdup (fname);
@@ -833,7 +834,18 @@ static void
 on_account_changed (TnyAccountStore *account_store, TnyAccount *tny_account,
                    gpointer user_data)
 {
 on_account_changed (TnyAccountStore *account_store, TnyAccount *tny_account,
                    gpointer user_data)
 {
-       g_warning ("%s: account_id = %s", __FUNCTION__, tny_account_get_id(tny_account));
+       ModestFolderView*  self;
+
+       self = MODEST_FOLDER_VIEW (user_data);
+       
+       /* Ignore transport account insertions, we're not showing them
+          in the folder view */
+       if (TNY_IS_TRANSPORT_ACCOUNT (tny_account))
+               return;
+       
+       /* ugly hack to force a redraw */
+       modest_folder_view_update_model (self,
+                                        account_store);
 }
 
 
 }
 
 
@@ -926,6 +938,9 @@ modest_folder_view_on_map (ModestFolderView *self,
                               signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
                               NULL);
        }
                               signals[FOLDER_DISPLAY_NAME_CHANGED_SIGNAL], 0,
                               NULL);
        }
+
+       expand_root_items (self); 
+
        return FALSE;
 }
 
        return FALSE;
 }
 
@@ -1140,7 +1155,7 @@ modest_folder_view_update_model (ModestFolderView *self,
        g_object_unref (model);
        g_object_unref (filter_model);          
        g_object_unref (sortable);
        g_object_unref (model);
        g_object_unref (filter_model);          
        g_object_unref (sortable);
-
+       
        /* Force a reselection of the INBOX next time the widget is shown */
        priv->reselect = TRUE;
                        
        /* Force a reselection of the INBOX next time the widget is shown */
        priv->reselect = TRUE;