[evolution-kolab/ek-wip-porting] CamelIMAPXExtdStore: implement local connect_sync() function



commit 88242b15a395938d5f688e09a486e88e0f7da5eb
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Mar 7 16:23:01 2012 +0100

    CamelIMAPXExtdStore: implement local connect_sync() function
    
    * we need our own function here, otherwise we'll not
      get our extended server object when connecting,
      but the parent one (which does not help us here)
    * put the proper object type check back in place

 src/camel/providers/imapx/camel-imapx-extd-store.c |   47 +++++++++++++++-----
 1 files changed, 36 insertions(+), 11 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-extd-store.c b/src/camel/providers/imapx/camel-imapx-extd-store.c
index 69a4d3b..e12690f 100644
--- a/src/camel/providers/imapx/camel-imapx-extd-store.c
+++ b/src/camel/providers/imapx/camel-imapx-extd-store.c
@@ -208,19 +208,14 @@ imapx_extd_store_authenticate_sync (CamelService *service,
 	istore = CAMEL_IMAPX_STORE (service);
 
 	/* CamelIMAPXConnManager sets this before calling
-	 * camel_imapx_server_connect()(), and then clears it
+	 * 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,
@@ -229,6 +224,31 @@ imapx_extd_store_authenticate_sync (CamelService *service,
 	                                             err);
 }
 
+static gboolean
+imapx_extd_store_connect_sync (CamelService *service,
+                               GCancellable *cancellable,
+                               GError **err)
+{
+	CamelIMAPXStore *istore = NULL;
+	CamelIMAPXServer *server = NULL;
+
+	g_assert (CAMEL_IS_SERVICE (service));
+	/* cancellable may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	istore = CAMEL_IMAPX_STORE (service);
+	server = camel_imapx_extd_store_get_server (istore,
+	                                            NULL,
+	                                            cancellable,
+	                                            err);
+	if (server != NULL) {
+		g_object_unref (server);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
 static GList*
 imapx_extd_store_query_auth_types_sync (CamelService *service,
                                         GCancellable *cancellable,
@@ -532,10 +552,15 @@ imapx_extd_store_get_server (CamelIMAPXStore *self,
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
-	server = camel_imapx_store_get_server (self,
-	                                       foldername,
-	                                       cancellable,
-	                                       &tmp_err);
+	camel_service_lock (CAMEL_SERVICE (self), CAMEL_SERVICE_REC_CONNECT_LOCK);
+
+	server = camel_imapx_extd_conn_manager_get_connection (self->con_man,
+	                                                       foldername,
+	                                                       cancellable,
+	                                                       &tmp_err);
+
+	camel_service_unlock (CAMEL_SERVICE (self), CAMEL_SERVICE_REC_CONNECT_LOCK);
+
 	if (server == NULL) {
 		g_propagate_error (err, tmp_err);
 		return NULL;
@@ -717,7 +742,7 @@ camel_imapx_extd_store_class_init (CamelIMAPXExtdStoreClass *klass)
 
 	service_class->settings_type = CAMEL_TYPE_IMAPX_SETTINGS; /* maybe need to get our own here */
 	service_class->get_name = parent_service_class->get_name;
-	service_class->connect_sync = parent_service_class->connect_sync;
+	service_class->connect_sync = imapx_extd_store_connect_sync;
 	service_class->disconnect_sync = parent_service_class->disconnect_sync;
 	service_class->authenticate_sync = imapx_extd_store_authenticate_sync;
 	service_class->query_auth_types_sync = imapx_extd_store_query_auth_types_sync;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]