[evolution-data-server] UOA: Return IMAP/SMTP user names when collecting user info.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] UOA: Return IMAP/SMTP user names when collecting user info.
- Date: Fri, 22 Nov 2013 16:07:53 +0000 (UTC)
commit 3fb3ba6bb2400a7805f05ed1a980f33d4122ea60
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Nov 22 10:10:51 2013 -0500
UOA: Return IMAP/SMTP user names when collecting user info.
Can't assume the user names are the same as the collection identity.
Would be better to specify this in the .service files.
e.g. <imapuser>EMAILADDRESS / USERIDENTITY</imapuser>
But that can wait. Hard-coding by provider is ugly but works for now.
.../module-ubuntu-online-accounts.c | 48 ++++++++++++++++---
modules/ubuntu-online-accounts/uoa-utils.c | 20 ++++++++
modules/ubuntu-online-accounts/uoa-utils.h | 2 +
3 files changed, 62 insertions(+), 8 deletions(-)
---
diff --git a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
index c1c054c..a57fbe5 100644
--- a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
+++ b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
@@ -392,13 +392,23 @@ ubuntu_online_accounts_config_collection (EUbuntuOnlineAccounts *extension,
static void
ubuntu_online_accounts_config_mail_account (EUbuntuOnlineAccounts *extension,
ESource *source,
- GHashTable *account_services)
+ GHashTable *account_services,
+ const gchar *imap_user_name)
{
EServerSideSource *server_side_source;
ubuntu_online_accounts_config_oauth2 (
extension, source, account_services);
+ if (imap_user_name != NULL) {
+ ESourceAuthentication *source_extension;
+
+ source_extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_AUTHENTICATION);
+ e_source_authentication_set_user (
+ source_extension, imap_user_name);
+ }
+
/* Clients may change the source but may not remove it. */
server_side_source = E_SERVER_SIDE_SOURCE (source);
e_server_side_source_set_writable (server_side_source, TRUE);
@@ -431,13 +441,23 @@ ubuntu_online_accounts_config_mail_identity (EUbuntuOnlineAccounts *extension,
static void
ubuntu_online_accounts_config_mail_transport (EUbuntuOnlineAccounts *extension,
ESource *source,
- GHashTable *account_services)
+ GHashTable *account_services,
+ const gchar *smtp_user_name)
{
EServerSideSource *server_side_source;
ubuntu_online_accounts_config_oauth2 (
extension, source, account_services);
+ if (smtp_user_name != NULL) {
+ ESourceAuthentication *source_extension;
+
+ source_extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_AUTHENTICATION);
+ e_source_authentication_set_user (
+ source_extension, smtp_user_name);
+ }
+
/* Clients may change the source but may not remove it. */
server_side_source = E_SERVER_SIDE_SOURCE (source);
e_server_side_source_set_writable (server_side_source, TRUE);
@@ -474,7 +494,7 @@ ubuntu_online_accounts_config_sources (EUbuntuOnlineAccounts *extension,
extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
if (e_source_has_extension (source, extension_name))
ubuntu_online_accounts_config_mail_account (
- extension, source, account_services);
+ extension, source, account_services, NULL);
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
if (e_source_has_extension (source, extension_name))
@@ -484,7 +504,7 @@ ubuntu_online_accounts_config_sources (EUbuntuOnlineAccounts *extension,
extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
if (e_source_has_extension (source, extension_name))
ubuntu_online_accounts_config_mail_transport (
- extension, source, account_services);
+ extension, source, account_services, NULL);
}
g_list_free_full (list, (GDestroyNotify) g_object_unref);
@@ -499,7 +519,9 @@ ubuntu_online_accounts_create_collection (EUbuntuOnlineAccounts *extension,
EBackendFactory *backend_factory,
AgAccount *ag_account,
const gchar *user_identity,
- const gchar *email_address)
+ const gchar *email_address,
+ const gchar *imap_user_name,
+ const gchar *smtp_user_name)
{
ESourceRegistryServer *server;
ESource *collection_source;
@@ -543,12 +565,14 @@ ubuntu_online_accounts_create_collection (EUbuntuOnlineAccounts *extension,
extension, collection_source, ag_account,
account_services, user_identity);
ubuntu_online_accounts_config_mail_account (
- extension, mail_account_source, account_services);
+ extension, mail_account_source,
+ account_services, imap_user_name);
ubuntu_online_accounts_config_mail_identity (
extension, mail_identity_source,
account_services, email_address);
ubuntu_online_accounts_config_mail_transport (
- extension, mail_transport_source, account_services);
+ extension, mail_transport_source,
+ account_services, smtp_user_name);
g_hash_table_unref (account_services);
/* Export the new source collection. */
@@ -577,6 +601,8 @@ ubuntu_online_accounts_got_userinfo_cb (GObject *source_object,
AsyncContext *async_context = user_data;
gchar *user_identity = NULL;
gchar *email_address = NULL;
+ gchar *imap_user_name = NULL;
+ gchar *smtp_user_name = NULL;
GError *local_error = NULL;
ag_account = AG_ACCOUNT (source_object);
@@ -585,6 +611,8 @@ ubuntu_online_accounts_got_userinfo_cb (GObject *source_object,
ag_account, result,
&user_identity,
&email_address,
+ &imap_user_name,
+ &smtp_user_name,
&local_error);
if (local_error == NULL) {
@@ -593,7 +621,9 @@ ubuntu_online_accounts_got_userinfo_cb (GObject *source_object,
async_context->backend_factory,
ag_account,
user_identity,
- email_address);
+ email_address,
+ imap_user_name,
+ smtp_user_name);
} else {
g_warning (
"%s: Failed to create ESource "
@@ -606,6 +636,8 @@ ubuntu_online_accounts_got_userinfo_cb (GObject *source_object,
g_free (user_identity);
g_free (email_address);
+ g_free (imap_user_name);
+ g_free (smtp_user_name);
async_context_free (async_context);
}
diff --git a/modules/ubuntu-online-accounts/uoa-utils.c b/modules/ubuntu-online-accounts/uoa-utils.c
index 917bf6a..2be6cc6 100644
--- a/modules/ubuntu-online-accounts/uoa-utils.c
+++ b/modules/ubuntu-online-accounts/uoa-utils.c
@@ -33,6 +33,8 @@ struct _AsyncContext {
GCancellable *cancellable;
gchar *user_identity;
gchar *email_address;
+ gchar *imap_user_name;
+ gchar *smtp_user_name;
};
static void
@@ -42,6 +44,8 @@ async_context_free (AsyncContext *async_context)
g_free (async_context->user_identity);
g_free (async_context->email_address);
+ g_free (async_context->imap_user_name);
+ g_free (async_context->smtp_user_name);
g_slice_free (AsyncContext, async_context);
}
@@ -105,6 +109,8 @@ e_ag_account_google_got_userinfo_cb (RestProxyCall *call,
if (email != NULL) {
async_context->user_identity = g_strdup (email);
async_context->email_address = g_strdup (email);
+ async_context->imap_user_name = g_strdup (email);
+ async_context->smtp_user_name = g_strdup (email);
} else {
g_simple_async_result_set_error (
simple, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -270,6 +276,8 @@ e_ag_account_collect_yahoo_userinfo (GSimpleAsyncResult *simple,
async_context->user_identity = g_strdup (email_address->str);
async_context->email_address = g_strdup (email_address->str);
+ async_context->imap_user_name = g_strdup (email_address->str);
+ async_context->smtp_user_name = g_strdup (email_address->str);
g_simple_async_result_complete_in_idle (simple);
@@ -328,6 +336,8 @@ e_ag_account_collect_userinfo_finish (AgAccount *ag_account,
GAsyncResult *result,
gchar **out_user_identity,
gchar **out_email_address,
+ gchar **out_imap_user_name,
+ gchar **out_smtp_user_name,
GError **error)
{
GSimpleAsyncResult *simple;
@@ -356,6 +366,16 @@ e_ag_account_collect_userinfo_finish (AgAccount *ag_account,
async_context->email_address = NULL;
}
+ if (out_imap_user_name != NULL) {
+ *out_imap_user_name = async_context->imap_user_name;
+ async_context->imap_user_name = NULL;
+ }
+
+ if (out_smtp_user_name != NULL) {
+ *out_smtp_user_name = async_context->smtp_user_name;
+ async_context->smtp_user_name = NULL;
+ }
+
return TRUE;
}
diff --git a/modules/ubuntu-online-accounts/uoa-utils.h b/modules/ubuntu-online-accounts/uoa-utils.h
index 6216b9e..0d84d76 100644
--- a/modules/ubuntu-online-accounts/uoa-utils.h
+++ b/modules/ubuntu-online-accounts/uoa-utils.h
@@ -38,6 +38,8 @@ gboolean e_ag_account_collect_userinfo_finish
GAsyncResult *result,
gchar **out_user_identity,
gchar **out_email_address,
+ gchar **out_imap_user_name,
+ gchar **out_smtp_user_name,
GError **error);
const gchar * e_source_get_ag_service_type (ESource *source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]