[gnome-online-accounts] exchange: Implement ensure_credentials_sync
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] exchange: Implement ensure_credentials_sync
- Date: Thu, 12 Apr 2012 19:27:22 +0000 (UTC)
commit 4d81858cbce30e2a862be9a5d94c15c4dd3f8c94
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Apr 10 15:32:04 2012 +0200
exchange: Implement ensure_credentials_sync
Fixes: https://bugzilla.gnome.org/667889
src/goabackend/goaexchangeprovider.c | 50 +++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index 00942ad..40849cd 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -248,9 +248,57 @@ ensure_credentials_sync (GoaProvider *provider,
GCancellable *cancellable,
GError **error)
{
+ GVariant *credentials;
+ GoaAccount *account;
+ GoaEwsClient *ews_client;
+ GoaExchange *exchange;
+ gboolean ret;
+ const gchar *email_address;
+ const gchar *server;
+ const gchar *username;
+ gchar *password;
+
+ credentials = NULL;
+ ews_client = NULL;
+ password = NULL;
+
+ ret = FALSE;
+
+ credentials = goa_provider_lookup_credentials_sync (provider,
+ object,
+ cancellable,
+ error);
+ if (credentials == NULL)
+ goto out;
+
+ if (!g_variant_lookup (credentials, "password", "s", &password))
+ goto out;
+
+ account = goa_object_peek_account (object);
+ email_address = goa_account_get_presentation_identity (account);
+ username = goa_account_get_identity (account);
+
+ exchange = goa_object_peek_exchange (object);
+ server = goa_exchange_get_host (exchange);
+
+ ews_client = goa_ews_client_new ();
+ ret = goa_ews_client_autodiscover_sync (ews_client,
+ email_address,
+ password,
+ username,
+ server,
+ cancellable,
+ error);
if (out_expires_in != NULL)
*out_expires_in = 0;
- return TRUE;
+
+ out:
+ if (ews_client != NULL)
+ g_object_unref (ews_client);
+ g_free (password);
+ if (credentials != NULL)
+ g_variant_unref (credentials);
+ return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]