[evolution-data-server] Add e_source_registry_server_new_auth_session().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add e_source_registry_server_new_auth_session().
- Date: Fri, 1 Feb 2013 19:17:28 +0000 (UTC)
commit 3d06623e01fb52d932ccf97779684e81359a617a
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Feb 1 14:03:14 2013 -0500
Add e_source_registry_server_new_auth_session().
Convenience function instantiates an appropriate authentication session
type for the given data source UID.
.../reference/libebackend/libebackend-sections.txt | 1 +
libebackend/e-source-registry-server.c | 52 ++++++++++++++++++++
libebackend/e-source-registry-server.h | 5 ++
3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libebackend/libebackend-sections.txt b/docs/reference/libebackend/libebackend-sections.txt
index 96dc658..4441793 100644
--- a/docs/reference/libebackend/libebackend-sections.txt
+++ b/docs/reference/libebackend/libebackend-sections.txt
@@ -408,6 +408,7 @@ e_source_registry_server_list_sources
e_source_registry_server_find_extension
e_source_registry_server_ref_backend
e_source_registry_server_ref_backend_factory
+e_source_registry_server_new_auth_session
e_source_registry_server_authenticate_sync
e_source_registry_server_authenticate
e_source_registry_server_authenticate_finish
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index f3bd2c5..e0db5b3 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -2290,6 +2290,58 @@ e_source_registry_server_ref_backend_factory (ESourceRegistryServer *server,
}
/**
+ * e_source_registry_server_new_auth_session:
+ * @server: an #ESourceRegistryServer
+ * @authenticator: an #ESourceAuthenticator
+ * @source_uid: a data source identifier
+ *
+ * Convenience function instantiates an appropriate authentication
+ * session type for @source_uid.
+ *
+ * If @server has an #EServerSideSource instance for @source_uid, then
+ * its #EServerSideSource:auth-session-type is used to instantiate a new
+ * authentication session. Otherwise a plain #EAuthenticationSession is
+ * instantiated.
+ *
+ * Unreference the returned #EAuthenticationSession with g_object_unref()
+ * when finished with it.
+ *
+ * Returns: a new #EAuthenticationSession for @source_uid
+ *
+ * Since: 3.8
+ **/
+EAuthenticationSession *
+e_source_registry_server_new_auth_session (ESourceRegistryServer *server,
+ ESourceAuthenticator *authenticator,
+ const gchar *source_uid)
+{
+ GType auth_session_type = E_TYPE_AUTHENTICATION_SESSION;
+ ESource *source;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY_SERVER (server), NULL);
+ g_return_val_if_fail (E_IS_SOURCE_AUTHENTICATOR (authenticator), NULL);
+ g_return_val_if_fail (source_uid != NULL, NULL);
+
+ source = e_source_registry_server_ref_source (server, source_uid);
+ if (source != NULL) {
+ auth_session_type =
+ e_server_side_source_get_auth_session_type (
+ E_SERVER_SIDE_SOURCE (source));
+ g_object_unref (source);
+ }
+
+ g_return_val_if_fail (
+ g_type_is_a (auth_session_type,
+ E_TYPE_AUTHENTICATION_SESSION), NULL);
+
+ return g_object_new (
+ auth_session_type,
+ "server", server,
+ "authenticator", authenticator,
+ "source-uid", source_uid, NULL);
+}
+
+/**
* e_source_registry_server_authenticate_sync:
* @server: an #ESourceRegistryServer
* @session: an #EAuthenticationSession
diff --git a/libebackend/e-source-registry-server.h b/libebackend/e-source-registry-server.h
index 725e0d0..add0b7c 100644
--- a/libebackend/e-source-registry-server.h
+++ b/libebackend/e-source-registry-server.h
@@ -146,6 +146,11 @@ ECollectionBackendFactory *
e_source_registry_server_ref_backend_factory
(ESourceRegistryServer *server,
ESource *source);
+EAuthenticationSession *
+ e_source_registry_server_new_auth_session
+ (ESourceRegistryServer *server,
+ ESourceAuthenticator *authenticator,
+ const gchar *source_uid);
gboolean e_source_registry_server_authenticate_sync
(ESourceRegistryServer *server,
EAuthenticationSession *session,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]