[evolution-kolab/ek-wip-porting] CamelIMAPXExtdStore: added own code paths for (extended) untagged response handler
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] CamelIMAPXExtdStore: added own code paths for (extended) untagged response handler
- Date: Mon, 23 Jan 2012 21:43:23 +0000 (UTC)
commit 63e91afb78e9b75303762093aa3cec02dbf8bd76
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Jan 23 22:28:03 2012 +0100
CamelIMAPXExtdStore: added own code paths for (extended) untagged response handler
* added own code paths to override the ones leading
to the execution of CamelIMAPXServer::imapx_untagged(),
so that our own modified variant of the function
will be called later on (the functions in CamelIMAPXExtdServer)
* added/changed implementations for connecting and
authenticating to the IMAP server (since these all
end in the untagged response handler)
(this is still WIP, the code paths are not yet
fully used)
src/camel/providers/imapx/camel-imapx-extd-store.c | 121 +++++++++++++++++++-
1 files changed, 117 insertions(+), 4 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-extd-store.c b/src/camel/providers/imapx/camel-imapx-extd-store.c
index 97e472b..323c929 100644
--- a/src/camel/providers/imapx/camel-imapx-extd-store.c
+++ b/src/camel/providers/imapx/camel-imapx-extd-store.c
@@ -55,6 +55,9 @@ static void imapx_extd_store_initable_init (GInitableIface *interface);
static void imapx_extd_store_network_service_init (CamelNetworkServiceInterface *interface);
static void imapx_extd_store_subscribable_init (CamelSubscribableInterface *interface);
+/* externs */
+extern CamelServiceAuthType camel_imapx_password_authtype;
+
G_DEFINE_TYPE_WITH_CODE (CamelIMAPXExtdStore,
camel_imapx_extd_store,
CAMEL_TYPE_IMAPX_STORE,
@@ -142,6 +145,9 @@ extd_store_get_folder_offline (CamelStore *self,
CamelStoreInfo *si = NULL;
const gchar *user_cache_dir = NULL;
+ g_assert (folder_name != NULL);
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
user_cache_dir = camel_service_get_user_cache_dir (service);
si = camel_store_summary_path (CAMEL_STORE_SUMMARY (imapx_store->summary), folder_name);
@@ -181,6 +187,105 @@ extd_store_get_folder_offline (CamelStore *self,
/*----------------------------------------------------------------------------*/
/* class functions */
+static CamelAuthenticationResult
+imapx_extd_store_authenticate_sync (CamelService *service,
+ const gchar *mechanism,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* modified dupe of imapx_authenticate_sync() */
+
+ CamelIMAPXStore *istore = NULL;
+ CamelIMAPXServer *server = NULL;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_STORE (service));
+ /* mechanism may be NULL */
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, CAMEL_AUTHENTICATION_REJECTED);
+
+ istore = CAMEL_IMAPX_STORE (service);
+
+ /* CamelIMAPXConnManager sets this before calling
+ * camel_imapx_server_connect()(), and then clears it
+ * immediately after, all while holding the recursive
+ * connection lock (CAMEL_SERVICE_REC_CONNECT_LOCK).
+ * Otherwise we'd have no way of knowing which server
+ * is trying to authenticate. */
+ server = istore->authenticating_server;
+
+ /* FIXME */
+ g_warning ("%s: FIXME getting CamelIMAPXServer, expected CamelIMAPXExtdServer",
+ __func__);
+#if 0
+ g_return_val_if_fail (CAMEL_IS_IMAPX_EXTD_SERVER (server), CAMEL_AUTHENTICATION_REJECTED);
+#endif
+
+ /* modified */
+ return camel_imapx_extd_server_authenticate (server,
+ mechanism,
+ cancellable,
+ err);
+}
+
+static GList*
+imapx_extd_store_query_auth_types_sync (CamelService *service,
+ GCancellable *cancellable,
+ GError **err)
+{
+ /* modified dupe of imapx_query_auth_types_sync() */
+
+ CamelIMAPXExtdStore *estore = NULL;
+ CamelIMAPXExtdServer *eserver = NULL;
+ CamelServiceAuthType *authtype = NULL;
+ GList *sasl_types = NULL;
+ GList *t = NULL;
+ GList *next = NULL;
+ gboolean connected = FALSE;
+
+ g_assert (CAMEL_IS_IMAPX_EXTD_STORE (service));
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+ estore = CAMEL_IMAPX_EXTD_STORE (service);
+
+ if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (estore))) {
+ g_set_error (err,
+ CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
+ return NULL;
+ }
+
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+
+ eserver = camel_imapx_extd_server_new (estore);
+
+ connected = CAMEL_IMAPX_SERVER (eserver)->stream != NULL;
+ if (!connected)
+ connected = camel_imapx_extd_server_connect_to_server (CAMEL_IMAPX_SERVER (eserver),
+ cancellable,
+ err);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
+ if (!connected)
+ return NULL;
+
+ sasl_types = camel_sasl_authtype_list (FALSE);
+ for (t = sasl_types; t; t = next) {
+ authtype = t->data;
+ next = t->next;
+
+ if (!g_hash_table_lookup (CAMEL_IMAPX_SERVER (eserver)->cinfo->auth_types,
+ authtype->authproto)) {
+ sasl_types = g_list_remove_link (sasl_types, t);
+ g_list_free_1 (t);
+ }
+ }
+
+ g_object_unref (eserver);
+
+ return g_list_prepend (sasl_types, &camel_imapx_password_authtype);
+}
+
static gboolean
imapx_extd_store_can_refresh_folder (CamelStore *self,
CamelFolderInfo *info,
@@ -189,6 +294,7 @@ imapx_extd_store_can_refresh_folder (CamelStore *self,
gboolean can = FALSE;
g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
+ g_assert (info != NULL);
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
can = parent_store_class->can_refresh_folder (self,
@@ -216,13 +322,20 @@ imapx_extd_store_get_folder_sync (CamelStore *self,
g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
g_assert (foldername != NULL);
- (void)cancellable;
+ (void)cancellable; /* FIXME */
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
folder = extd_store_get_folder_offline (self,
foldername,
flags,
err);
+ /* FIXME */
+ g_warning ("%s: FIXME getting CamelIMAPXFolder, expected CamelIMAPXExtdFolder",
+ __func__);
+#if 0
+ if (folder != NULL)
+ g_assert (CAMEL_IS_IMAPX_EXTD_FOLDER (folder));
+#endif
return folder;
}
@@ -437,7 +550,7 @@ imapx_extd_store_op_done (CamelIMAPXStore *self,
const gchar *foldername)
{
g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
- g_assert (CAMEL_IS_IMAPX_SERVER (server));
+ g_assert (CAMEL_IS_IMAPX_EXTD_SERVER (server));
g_assert (foldername != NULL);
camel_imapx_store_op_done (self,
@@ -604,8 +717,8 @@ camel_imapx_extd_store_class_init (CamelIMAPXExtdStoreClass *klass)
service_class->get_name = parent_service_class->get_name;
service_class->connect_sync = parent_service_class->connect_sync;
service_class->disconnect_sync = parent_service_class->disconnect_sync;
- service_class->authenticate_sync = parent_service_class->authenticate_sync;
- service_class->query_auth_types_sync = parent_service_class->query_auth_types_sync;
+ service_class->authenticate_sync = imapx_extd_store_authenticate_sync;
+ service_class->query_auth_types_sync = imapx_extd_store_query_auth_types_sync;
store_class->hash_folder_name = parent_store_class->hash_folder_name;
store_class->compare_folder_name = parent_store_class->compare_folder_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]