[evolution-kolab/ek-wip-porting: 4/8] CamelKolabIMAPXStore: folder creation type getter/setter API change
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 4/8] CamelKolabIMAPXStore: folder creation type getter/setter API change
- Date: Fri, 31 Aug 2012 16:11:04 +0000 (UTC)
commit 05fa52418229112ccf91ed00755771c24461c99c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Aug 31 17:37:37 2012 +0200
CamelKolabIMAPXStore: folder creation type getter/setter API change
* added a flag to the type setter whether to check the type
to be set against the configured context (mail, contact, calendar)
* added a getter function to retrieve the currently-set folder
creation type
src/libekolab/camel-kolab-imapx-store.c | 50 +++++++++++++++++++++++++-----
src/libekolab/camel-kolab-imapx-store.h | 13 ++++++--
2 files changed, 51 insertions(+), 12 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-store.c b/src/libekolab/camel-kolab-imapx-store.c
index dee055e..313de8d 100644
--- a/src/libekolab/camel-kolab-imapx-store.c
+++ b/src/libekolab/camel-kolab-imapx-store.c
@@ -393,7 +393,7 @@ imapx_store_set_foldertype (CamelKolabIMAPXStore *self,
ma->data[acc] = g_byte_array_new ();
g_byte_array_append (ma->data[acc],
(guchar *) g_strdup (typestring),
- strlen (typestring));
+ strlen (typestring) + 1);
me = camel_imapx_metadata_entry_new ();
g_hash_table_insert (me->attributes,
g_strdup ("value"),
@@ -725,7 +725,7 @@ kolab_imapx_store_create_folder_sync (CamelStore *self,
gboolean ok = FALSE;
g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
- /* parentname may be NULL */ /* FIXME correct? */
+ /* parentname may be NULL */
g_assert (foldername != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
@@ -753,14 +753,15 @@ kolab_imapx_store_create_folder_sync (CamelStore *self,
priv->folder_create_type,
cancellable,
&tmp_err);
- g_free (fullname);
if (! ok) {
g_warning ("%s: setting type [%i] for [%s] on server failed.",
__func__, priv->folder_create_type, fullname);
+ g_free (fullname);
camel_store_free_folder_info (self, fi);
g_propagate_error (err, tmp_err);
return NULL;
}
+ g_free (fullname);
k_fi = imapx_store_folder_info_build_restricted (myself,
fi,
@@ -834,7 +835,8 @@ kolab_imapx_store_rename_folder_sync (CamelStore *self,
static gboolean
kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *self,
- KolabFolderTypeID type_id)
+ KolabFolderTypeID type_id,
+ gboolean check_context)
{
CamelKolabIMAPXStorePrivate *priv = NULL;
@@ -844,15 +846,29 @@ kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *self,
priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
- /* check that the given folder type id lies within the configured folder context */
- if (! kolab_util_folder_type_match_with_context_id (type_id, priv->folder_context))
- return FALSE;
+ if (check_context) {
+ /* check that the given folder type id lies within the configured folder context */
+ if (! kolab_util_folder_type_match_with_context_id (type_id, priv->folder_context))
+ return FALSE;
+ }
priv->folder_create_type = type_id;
return TRUE;
}
+static KolabFolderTypeID
+kolab_imapx_store_get_folder_creation_type (CamelKolabIMAPXStore *self)
+{
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
+
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ return priv->folder_create_type;
+}
+
static gboolean
kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *self,
KolabFolderContextID context)
@@ -1164,6 +1180,7 @@ camel_kolab_imapx_store_class_init (CamelKolabIMAPXStoreClass *klass)
store_class->rename_folder_sync = kolab_imapx_store_rename_folder_sync;
klass->set_folder_creation_type = kolab_imapx_store_set_folder_creation_type;
+ klass->get_folder_creation_type = kolab_imapx_store_get_folder_creation_type;
klass->set_folder_context = kolab_imapx_store_set_folder_context;
klass->get_folder_type = kolab_imapx_store_get_folder_type;
klass->get_folder_info_online = kolab_imapx_store_get_folder_info_online;
@@ -1175,7 +1192,22 @@ camel_kolab_imapx_store_class_init (CamelKolabIMAPXStoreClass *klass)
gboolean
camel_kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *self,
- KolabFolderTypeID type_id)
+ KolabFolderTypeID type_id,
+ gboolean check_context)
+{
+ CamelKolabIMAPXStoreClass *klass = NULL;
+ gboolean ok = FALSE;
+
+ g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_STORE (self), FALSE);
+
+ klass = CAMEL_KOLAB_IMAPX_STORE_GET_CLASS (self);
+ ok = klass->set_folder_creation_type (self, type_id, check_context);
+
+ return ok;
+}
+
+KolabFolderTypeID
+camel_kolab_imapx_store_get_folder_creation_type (CamelKolabIMAPXStore *self)
{
CamelKolabIMAPXStoreClass *klass = NULL;
gboolean ok = FALSE;
@@ -1183,7 +1215,7 @@ camel_kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *self,
g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_STORE (self), FALSE);
klass = CAMEL_KOLAB_IMAPX_STORE_GET_CLASS (self);
- ok = klass->set_folder_creation_type (self, type_id);
+ ok = klass->get_folder_creation_type (self);
return ok;
}
diff --git a/src/libekolab/camel-kolab-imapx-store.h b/src/libekolab/camel-kolab-imapx-store.h
index 0c1dfc4..c4c28b7 100644
--- a/src/libekolab/camel-kolab-imapx-store.h
+++ b/src/libekolab/camel-kolab-imapx-store.h
@@ -75,7 +75,10 @@ struct _CamelKolabIMAPXStoreClass {
CamelIMAPXExtdStoreClass parent_class;
gboolean (*set_folder_creation_type) (CamelKolabIMAPXStore *self,
- KolabFolderTypeID type_id);
+ KolabFolderTypeID type_id,
+ gboolean check_context);
+
+ KolabFolderTypeID (*get_folder_creation_type) (CamelKolabIMAPXStore *self);
gboolean (*set_folder_context) (CamelKolabIMAPXStore *self,
KolabFolderContextID context);
@@ -97,10 +100,14 @@ struct _CamelKolabIMAPXStoreClass {
GType camel_kolab_imapx_store_get_type (void);
-/* Kolab extension: set type for newly created folders */
+/* Kolab extension: set/get type for newly created folders */
gboolean
camel_kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *self,
- KolabFolderTypeID type_id);
+ KolabFolderTypeID type_id,
+ gboolean check_context);
+
+KolabFolderTypeID
+camel_kolab_imapx_store_get_folder_creation_type (CamelKolabIMAPXStore *self);
/* Kolab extension: set the folder context (email, calendar, contacts (defaults to email)) */
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]