When moving messages to a local folder don't try to connect if the
[modest] / src / widgets / modest-account-view.c
index fe15737..7a828fb 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <modest-account-mgr.h>
 #include <modest-account-mgr-helpers.h>
+#include <modest-tny-account.h>
 #include <modest-text-utils.h>
 #include <modest-runtime.h>
 
@@ -255,9 +256,9 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
 
 static void
 on_account_busy_changed(ModestAccountMgr *account_mgr, 
-                       const gchar *account_name,
-                       gboolean busy, 
-                       ModestAccountView *self)
+                        const gchar *account_name,
+                        gboolean busy, 
+                        ModestAccountView *self)
 {
        GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self)));
        GtkTreeIter iter;
@@ -329,9 +330,10 @@ on_account_changed (TnyAccountStore *account_store,
        ModestAccountViewPrivate *priv = NULL;
        TnyTransportAccount *transport_account = NULL;
        ModestTnySendQueue *send_queue = NULL;
-       const gchar *account_name = NULL;
 
        g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data));
+       g_return_if_fail (account);
+       g_return_if_fail (TNY_IS_ACCOUNT (account));
 
        self = MODEST_ACCOUNT_VIEW (user_data);
        priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
@@ -342,16 +344,23 @@ on_account_changed (TnyAccountStore *account_store,
        update_account_view (priv->account_mgr, self);
 
        /* Get transport account */
-       account_name = tny_account_get_name (account);
-       transport_account = (TnyTransportAccount *)
+       const gchar *modest_account_name = 
+                       modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+       g_return_if_fail (modest_account_name);
+               
+       transport_account = (TnyTransportAccount*)
                modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
-                                                                                   account_name);
-
-       /* Restart send queue */                
-       g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT(transport_account));
-       send_queue = modest_runtime_get_send_queue (transport_account);
-       g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(send_queue));
-       modest_tny_send_queue_try_to_send (send_queue); 
+                                                                                   modest_account_name);
+
+       /* Restart send queue */
+       if (transport_account) {        
+               g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT(transport_account));
+               send_queue = modest_runtime_get_send_queue (transport_account);
+               g_return_if_fail (MODEST_IS_TNY_SEND_QUEUE(send_queue));
+               modest_tny_send_queue_try_to_send (send_queue);
+               
+               g_object_unref (transport_account);
+       }
 }
 
 
@@ -476,10 +485,11 @@ init_view (ModestAccountView *self)
         *
         * djcb: indeed, they have been removed for post-bora, i added the ifdefs...
                 */
-#ifdef MODEST_HILDON_VERSION_0 
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
        g_object_set(G_OBJECT(self), "allow-checkbox-mode", FALSE, NULL);
        g_object_set(G_OBJECT(toggle_renderer), "checkbox-mode", FALSE, NULL);
-#endif /*MODEST_HILDON_VERSION_0 */
+#endif /* MODEST_HAVE_HILDON0_WIDGETS */
+
        g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK(on_account_default_toggled),
                          self);