[evolution-ews/gnome-3-4] Bug #677007 - Add Basic authentication type



commit 8b744e516720db3fc21d138f2246af8853c0cc41
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 11 14:27:04 2012 +0200

    Bug #677007 - Add Basic authentication type

 .../exchange-ews-account-listener.c                |    1 +
 .../exchange-ews-account-out-of-office.c           |    4 +++-
 .../exchange-ews-account-setup.c                   |   13 +++++++++++--
 src/addressbook/e-book-backend-ews.c               |   14 ++++++++++++--
 src/calendar/e-cal-backend-ews.c                   |   10 ++++++++++
 src/camel/camel-ews-provider.c                     |   19 ++++++++++++++-----
 src/camel/camel-ews-store.c                        |    8 +++-----
 src/camel/camel-ews-utils.c                        |    6 +++++-
 src/server/e-ews-connection.c                      |   10 ++++++++--
 src/server/e-ews-connection.h                      |    4 +++-
 src/server/tests/test-autocompletion.c             |    2 +-
 src/server/tests/test-connection.c                 |   12 ++++++------
 src/server/tests/test-createfolder.c               |    2 +-
 src/server/tests/test-cuditem.c                    |    2 +-
 src/server/tests/test-deletefolder.c               |    2 +-
 src/server/tests/test-get-oof-settings.c           |    2 +-
 src/server/tests/test-getattachment.c              |    2 +-
 src/server/tests/test-getdelegate.c                |    2 +-
 src/server/tests/test-set-oof-settings.c           |    2 +-
 src/server/tests/test-syncfolder.c                 |    6 +++---
 src/utils/ews-esource-utils.c                      |    4 +++-
 src/utils/ews-esource-utils.h                      |    3 ++-
 src/utils/ews-test-finditem-query.c                |    2 +-
 23 files changed, 93 insertions(+), 39 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-ews-account-listener.c b/src/account-setup-eplugin/exchange-ews-account-listener.c
index 4bece1e..64d3eb9 100644
--- a/src/account-setup-eplugin/exchange-ews-account-listener.c
+++ b/src/account-setup-eplugin/exchange-ews-account-listener.c
@@ -261,6 +261,7 @@ add_gal_esource (CamelURL *url)
 
 	e_source_set_property (source, "auth", "plain/password");
 	e_source_set_property (source, "completion", "true");
+	e_source_set_property (source, "ews-auth-type", camel_url_get_param (url, "auth"));
 
 	/* add the source to group and sync */
 	group = ews_esource_utils_ensure_group (source_list, url);
diff --git a/src/account-setup-eplugin/exchange-ews-account-out-of-office.c b/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
index dbd5fe0..c143125 100644
--- a/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
+++ b/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
@@ -246,6 +246,7 @@ get_connection (EMConfigTargetSettings *target)
 	const gchar *user;
 	gchar *email, *password;
 	GError *error = NULL;
+	gboolean use_ntlm;
 
 	ews_settings = CAMEL_EWS_SETTINGS (target->storage_settings);
 	network_settings = CAMEL_NETWORK_SETTINGS (target->storage_settings);
@@ -255,8 +256,9 @@ get_connection (EMConfigTargetSettings *target)
 	user = camel_network_settings_get_user (network_settings);
 	password = get_password (target->storage_settings);
 	email = target->email_address;
+	use_ntlm = g_strcmp0 ("PLAIN", camel_network_settings_get_auth_mechanism (network_settings)) != 0;
 
-	cnc = e_ews_connection_new (host_url, user, password, NULL, NULL, &error);
+	cnc = e_ews_connection_new (host_url, user, password, use_ntlm, NULL, NULL, &error);
 
 	if (!cnc) {
 		g_warning ("Error in connection: %s\n", error->message);
diff --git a/src/account-setup-eplugin/exchange-ews-account-setup.c b/src/account-setup-eplugin/exchange-ews-account-setup.c
index 9a2bbf3..cc5738d 100644
--- a/src/account-setup-eplugin/exchange-ews-account-setup.c
+++ b/src/account-setup-eplugin/exchange-ews-account-setup.c
@@ -182,12 +182,19 @@ validate_credentials (GtkWidget *widget,
 	password = get_password (target_account);
 	/*Can there be a account without password ?*/
 	if (password && *password) {
+		CamelNetworkSettings *network_settings;
+		gboolean use_ntlm;
+
+		network_settings = CAMEL_NETWORK_SETTINGS (ews_settings);
+		use_ntlm = g_strcmp0 ("PLAIN", camel_network_settings_get_auth_mechanism (network_settings)) != 0;
+
 		e_ews_autodiscover_ws_url (
 			autodiscover_callback, cbdata,
 			target_account->email_address,
 			password,
 			camel_ews_settings_get_hosturl (ews_settings),
-			camel_network_settings_get_user (CAMEL_NETWORK_SETTINGS (ews_settings)));
+			camel_network_settings_get_user (network_settings),
+			use_ntlm);
 	}
 	g_free (password);
 }
@@ -511,6 +518,7 @@ fetch_button_clicked_cb (GtkButton *button,
 	const gchar *oab_url;
 	const gchar *user;
 	gchar *password;
+	gboolean use_ntlm;
 
 	cancellable = g_cancellable_new ();
 
@@ -531,9 +539,10 @@ fetch_button_clicked_cb (GtkButton *button,
 	oab_url = camel_ews_settings_get_oaburl (ews_settings);
 	user = camel_network_settings_get_user (network_settings);
 	password = get_password (target);
+	use_ntlm = g_strcmp0 ("PLAIN", camel_network_settings_get_auth_mechanism (network_settings)) != 0;
 
 	/* pass user name while creating connection  to fetch oals */
-	cnc = e_ews_connection_new (oab_url, user, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (oab_url, user, password, use_ntlm, NULL, NULL, NULL);
 	cbdata->cancellable = cancellable;
 	e_ews_connection_get_oal_list_start (cnc, ews_oal_list_ready, cancellable, cbdata);
 
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 6b27f31..7ea9d0f 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -1637,6 +1637,15 @@ exit:
 	return ret;
 }
 
+static gboolean
+ews_book_backend_get_use_ntlm (EBookBackendEws *cbews)
+{
+	ESource *source;
+
+	source = e_backend_get_source (E_BACKEND (cbews));
+	return g_strcmp0 ("PLAIN", e_source_get_property (source, "ews-auth-type")) != 0;
+}
+
 static gchar *
 ews_download_full_gal (EBookBackendEws *cbews,
                        EwsOALDetails *full,
@@ -1655,7 +1664,7 @@ ews_download_full_gal (EBookBackendEws *cbews,
 	cache_dir = e_book_backend_get_cache_dir (E_BOOK_BACKEND (cbews));
 	comp_cache_file = g_build_filename (cache_dir, full->filename, NULL);
 
-	oab_cnc = e_ews_connection_new (full_url, priv->username, priv->password, NULL, NULL, NULL);
+	oab_cnc = e_ews_connection_new (full_url, priv->username, priv->password, ews_book_backend_get_use_ntlm (cbews), NULL, NULL, NULL);
 	if (!e_ews_connection_download_oal_file (oab_cnc, comp_cache_file, NULL, NULL, cancellable, error))
 		goto exit;
 
@@ -1808,7 +1817,7 @@ ebews_start_gal_sync (gpointer data)
 	priv = cbews->priv;
 
 	cancellable = g_cancellable_new ();
-	oab_cnc = e_ews_connection_new (priv->oab_url, priv->username, priv->password, NULL, NULL, NULL);
+	oab_cnc = e_ews_connection_new (priv->oab_url, priv->username, priv->password, ews_book_backend_get_use_ntlm (cbews), NULL, NULL, NULL);
 
 	d(printf ("Ewsgal: Fetching oal full details file \n");)
 
@@ -2686,6 +2695,7 @@ e_book_backend_ews_authenticate_user (EBookBackend *backend,
 
 	cnc = e_ews_connection_new (host_url, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME),
 					  e_credentials_peek (credentials, E_CREDENTIALS_KEY_PASSWORD),
+					  ews_book_backend_get_use_ntlm (ebews),
 					  NULL, NULL, &error);
 
 	if ((read_only && !strcmp (read_only, "true")) || priv->is_gal) {
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index f50b18d..7de2bfb 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -528,6 +528,15 @@ add_comps_to_item_id_hash (ECalBackendEws *cbews)
 }
 
 static gboolean
+ews_cal_backend_get_use_ntlm (ECalBackendEws *cbews)
+{
+	ESource *source;
+
+	source = e_backend_get_source (E_BACKEND (cbews));
+	return g_strcmp0 ("PLAIN", e_source_get_property (source, "ews-auth-type")) != 0;
+}
+
+static gboolean
 connect_to_server (ECalBackendEws *cbews,
                    const gchar *username,
                    const gchar *password,
@@ -556,6 +565,7 @@ connect_to_server (ECalBackendEws *cbews,
 
 		host_url = e_source_get_property (esource, "hosturl");
 		cnc = e_ews_connection_new (host_url, username, password,
+						ews_cal_backend_get_use_ntlm (cbews),
 						  NULL, NULL, error);
 
 		fid = g_new0 (EwsFolderId, 1);
diff --git a/src/camel/camel-ews-provider.c b/src/camel/camel-ews-provider.c
index 557b38b..4903a06 100644
--- a/src/camel/camel-ews-provider.c
+++ b/src/camel/camel-ews-provider.c
@@ -82,23 +82,32 @@ static CamelProvider ews_provider = {
 	/* ... */
 };
 
-/*TODO support more auth types */
-CamelServiceAuthType camel_ews_password_authtype = {
-	N_("Password"),
+CamelServiceAuthType camel_ews_ntlm_authtype = {
+	N_("NTLM"),
 
 	N_("This option will connect to the Exchange server using a "
-	   "plaintext password."),
+	   "plaintext password with NTLM authentication."),
 
 	"",
 	TRUE
 };
 
+CamelServiceAuthType camel_ews_basic_authtype = {
+	N_("Basic"),
+
+	N_("This option will connect to the Exchange server using a "
+	   "plaintext password with Basic authentication."),
+
+	"PLAIN",
+	TRUE
+};
+
 void
 camel_provider_module_init (void)
 {
 	ews_provider.url_hash = ews_url_hash;
 	ews_provider.url_equal = ews_url_equal;
-	ews_provider.authtypes = g_list_prepend (ews_provider.authtypes, &camel_ews_password_authtype);
+	ews_provider.authtypes = g_list_prepend (g_list_prepend (NULL, &camel_ews_basic_authtype), &camel_ews_ntlm_authtype);
 	ews_provider.translation_domain = GETTEXT_PACKAGE;
 
 	ews_provider.object_types[CAMEL_PROVIDER_STORE] =  camel_ews_store_get_type ();
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index 1ca2f38..25f1163 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -68,7 +68,6 @@ struct _CamelEwsStorePrivate {
 	EEwsConnection *cnc;
 };
 
-extern CamelServiceAuthType camel_ews_password_authtype; /*for the query_auth_types function */
 static gboolean	ews_store_construct	(CamelService *service, CamelSession *session,
 					 CamelProvider *provider, GError **error);
 
@@ -295,6 +294,7 @@ ews_connect_sync (CamelService *service,
 	}
 
 	priv->cnc = e_ews_connection_new (hosturl, user, NULL,
+					  g_strcmp0 ("PLAIN", camel_network_settings_get_auth_mechanism (network_settings)) != 0,
 					  G_CALLBACK (ews_store_authenticate), service,
 					  error);
 
@@ -499,11 +499,9 @@ ews_store_query_auth_types_sync (CamelService *service,
                                  GCancellable *cancellable,
                                  GError **error)
 {
-	GList *auth_types = NULL;
+	g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Query for authentication types is not supported"));
 
-	d(printf("in query auth types\n"));
-	auth_types = g_list_prepend (auth_types,  &camel_ews_password_authtype);
-	return auth_types;
+	return NULL;
 }
 
 static CamelFolderInfo * ews_create_folder_sync (CamelStore *store, const gchar *parent_name,const gchar *folder_name, GCancellable *cancellable, GError **error);
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 66f13e0..8b5be9e 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -521,6 +521,7 @@ struct add_esrc_data {
 	gchar *username;
 	gchar *email_id;
 	gchar *hosturl;
+	gchar *ews_auth_type;
 	gint refresh_timeout;
 };
 
@@ -531,7 +532,8 @@ static gboolean ews_do_add_esource (gpointer user_data)
 	ews_esource_utils_add_esource (add_data->folder, add_data->account_uri,
 				       add_data->account_name,
 				       add_data->username, add_data->email_id,
-				       add_data->hosturl, add_data->refresh_timeout);
+				       add_data->hosturl, add_data->refresh_timeout,
+				       add_data->ews_auth_type);
 
 	g_object_unref (add_data->folder);
 	g_free (add_data->account_uri);
@@ -539,6 +541,7 @@ static gboolean ews_do_add_esource (gpointer user_data)
 	g_free (add_data->username);
 	g_free (add_data->email_id);
 	g_free (add_data->hosturl);
+	g_free (add_data->ews_auth_type);
 	g_free (add_data);
 
 	return FALSE;
@@ -587,6 +590,7 @@ sync_created_folders (CamelEwsStore *ews_store,
 			/* Duplicate... for now */
 			add_data->email_id = g_strdup (email);
 			add_data->hosturl = g_strdup (hosturl);
+			add_data->ews_auth_type = g_strdup (camel_network_settings_get_auth_mechanism (network_settings));
 			/* FIXME pass right refresh timeout */
 
 			camel_url_free (url);
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index da3adeb..6c8dc51 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -1190,6 +1190,7 @@ e_ews_connection_find (const gchar *uri,
  * @uri: Exchange server uri
  * @username:
  * @password:
+ * @use_ntlm: Whether to use NTLM authentication; FALSE for Basic
  * @error: Currently unused, but may require in future. Can take NULL value.
  *
  * This does not authenticate to the server. It merely stores the username and password.
@@ -1201,6 +1202,7 @@ EEwsConnection *
 e_ews_connection_new (const gchar *uri,
                       const gchar *username,
                       const gchar *password,
+		      gboolean use_ntlm,
                       GCallback authenticate_cb,
                       gpointer authenticate_ctx,
                       GError **error)
@@ -1225,6 +1227,7 @@ e_ews_connection_new (const gchar *uri,
 
 		if (E_IS_EWS_CONNECTION (cnc)) {
 			g_object_ref (cnc);
+			g_object_set (G_OBJECT (cnc->priv->soup_session), SOUP_SESSION_USE_NTLM, use_ntlm, NULL);
 			g_static_mutex_unlock (&connecting);
 			return cnc;
 		}
@@ -1233,6 +1236,8 @@ e_ews_connection_new (const gchar *uri,
 	/* not found, so create a new connection */
 	cnc = g_object_new (E_TYPE_EWS_CONNECTION, NULL);
 
+	g_object_set (G_OBJECT (cnc->priv->soup_session), SOUP_SESSION_USE_NTLM, use_ntlm, NULL);
+
 	cnc->priv->username = g_strdup (username);
 	cnc->priv->password = g_strdup (password);
 	cnc->priv->uri = g_strdup (uri);
@@ -1519,7 +1524,8 @@ e_ews_autodiscover_ws_url (EEwsAutoDiscoverCallback cb,
                            const gchar *email,
                            const gchar *password,
                            const gchar *ews_url,
-                           const gchar *username)
+                           const gchar *username,
+			   gboolean use_ntlm)
 {
 	struct _autodiscover_data *ad;
 	xmlOutputBuffer *buf;
@@ -1568,7 +1574,7 @@ e_ews_autodiscover_ws_url (EEwsAutoDiscoverCallback cb,
 	url3 = g_strdup_printf ("http%s://%s/autodiscover/autodiscover.xml", use_secure ? "s" : "", domain);
 	url4 = g_strdup_printf ("http%s://autodiscover.%s/autodiscover/autodiscover.xml", use_secure ? "s" : "", domain);
 
-	cnc = e_ews_connection_new (url3, (username && *username) ? username : email, password, NULL, NULL, &error);
+	cnc = e_ews_connection_new (url3, (username && *username) ? username : email, password, use_ntlm, NULL, NULL, &error);
 	if (!cnc) {
 		g_free (url1);
 		g_free (url2);
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index b8aee28..7bea2a0 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -183,6 +183,7 @@ GType		e_ews_connection_get_type	(void);
 EEwsConnection *e_ews_connection_new		(const gchar *uri,
 						 const gchar *username,
 						 const gchar *password,
+						 gboolean use_ntlm,
 						 GCallback authenticate_cb,
 						 gpointer authenticate_ctx,
 						 GError **error);
@@ -200,7 +201,8 @@ void		e_ews_autodiscover_ws_url	(EEwsAutoDiscoverCallback cb,
 						 const gchar *email,
 						 const gchar *password,
 						 const gchar *ews_url,
-						 const gchar *username);
+						 const gchar *username,
+						 gboolean use_ntlm);
 void		e_ews_connection_set_mailbox	(EEwsConnection *cnc,
 						 const gchar *email);
 
diff --git a/src/server/tests/test-autocompletion.c b/src/server/tests/test-autocompletion.c
index de93cf1..af9afef 100644
--- a/src/server/tests/test-autocompletion.c
+++ b/src/server/tests/test-autocompletion.c
@@ -88,7 +88,7 @@ op_test_resolve_names ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 	e_ews_connection_resolve_names_start	(cnc, EWS_PRIORITY_MEDIUM, username,
 						 EWS_SEARCH_AD, NULL, FALSE, resolve_names_cb,
diff --git a/src/server/tests/test-connection.c b/src/server/tests/test-connection.c
index dc9a646..fa4be99 100644
--- a/src/server/tests/test-connection.c
+++ b/src/server/tests/test-connection.c
@@ -52,7 +52,7 @@ con_test_create_new_connection ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	g_print ("\nSuccess : Created a new connection\n");
@@ -123,24 +123,24 @@ con_test_autodiscover ()
 	user_data->test_case = g_strdup ("postive case... \n");
 	g_print ("Testing %s \n", user_data->test_case);
 	user_data->positive_case = TRUE;
-	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, email, password, NULL, NULL);
+	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, email, password, NULL, NULL, TRUE);
 
 	user_data = g_new0 (struct _cb_data, 1);
 	user_data->test_case =	g_strdup ("wrong password... \n");
 	/* It does respond properly with the url, Check it out */
 	user_data->positive_case = TRUE;
 	g_print ("Testing %s \n", user_data->test_case);
-	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, email, "wrongpassword", NULL, NULL);
+	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, email, "wrongpassword", NULL, NULL, TRUE);
 
 	user_data = g_new0 (struct _cb_data, 1);
 	user_data->test_case = g_strdup ("email without domain ... \n");
 	g_print ("Testing %s \n", user_data->test_case);
-	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, "wronguseremail", password, NULL, NULL);
+	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, "wronguseremail", password, NULL, NULL, TRUE);
 
 	user_data = g_new0 (struct _cb_data, 1);
 	user_data->test_case = g_strdup ("wrong email address and password... \n");
 	g_print ("Testing %s \n", user_data->test_case);
-	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, "godknows donknow com", "wrongpassword", NULL, NULL);
+	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, "godknows donknow com", "wrongpassword", NULL, NULL, TRUE);
 
 	user_data->test_case = g_strdup ("wrong user name ... \n");
 	g_print ("Testing %s \n", user_data->test_case);
@@ -150,7 +150,7 @@ con_test_autodiscover ()
 	user_data->test_case = g_strdup ("wrong user name ... \n");
 	g_print ("Testing %s \n", user_data->test_case);
 	user_data->quit = TRUE;
-	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, wrong_username, password, NULL, NULL);
+	e_ews_autodiscover_ws_url (autodiscover_cb, user_data, wrong_username, password, NULL, NULL, TRUE);
 	g_free (wrong_username);
 }
 
diff --git a/src/server/tests/test-createfolder.c b/src/server/tests/test-createfolder.c
index 13dd411..724b598 100644
--- a/src/server/tests/test-createfolder.c
+++ b/src/server/tests/test-createfolder.c
@@ -83,7 +83,7 @@ op_test_create_folder ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 	e_ews_connection_create_folder_start	(cnc, EWS_PRIORITY_MEDIUM, "inbox",
 						 TRUE ,"test",
diff --git a/src/server/tests/test-cuditem.c b/src/server/tests/test-cuditem.c
index d817bd2..1bb4c7b 100644
--- a/src/server/tests/test-cuditem.c
+++ b/src/server/tests/test-cuditem.c
@@ -106,7 +106,7 @@ op_test_create_item ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	//to check how to change to real data
diff --git a/src/server/tests/test-deletefolder.c b/src/server/tests/test-deletefolder.c
index a91e78f..c54a216 100644
--- a/src/server/tests/test-deletefolder.c
+++ b/src/server/tests/test-deletefolder.c
@@ -74,7 +74,7 @@ op_test_delete_folder (gpointer data)
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 	e_ews_connection_delete_folder_start	(cnc, EWS_PRIORITY_MEDIUM, (*fid)->id,
 						 FALSE ,"HardDelete",
diff --git a/src/server/tests/test-get-oof-settings.c b/src/server/tests/test-get-oof-settings.c
index c8f4be0..9eeaafb 100644
--- a/src/server/tests/test-get-oof-settings.c
+++ b/src/server/tests/test-get-oof-settings.c
@@ -75,7 +75,7 @@ op_test_get_oof_settings ()
 	g_assert_cmpstr (uri, !=, NULL);
 	g_assert_cmpstr (email, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	e_ews_connection_set_mailbox (cnc, email);
diff --git a/src/server/tests/test-getattachment.c b/src/server/tests/test-getattachment.c
index a763267..9b27233 100644
--- a/src/server/tests/test-getattachment.c
+++ b/src/server/tests/test-getattachment.c
@@ -79,7 +79,7 @@ op_test_get_attachments ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	attachmentid = "AAASAG1hbmR5Lnd1QGludGVsLmNvbQBGAAAAAACdSXexmsgJTpd3WpdX6ulXBwAm9E+BClHfQqEnvCoGvhheAAAAjpb6AACIeDU1D80fTrC3245yXdhOADUAPRB8AAABEgAQAIlh9YZzdzdMtvWW9ZI7+vM=";
diff --git a/src/server/tests/test-getdelegate.c b/src/server/tests/test-getdelegate.c
index 35ff33a..9dfdab2 100644
--- a/src/server/tests/test-getdelegate.c
+++ b/src/server/tests/test-getdelegate.c
@@ -82,7 +82,7 @@ op_test_get_delegate ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 	e_ews_connection_get_delegate_start	(cnc, EWS_PRIORITY_MEDIUM, "abc xyz com",
 						 "true" ,
diff --git a/src/server/tests/test-set-oof-settings.c b/src/server/tests/test-set-oof-settings.c
index b9fbda4..54b60a5 100644
--- a/src/server/tests/test-set-oof-settings.c
+++ b/src/server/tests/test-set-oof-settings.c
@@ -90,7 +90,7 @@ op_test_set_oof_settings ()
 	g_assert_cmpstr (uri, !=, NULL);
 	g_assert_cmpstr (email, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	e_ews_connection_set_mailbox (cnc, email);
diff --git a/src/server/tests/test-syncfolder.c b/src/server/tests/test-syncfolder.c
index b4dd79d..a974212 100644
--- a/src/server/tests/test-syncfolder.c
+++ b/src/server/tests/test-syncfolder.c
@@ -98,7 +98,7 @@ op_test_sync_folder_items ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	e_ews_connection_sync_folder_items_start	(cnc, EWS_PRIORITY_MEDIUM,
@@ -170,7 +170,7 @@ op_test_sync_folder_hierarchy ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	e_ews_connection_sync_folder_hierarchy_start	(cnc, EWS_PRIORITY_MEDIUM,
@@ -230,7 +230,7 @@ op_test_get_item ()
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	ids = g_slist_reverse (ids);
diff --git a/src/utils/ews-esource-utils.c b/src/utils/ews-esource-utils.c
index e10ac3c..c10a57e 100644
--- a/src/utils/ews-esource-utils.c
+++ b/src/utils/ews-esource-utils.c
@@ -108,7 +108,8 @@ ews_esource_utils_add_esource (EEwsFolder *folder,
                                const gchar *username,
                                const gchar *email_id,
                                const gchar *hosturl,
-                               gint refresh_timeout)
+                               gint refresh_timeout,
+			       const gchar *ews_auth_type)
 {
 	ESourceList *source_list;
 	ESourceGroup *group;
@@ -174,6 +175,7 @@ ews_esource_utils_add_esource (EEwsFolder *folder,
 	e_source_set_property (source, "hosturl", hosturl);
 	e_source_set_property (source, "delete", "no");
 	e_source_set_property (source, "offline_sync", "1");
+	e_source_set_property (source, "ews-auth-type", (ews_auth_type && !*ews_auth_type) ? NULL : ews_auth_type);
 	if (ftype != EWS_FOLDER_TYPE_CONTACTS)
 		e_source_set_color_spec (source, "#EEBC60");
 
diff --git a/src/utils/ews-esource-utils.h b/src/utils/ews-esource-utils.h
index 9ebf5d5..193cfaf 100644
--- a/src/utils/ews-esource-utils.h
+++ b/src/utils/ews-esource-utils.h
@@ -40,7 +40,8 @@ ews_esource_utils_add_esource	(EEwsFolder *folder,
 				 const gchar *username,
 				 const gchar *email_id,
 				 const gchar *hosturl,
-				 gint refresh_timeout);
+				 gint refresh_timeout,
+				 const gchar *ews_auth_type);
 gboolean
 ews_esource_utils_remove_esource
 				(const gchar *fid,
diff --git a/src/utils/ews-test-finditem-query.c b/src/utils/ews-test-finditem-query.c
index 2ca6486..6539569 100644
--- a/src/utils/ews-test-finditem-query.c
+++ b/src/utils/ews-test-finditem-query.c
@@ -111,7 +111,7 @@ op_test_finditem_run (void)
 	g_assert_cmpstr (password, !=, NULL);
 	g_assert_cmpstr (uri, !=, NULL);
 
-	cnc = e_ews_connection_new (uri, username, password, NULL, NULL, NULL);
+	cnc = e_ews_connection_new (uri, username, password, TRUE, NULL, NULL, NULL);
 	g_assert (cnc != NULL);
 
 	/*Along with finditem api we check query conversion too*/



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