+static gboolean
+is_memory_full_error (GError *error)
+{
+ gboolean enough_free_space = TRUE;
+ GnomeVFSURI *cache_dir_uri;
+ const gchar *cache_dir;
+ GnomeVFSFileSize free_space;
+
+ cache_dir = tny_account_store_get_cache_dir (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+ cache_dir_uri = gnome_vfs_uri_new (cache_dir);
+ if (gnome_vfs_get_volume_free_space (cache_dir_uri, &free_space) == GNOME_VFS_OK) {
+ if (free_space < MIN_FREE_SPACE)
+ enough_free_space = FALSE;
+ }
+ gnome_vfs_uri_unref (cache_dir_uri);
+
+ if ((error->code == TNY_SYSTEM_ERROR_MEMORY ||
+ /* When asking for a mail and no space left on device
+ tinymail returns this error */
+ error->code == TNY_SERVICE_ERROR_MESSAGE_NOT_AVAILABLE ||
+ /* When the folder summary could not be read or
+ written */
+ error->code == TNY_IO_ERROR_WRITE ||
+ error->code == TNY_IO_ERROR_READ) &&
+ !enough_free_space) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static gboolean
+check_memory_full_error (GtkWidget *parent_window, GError *err)
+{
+ if (err == NULL)
+ return FALSE;
+
+ if (is_memory_full_error (err))
+ modest_platform_information_banner (parent_window,
+ NULL, dgettext("ke-recv",
+ "cerm_device_memory_full"));
+ else if (err->code == TNY_SYSTEM_ERROR_MEMORY)
+ /* If the account was created in memory full
+ conditions then tinymail won't be able to
+ connect so it'll return this error code */
+ modest_platform_information_banner (parent_window,
+ NULL, _("emev_ui_imap_inbox_select_error"));
+ else
+ return FALSE;
+
+ return TRUE;
+}
+