[evolution-data-server/account-mgmt: 11/40] Adapt EClient to the new ESource API.



commit bad011c72d86b847bcc327c54e395c5f31ebe412
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed May 25 14:18:31 2011 -0400

    Adapt EClient to the new ESource API.

 .../libedataserver/libedataserver-sections.txt     |   79 -----
 libedataserver/e-client-private.h                  |    7 -
 libedataserver/e-client.c                          |  324 --------------------
 libedataserver/e-client.h                          |    6 -
 libedataserver/e-credentials.h                     |    4 +
 5 files changed, 4 insertions(+), 416 deletions(-)
---
diff --git a/docs/reference/libedataserver/libedataserver-sections.txt b/docs/reference/libedataserver/libedataserver-sections.txt
index 83e5e5f..98d631b 100644
--- a/docs/reference/libedataserver/libedataserver-sections.txt
+++ b/docs/reference/libedataserver/libedataserver-sections.txt
@@ -33,7 +33,6 @@ CLIENT_BACKEND_PROPERTY_CAPABILITIES
 CLIENT_BACKEND_PROPERTY_REVISION
 EClient
 e_client_get_source
-e_client_get_uri
 e_client_get_capabilities
 e_client_check_capability
 e_client_check_refresh_supported
@@ -87,13 +86,9 @@ e_client_error_quark
 <FILE>e-credentials</FILE>
 <TITLE>ECredentials</TITLE>
 ECredentials
-E_CREDENTIALS_KEY_USERNAME
 E_CREDENTIALS_KEY_PASSWORD
-E_CREDENTIALS_KEY_AUTH_METHOD
-E_CREDENTIALS_KEY_PROMPT_TITLE
 E_CREDENTIALS_KEY_PROMPT_TEXT
 E_CREDENTIALS_KEY_PROMPT_REASON
-E_CREDENTIALS_KEY_PROMPT_KEY
 E_CREDENTIALS_KEY_PROMPT_FLAGS
 E_CREDENTIALS_KEY_FOREIGN_REQUEST
 ECredentialsPromptFlags
@@ -192,80 +187,6 @@ e_dbus_authenticator_skeleton_get_type
 </SECTION>
 
 <SECTION>
-<FILE>e-dbus-authenticator</FILE>
-<TITLE>EDBusAuthenticator</TITLE>
-EDBusAuthenticator
-e_dbus_authenticator_call_ready_sync
-e_dbus_authenticator_call_ready
-e_dbus_authenticator_call_ready_finish
-e_dbus_authenticator_complete_ready
-e_dbus_authenticator_call_cancel_sync
-e_dbus_authenticator_call_cancel
-e_dbus_authenticator_call_cancel_finish
-e_dbus_authenticator_complete_cancel
-e_dbus_authenticator_call_secret_accepted_sync
-e_dbus_authenticator_call_secret_accepted
-e_dbus_authenticator_call_secret_accepted_finish
-e_dbus_authenticator_complete_secret_accepted
-e_dbus_authenticator_call_secret_rejected_sync
-e_dbus_authenticator_call_secret_rejected
-e_dbus_authenticator_call_secret_rejected_finish
-e_dbus_authenticator_complete_secret_rejected
-e_dbus_authenticator_emit_response
-e_dbus_authenticator_interface_info
-e_dbus_authenticator_override_properties
-<SUBSECTION Standard>
-E_DBUS_AUTHENTICATOR
-E_DBUS_IS_AUTHENTICATOR
-E_DBUS_TYPE_AUTHENTICATOR
-E_DBUS_AUTHENTICATOR_GET_IFACE
-EDBusAuthenticatorIface
-<SUBSECTION Private>
-e_dbus_authenticator_get_type
-</SECTION>
-
-<SECTION>
-<FILE>e-dbus-authenticator-proxy</FILE>
-<TITLE>EDBusAuthenticatorProxy</TITLE>
-EDBusAuthenticatorProxy
-e_dbus_authenticator_proxy_new_sync
-e_dbus_authenticator_proxy_new
-e_dbus_authenticator_proxy_new_finish
-e_dbus_authenticator_proxy_new_for_bus_sync
-e_dbus_authenticator_proxy_new_for_bus
-e_dbus_authenticator_proxy_new_for_bus_finish
-<SUBSECTION Standard>
-E_DBUS_AUTHENTICATOR_PROXY
-E_DBUS_IS_AUTHENTICATOR_PROXY
-E_DBUS_TYPE_AUTHENTICATOR_PROXY
-E_DBUS_AUTHENTICATOR_PROXY_CLASS
-E_DBUS_IS_AUTHENTICATOR_PROXY_CLASS
-E_DBUS_AUTHENTICATOR_PROXY_GET_CLASS
-EDBusAuthenticatorProxyClass
-<SUBSECTION Private>
-EDBusAuthenticatorProxyPrivate
-e_dbus_authenticator_proxy_get_type
-</SECTION>
-
-<SECTION>
-<FILE>e-dbus-authenticator-skeleton</FILE>
-<TITLE>EDBusAuthenticatorSkeleton</TITLE>
-EDBusAuthenticatorSkeleton
-e_dbus_authenticator_skeleton_new
-<SUBSECTION Standard>
-E_DBUS_AUTHENTICATOR_SKELETON
-E_DBUS_IS_AUTHENTICATOR_SKELETON
-E_DBUS_TYPE_AUTHENTICATOR_SKELETON
-E_DBUS_AUTHENTICATOR_SKELETON_CLASS
-E_DBUS_IS_AUTHENTICATOR_SKELETON_CLASS
-E_DBUS_AUTHENTICATOR_SKELETON_GET_CLASS
-EDBusAuthenticatorSkeletonClass
-<SUBSECTION Private>
-EDBusAuthenticatorSkeletonPrivate
-e_dbus_authenticator_skeleton_get_type
-</SECTION>
-
-<SECTION>
 <FILE>e-dbus-object</FILE>
 <TITLE>EDBusObject</TITLE>
 EDBusObject
diff --git a/libedataserver/e-client-private.h b/libedataserver/e-client-private.h
index 23736d1..72aebea 100644
--- a/libedataserver/e-client-private.h
+++ b/libedataserver/e-client-private.h
@@ -26,7 +26,6 @@
 
 #include "libedataserver/e-credentials.h"
 #include "libedataserver/e-source.h"
-#include "libedataserver/e-source-list.h"
 #include "libedataserver/e-client.h"
 
 G_BEGIN_DECLS
@@ -36,9 +35,7 @@ void		e_client_set_readonly		(EClient *client, gboolean readonly);
 void		e_client_set_online		(EClient *client, gboolean is_online);
 guint32		e_client_register_op		(EClient *client, GCancellable *cancellable);
 void		e_client_unregister_op		(EClient *client, guint32 opid);
-void		e_client_process_authentication	(EClient *client, const ECredentials *credentials);
 
-gboolean	e_client_emit_authenticate	(EClient *client, ECredentials *credentials);
 void		e_client_emit_opened		(EClient *client, const GError *error);
 void		e_client_emit_backend_error	(EClient *client, const gchar *error_msg);
 void		e_client_emit_backend_died	(EClient *client);
@@ -47,10 +44,6 @@ void		e_client_emit_backend_property_changed   (EClient *client, const gchar *pr
 void		e_client_update_backend_property_cache   (EClient *client, const gchar *prop_name, const gchar *prop_value);
 gchar *		e_client_get_backend_property_from_cache (EClient *client, const gchar *prop_name);
 
-ESource *	e_client_util_get_system_source	(ESourceList *source_list);
-gboolean	e_client_util_set_default	(ESourceList *source_list, ESource *source);
-ESource *	e_client_util_get_source_for_uri (ESourceList *source_list, const gchar *uri);
-
 /* protected functions simplifying sync/async calls */
 void		e_client_finish_async_without_dbus (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, gpointer soure_tag, gpointer op_res, GDestroyNotify destroy_op_res);
 GDBusProxy *	e_client_get_dbus_proxy		(EClient *client);
diff --git a/libedataserver/e-client.c b/libedataserver/e-client.c
index 74d7c02..04f65af 100644
--- a/libedataserver/e-client.c
+++ b/libedataserver/e-client.c
@@ -65,7 +65,6 @@ enum {
 };
 
 enum {
-	AUTHENTICATE,
 	OPENED,
 	BACKEND_ERROR,
 	BACKEND_DIED,
@@ -188,7 +187,6 @@ e_client_error_create (EClientError code,
 }
 
 static void client_set_source (EClient *client, ESource *source);
-static void client_handle_authentication (EClient *client, const ECredentials *credentials);
 
 static void
 e_client_init (EClient *client)
@@ -380,16 +378,6 @@ e_client_class_init (EClientClass *class)
 			FALSE,
 			G_PARAM_READABLE));
 
-	signals[AUTHENTICATE] = g_signal_new (
-		"authenticate",
-		G_OBJECT_CLASS_TYPE (class),
-		G_SIGNAL_RUN_LAST,
-		G_STRUCT_OFFSET (EClientClass, authenticate),
-		NULL, NULL,
-		e_gdbus_marshallers_BOOLEAN__POINTER,
-		G_TYPE_BOOLEAN, 1,
-		G_TYPE_POINTER);
-
 	signals[OPENED] = g_signal_new (
 		"opened",
 		G_OBJECT_CLASS_TYPE (class),
@@ -467,29 +455,6 @@ e_client_get_source (EClient *client)
 	return client->priv->source;
 }
 
-/**
- * e_client_get_uri:
- * @client: an #EClient
- *
- * Get the URI that this client has assigned. This string should not be freed.
- *
- * Returns: The URI.
- *
- * Since: 3.2
- **/
-const gchar *
-e_client_get_uri (EClient *client)
-{
-	g_return_val_if_fail (client != NULL, NULL);
-	g_return_val_if_fail (E_IS_CLIENT (client), NULL);
-	g_return_val_if_fail (client->priv != NULL, NULL);
-
-	if (!client->priv->uri)
-		client->priv->uri = e_source_get_uri (e_client_get_source (client));
-
-	return client->priv->uri;
-}
-
 static void
 client_ensure_capabilities (EClient *client)
 {
@@ -855,110 +820,6 @@ e_client_unregister_op (EClient *client,
 	g_static_rec_mutex_unlock (&client->priv->ops_mutex);
 }
 
-static void
-client_handle_authentication (EClient *client,
-                              const ECredentials *credentials)
-{
-	EClientClass *class;
-
-	g_return_if_fail (client != NULL);
-	g_return_if_fail (E_IS_CLIENT (client));
-	g_return_if_fail (credentials != NULL);
-
-	class = E_CLIENT_GET_CLASS (client);
-	g_return_if_fail (class != NULL);
-	g_return_if_fail (class->handle_authentication != NULL);
-
-	return class->handle_authentication (client, credentials);
-}
-
-struct EClientAuthData {
-	EClient *client;
-	ECredentials *credentials;
-};
-
-static gboolean
-client_process_authentication_idle_cb (gpointer user_data)
-{
-	static gboolean processing_one = FALSE;
-	struct EClientAuthData *auth_data = user_data;
-
-	g_return_val_if_fail (auth_data != NULL, FALSE);
-
-	/* there is one currently processing, postpone this request for later */
-	if (processing_one)
-		return TRUE;
-
-	/* no need for locking, this is always main-thread's idle */
-	processing_one = TRUE;
-
-	if (e_client_emit_authenticate (auth_data->client, auth_data->credentials)) {
-		client_handle_authentication (auth_data->client, auth_data->credentials);
-	} else {
-		/* Always pass credentials to backend to finish opening phase.
-		 * Empty username indicates that either user cancelled password prompt
-		 * or there was no authentication callback set.
-		*/
-		e_credentials_set (auth_data->credentials, E_CREDENTIALS_KEY_USERNAME, NULL);
-		client_handle_authentication (auth_data->client, auth_data->credentials);
-
-		if (g_strcmp0 (e_credentials_peek (auth_data->credentials, E_CREDENTIALS_KEY_FOREIGN_REQUEST), "1") != 0) {
-			GError *error;
-
-			error = e_client_error_create (E_CLIENT_ERROR_AUTHENTICATION_REQUIRED, NULL);
-			e_client_emit_opened (auth_data->client, error);
-			g_error_free (error);
-		}
-	}
-
-	e_credentials_free (auth_data->credentials);
-	g_object_unref (auth_data->client);
-	g_free (auth_data);
-
-	processing_one = FALSE;
-
-	return FALSE;
-}
-
-/* Processes authentication request in idle callback. Usual steps are:
- * a) backend sends an auth - required signal
- * b) EClient implementation calls this function
- * c) a new idle callback is run which emits authenticate signal by e_client_emit_authenticate ()
- * d) if anyone responds (returns true), the EClient::handle_authentication
- *    is called from the same idle callback with new credentials
- * e) EClient implementation passes results to backend in the EClient::handle_authentication
-*/
-void
-e_client_process_authentication (EClient *client,
-                                 const ECredentials *credentials)
-{
-	struct EClientAuthData *auth_data;
-
-	g_return_if_fail (client != NULL);
-	g_return_if_fail (E_IS_CLIENT (client));
-
-	auth_data = g_new0 (struct EClientAuthData, 1);
-	auth_data->client = g_object_ref (client);
-	auth_data->credentials = credentials ? e_credentials_new_clone (credentials) : e_credentials_new ();
-
-	g_idle_add (client_process_authentication_idle_cb, auth_data);
-}
-
-gboolean
-e_client_emit_authenticate (EClient *client,
-                            ECredentials *credentials)
-{
-	gboolean handled = FALSE;
-
-	g_return_val_if_fail (client != NULL, FALSE);
-	g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
-	g_return_val_if_fail (credentials != NULL, FALSE);
-
-	g_signal_emit (client, signals[AUTHENTICATE], 0, credentials, &handled);
-
-	return handled;
-}
-
 void
 e_client_emit_opened (EClient *client,
                       const GError *dbus_error)
@@ -1809,191 +1670,6 @@ e_client_util_parse_comma_strings (const gchar *strings)
 	return g_slist_reverse (strs_slist);
 }
 
-/* for each known source calls check_func, which should return TRUE if the required
- * source have been found. Function returns NULL or the source on which was returned
- * TRUE by the check_func. Non - NULL pointer should be unreffed by g_object_unref. */
-static ESource *
-search_known_sources (ESourceList *sources,
-                      gboolean (*check_func) (ESource *source,
-                                              gpointer user_data),
-                      gpointer user_data)
-{
-	ESource *res = NULL;
-	GSList *g;
-
-	g_return_val_if_fail (check_func != NULL, NULL);
-	g_return_val_if_fail (sources != NULL, NULL);
-
-	for (g = e_source_list_peek_groups (sources); g; g = g->next) {
-		ESourceGroup *group = E_SOURCE_GROUP (g->data);
-		GSList *s;
-
-		for (s = e_source_group_peek_sources (group); s; s = s->next) {
-			ESource *source = E_SOURCE (s->data);
-
-			if (check_func (source, user_data)) {
-				res = g_object_ref (source);
-				break;
-			}
-		}
-
-		if (res)
-			break;
-	}
-
-	return res;
-}
-
-static gboolean
-check_uri (ESource *source,
-           gpointer uri)
-{
-	const gchar *suri;
-	gchar *suri2;
-	gboolean res;
-
-	g_return_val_if_fail (source != NULL, FALSE);
-	g_return_val_if_fail (uri != NULL, FALSE);
-
-	suri = e_source_peek_absolute_uri (source);
-
-	if (suri)
-		return g_ascii_strcasecmp (suri, uri) == 0;
-
-	suri2 = e_source_get_uri (source);
-	res = suri2 && g_ascii_strcasecmp (suri2, uri) == 0;
-	g_free (suri2);
-
-	return res;
-}
-
-struct check_system_data
-{
-	const gchar *uri;
-	ESource *uri_source;
-};
-
-static gboolean
-check_system (ESource *source,
-              gpointer data)
-{
-	struct check_system_data *csd = data;
-
-	g_return_val_if_fail (source != NULL, FALSE);
-	g_return_val_if_fail (data != NULL, FALSE);
-
-	if (e_source_get_property (source, "system")) {
-		return TRUE;
-	}
-
-	if (check_uri (source, (gpointer) csd->uri)) {
-		if (csd->uri_source)
-			g_object_unref (csd->uri_source);
-		csd->uri_source = g_object_ref (source);
-	}
-
-	return FALSE;
-}
-
-ESource *
-e_client_util_get_system_source (ESourceList *source_list)
-{
-	struct check_system_data csd;
-	ESource *system_source = NULL;
-
-	g_return_val_if_fail (source_list != NULL, NULL);
-	g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
-
-	csd.uri = "local:system";
-	csd.uri_source = NULL;
-
-	system_source = search_known_sources (source_list, check_system, &csd);
-
-	if (!system_source) {
-		system_source = csd.uri_source;
-		csd.uri_source = NULL;
-	}
-
-	if (csd.uri_source)
-		g_object_unref (csd.uri_source);
-
-	if (!system_source) {
-		/* create a new one, if not found */
-		ESourceGroup *on_this_computer;
-
-		on_this_computer = e_source_list_ensure_group (source_list,
-						       _("On This Computer"),
-						       "local:", TRUE);
-		if (on_this_computer) {
-			GError *error = NULL;
-
-			system_source = e_source_new (_("Personal"), "system");
-			e_source_set_color_spec (system_source, "#BECEDD");
-			e_source_group_add_source (on_this_computer, system_source, -1);
-
-			if (!e_source_list_sync (source_list, &error))
-				g_warning ("Cannot add system source to GConf: %s", error ? error->message : "Unknown error");
-
-			if (error)
-				g_error_free (error);
-		}
-	}
-
-	return system_source;
-}
-
-gboolean
-e_client_util_set_default (ESourceList *source_list,
-                           ESource *source)
-{
-	const gchar *uid;
-	GSList *g;
-
-	g_return_val_if_fail (source_list != NULL, FALSE);
-	g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), FALSE);
-	g_return_val_if_fail (source != NULL, FALSE);
-	g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
-	uid = e_source_peek_uid (source);
-
-	/* make sure the source is actually in the ESourceList.  If
-	 * it's not we don't bother adding it, just return an error */
-	source = e_source_list_peek_source_by_uid (source_list, uid);
-	if (!source)
-		return FALSE;
-
-	/* loop over all the sources clearing out any "default"
-	 * properties we find */
-	for (g = e_source_list_peek_groups (source_list); g; g = g->next) {
-		GSList *s;
-		for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data));
-		     s; s = s->next) {
-			e_source_set_property (E_SOURCE (s->data), "default", NULL);
-		}
-	}
-
-	/* set the "default" property on the source */
-	e_source_set_property (source, "default", "true");
-
-	return TRUE;
-}
-
-ESource *
-e_client_util_get_source_for_uri (ESourceList *source_list,
-                                  const gchar *uri)
-{
-	ESource *source;
-
-	g_return_val_if_fail (source_list != NULL, NULL);
-	g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
-	g_return_val_if_fail (uri != NULL, NULL);
-
-	source = search_known_sources (source_list, check_uri, (gpointer) uri);
-	if (!source)
-		source = e_source_new_with_absolute_uri ("", uri);
-
-	return source;
-}
 
 void
 e_client_finish_async_without_dbus (EClient *client,
diff --git a/libedataserver/e-client.h b/libedataserver/e-client.h
index fced505..fbf642e 100644
--- a/libedataserver/e-client.h
+++ b/libedataserver/e-client.h
@@ -26,7 +26,6 @@
 
 #include <libedataserver/e-credentials.h>
 #include <libedataserver/e-source.h>
-#include <libedataserver/e-source-list.h>
 
 #define E_TYPE_CLIENT		(e_client_get_type ())
 #define E_CLIENT(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CLIENT, EClient))
@@ -210,10 +209,6 @@ struct _EClientClass {
 	gboolean	(* refresh_finish) (EClient *client, GAsyncResult *result, GError **error);
 	gboolean	(* refresh_sync) (EClient *client, GCancellable *cancellable, GError **error);
 
-	void		(* handle_authentication) (EClient *client, const ECredentials *credentials);
-
-	/* signals */
-	gboolean	(* authenticate) (EClient *client, ECredentials *credentials);
 	void		(* opened) (EClient *client, const GError *error);
 	void		(* backend_error) (EClient *client, const gchar *error_msg);
 	void		(* backend_died) (EClient *client);
@@ -223,7 +218,6 @@ struct _EClientClass {
 GType		e_client_get_type			(void);
 
 ESource *	e_client_get_source			(EClient *client);
-const gchar *	e_client_get_uri			(EClient *client);
 const GSList *	e_client_get_capabilities		(EClient *client);
 gboolean	e_client_check_capability		(EClient *client, const gchar *capability);
 gboolean	e_client_check_refresh_supported	(EClient *client);
diff --git a/libedataserver/e-credentials.h b/libedataserver/e-credentials.h
index f771f03..8078fcd 100644
--- a/libedataserver/e-credentials.h
+++ b/libedataserver/e-credentials.h
@@ -19,6 +19,8 @@
  *
  */
 
+#ifndef EDS_DISABLE_DEPRECATED
+
 #ifndef E_CREDENTIALS_H
 #define E_CREDENTIALS_H
 
@@ -168,3 +170,5 @@ guint		e_credentials_util_string_to_prompt_flags (const gchar *prompt_flags_stri
 G_END_DECLS
 
 #endif /* E_CREDENTIALS_H */
+
+#endif /* EDS_DISABLE_DEPRECATED */



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