[evolution-kolab/ek-wip-porting] CamelKolabIMAPXStore: create CamelKolabIMAPXFolder instances
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] CamelKolabIMAPXStore: create CamelKolabIMAPXFolder instances
- Date: Mon, 16 Jan 2012 18:24:26 +0000 (UTC)
commit 53244e9f614ba353b8a5249bf5395520716e8c4c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Jan 16 19:14:58 2012 +0100
CamelKolabIMAPXStore: create CamelKolabIMAPXFolder instances
* return CamelKolabIMAPXFolder instances when queried for
a folder (instead of CamelIMAPXExtdFolder)
* requires some code dupe from CamelIMAPXExtdStore so we
can allocate our own type
src/camel/camel-kolab-imapx-store.c | 80 ++++++++++++++++++++++++++++------
src/camel/camel-kolab-imapx-store.h | 1 +
2 files changed, 67 insertions(+), 14 deletions(-)
---
diff --git a/src/camel/camel-kolab-imapx-store.c b/src/camel/camel-kolab-imapx-store.c
index 6631179..0a0f95b 100644
--- a/src/camel/camel-kolab-imapx-store.c
+++ b/src/camel/camel-kolab-imapx-store.c
@@ -204,6 +204,66 @@ camel_kolab_imapx_store_finalize (GObject *object)
}
/*----------------------------------------------------------------------------*/
+/* internal statics */
+
+static CamelFolder*
+imapx_store_get_folder_offline (CamelStore *self,
+ const gchar *folder_name,
+ guint32 flags,
+ GError **err)
+{
+ /* This function is a dupe of extd_store_get_folder_offline() in
+ * CamelIMAPXExtdStore, which is a dupe of get_folder_offline()
+ * in CamelIMAPXStore.
+ * We need to dupe it in order to return a CamelKolabIMAPXFolder
+ * (disguised as a CamelFolder). Upstream fixes need to be applied
+ * here, too.
+ */
+
+ CamelKolabIMAPXStore *myself = CAMEL_KOLAB_IMAPX_STORE (self);
+ CamelIMAPXStore *imapx_store = CAMEL_IMAPX_STORE (self);
+ CamelService *service = CAMEL_SERVICE (self);
+ CamelFolder *new_folder = NULL;
+ CamelStoreInfo *si = NULL;
+ const gchar *user_cache_dir = NULL;
+
+ user_cache_dir = camel_service_get_user_cache_dir (service);
+
+ si = camel_store_summary_path (CAMEL_STORE_SUMMARY (imapx_store->summary), folder_name);
+ if (si) {
+ gchar *folder_dir, *storage_path;
+
+ /* Note: Although the INBOX is defined to be case-insensitive in the IMAP RFC
+ * it is still up to the server how to acutally name it in a LIST response. Since
+ * we stored the name as the server provided it us in the summary we take that name
+ * to look up the folder.
+ * But for the on-disk cache we do always capitalize the Inbox no matter what the
+ * server provided.
+ */
+ if (!g_ascii_strcasecmp (folder_name, "INBOX"))
+ folder_name = "INBOX";
+
+ storage_path = g_build_filename (user_cache_dir, "folders", NULL);
+ folder_dir = imapx_path_to_physical (storage_path, folder_name);
+ g_free (storage_path);
+ /* FIXME */ /* (create CamelKolabIMAPXFolder) */
+ new_folder = CAMEL_FOLDER (camel_kolab_imapx_folder_new (myself,
+ folder_dir,
+ folder_name,
+ err));
+ g_free (folder_dir);
+ camel_store_summary_info_free (CAMEL_STORE_SUMMARY (imapx_store->summary), si);
+ } else {
+ g_set_error (err,
+ CAMEL_STORE_ERROR,
+ CAMEL_STORE_ERROR_NO_FOLDER,
+ _("No such folder %s"), folder_name);
+ }
+
+ return new_folder;
+}
+
+/*----------------------------------------------------------------------------*/
/* class functions */
static gchar*
@@ -353,23 +413,15 @@ kolab_imapx_store_get_folder_sync (CamelStore *self,
{
CamelFolder *folder = NULL;
- g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
+ g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
g_assert (foldername != NULL);
- /* cancellable may be NULL */
+ (void)cancellable;
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
- folder = parent_store_class->get_folder_sync (self,
- foldername,
- flags,
- cancellable,
- err);
- if (folder != NULL) {
- /* FIXME need to get a CamelKolabImapxFolder here?
- * how?
- */
- g_assert (CAMEL_IS_IMAPX_EXTD_FOLDER (folder));
- }
-
+ folder = imapx_store_get_folder_offline (self,
+ foldername,
+ flags,
+ err);
return folder;
}
diff --git a/src/camel/camel-kolab-imapx-store.h b/src/camel/camel-kolab-imapx-store.h
index 9c74ebe..4709384 100644
--- a/src/camel/camel-kolab-imapx-store.h
+++ b/src/camel/camel-kolab-imapx-store.h
@@ -40,6 +40,7 @@
#include <camel/providers/imapx/camel-imapx-extd-store.h>
#include "camel-kolab-imapx-metadata.h"
+#include "camel-kolab-imapx-folder.h"
#include "camel-kolab-imapx-server.h"
/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]