From: Matthew Barnes Date: Fri, 1 Feb 2013 19:03:14 +0000 (-0500) Subject: Add e_source_registry_server_new_auth_session(). X-Git-Tag: upstream/3.7.5~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d06623e01fb52d932ccf97779684e81359a617a;p=platform%2Fupstream%2Fevolution-data-server.git Add e_source_registry_server_new_auth_session(). Convenience function instantiates an appropriate authentication session type for the given data source UID. --- 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,