Commit 66121edf authored by Milan Crha's avatar Milan Crha
Browse files

I#34 - Remove Ubuntu Online Accounts from master

It had been moved to https://gitlab.com/accounts-sso/evolution-data-server-signon

Closes #34
parent c8a2c68e
......@@ -25,7 +25,6 @@ set(GETTEXT_PO_DIR ${CMAKE_SOURCE_DIR}/po)
# Required for 'disttest' and 'ditcheck' of DistTarget module
set(PROJECT_DISTCONFIGURE_PARAMS
-DENABLE_GOA=ON
-DENABLE_UOA=ON
-DENABLE_EXAMPLES=ON
-DENABLE_INTROSPECTION=ON
-DENABLE_VALA_BINDINGS=ON
......@@ -440,21 +439,6 @@ if(ENABLE_GOA)
set(HAVE_GOA 1)
endif(ENABLE_GOA)
# ********************************
# Check for Ubuntu Online Accounts
# ********************************
add_printable_option(ENABLE_UOA "Enable Ubuntu Online Accounts support" ON)
if(ENABLE_UOA)
pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBACCOUNTS_GLIB libaccounts-glib>=${libaccounts_glib_minimum_version})
pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" LIBSIGNON_GLIB libsignon-glib>=${libsignon_glib_minimum_version})
pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" JSON_GLIB json-glib-1.0)
pkg_check_modules_for_option(ENABLE_UOA "Ubuntu Online Accounts support" REST rest-0.7)
set(HAVE_UOA 1)
endif(ENABLE_UOA)
# **********************************************
# Check if backend per process should be enabled
# **********************************************
......
......@@ -197,9 +197,6 @@
#define O_LARGEFILE 0
#endif /* HAVE_O_LARGEFILE */
/* Have libaccounts-glib */
#cmakedefine HAVE_UOA 1
/* gweather_info_new() has only one argument */
#cmakedefine HAVE_ONE_ARG_GWEATHER_INFO_NEW 1
......
......@@ -221,19 +221,6 @@ src/modules/gnome-online-accounts/module-gnome-online-accounts.c
src/modules/google-backend/module-google-backend.c
src/modules/trust-prompt/module-trust-prompt.c
src/modules/trust-prompt/trust-prompt-gtk.c
[type: gettext/xml]src/modules/ubuntu-online-accounts/calendar.service-type.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/contacts.service-type.in.in
src/modules/ubuntu-online-accounts/e-signon-session-password.c
src/modules/ubuntu-online-accounts/evolution-data-server-uoa.desktop.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/google-calendar.service.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/google-contacts.service.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/google-gmail.service.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/mail.service-type.in.in
src/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
src/modules/ubuntu-online-accounts/uoa-utils.c
[type: gettext/xml]src/modules/ubuntu-online-accounts/windows-live-mail.service.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/yahoo-calendar.service.in.in
[type: gettext/xml]src/modules/ubuntu-online-accounts/yahoo-mail.service.in.in
src/modules/yahoo-backend/module-yahoo-backend.c
src/services/evolution-addressbook-factory/evolution-addressbook-factory.c
src/services/evolution-alarm-notify/e-alarm-notify.c
......
......@@ -11,7 +11,4 @@ src/camel/providers/nntp/test-newsrc.c
src/examples/cursor/cursor-example.ui
src/examples/cursor/cursor-search.ui
src/examples/cursor/cursor-slot.ui
src/modules/ubuntu-online-accounts/evolution-data-server-uoa.desktop.in
src/modules/ubuntu-online-accounts/google-contacts.service.in
src/modules/ubuntu-online-accounts/google-gmail.service.in
src/servers/exchange/lib/e2k-user-dialog.c
......@@ -80,10 +80,6 @@ if(HAVE_GOA)
add_subdirectory(gnome-online-accounts)
endif(HAVE_GOA)
if(HAVE_UOA)
add_subdirectory(ubuntu-online-accounts)
endif(HAVE_UOA)
if(NOT WIN32)
add_subdirectory(secret-monitor)
endif(NOT WIN32)
# ******************************
# Data files
# ******************************
set(filedeps)
set(servicetype_files)
set(servicetype_files_gen)
list(APPEND servicetype_files
mail.service-type
calendar.service-type
contacts.service-type
)
set(service_files)
set(service_files_gen)
list(APPEND service_files
google-gmail.service
google-calendar.service
google-contacts.service
windows-live-mail.service
yahoo-mail.service
yahoo-calendar.service
)
configure_file(evolution-data-server.application.in.in
evolution-data-server.application.in
@ONLY
)
intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application.in evolution-data-server.application --no-translations --xml-style --utf8)
configure_file(evolution-data-server-uoa.desktop.in.in
evolution-data-server-uoa.desktop.in
@ONLY
)
intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop.in evolution-data-server-uoa.desktop --desktop-style --utf8)
list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application)
list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop)
foreach(_file IN LISTS servicetype_files)
configure_file(${_file}.in.in
${_file}.in
@ONLY
)
intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/${_file}.in ${_file} --no-translations --xml-style --utf8)
list(APPEND servicetype_files_gen ${CMAKE_CURRENT_BINARY_DIR}/${_file})
list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/${_file})
endforeach(_file)
foreach(_file IN LISTS service_files)
configure_file(${_file}.in.in
${_file}.in
@ONLY
)
intltool_merge(${CMAKE_CURRENT_BINARY_DIR}/${_file}.in ${_file} --no-translations --xml-style --utf8)
list(APPEND service_files_gen ${CMAKE_CURRENT_BINARY_DIR}/${_file})
list(APPEND filedeps ${CMAKE_CURRENT_BINARY_DIR}/${_file})
endforeach(_file)
set(desktopdir ${SHARE_INSTALL_PREFIX}/applications)
pkg_check_variable(libaccountsprefixdir libaccounts-glib prefix)
pkg_check_variable(applicationdir libaccounts-glib applicationfilesdir)
pkg_check_variable(servicetypedir libaccounts-glib servicetypefilesdir)
pkg_check_variable(servicedir libaccounts-glib servicefilesdir)
# To honor configured prefix, but still use the right place
string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" applicationdir "${applicationdir}")
string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" servicetypedir "${servicetypedir}")
string(REPLACE "${libaccountsprefixdir}" "${CMAKE_INSTALL_PREFIX}" servicedir "${servicedir}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application
DESTINATION ${applicationdir}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop
DESTINATION ${desktopdir}
)
install(FILES ${servicetype_files_gen}
DESTINATION ${servicetypedir}
)
install(FILES ${service_files_gen}
DESTINATION ${servicedir}
)
# ******************************
# Source registry module
# ******************************
set(sources
module-ubuntu-online-accounts.c
uoa-utils.c
uoa-utils.h
)
set(extra_deps)
set(extra_filedeps
${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server.application
${CMAKE_CURRENT_BINARY_DIR}/evolution-data-server-uoa.desktop
${servicetype_files_gen}
${service_files_gen}
)
set(extra_defines)
set(extra_cflags
${LIBACCOUNTS_GLIB_CFLAGS}
${LIBSIGNON_GLIB_CFLAGS}
${JSON_GLIB_CFLAGS}
${REST_CFLAGS}
)
set(extra_incdirs
${LIBACCOUNTS_GLIB_INCLUDE_DIRS}
${LIBSIGNON_GLIB_INCLUDE_DIRS}
${JSON_GLIB_INCLUDE_DIRS}
${REST_INCLUDE_DIRS}
)
set(extra_ldflags
${LIBACCOUNTS_GLIB_LDFLAGS}
${LIBSIGNON_GLIB_LDFLAGS}
${JSON_GLIB_LDFLAGS}
${REST_LDFLAGS}
)
add_source_registry_module(module-ubuntu-online-accounts
sources
extra_deps
extra_defines
extra_cflags
extra_incdirs
extra_ldflags
)
add_custom_target(module-ubuntu-online-accounts-files
DEPENDS ${filedeps}
)
add_dependencies(module-ubuntu-online-accounts module-ubuntu-online-accounts-files)
# ******************************
# Credentials module
# ******************************
set(sources
module-credentials-uoa.c
e-signon-session-password.c
e-signon-session-password.h
)
add_credentials_module(module-credentials-uoa
sources
extra_deps
extra_defines
extra_cflags
extra_incdirs
extra_ldflags
)
<?xml version="1.0" encoding="UTF-8"?>
<service-type id="calendar">
<_name>Calendar</_name>
<_description>Integrate your calendars</_description>
<icon>x-office-calendar</icon>
<translations>@GETTEXT_PACKAGE@</translations>
</service-type>
<?xml version="1.0" encoding="UTF-8"?>
<service-type id="contacts">
<_name>Contacts</_name>
<_description>Integrate your contacts</_description>
<icon>x-office-address-book</icon>
<translations>@GETTEXT_PACKAGE@</translations>
</service-type>
/*
* e-signon-session-password.c
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "evolution-data-server-config.h"
#include <glib/gi18n-lib.h>
#include <libsignon-glib/signon-glib.h>
#include "uoa-utils.h"
#include "e-signon-session-password.h"
#define SIGNON_METHOD_PASSWORD "password"
#define SIGNON_MECHANISM_PASSWORD "password"
#define E_SIGNON_SESSION_PASSWORD_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SIGNON_SESSION_PASSWORD, ESignonSessionPasswordPrivate))
typedef struct _AsyncContext AsyncContext;
struct _ESignonSessionPasswordPrivate {
AgManager *ag_manager;
};
struct _AsyncContext {
SignonAuthSession *signon_auth_session;
EAuthenticationSessionResult session_result;
AgAuthData *ag_auth_data;
GCancellable *cancellable;
GString *password;
};
G_DEFINE_DYNAMIC_TYPE (ESignonSessionPassword, e_signon_session_password, E_TYPE_SOURCE_CREDENTIALS_PROVIDER_IMPL)
static void
async_context_free (AsyncContext *async_context)
{
g_clear_object (&async_context->signon_auth_session);
g_clear_object (&async_context->cancellable);
if (async_context->ag_auth_data != NULL)
ag_auth_data_unref (async_context->ag_auth_data);
if (async_context->password) {
if (async_context->password->len)
memset (async_context->password->str, 0, async_context->password->len);
g_string_free (async_context->password, TRUE);
}
g_slice_free (AsyncContext, async_context);
}
static void
e_signon_session_password_msg (ESource *source,
const gchar *format,
...)
{
GString *buffer;
const gchar *source_uid;
va_list args;
buffer = g_string_sized_new (256);
source_uid = e_source_get_uid (source);
g_string_append_printf (buffer, "AUTH (%s): ", source_uid);
va_start (args, format);
g_string_append_vprintf (buffer, format, args);
va_end (args);
e_source_registry_debug_print ("%s\n", buffer->str);
g_string_free (buffer, TRUE);
}
static void
signon_session_password_state_changed_cb (SignonAuthSession *signon_auth_session,
gint state,
const gchar *message,
ESource *source)
{
e_signon_session_password_msg (source, "(signond) %s", message);
}
static ESource *
e_uoa_signon_session_password_ref_credentials_source (ESourceCredentialsProvider *provider,
ESource *source)
{
ESource *adept, *cred_source = NULL;
g_return_val_if_fail (E_IS_SOURCE_CREDENTIALS_PROVIDER (provider), NULL);
g_return_val_if_fail (E_IS_SOURCE (source), NULL);
adept = g_object_ref (source);
while (adept && !e_source_has_extension (adept, E_SOURCE_EXTENSION_UOA)) {
ESource *parent;
if (!e_source_get_parent (adept)) {
break;
}
parent = e_source_credentials_provider_ref_source (provider, e_source_get_parent (adept));
g_clear_object (&adept);
adept = parent;
}
if (adept && e_source_has_extension (adept, E_SOURCE_EXTENSION_UOA)) {
cred_source = g_object_ref (adept);
}
g_clear_object (&adept);
if (!cred_source)
cred_source = e_source_credentials_provider_ref_credentials_source (provider, source);
return cred_source;
}
static AgAccountService *
signon_session_password_new_account_service (ESourceCredentialsProviderImpl *provider_impl,
ESource *source,
GError **error)
{
ESignonSessionPasswordPrivate *priv;
ESource *cred_source = NULL;
ESourceUoa *extension = NULL;
AgAccountId account_id;
AgAccount *ag_account = NULL;
AgAccountService *ag_account_service;
GList *list;
priv = E_SIGNON_SESSION_PASSWORD_GET_PRIVATE (provider_impl);
if (e_source_has_extension (source, E_SOURCE_EXTENSION_UOA)) {
extension = e_source_get_extension (source, E_SOURCE_EXTENSION_UOA);
} else {
ESourceCredentialsProvider *provider;
provider = e_source_credentials_provider_impl_get_provider (provider_impl);
cred_source = e_uoa_signon_session_password_ref_credentials_source (provider, source);
if (cred_source && e_source_has_extension (cred_source, E_SOURCE_EXTENSION_UOA))
extension = e_source_get_extension (cred_source, E_SOURCE_EXTENSION_UOA);
}
if (!extension) {
g_clear_object (&cred_source);
return NULL;
}
account_id = e_source_uoa_get_account_id (extension);
ag_account = ag_manager_load_account (
priv->ag_manager, account_id, error);
if (ag_account == NULL)
return NULL;
/* XXX We can't accurately determine the appropriate service
* type from a collection source, but all services for an
* account should be using the same authentication method
* and mechanism so any service should work. */
list = ag_account_list_services (ag_account);
g_return_val_if_fail (list != NULL, NULL);
ag_account_service = ag_account_service_new (ag_account, list->data);
ag_service_list_free (list);
g_object_unref (ag_account);
return ag_account_service;
}
static gboolean
e_signon_session_password_can_process (ESourceCredentialsProviderImpl *provider_impl,
ESource *source)
{
gboolean can_process;
g_return_val_if_fail (E_IS_SIGNON_SESSION_PASSWORD (provider_impl), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
can_process = e_source_has_extension (source, E_SOURCE_EXTENSION_UOA);
if (!can_process) {
ESource *cred_source;
cred_source = e_uoa_signon_session_password_ref_credentials_source (
e_source_credentials_provider_impl_get_provider (provider_impl),
source);
if (cred_source) {
can_process = e_source_has_extension (cred_source, E_SOURCE_EXTENSION_UOA);
g_clear_object (&cred_source);
}
}
return can_process;
}
static gboolean
e_signon_session_password_can_store (ESourceCredentialsProviderImpl *provider_impl)
{
g_return_val_if_fail (E_IS_SIGNON_SESSION_PASSWORD (provider_impl), FALSE);
return FALSE;
}
static gboolean
e_signon_session_password_can_prompt (ESourceCredentialsProviderImpl *provider_impl)
{
g_return_val_if_fail (E_IS_SIGNON_SESSION_PASSWORD (provider_impl), FALSE);
return FALSE;
}
static void
signon_session_password_process_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *simple;
AsyncContext *async_context;
GVariant *session_data;
GVariant *secret;
GError *error = NULL;
simple = G_SIMPLE_ASYNC_RESULT (user_data);
async_context = g_simple_async_result_get_op_res_gpointer (simple);
session_data = signon_auth_session_process_finish (
SIGNON_AUTH_SESSION (source_object), result, &error);
/* Sanity check. */
g_return_if_fail (
((session_data != NULL) && (error == NULL)) ||
((session_data == NULL) && (error != NULL)));
if (error != NULL) {
g_simple_async_result_take_error (simple, error);
goto exit;
}
secret = g_variant_lookup_value (
session_data,
SIGNON_SESSION_DATA_SECRET,
G_VARIANT_TYPE_STRING);
g_variant_unref (session_data);
if (secret == NULL) {
g_simple_async_result_set_error (
simple, SIGNON_ERROR,
SIGNON_ERROR_MISSING_DATA,
_("Signon service did not return a secret"));
goto exit;
}
async_context->password = g_string_new (g_variant_get_string (secret, NULL));
g_variant_unref (secret);
exit:
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static void
e_signon_session_password_get (ESourceCredentialsProviderImpl *provider_impl,
ESource *source,
gint io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
AsyncContext *async_context;
AgAccountService *ag_account_service;
AgAuthData *ag_auth_data;
SignonAuthSession *signon_auth_session;
guint credentials_id;
GError *error = NULL;
e_signon_session_password_msg (source, "Initiated");
async_context = g_slice_new0 (AsyncContext);
if (G_IS_CANCELLABLE (cancellable))
async_context->cancellable = g_object_ref (cancellable);
simple = g_simple_async_result_new (
G_OBJECT (provider_impl), callback, user_data,
e_signon_session_password_get);
g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free);
ag_account_service = signon_session_password_new_account_service (provider_impl, source, &error);
/* Sanity check. */
g_return_if_fail (
((ag_account_service != NULL) && (error == NULL)) ||
((ag_account_service == NULL) && (error != NULL)));
if (error != NULL) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
return;
}
ag_auth_data = ag_account_service_get_auth_data (ag_account_service);
credentials_id = ag_auth_data_get_credentials_id (ag_auth_data);
/* Hard-code the method and mechanism names. If they disagree
* with AgAuthData then hopefully the signon process will fail
* with a suitable error message. */
signon_auth_session = signon_auth_session_new (
credentials_id, SIGNON_METHOD_PASSWORD, &error);
/* Sanity check. */
g_return_if_fail (
((signon_auth_session != NULL) && (