[evolution-kolab/ek-wip-porting-imapx] CamelKolabIMAPXStore: initial rewrite to GObject
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting-imapx] CamelKolabIMAPXStore: initial rewrite to GObject
- Date: Tue, 6 Dec 2011 12:09:27 +0000 (UTC)
commit 0c0b6094d6c947e138a0e807abd9518cb54ec3d6
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Tue Dec 6 13:01:39 2011 +0100
CamelKolabIMAPXStore: initial rewrite to GObject
* replaced Camel type boilerplate with GObject one
* derive from CamelIMAPXExtdStore instead of CamelIMAPXStore
* implemented internal skeleton functions for
the following interfaces:
- GInitable
- CamelNetworkServiceInterface
- CamelSubscribableInterface
* implemented internal skeleton functions for
the following classes:
- CamelService
- CamelStore
* replaced CamelException with GError
src/camel/camel-kolab-imapx-store.c | 741 ++++++++++++++++++++++++++++++++---
src/camel/camel-kolab-imapx-store.h | 85 +++--
2 files changed, 747 insertions(+), 79 deletions(-)
---
diff --git a/src/camel/camel-kolab-imapx-store.c b/src/camel/camel-kolab-imapx-store.c
index 2e3a799..6af196f 100644
--- a/src/camel/camel-kolab-imapx-store.c
+++ b/src/camel/camel-kolab-imapx-store.c
@@ -25,52 +25,697 @@
/*----------------------------------------------------------------------------*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
#include <libekolabutil/camel-system-headers.h>
#include <camel/providers/imapx/camel-imapx-store-summary.h>
-#include <camel/providers/imapx/camel-imapx-server.h>
+#include <camel/providers/imapx/camel-imapx-extd-server.h>
#include <camel/providers/imapx/camel-imapx-metadata.h>
#include <camel/providers/imapx/camel-imapx-utils.h>
#include <libekolabutil/kolab-util-error.h>
-#include <libekolabutil/kolab-util-folder.h>
+#include "camel-kolab-imapx-settings.h"
#include "camel-kolab-imapx-store.h"
/*----------------------------------------------------------------------------*/
-static CamelIMAPXStoreClass* parent_class = NULL;
+static GInitableIface *parent_initable_interface = NULL;
+
+/*----------------------------------------------------------------------------*/
+/* forward declarations */
+
+static void camel_kolab_imapx_store_initable_init (GInitableIface *interface);
+static void camel_kolab_imapx_store_network_service_init (CamelNetworkServiceInterface *interface);
+static void camel_kolab_imapx_store_subscribable_init (CamelSubscribableInterface *interface);
+
+/*----------------------------------------------------------------------------*/
+
+typedef struct _CamelKolabIMAPXStorePrivate CamelKolabIMAPXStorePrivate;
+struct _CamelKolabIMAPXStorePrivate {
+ CamelKolabIMAPXServer *server;
+
+ /* Used for syncronizing get_folder_info.
+ * TODO check whether we can re-use any other lock
+ */
+ GMutex *kolab_finfo_lock;
+
+ CamelKolabImapxMetadata *kmd;
+ KolabFolderTypeID folder_create_type;
+ KolabFolderContextID folder_context;
+ gboolean folder_types_do_care[KOLAB_FOLDER_LAST_TYPE];
+ GList *folder_names_do_care;
+};
+
+#define CAMEL_KOLAB_IMAPX_STORE_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CAMEL_TYPE_KOLAB_IMAPX_STORE, CamelKolabIMAPXStorePrivate))
+
+G_DEFINE_TYPE_WITH_CODE (CamelKolabIMAPXStore,
+ camel_kolab_imapx_store,
+ CAMEL_TYPE_IMAPX_EXTD_STORE,
+ G_IMPLEMENT_INTERFACE (
+ G_TYPE_INITABLE,
+ camel_kolab_imapx_store_initable_init)
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SERVICE,
+ camel_kolab_imapx_store_network_service_init)
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_SUBSCRIBABLE,
+ camel_kolab_imapx_store_subscribable_init))
+
+/*----------------------------------------------------------------------------*/
+/* class functions */
+
+static void
+camel_kolab_imapx_store_init (CamelKolabIMAPXStore *store)
+{
+ CamelKolabIMAPXStore *self = NULL;
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+ gint ii = 0;
+
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+
+ self = store;
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ /* FIXME get the CamelKolabIMAPXServer instance */
+ priv->server = NULL;
+
+ /* folder info lock */
+ priv->kolab_finfo_lock = g_mutex_new ();
+
+ /* metadata db and lookup table */
+ priv->kmd = camel_kolab_imapx_metadata_new ();
+
+ /* default folder type to create (for use in Evo) */
+ priv->folder_create_type = KOLAB_FOLDER_TYPE_EMAIL;
+
+ /* default folder context (for use in Evo) */
+ priv->folder_context = KOLAB_FOLDER_CONTEXT_EMAIL;
+
+ /* folder types to care for with this CamelKolabIMAPXStore
+ * instance.
+ * Default: Email and unknown (so no need to reconfigure
+ * this instance for use in Evo). Needs to be reconfigured
+ * when used in ECal/EBook backends
+ */
+ for (ii = 0; ii < KOLAB_FOLDER_LAST_TYPE; ii++)
+ priv->folder_types_do_care[ii] = FALSE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_UNKNOWN] = TRUE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL] = TRUE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_INBOX] = TRUE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_DRAFTS] = TRUE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_SENTITEMS] = TRUE;
+ priv->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_JUNKEMAIL] = TRUE;
+
+ priv->folder_names_do_care = NULL;
+}
+
+static void
+camel_kolab_imapx_store_dispose (GObject *object)
+{
+ CamelKolabIMAPXStore *self = NULL;
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (object));
+
+ self = CAMEL_KOLAB_IMAPX_STORE (object);
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ if (priv->server != NULL) {
+ g_object_unref (priv->server);
+ priv->server = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (camel_kolab_imapx_store_parent_class)->dispose (object);
+}
+
+static void
+camel_kolab_imapx_store_finalize (GObject *object)
+{
+ CamelKolabIMAPXStore *self = NULL;
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (object));
+
+ self = CAMEL_KOLAB_IMAPX_STORE (object);
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ while (! g_mutex_trylock (priv->kolab_finfo_lock));
+ g_mutex_unlock (priv->kolab_finfo_lock);
+ g_mutex_free (priv->kolab_finfo_lock);
+
+ camel_kolab_imapx_metadata_free (priv->kmd);
+
+ if (priv->folder_names_do_care != NULL) {
+ GList *list_ptr = priv->folder_names_do_care;
+ while (list_ptr != NULL) {
+ g_free (list_ptr);
+ list_ptr = g_list_next (list_ptr);
+ }
+ g_free (priv->folder_names_do_care);
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (camel_kolab_imapx_store_parent_class)->finalize (object);
+}
+
+static gchar*
+camel_kolab_imapx_store_get_name (CamelService *service,
+ gboolean brief)
+{
+ CamelNetworkSettings *network_settings = NULL;
+ CamelSettings *settings = NULL;
+ const gchar *host = NULL;
+ const gchar *user = NULL;
+ gchar *name = NULL;
+
+ /* TODO type-check that we get CamelKolab* instances here */
+
+ g_assert (CAMEL_IS_SERVICE (service));
+ settings = camel_service_get_settings (service);
+
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+ host = camel_network_settings_get_host (network_settings);
+ user = camel_network_settings_get_user (network_settings);
+
+ if (brief)
+ name = g_strdup_printf (_("Kolab server %s"),
+ host);
+ else
+ name = g_strdup_printf (_("Kolab service for user %s on host %s"),
+ user, host);
+ return name;
+}
+
+static gboolean
+camel_kolab_imapx_store_connect_sync (CamelService *service,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* TODO type-check that we get CamelKolab* instances here */
+
+ g_assert (CAMEL_IS_SERVICE (service));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static gboolean
+camel_kolab_imapx_store_disconnect_sync (CamelService *service,
+ gboolean clean,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* TODO type-check that we get CamelKolab* instances here */
+
+ g_assert (CAMEL_IS_SERVICE (service));
+ (void)clean; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static CamelAuthenticationResult
+camel_kolab_imapx_store_authenticate_sync (CamelService *service,
+ const gchar *mechanism,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* TODO type-check that we get CamelKolab* instances here */
+
+ g_assert (CAMEL_IS_SERVICE (service));
+ (void)mechanism; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, CAMEL_AUTHENTICATION_ERROR);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return CAMEL_AUTHENTICATION_ERROR;
+}
+
+static GList*
+camel_kolab_imapx_store_query_auth_types_sync (CamelService *service,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* TODO type-check that we get CamelKolab* instances here */
+
+ g_assert (CAMEL_IS_SERVICE (service));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static guint
+camel_kolab_imapx_store_name_hash (gconstpointer key)
+{
+ if (g_ascii_strcasecmp (key, "INBOX") == 0)
+ return g_str_hash ("INBOX");
+ else
+ return g_str_hash (key);
+}
+
+static gint
+camel_kolab_imapx_store_name_equal (gconstpointer a,
+ gconstpointer b)
+{
+ gconstpointer aname = a, bname = b;
+
+ if (g_ascii_strcasecmp(a, "INBOX") == 0)
+ aname = "INBOX";
+ if (g_ascii_strcasecmp(b, "INBOX") == 0)
+ bname = "INBOX";
+ return g_str_equal (aname, bname);
+}
+
+static gboolean
+camel_kolab_imapx_store_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *finfo,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert (finfo != NULL);
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static CamelFolder*
+camel_kolab_imapx_store_get_folder_sync (CamelStore *store,
+ const gchar *foldername,
+ CamelStoreGetFolderFlags flags,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)foldername; /* FIXME */
+ (void)flags; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static CamelFolderInfo*
+camel_kolab_imapx_store_get_folder_info_sync (CamelStore *store,
+ const gchar *top,
+ CamelStoreGetFolderInfoFlags flags,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)top; /* FIXME */ /* top may be NULL */
+ (void)flags; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static CamelFolder*
+camel_kolab_imapx_store_get_junk_folder_sync (CamelStore *store,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static CamelFolder*
+camel_kolab_imapx_store_get_trash_folder_sync (CamelStore *store,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static CamelFolderInfo*
+camel_kolab_imapx_store_create_folder_sync (CamelStore *store,
+ const gchar *parentname,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)parentname; /* FIXME */
+ (void)foldername; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static gboolean
+camel_kolab_imapx_store_delete_folder_sync (CamelStore *store,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)foldername; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static gboolean
+camel_kolab_imapx_store_rename_folder_sync (CamelStore *store,
+ const gchar *foldername_old,
+ const gchar *foldername_new,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)foldername_old; /* FIXME */
+ (void)foldername_new; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static gboolean
+camel_kolab_imapx_store_noop_sync (CamelStore *store,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+/*----------------------------------------------------------------------------*/
+/* interface functions */
+
+static gboolean
+camel_kolab_imapx_store_initable_initialize (GInitable *initable,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (initable));
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static const gchar*
+camel_kolab_imapx_store_get_service_name (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
+{
+ g_assert (CAMEL_IS_NETWORK_SERVICE (service));
+ (void)method; /* FIXME */
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+static guint16
+camel_kolab_imapx_store_get_default_port (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
+{
+ g_assert (CAMEL_IS_NETWORK_SERVICE (service));
+ (void)method; /* FIXME */
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return 0;
+}
+
+static gboolean
+camel_kolab_imapx_store_folder_is_subscribed (CamelSubscribable *subscribable,
+ const gchar *foldername)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (subscribable));
+ (void)foldername; /* FIXME */
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static gboolean
+camel_kolab_imapx_store_subscribe_folder_sync (CamelSubscribable *subscribable,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (subscribable));
+ (void)foldername; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static gboolean
+camel_kolab_imapx_store_unsubscribe_folder_sync (CamelSubscribable *subscribable,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (subscribable));
+ (void)foldername; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+static void
+camel_kolab_imapx_store_initable_init (GInitableIface *interface)
+{
+ parent_initable_interface = g_type_interface_peek_parent (interface);
+ interface->init = camel_kolab_imapx_store_initable_initialize;
+}
+
+static void
+camel_kolab_imapx_store_network_service_init (CamelNetworkServiceInterface *interface)
+{
+ interface->get_service_name = camel_kolab_imapx_store_get_service_name;
+ interface->get_default_port = camel_kolab_imapx_store_get_default_port;
+}
+
+static void
+camel_kolab_imapx_store_subscribable_init (CamelSubscribableInterface *interface)
+{
+ interface->folder_is_subscribed = camel_kolab_imapx_store_folder_is_subscribed;
+ interface->subscribe_folder_sync = camel_kolab_imapx_store_subscribe_folder_sync;
+ interface->unsubscribe_folder_sync = camel_kolab_imapx_store_unsubscribe_folder_sync;
+}
+
+/*----------------------------------------------------------------------------*/
+/* class initialization */
+
+static void
+camel_kolab_imapx_store_class_init (CamelKolabIMAPXStoreClass *klass)
+{
+ GObjectClass *object_class;
+ CamelServiceClass *service_class;
+ CamelStoreClass *store_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (CamelKolabIMAPXStorePrivate));
+ object_class->dispose = camel_kolab_imapx_store_dispose;
+ object_class->finalize = camel_kolab_imapx_store_finalize;
+
+ service_class = CAMEL_SERVICE_CLASS (klass);
+ service_class->settings_type = CAMEL_TYPE_KOLAB_IMAPX_SETTINGS;
+ service_class->get_name = camel_kolab_imapx_store_get_name;
+ service_class->connect_sync = camel_kolab_imapx_store_connect_sync;
+ service_class->disconnect_sync = camel_kolab_imapx_store_disconnect_sync;
+ service_class->authenticate_sync = camel_kolab_imapx_store_authenticate_sync;
+ service_class->query_auth_types_sync = camel_kolab_imapx_store_query_auth_types_sync;
+
+ store_class = CAMEL_STORE_CLASS (klass);
+ store_class->hash_folder_name = camel_kolab_imapx_store_name_hash;
+ store_class->compare_folder_name = camel_kolab_imapx_store_name_equal;
+ store_class->can_refresh_folder = camel_kolab_imapx_store_can_refresh_folder;
+ store_class->free_folder_info = camel_store_free_folder_info_full;
+ store_class->get_folder_sync = camel_kolab_imapx_store_get_folder_sync;
+ store_class->get_folder_info_sync = camel_kolab_imapx_store_get_folder_info_sync;
+ store_class->get_junk_folder_sync = camel_kolab_imapx_store_get_junk_folder_sync;
+ store_class->get_trash_folder_sync = camel_kolab_imapx_store_get_trash_folder_sync;
+ store_class->create_folder_sync = camel_kolab_imapx_store_create_folder_sync;
+ store_class->delete_folder_sync = camel_kolab_imapx_store_delete_folder_sync;
+ store_class->rename_folder_sync = camel_kolab_imapx_store_rename_folder_sync;
+ store_class->noop_sync = camel_kolab_imapx_store_noop_sync;
+}
+
+/*----------------------------------------------------------------------------*/
+/* API functions */
+
+CamelKolabIMAPXServer*
+camel_kolab_imapx_store_get_server (CamelKolabIMAPXStore *store,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)foldername; /* FIXME */
+ g_assert (G_IS_CANCELLABLE (cancellable));
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
+
+gboolean
+camel_kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *store,
+ KolabFolderTypeID type_id)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert ((type_id > KOLAB_FOLDER_TYPE_UNKNOWN) &&
+ (type_id < KOLAB_FOLDER_LAST_TYPE));
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+gboolean
+camel_kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *store,
+ KolabFolderContextID context)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ g_assert ((context > KOLAB_FOLDER_CONTEXT_INVAL) &&
+ (context < KOLAB_FOLDER_LAST_CONTEXT));
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return FALSE;
+}
+
+KolabFolderTypeID
+camel_kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *store,
+ const gchar *foldername,
+ GError **err)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+ (void)foldername; /* FIXME */
+ g_return_val_if_fail (err == NULL || *err == NULL, KOLAB_FOLDER_TYPE_INVAL);
+
+ /* FIXME implement me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return KOLAB_FOLDER_TYPE_INVAL;
+}
+
+GList*
+camel_kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *store)
+{
+ g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (store));
+
+ /* FIXME remove me */
+ g_error ("%s: FIXME implement me", __func__);
+
+ return NULL;
+}
/*----------------------------------------------------------------------------*/
-/* Service class construction */
+/*----------------------------------------------------------------------------*/
+
+
+
+#if 0
static void
kolab_imapx_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
CamelURL *url,
- CamelException *ex)
+ GError **err)
{
CamelKolabIMAPXStore *store = NULL;
gboolean metadata_ok = FALSE;
- CamelException *tmp_ex = NULL;
GError *tmp_err = NULL;
g_assert (CAMEL_IS_SERVICE (service));
g_assert (CAMEL_IS_SESSION (session));
g_assert (provider != NULL);
g_assert (url != NULL);
- g_assert (ex != NULL);
-
- tmp_ex = camel_exception_new ();
+ g_return_if_fail (err == NULL || *err == NULL);
(CAMEL_SERVICE_CLASS (parent_class))->construct (service,
session,
provider,
url,
- tmp_ex);
- if (camel_exception_is_set (tmp_ex)) {
- camel_exception_xfer (ex, tmp_ex);
+ tmp_err);
+ if (tmp_err != NULL) {
+ g_propagate_error (err, tmp_err);
return;
}
@@ -223,8 +868,8 @@ kolab_imapx_folder_info_build_restricted (CamelService *service,
self_fi->child->parent = self_fi;
if ((self->folder_context != KOLAB_FOLDER_CONTEXT_EMAIL) &&
do_care[folder_type]) {
- self->folder_names_do_care = g_list_prepend (self->folder_names_do_care,
- g_strdup (self_fi->full_name));
+ self->folder_names_do_care = g_list_prepend (self->folder_names_do_care,
+ g_strdup (self_fi->full_name));
}
if (!do_care[folder_type]) {
self_fi->flags |= CAMEL_FOLDER_NOSELECT;
@@ -266,16 +911,16 @@ kolab_imapx_get_folder_info (CamelStore *store,
g_warning ("%s: aborted.", __func__);
if (camel_exception_is_set (tmp_ex))
camel_exception_xfer (ex, tmp_ex);
- else
+ else
camel_exception_free (tmp_ex);
g_mutex_unlock (ikstore->kolab_finfo_lock);
return NULL;
}
k_fi = kolab_imapx_folder_info_build_restricted (service,
- fi,
- ikstore->kmd,
- ikstore->folder_types_do_care);
+ fi,
+ ikstore->kmd,
+ ikstore->folder_types_do_care);
camel_store_free_folder_info (store, fi);
g_mutex_unlock (ikstore->kolab_finfo_lock);
@@ -339,9 +984,9 @@ kolab_imapx_create_folder (CamelStore *store,
}
k_fi = kolab_imapx_folder_info_build_restricted (service,
- fi,
- ikstore->kmd,
- ikstore->folder_types_do_care);
+ fi,
+ ikstore->kmd,
+ ikstore->folder_types_do_care);
camel_store_free_folder_info (store, fi);
return k_fi;
}
@@ -513,7 +1158,7 @@ camel_kolab_imapx_store_finalize (CamelObject* object)
list_ptr = g_list_next (list_ptr);
}
g_free (store->folder_names_do_care);
- }
+ }
g_debug ("%s: done", __func__);
}
@@ -571,31 +1216,31 @@ kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *store,
store->folder_context = context;
switch (context) {
- case KOLAB_FOLDER_CONTEXT_EMAIL:
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_UNKNOWN] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_INBOX] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_DRAFTS] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_SENTITEMS] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_JUNKEMAIL] = TRUE;
- break;
- case KOLAB_FOLDER_CONTEXT_CALENDAR:
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EVENT] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_EVENT_DEFAULT] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_JOURNAL] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_JOURNAL_DEFAULT] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_TASK] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_TASK_DEFAULT] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_NOTE] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_NOTE_DEFAULT] = TRUE;
- break;
- case KOLAB_FOLDER_CONTEXT_CONTACT:
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_CONTACT] = TRUE;
- store->folder_types_do_care[KOLAB_FOLDER_TYPE_CONTACT_DEFAULT] = TRUE;
- break;
- default:
- /* can't happen */
- g_assert_not_reached ();
+ case KOLAB_FOLDER_CONTEXT_EMAIL:
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_UNKNOWN] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_INBOX] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_DRAFTS] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_SENTITEMS] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EMAIL_JUNKEMAIL] = TRUE;
+ break;
+ case KOLAB_FOLDER_CONTEXT_CALENDAR:
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EVENT] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_EVENT_DEFAULT] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_JOURNAL] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_JOURNAL_DEFAULT] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_TASK] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_TASK_DEFAULT] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_NOTE] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_NOTE_DEFAULT] = TRUE;
+ break;
+ case KOLAB_FOLDER_CONTEXT_CONTACT:
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_CONTACT] = TRUE;
+ store->folder_types_do_care[KOLAB_FOLDER_TYPE_CONTACT_DEFAULT] = TRUE;
+ break;
+ default:
+ /* can't happen */
+ g_assert_not_reached ();
}
return TRUE;
@@ -680,4 +1325,4 @@ kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *store)
return folder_list;
}
-/*----------------------------------------------------------------------------*/
+#endif
diff --git a/src/camel/camel-kolab-imapx-store.h b/src/camel/camel-kolab-imapx-store.h
index 7092425..722d521 100644
--- a/src/camel/camel-kolab-imapx-store.h
+++ b/src/camel/camel-kolab-imapx-store.h
@@ -30,58 +30,81 @@
/*----------------------------------------------------------------------------*/
-#include <camel/camel-types.h>
-#include <camel/camel-store.h>
-#include <camel/camel-offline-store.h>
+#include <glib.h>
+#include <glib-object.h>
-#include <camel/providers/imapx/camel-imapx-store.h>
+#include <libekolabutil/camel-system-headers.h>
+#include <libekolabutil/kolab-util-folder.h>
+
+#include <camel/providers/imapx/camel-imapx-extd-store.h>
#include "camel-kolab-imapx-metadata.h"
+#include "camel-kolab-imapx-server.h"
/*----------------------------------------------------------------------------*/
+/* GObject macros */
+
+#define CAMEL_TYPE_KOLAB_IMAPX_STORE \
+ (camel_kolab_imapx_store_get_type ())
+#define CAMEL_KOLAB_IMAPX_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_KOLAB_IMAPX_STORE, CamelKolabIMAPXStore))
+#define CAMEL_KOLAB_IMAPX_STORE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_KOLAB_IMAPX_STORE, CamelKolabIMAPXStoreClass))
+#define CAMEL_IS_KOLAB_IMAPX_STORE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_KOLAB_IMAPX_STORE))
+#define CAMEL_IS_KOLAB_IMAPX_STORE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_KOLAB_IMAPX_STORE))
+#define CAMEL_KOLAB_IMAPX_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_KOLAB_IMAPX_STORE, CamelKolabIMAPXStoreClass))
-#define CAMEL_KOLAB_IMAPX_STORE_TYPE (camel_kolab_imapx_store_get_type ())
-#define CAMEL_KOLAB_IMAPX_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_KOLAB_IMAPX_STORE_TYPE, CamelKolabIMAPXStore))
-#define CAMEL_KOLAB_IMAPX_STORE_CLASS(klass) (CAMEL_CHECK_CLASS_CAST ((klass), CAMEL_KOLAB_IMAPX_STORE_TYPE, CamelKolabIMAPXStoreClass))
-#define CAMEL_IS_KOLAB_IMAPX_STORE(obj) (CAMEL_CHECK_TYPE((obj), CAMEL_KOLAB_IMAPX_STORE_TYPE))
G_BEGIN_DECLS
-/* We're a direct descendant of CamelIMAPXStore */
-
-typedef struct {
- CamelIMAPXStore parent_object;
+/* We're a descendant of CamelIMAPXExtdStore */
- /* Used for syncronizing get_folder_info. Check for re-use of any other lock. At the
- moment, could not find anything suitable for this */
- GMutex *kolab_finfo_lock;
+typedef struct _CamelKolabIMAPXStore CamelKolabIMAPXStore;
+typedef struct _CamelKolabIMAPXStoreClass CamelKolabIMAPXStoreClass;
- CamelKolabIMAPXMetaData *kmd;
- KolabFolderTypeID folder_create_type;
- KolabFolderContextID folder_context;
- gboolean folder_types_do_care[KOLAB_FOLDER_LAST_TYPE];
- GList *folder_names_do_care;
-} CamelKolabIMAPXStore;
+struct _CamelKolabIMAPXStore {
+ CamelIMAPXExtdStore parent;
+};
-typedef struct {
+struct _CamelKolabIMAPXStoreClass {
CamelIMAPXStoreClass parent_class;
+};
-} CamelKolabIMAPXStoreClass;
+GType camel_kolab_imapx_store_get_type (void);
-/* Standard Camel function */
-CamelType camel_kolab_imapx_store_get_type (void);
+/* CamelServer getter */
+CamelKolabIMAPXServer*
+camel_kolab_imapx_store_get_server (CamelKolabIMAPXStore *store,
+ const gchar *foldername,
+ GCancellable *cancellable,
+ GError **err);
/* Kolab extension: set type for newly created folders */
-gboolean kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *store, KolabFolderTypeID type_id);
+gboolean
+camel_kolab_imapx_store_set_folder_creation_type (CamelKolabIMAPXStore *store,
+ KolabFolderTypeID type_id);
-/* Kolab extension: set the folder context (email, calendar, contacts (defaults to email))*/
-gboolean kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *store, KolabFolderContextID context);
+/* Kolab extension: set the folder context (email, calendar, contacts (defaults to email)) */
+gboolean
+camel_kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *store,
+ KolabFolderContextID context);
/* Kolab extension: get the folder type id */
-KolabFolderTypeID kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *store, const gchar *foldername, GError **err);
+KolabFolderTypeID
+camel_kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *store,
+ const gchar *foldername,
+ GError **err);
-void kolab_imapx_store_logout_sync (CamelKolabIMAPXStore *store);
-GList *kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *store);
+GList*
+camel_kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *store);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]