[evolution-kolab] CamelKolabIMAPXStore: try to unset folder type annotation after delete
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] CamelKolabIMAPXStore: try to unset folder type annotation after delete
- Date: Thu, 20 Sep 2012 12:26:56 +0000 (UTC)
commit 333e339f8e635fbaef74b6271cc42e7a79d75c28
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Thu Sep 20 14:12:24 2012 +0200
CamelKolabIMAPXStore: try to unset folder type annotation after delete
* after deleting a folder from the Kolab server, we make
an attempt to remove the folder annotation for that folder
* it is not fatal if the attempt fails since the server may
well have deleted the folder metadata along with the
folder itself or deny setting of annotations for no-longer
existing folders right away
* we do, however, delete the folder first, since unsetting the
folder annotation and deleting the folder afterwards - which
may fail for multiple reasons - would result in an unusable
PIM folder and induce errors in other clients
src/libekolab/camel-kolab-imapx-store.c | 35 ++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-store.c b/src/libekolab/camel-kolab-imapx-store.c
index bab0d5f..a4a547d 100644
--- a/src/libekolab/camel-kolab-imapx-store.c
+++ b/src/libekolab/camel-kolab-imapx-store.c
@@ -388,12 +388,17 @@ imapx_store_set_foldertype (CamelKolabIMAPXStore *self,
/* create local CamelImapxMetadata for setting type */
acc = CAMEL_IMAPX_METADATA_ACCESS_SHARED;
ma = camel_imapx_metadata_attrib_new ();
- ma->type[acc] = CAMEL_IMAPX_METADATA_ATTRIB_TYPE_UTF8;
- typestring = kolab_util_folder_type_get_string (foldertype);
- ma->data[acc] = g_byte_array_new ();
- g_byte_array_append (ma->data[acc],
- (guchar *) g_strdup (typestring),
- (guint) strlen (typestring) + 1);
+ if (foldertype == KOLAB_FOLDER_TYPE_UNKNOWN) {
+ /* for unsetting the annotation */
+ ma->type[acc] = CAMEL_IMAPX_METADATA_ATTRIB_TYPE_NIL;
+ } else {
+ ma->type[acc] = CAMEL_IMAPX_METADATA_ATTRIB_TYPE_UTF8;
+ typestring = kolab_util_folder_type_get_string (foldertype);
+ ma->data[acc] = g_byte_array_new ();
+ g_byte_array_append (ma->data[acc],
+ (guchar *) g_strdup (typestring),
+ (guint) strlen (typestring) + 1);
+ }
me = camel_imapx_metadata_entry_new ();
g_hash_table_insert (me->attributes,
g_strdup ("value"),
@@ -947,6 +952,7 @@ kolab_imapx_store_delete_folder_sync (CamelStore *self,
GCancellable *cancellable,
GError **err)
{
+ CamelKolabIMAPXStore *myself = NULL;
GError *tmp_err = NULL;
gboolean ok = FALSE;
@@ -956,6 +962,8 @@ kolab_imapx_store_delete_folder_sync (CamelStore *self,
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+ myself = CAMEL_KOLAB_IMAPX_STORE (self);
+
ok = parent_store_class->delete_folder_sync (self,
foldername,
cancellable,
@@ -965,7 +973,20 @@ kolab_imapx_store_delete_folder_sync (CamelStore *self,
return FALSE;
}
- /* FIXME remove metadata of deleted folder from CamelKolabIMAPXServer */
+ /* try to remove metadata of deleted folder from Kolab server
+ * (failure is non-fatal, since the RFC recommends that servers
+ * should delete the metadata for deleted foldersy)
+ */
+ ok = imapx_store_set_foldertype (myself,
+ foldername,
+ KOLAB_FOLDER_TYPE_UNKNOWN,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ g_debug ("%s: removing type annotation for '%s' on server failed: %s",
+ __func__, foldername, tmp_err->message);
+ g_error_free (tmp_err);
+ }
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]