+on_connection_status_changed (TnyAccount *self,
+ TnyConnectionStatus status,
+ gpointer user_data)
+{
+ /* If the account becomes online then refresh it */
+ if (status == TNY_CONNECTION_STATUS_CONNECTED) {
+ const gchar *acc_name;
+ GtkWidget *my_window;
+
+ my_window = gtk_widget_get_ancestor (GTK_WIDGET (user_data), MODEST_TYPE_WINDOW);
+ acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (self);
+ modest_ui_actions_do_send_receive (acc_name, MODEST_WINDOW (my_window));
+ }
+}
+
+static void
+on_account_inserted (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ ModestFolderViewPrivate *priv;
+ GtkTreeModel *sort_model, *filter_model;
+
+ /* Ignore transport account insertions, we're not showing them
+ in the folder view */
+ if (TNY_IS_TRANSPORT_ACCOUNT (account))
+ return;
+
+ priv = MODEST_FOLDER_VIEW_GET_PRIVATE (user_data);
+
+ /* If we're adding a new account, and there is no previous
+ one, we need to select the visible server account */
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
+ !priv->visible_account_id)
+ modest_widget_memory_restore (modest_runtime_get_conf(),
+ G_OBJECT (user_data),
+ MODEST_CONF_FOLDER_VIEW_KEY);
+
+ /* Get the inner model */
+ filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (user_data));
+ sort_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
+
+ /* Insert the account in the model */
+ tny_list_append (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
+ G_OBJECT (account));
+
+
+ /* When the store account gets online refresh it */
+ g_signal_connect (account, "connection_status_changed",
+ G_CALLBACK (on_connection_status_changed),
+ MODEST_FOLDER_VIEW (user_data));
+
+ /* Refilter the model */
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model));
+}
+
+
+static void
+on_account_changed (TnyAccountStore *account_store,
+ TnyAccount *tny_account,