[gnome-online-accounts] live: Add support for mail



commit 31e617262fc9d4abfb2de40e45e5fa2177234d1b
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 7 13:55:56 2013 +0200

    live: Add support for mail
    
    Fixes: https://bugzilla.gnome.org/709393

 README                                  |    5 +++-
 src/goabackend/goawindowsliveprovider.c |   45 ++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/README b/README
index aac1b26..dae1257 100644
--- a/README
+++ b/README
@@ -43,7 +43,10 @@ Windows Live
 ------------
 
 OAuth 2.0: http://msdn.microsoft.com/en-us/library/live/hh243647.aspx
-Scopes: http://msdn.microsoft.com/en-us/library/live/hh243646.aspx
+
+Scopes:
+http://msdn.microsoft.com/en-us/library/live/hh243646.aspx
+http://blogs.office.com/b/microsoft-outlook/archive/2013/09/12/outlook-com-now-with-imap.aspx
 
 Notes:
 We do not need the client_secret because we are marked as a desktop or mobile
diff --git a/src/goabackend/goawindowsliveprovider.c b/src/goabackend/goawindowsliveprovider.c
index ada340a..19b91e8 100644
--- a/src/goabackend/goawindowsliveprovider.c
+++ b/src/goabackend/goawindowsliveprovider.c
@@ -94,6 +94,7 @@ static GoaProviderFeatures
 get_provider_features (GoaProvider *_provider)
 {
   return GOA_PROVIDER_FEATURE_BRANDED |
+         GOA_PROVIDER_FEATURE_MAIL |
          GOA_PROVIDER_FEATURE_CHAT |
          GOA_PROVIDER_FEATURE_DOCUMENTS;
 }
@@ -122,6 +123,7 @@ static const gchar *
 get_scope (GoaOAuth2Provider *provider)
 {
   return "wl.messenger,"
+         "wl.imap,"
          "wl.offline_access,"
          "wl.skydrive_update,"
          "wl.emails";
@@ -130,7 +132,7 @@ get_scope (GoaOAuth2Provider *provider)
 static guint
 get_credentials_generation (GoaProvider *provider)
 {
-  return 1;
+  return 2;
 }
 
 static const gchar *
@@ -330,13 +332,17 @@ build_object (GoaProvider         *provider,
               GError             **error)
 {
   GoaAccount *account;
+  GoaMail *mail;
   GoaChat *chat = NULL;
   GoaDocuments *documents;
+  gboolean mail_enabled;
   gboolean chat_enabled;
   gboolean documents_enabled;
   gboolean ret = FALSE;
+  const gchar *email_address;
 
   account = NULL;
+  mail = NULL;
 
   /* Chain up */
   if (!GOA_PROVIDER_CLASS (goa_windows_live_provider_parent_class)->build_object (provider,
@@ -349,6 +355,36 @@ build_object (GoaProvider         *provider,
     goto out;
 
   account = goa_object_get_account (GOA_OBJECT (object));
+  email_address = goa_account_get_presentation_identity (account);
+
+  /* Email */
+  mail = goa_object_get_mail (GOA_OBJECT (object));
+  mail_enabled = g_key_file_get_boolean (key_file, group, "MailEnabled", NULL);
+  if (mail_enabled)
+    {
+      if (mail == NULL)
+        {
+          mail = goa_mail_skeleton_new ();
+          g_object_set (G_OBJECT (mail),
+                        "email-address",   email_address,
+                        "imap-supported",  TRUE,
+                        "imap-host",       "imap-mail.outlook.com",
+                        "imap-user-name",  email_address,
+                        "imap-use-ssl",    TRUE,
+                        "smtp-supported",  TRUE,
+                        "smtp-host",       "smtp-mail.outlook.com",
+                        "smtp-user-name",  email_address,
+                        "smtp-use-auth",   TRUE,
+                        "smtp-use-tls",    TRUE,
+                        NULL);
+          goa_object_skeleton_set_mail (object, mail);
+        }
+    }
+  else
+    {
+      if (mail != NULL)
+        goa_object_skeleton_set_mail (object, NULL);
+    }
 
   /* Chat */
   chat = goa_object_get_chat (GOA_OBJECT (object));
@@ -405,6 +441,7 @@ build_object (GoaProvider         *provider,
  out:
   if (chat != NULL)
     g_object_unref (chat);
+  g_clear_object (&mail);
   if (account != NULL)
     g_object_unref (account);
   return ret;
@@ -430,6 +467,11 @@ show_account (GoaProvider         *provider,
                                                    /* Translators: This is a label for a series of
                                                     * options switches. For example: “Use for Mail”. */
                                                    _("Use for"),
+                                                   "mail-disabled",
+                                                   _("_Mail"));
+
+  goa_util_add_row_switch_from_keyfile_with_blurb (grid, row++, object,
+                                                   NULL,
                                                    "chat-disabled",
                                                    _("C_hat"));
 
@@ -445,6 +487,7 @@ static void
 add_account_key_values (GoaOAuth2Provider *provider,
                         GVariantBuilder   *builder)
 {
+  g_variant_builder_add (builder, "{ss}", "MailEnabled", "true");
   g_variant_builder_add (builder, "{ss}", "ChatEnabled", "true");
   g_variant_builder_add (builder, "{ss}", "DocumentsEnabled", "true");
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]