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



commit 999e2e03dbfdae6904f3efb0097db4b59178f81b
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                          |  314 --------------------
 libedataserver/e-client.h                          |    6 -
 libedataserver/e-credentials.c                     |  195 +++----------
 libedataserver/e-credentials.h                     |   81 +-----
 6 files changed, 47 insertions(+), 635 deletions(-)
---
diff --git a/docs/reference/libedataserver/libedataserver-sections.txt b/docs/reference/libedataserver/libedataserver-sections.txt
index a5d263d..166faa7 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 0f58720..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,100 +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)
-{
-	struct EClientAuthData *auth_data = user_data;
-
-	g_return_val_if_fail (auth_data != NULL, FALSE);
-
-	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);
-
-	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)
@@ -1799,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.c b/libedataserver/e-credentials.c
index f2cfb62..68d1f01 100644
--- a/libedataserver/e-credentials.c
+++ b/libedataserver/e-credentials.c
@@ -30,8 +30,7 @@
 
 #include "e-credentials.h"
 
-struct _ECredentialsPrivate
-{
+struct _ECredentials {
 	GHashTable *keys;
 	GHashTable *peek_keys;
 };
@@ -62,9 +61,8 @@ e_credentials_new (void)
 	ECredentials *credentials;
 
 	credentials = g_new0 (ECredentials, 1);
-	credentials->priv = g_new0 (ECredentialsPrivate, 1);
-	credentials->priv->keys = g_hash_table_new_full (g_str_hash, key_equal, g_free, (GDestroyNotify) e_credentials_util_safe_free_string);
-	credentials->priv->peek_keys = g_hash_table_new_full (g_str_hash, key_equal, g_free, (GDestroyNotify) e_credentials_util_safe_free_string);
+	credentials->keys = g_hash_table_new_full (g_str_hash, key_equal, g_free, (GDestroyNotify) e_credentials_util_safe_free_string);
+	credentials->peek_keys = g_hash_table_new_full (g_str_hash, key_equal, g_free, (GDestroyNotify) e_credentials_util_safe_free_string);
 
 	return credentials;
 }
@@ -97,7 +95,7 @@ e_credentials_new_strv (const gchar * const *keys)
 
 		/* skip empty and invalid values */
 		if (sep)
-			g_hash_table_insert (credentials->priv->keys, g_strndup (key, sep - key), g_strdup (sep + 1));
+			g_hash_table_insert (credentials->keys, g_strndup (key, sep - key), g_strdup (sep + 1));
 	}
 
 	return credentials;
@@ -161,12 +159,11 @@ e_credentials_new_clone (const ECredentials *credentials)
 	ECredentials *res;
 
 	g_return_val_if_fail (credentials != NULL, NULL);
-	g_return_val_if_fail (credentials->priv != NULL, NULL);
-	g_return_val_if_fail (credentials->priv->keys != NULL, NULL);
+	g_return_val_if_fail (credentials->keys != NULL, NULL);
 
 	res = e_credentials_new ();
 
-	g_hash_table_foreach (credentials->priv->keys, copy_keys_cb, res->priv->keys);
+	g_hash_table_foreach (credentials->keys, copy_keys_cb, res->keys);
 
 	return res;
 }
@@ -184,11 +181,8 @@ e_credentials_free (ECredentials *credentials)
 	if (!credentials)
 		return;
 
-	g_return_if_fail (credentials->priv != NULL);
-
-	g_hash_table_destroy (credentials->priv->keys);
-	g_hash_table_destroy (credentials->priv->peek_keys);
-	g_free (credentials->priv);
+	g_hash_table_destroy (credentials->keys);
+	g_hash_table_destroy (credentials->peek_keys);
 	g_free (credentials);
 }
 
@@ -225,12 +219,11 @@ e_credentials_to_strv (const ECredentials *credentials)
 	GPtrArray *array;
 
 	g_return_val_if_fail (credentials != NULL, NULL);
-	g_return_val_if_fail (credentials->priv != NULL, NULL);
-	g_return_val_if_fail (credentials->priv->keys != NULL, NULL);
+	g_return_val_if_fail (credentials->keys != NULL, NULL);
 
-	array = g_ptr_array_sized_new (g_hash_table_size (credentials->priv->keys) + 1);
+	array = g_ptr_array_sized_new (g_hash_table_size (credentials->keys) + 1);
 
-	g_hash_table_foreach (credentials->priv->keys, add_to_array_cb, array);
+	g_hash_table_foreach (credentials->keys, add_to_array_cb, array);
 
 	/* NULL-terminated */
 	g_ptr_array_add (array, NULL);
@@ -309,19 +302,18 @@ e_credentials_set (ECredentials *credentials,
                    const gchar *value)
 {
 	g_return_if_fail (credentials != NULL);
-	g_return_if_fail (credentials->priv != NULL);
-	g_return_if_fail (credentials->priv->keys != NULL);
-	g_return_if_fail (credentials->priv->peek_keys != NULL);
+	g_return_if_fail (credentials->keys != NULL);
+	g_return_if_fail (credentials->peek_keys != NULL);
 	g_return_if_fail (key != NULL);
 	g_return_if_fail (*key);
 	g_return_if_fail (strchr (key, ':') == NULL);
 
-	g_hash_table_remove (credentials->priv->peek_keys, key);
+	g_hash_table_remove (credentials->peek_keys, key);
 
 	if (!value) {
-		g_hash_table_remove (credentials->priv->keys, key);
+		g_hash_table_remove (credentials->keys, key);
 	} else {
-		g_hash_table_insert (credentials->priv->keys, g_strdup (key), encode_string (value));
+		g_hash_table_insert (credentials->keys, g_strdup (key), encode_string (value));
 	}
 }
 
@@ -342,12 +334,11 @@ e_credentials_get (const ECredentials *credentials,
 	 * e_credentials_util_safe_free_string() when no longer needed. */
 
 	g_return_val_if_fail (credentials != NULL, NULL);
-	g_return_val_if_fail (credentials->priv != NULL, NULL);
-	g_return_val_if_fail (credentials->priv->keys != NULL, NULL);
+	g_return_val_if_fail (credentials->keys != NULL, NULL);
 	g_return_val_if_fail (key != NULL, NULL);
 	g_return_val_if_fail (*key, NULL);
 
-	stored = g_hash_table_lookup (credentials->priv->keys, key);
+	stored = g_hash_table_lookup (credentials->keys, key);
 	if (!stored)
 		return NULL;
 
@@ -374,18 +365,17 @@ e_credentials_peek (ECredentials *credentials,
 	gchar *value;
 
 	g_return_val_if_fail (credentials != NULL, NULL);
-	g_return_val_if_fail (credentials->priv != NULL, NULL);
-	g_return_val_if_fail (credentials->priv->peek_keys != NULL, NULL);
+	g_return_val_if_fail (credentials->peek_keys != NULL, NULL);
 	g_return_val_if_fail (key != NULL, NULL);
 	g_return_val_if_fail (*key, NULL);
 
-	value = g_hash_table_lookup (credentials->priv->peek_keys, key);
+	value = g_hash_table_lookup (credentials->peek_keys, key);
 	if (value)
 		return value;
 
 	value = e_credentials_get (credentials, key);
 	if (value)
-		g_hash_table_insert (credentials->priv->peek_keys, g_strdup (key), value);
+		g_hash_table_insert (credentials->peek_keys, g_strdup (key), value);
 
 	return value;
 }
@@ -438,18 +428,16 @@ e_credentials_equal (const ECredentials *credentials1,
 	if (!credentials1 || !credentials2)
 		return FALSE;
 
-	g_return_val_if_fail (credentials1->priv != NULL, FALSE);
-	g_return_val_if_fail (credentials1->priv->keys != NULL, FALSE);
-	g_return_val_if_fail (credentials2->priv != NULL, FALSE);
-	g_return_val_if_fail (credentials2->priv->keys != NULL, FALSE);
+	g_return_val_if_fail (credentials1->keys != NULL, FALSE);
+	g_return_val_if_fail (credentials2->keys != NULL, FALSE);
 
-	if (g_hash_table_size (credentials1->priv->keys) != g_hash_table_size (credentials2->priv->keys))
+	if (g_hash_table_size (credentials1->keys) != g_hash_table_size (credentials2->keys))
 		return FALSE;
 
 	ed.equal = TRUE;
-	ed.keys = credentials2->priv->keys;
+	ed.keys = credentials2->keys;
 
-	g_hash_table_foreach (credentials1->priv->keys, check_equal_cb, &ed);
+	g_hash_table_foreach (credentials1->keys, check_equal_cb, &ed);
 
 	return ed.equal;
 }
@@ -476,17 +464,15 @@ e_credentials_equal_keys (const ECredentials *credentials1,
 	gboolean equal = TRUE;
 
 	g_return_val_if_fail (credentials1 != NULL, FALSE);
-	g_return_val_if_fail (credentials1->priv != NULL, FALSE);
-	g_return_val_if_fail (credentials1->priv->keys != NULL, FALSE);
+	g_return_val_if_fail (credentials1->keys != NULL, FALSE);
 	g_return_val_if_fail (credentials2 != NULL, FALSE);
-	g_return_val_if_fail (credentials2->priv != NULL, FALSE);
-	g_return_val_if_fail (credentials2->priv->keys != NULL, FALSE);
+	g_return_val_if_fail (credentials2->keys != NULL, FALSE);
 	g_return_val_if_fail (key1 != NULL, FALSE);
 
 	va_start (va, key1);
 
 	while (key1 && equal) {
-		equal = g_strcmp0 (g_hash_table_lookup (credentials1->priv->keys, key1), g_hash_table_lookup (credentials2->priv->keys, key1)) == 0;
+		equal = g_strcmp0 (g_hash_table_lookup (credentials1->keys, key1), g_hash_table_lookup (credentials2->keys, key1)) == 0;
 
 		key1 = va_arg (va, const gchar *);
 	}
@@ -512,12 +498,11 @@ e_credentials_has_key (const ECredentials *credentials,
                        const gchar *key)
 {
 	g_return_val_if_fail (credentials != NULL, FALSE);
-	g_return_val_if_fail (credentials->priv != NULL, FALSE);
-	g_return_val_if_fail (credentials->priv->keys != NULL, FALSE);
+	g_return_val_if_fail (credentials->keys != NULL, FALSE);
 	g_return_val_if_fail (key != NULL, FALSE);
 	g_return_val_if_fail (*key, FALSE);
 
-	return g_hash_table_lookup (credentials->priv->keys, key) != NULL;
+	return g_hash_table_lookup (credentials->keys, key) != NULL;
 }
 
 /**
@@ -534,10 +519,9 @@ guint
 e_credentials_keys_size (const ECredentials *credentials)
 {
 	g_return_val_if_fail (credentials != NULL, 0);
-	g_return_val_if_fail (credentials->priv != NULL, 0);
-	g_return_val_if_fail (credentials->priv->keys != NULL, 0);
+	g_return_val_if_fail (credentials->keys != NULL, 0);
 
-	return g_hash_table_size (credentials->priv->keys);
+	return g_hash_table_size (credentials->keys);
 }
 
 static void
@@ -571,12 +555,11 @@ e_credentials_list_keys (const ECredentials *credentials)
 	GSList *keys = NULL;
 
 	g_return_val_if_fail (credentials != NULL, NULL);
-	g_return_val_if_fail (credentials->priv != NULL, NULL);
-	g_return_val_if_fail (credentials->priv->keys != NULL, NULL);
+	g_return_val_if_fail (credentials->keys != NULL, NULL);
 
 	/* XXX g_hash_table_get_keys() would have been
 	 *     easier had we used #GList instead. */
-	g_hash_table_foreach (credentials->priv->keys, gather_key_names, &keys);
+	g_hash_table_foreach (credentials->keys, gather_key_names, &keys);
 
 	return g_slist_reverse (keys);
 }
@@ -592,12 +575,11 @@ void
 e_credentials_clear (ECredentials *credentials)
 {
 	g_return_if_fail (credentials != NULL);
-	g_return_if_fail (credentials->priv != NULL);
-	g_return_if_fail (credentials->priv->keys != NULL);
-	g_return_if_fail (credentials->priv->peek_keys != NULL);
+	g_return_if_fail (credentials->keys != NULL);
+	g_return_if_fail (credentials->peek_keys != NULL);
 
-	g_hash_table_remove_all (credentials->priv->peek_keys);
-	g_hash_table_remove_all (credentials->priv->keys);
+	g_hash_table_remove_all (credentials->peek_keys);
+	g_hash_table_remove_all (credentials->keys);
 }
 
 /**
@@ -611,10 +593,9 @@ void
 e_credentials_clear_peek (ECredentials *credentials)
 {
 	g_return_if_fail (credentials != NULL);
-	g_return_if_fail (credentials->priv != NULL);
-	g_return_if_fail (credentials->priv->peek_keys != NULL);
+	g_return_if_fail (credentials->peek_keys != NULL);
 
-	g_hash_table_remove_all (credentials->priv->peek_keys);
+	g_hash_table_remove_all (credentials->peek_keys);
 }
 
 /**
@@ -636,97 +617,3 @@ e_credentials_util_safe_free_string (gchar *str)
 	g_free (str);
 }
 
-static struct _PromptFlags {
-	ECredentialsPromptFlags flag_uint;
-	const gchar *flag_string;
-	gboolean is_bit_flag; /* if false, then checked against E_CREDENTIALS_PROMPT_FLAG_REMEMBER_MASK */
-} PromptFlags[] = {
-	{ E_CREDENTIALS_PROMPT_FLAG_REMEMBER_NEVER,	"remember-never",	FALSE },
-	{ E_CREDENTIALS_PROMPT_FLAG_REMEMBER_SESSION,	"remember-session",	FALSE },
-	{ E_CREDENTIALS_PROMPT_FLAG_REMEMBER_FOREVER,	"remember-forever",	FALSE },
-
-	{ E_CREDENTIALS_PROMPT_FLAG_SECRET,		"secret",		TRUE },
-	{ E_CREDENTIALS_PROMPT_FLAG_REPROMPT,		"reprompt",		TRUE },
-	{ E_CREDENTIALS_PROMPT_FLAG_ONLINE,		"online",		TRUE },
-	{ E_CREDENTIALS_PROMPT_FLAG_DISABLE_REMEMBER,	"disable-remember",	TRUE },
-	{ E_CREDENTIALS_PROMPT_FLAG_PASSPHRASE,		"passphrase",		TRUE }
-};
-
-/**
- * e_credentials_util_prompt_flags_to_string:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-gchar *
-e_credentials_util_prompt_flags_to_string (guint prompt_flags)
-{
-	gint ii;
-	guint masked = prompt_flags & E_CREDENTIALS_PROMPT_FLAG_REMEMBER_MASK;
-	GString *str = g_string_new ("");
-
-	/* Returned pointer can be passed to
-	 * e_credentials_util_string_to prompt_flags() to decode
-	 * it back to flags. Free returned pointer with g_free(). */
-
-	for (ii = 0; ii < G_N_ELEMENTS (PromptFlags); ii++) {
-		const gchar *add = NULL;
-
-		if (PromptFlags[ii].is_bit_flag) {
-			if ((prompt_flags & PromptFlags[ii].flag_uint) != 0)
-				add = PromptFlags[ii].flag_string;
-		} else if (masked == PromptFlags[ii].flag_uint) {
-			add = PromptFlags[ii].flag_string;
-		}
-
-		if (!add)
-			continue;
-
-		if (str->len)
-			g_string_append (str, ",");
-
-		g_string_append (str, add);
-	}
-
-	return g_string_free (str, FALSE);
-}
-
-/**
- * e_credentials_util_string_to_prompt_flags:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-guint
-e_credentials_util_string_to_prompt_flags (const gchar *prompt_flags_string)
-{
-	gchar **strv;
-	gint ii, jj;
-	guint flags = 0;
-
-	if (!prompt_flags_string || !*prompt_flags_string)
-		return flags;
-
-	strv = g_strsplit (prompt_flags_string, ",", -1);
-	if (!strv)
-		return flags;
-
-	for (jj = 0; strv[jj]; jj++) {
-		const gchar *str = strv[jj];
-
-		for (ii = 0; ii < G_N_ELEMENTS (PromptFlags); ii++) {
-			if (g_str_equal (PromptFlags[ii].flag_string, str)) {
-				if (PromptFlags[ii].is_bit_flag)
-					flags |= PromptFlags[ii].flag_uint;
-				else
-					flags = (flags & (~E_CREDENTIALS_PROMPT_FLAG_REMEMBER_MASK)) | PromptFlags[ii].flag_uint;
-			}
-		}
-	}
-
-	g_strfreev (strv);
-
-	return flags;
-}
diff --git a/libedataserver/e-credentials.h b/libedataserver/e-credentials.h
index f771f03..daa876c 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
 
@@ -26,9 +28,6 @@
 
 G_BEGIN_DECLS
 
-typedef struct _ECredentials ECredentials;
-typedef struct _ECredentialsPrivate ECredentialsPrivate;
-
 /**
  * ECredentials:
  *
@@ -37,18 +36,7 @@ typedef struct _ECredentialsPrivate ECredentialsPrivate;
  *
  * Since: 3.2
  **/
-struct _ECredentials {
-	ECredentialsPrivate *priv;
-};
-
-/**
- * E_CREDENTIALS_KEY_USERNAME:
- *
- * FIXME Docment me.
- *
- * Since: 3.2
- **/
-#define E_CREDENTIALS_KEY_USERNAME	"username"
+typedef struct _ECredentials ECredentials;
 
 /**
  * E_CREDENTIALS_KEY_PASSWORD:
@@ -60,24 +48,6 @@ struct _ECredentials {
 #define E_CREDENTIALS_KEY_PASSWORD	"password"
 
 /**
- * E_CREDENTIALS_KEY_AUTH_METHOD:
- *
- * FIXME Document me.
- *
- * Since: 3.2
- **/
-#define E_CREDENTIALS_KEY_AUTH_METHOD	"auth-method"
-
-/**
- * E_CREDENTIALS_KEY_PROMPT_TITLE:
- *
- * FIXME Document me.
- *
- * Since: 3.2
- **/
-#define E_CREDENTIALS_KEY_PROMPT_TITLE	"prompt-title"
-
-/**
  * E_CREDENTIALS_KEY_PROMPT_TEXT:
  *
  * FIXME: Document me.
@@ -96,15 +66,6 @@ struct _ECredentials {
 #define E_CREDENTIALS_KEY_PROMPT_REASON	"prompt-reason"
 
 /**
- * E_CREDENTIALS_KEY_PROMPT_KEY:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-#define E_CREDENTIALS_KEY_PROMPT_KEY	"prompt-key"
-
-/**
  * E_CREDENTIALS_KEY_PROMPT_FLAGS:
  *
  * FIXME Document me.
@@ -113,37 +74,6 @@ struct _ECredentials {
  **/
 #define E_CREDENTIALS_KEY_PROMPT_FLAGS	"prompt-flags"
 
-/**
- * E_CREDENTIALS_KEY_FOREIGN_REQUEST:
- *
- * Set to "1" when the ECredentials is used to authenticate
- * other than current EClient.
- *
- * Since: 3.4
- **/
-#define E_CREDENTIALS_KEY_FOREIGN_REQUEST "foreign-request"
-
-/**
- * ECredentialsPromptFlags:
- *
- * FIXME Document me.
- *
- * Since: 3.2
- **/
-/* this is 1:1 with EPasswordsRememberType */
-typedef enum {
-	E_CREDENTIALS_PROMPT_FLAG_REMEMBER_NEVER,
-	E_CREDENTIALS_PROMPT_FLAG_REMEMBER_SESSION,
-	E_CREDENTIALS_PROMPT_FLAG_REMEMBER_FOREVER,
-	E_CREDENTIALS_PROMPT_FLAG_REMEMBER_MASK = 0xf,
-
-	E_CREDENTIALS_PROMPT_FLAG_SECRET = 1 << 8, /* whether hide password letters in the UI */
-	E_CREDENTIALS_PROMPT_FLAG_REPROMPT = 1 << 9, /* automatically set when username and password is provided */
-	E_CREDENTIALS_PROMPT_FLAG_ONLINE = 1 << 10, /* only ask if we're online */
-	E_CREDENTIALS_PROMPT_FLAG_DISABLE_REMEMBER = 1 << 11, /* disable the 'remember password' checkbox */
-	E_CREDENTIALS_PROMPT_FLAG_PASSPHRASE = 1 << 12 /* We are asking a passphrase */
-} ECredentialsPromptFlags;
-
 ECredentials *	e_credentials_new	(void);
 ECredentials *	e_credentials_new_strv	(const gchar * const *strv);
 ECredentials *	e_credentials_new_args	(const gchar *key, ...) G_GNUC_NULL_TERMINATED;
@@ -162,9 +92,10 @@ void		e_credentials_clear	(      ECredentials *credentials);
 void		e_credentials_clear_peek (      ECredentials *credentials);
 
 void		e_credentials_util_safe_free_string (gchar *str);
-gchar *		e_credentials_util_prompt_flags_to_string (guint prompt_flags); /* bit-or of ECredentialsPromptFlags */
-guint		e_credentials_util_string_to_prompt_flags (const gchar *prompt_flags_string); /* bit-or of ECredentialsPromptFlags */
 
 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]