[evolution-kolab] KolabMailAccess: do online folder existence check when deleting
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] KolabMailAccess: do online folder existence check when deleting
- Date: Wed, 19 Sep 2012 17:30:55 +0000 (UTC)
commit 42a11fe44d2fb51575feea46f0e0c7cad26b1007
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Wed Sep 19 15:02:56 2012 +0200
KolabMailAccess: do online folder existence check when deleting
* we're requiring online operational mode for folder deletion,
so we can just ask the server for folder existence
* this enables us to become folder type agnostic in the delete()
operation, which we need to be in the collection backend
(which handles create/delete for folders (sources))
src/libekolab/kolab-mail-access.c | 70 ++++++++++++++++++++++++++++++++-----
1 files changed, 61 insertions(+), 9 deletions(-)
---
diff --git a/src/libekolab/kolab-mail-access.c b/src/libekolab/kolab-mail-access.c
index a1853ec..8a54173 100644
--- a/src/libekolab/kolab-mail-access.c
+++ b/src/libekolab/kolab-mail-access.c
@@ -2961,7 +2961,7 @@ kolab_mail_access_query_sources (KolabMailAccess *self,
* Returns: a #GList of pointers to newly allocated
* #KolabFolderDescriptor objects. Free the
* list with kolab_util_folder_descriptor_glist_free()
- * once you're done using the list. The list
+ * once you're done using it. The list
* returned may be NULL without that being an
* error (check @err separately)
*
@@ -3154,7 +3154,9 @@ kolab_mail_access_delete_source (KolabMailAccess *self,
GError **err)
{
KolabMailAccessPrivate *priv = NULL;
- /* gboolean exists = FALSE; */
+ GList *folders_desc = NULL;
+ GList *folders_desc_ptr = NULL;
+ gboolean exists = FALSE;
gboolean ok = TRUE;
GError *tmp_err = NULL;
@@ -3167,22 +3169,72 @@ kolab_mail_access_delete_source (KolabMailAccess *self,
g_mutex_lock (&(priv->big_lock));
- if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+ if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_OFFLINE) {
+ g_set_error (&tmp_err,
+ KOLAB_BACKEND_ERROR,
+ KOLAB_BACKEND_ERROR_STATE_WRONG_FOR_OP,
+ _("You must be working online to complete this operation"));
+ ok = FALSE;
goto exit;
-#if 0
+ }
/* check whether folder exists */
- exists = kolab_mail_info_db_exists_foldername (priv->infodb,
- sourcename,
- &tmp_err);
+
+ /* We are in online mode, so we can directly query the folder
+ * situation from the server. Moreover, our local InfoDb will
+ * be blind w.r.t. folders not matching the currently-configured
+ * folder context (mail, calendar, contacts). We need the folder
+ * delete operation to be foldertype-agnostic since the collection
+ * backend needs to be able to delete all (PIM) types of folders
+ * without prior reconfiguring of the folder context it is in.
+ * So we online-query the list of folders (and their types) from
+ * the server and check whether we find the to-be-deleted folder
+ * there
+ */
+ folders_desc = kolab_mail_imap_client_query_folder_info_online (priv->client,
+ cancellable,
+ &tmp_err);
if (tmp_err != NULL) {
ok = FALSE;
goto exit;
}
- if (! exists)
+ folders_desc_ptr = folders_desc;
+ while (folders_desc_ptr != NULL) {
+ KolabFolderDescriptor *desc = (KolabFolderDescriptor *) folders_desc_ptr->data;
+ exists = g_str_equal (desc->name, sourcename);
+ if (exists)
+ break;
+ folders_desc_ptr = g_list_next (folders_desc_ptr);
+ }
+
+ kolab_util_folder_descriptor_glist_free (folders_desc);
+
+ if (! exists) {
+ /* We assume here that if a folder has been deleted,
+ * the folder annotation has been deleted as well
+ * (either by the client deleting the folder or by
+ * a well-bahaving server, which deletes the folder
+ * metadata once the folder is deleted, as per RFC
+ * recommendation), We could check for existing folder
+ * metadata here and delete it here, but it needs
+ * second thought whether we should even try that.
+ *
+ * The locally cached data will no longer be accessed
+ * since the backend for that folder will be removed
+ * after successful deletion of the server folder, and
+ * the ESource (config data) for the folder will be
+ * deleted. The E-D-S cache reaper will then kill the
+ * orphaned cache directory and we're done. This of
+ * course means that if we still have objects in the
+ * offline cache for this folder, they will silently
+ * be dropped along with the rest of the folder (we
+ * would need a way to differentiate between "delete
+ * locally only" and "delete completely", which EClients
+ * currently don't do)
+ */
goto exit;
-#endif
+ }
/* delete folder */
ok = mail_access_local_delete (self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]