* added a missing initialization
[modest] / src / modest-tny-account-store.c
index acee4be..754ea01 100644 (file)
@@ -312,9 +312,6 @@ account_verify_last_ref (TnyAccount *account, const gchar *str)
        g_free (txt);
 }
 
-
-
-
 static void
 foreach_account_append_to_list (gpointer data, 
                                gpointer user_data)
@@ -836,8 +833,6 @@ modest_tny_account_store_finalize (GObject *obj)
                priv->session = NULL;
        }
 
-       camel_shutdown ();
-
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -1047,7 +1042,7 @@ modest_tny_account_store_alert (TnyAccountStore *self,
                MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN; 
        const gchar* server_name = "";
        gchar *prompt = NULL;
-       gboolean retval;
+       gboolean retval = TRUE;
 
        /* NOTE: account may be NULL in some cases */
        g_return_val_if_fail (error, FALSE);
@@ -1136,7 +1131,7 @@ modest_tny_account_store_alert (TnyAccountStore *self,
        if (error->code == TNY_SERVICE_ERROR_CERTIFICATE)
                retval = modest_platform_run_certificate_confirmation_dialog (server_name,
                                                                              error->message);
-       else {
+       else if (error->code == TNY_SERVICE_ERROR_AUTHENTICATE) {
                modest_platform_run_information_dialog (NULL, prompt, TRUE);
 
                /* Show the account dialog if it was wrong */
@@ -1147,6 +1142,7 @@ modest_tny_account_store_alert (TnyAccountStore *self,
                retval = TRUE;
        }
 
+       g_debug ("%s: error code %d (%s", __FUNCTION__, error->code, error->message);
        
        if (prompt)
                g_free (prompt);
@@ -1869,6 +1865,25 @@ remove_transport_account (ModestTnyAccountStore *self,
                                      on_account_disconnect_when_removing, self);
 }
 
+static gboolean
+images_cache_remove_filter (TnyStreamCache *self, const gchar *id, const gchar *account_name)
+{
+       gchar *account_name_with_separator;
+       gboolean result;
+       if (account_name == NULL || account_name[0] == '\0')
+               return FALSE;
+
+       if (id == NULL || id[0] == '\0')
+               return FALSE;
+
+       account_name_with_separator = g_strconcat (account_name, "__", NULL);
+
+       result = (g_str_has_prefix (id, account_name));
+       g_free (account_name_with_separator);
+
+       return result;
+}
+
 static void
 on_account_removed (ModestAccountMgr *acc_mgr, 
                    const gchar *account,
@@ -1877,6 +1892,7 @@ on_account_removed (ModestAccountMgr *acc_mgr,
        TnyAccount *store_account = NULL, *transport_account = NULL;
        ModestTnyAccountStore *self;
        ModestTnyAccountStorePrivate *priv;
+       TnyStreamCache *stream_cache;
        
        self = MODEST_TNY_ACCOUNT_STORE (user_data);
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
@@ -1929,6 +1945,10 @@ on_account_removed (ModestAccountMgr *acc_mgr,
                           __FUNCTION__, account);
        }
 
+       /* Remove cached images */
+       stream_cache = modest_runtime_get_images_cache ();
+       tny_stream_cache_remove (stream_cache, (TnyStreamCacheRemoveFilter) images_cache_remove_filter, (gpointer) account);
+
        /* If there are no more user accounts then delete the
           transport specific SMTP servers */
        if (only_local_accounts (self))