[evolution-data-server/gnome-40] I#317 - Add OAuth2 for Yahoo! accounts



commit d737ed9d8359bb06083699fc686c02f02c859f9a
Author: Milan Crha <mcrha redhat com>
Date:   Fri Mar 19 09:41:50 2021 +0100

    I#317 - Add OAuth2 for Yahoo! accounts
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/317

 CMakeLists.txt                                     |  11 +
 config.h.in                                        |   6 +
 .../org.gnome.evolution-data-server.gschema.xml.in |  10 +
 po/POTFILES.in                                     |   2 +
 src/camel/CMakeLists.txt                           |   2 +
 src/camel/camel-sasl-xoauth2-yahoo.c               |  43 ++++
 src/camel/camel-sasl-xoauth2-yahoo.h               |  63 ++++++
 src/camel/camel-sasl.c                             |   2 +
 src/camel/camel.h                                  |   1 +
 src/libedataserver/CMakeLists.txt                  |   2 +
 src/libedataserver/e-oauth2-service-yahoo.c        | 233 +++++++++++++++++++++
 src/libedataserver/e-oauth2-service-yahoo.h        |  62 ++++++
 src/libedataserver/e-oauth2-services.c             |   2 +
 src/libedataserver/libedataserver.h                |   1 +
 src/modules/yahoo-backend/module-yahoo-backend.c   |   6 +-
 15 files changed, 443 insertions(+), 3 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96930d395..08dc111e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -424,6 +424,17 @@ if(ENABLE_OAUTH2)
        #if(WITH_OUTLOOK_CLIENT_SECRET STREQUAL "")
        #       set(WITH_OUTLOOK_CLIENT_SECRET "")
        #endif(WITH_OUTLOOK_CLIENT_SECRET STREQUAL "")
+
+       add_printable_variable(WITH_YAHOO_CLIENT_ID "Yahoo! OAuth 2.0 client id" "")
+       add_printable_variable(WITH_YAHOO_CLIENT_SECRET "Yahoo! OAuth 2.0 client secret" "")
+
+       if(WITH_YAHOO_CLIENT_ID STREQUAL "")
+               set(WITH_YAHOO_CLIENT_ID 
"dj0yJmk9RHNlMGFKTXdkYzRXJmQ9WVdrOVNUUXpUWGhzWjJzbWNHbzlNQT09JnM9Y29uc3VtZXJzZWNyZXQmc3Y9MCZ4PWNi")
+       endif(WITH_YAHOO_CLIENT_ID STREQUAL "")
+
+       if(WITH_YAHOO_CLIENT_SECRET STREQUAL "")
+               set(WITH_YAHOO_CLIENT_SECRET "35f49f199dd754ec5e86d3c7cd576a1341c9bc0b")
+       endif(WITH_YAHOO_CLIENT_SECRET STREQUAL "")
 endif(ENABLE_OAUTH2)
 
 # ******************************************
diff --git a/config.h.in b/config.h.in
index 2343e2444..bd2978acf 100644
--- a/config.h.in
+++ b/config.h.in
@@ -45,6 +45,12 @@
 /* Define Outlook.com OAuth 2.0 Client Secret to use */
 #define OUTLOOK_CLIENT_SECRET "@WITH_OUTLOOK_CLIENT_SECRET@"
 
+/* Define Yahoo! OAuth 2.0 Client ID to use */
+#define YAHOO_CLIENT_ID "@WITH_YAHOO_CLIENT_ID@"
+
+/* Define Yahoo! OAuth 2.0 Client Secret to use */
+#define YAHOO_CLIENT_SECRET "@WITH_YAHOO_CLIENT_SECRET@"
+
 /* Path to a sendmail binary, or equivalent */
 #define SENDMAIL_PATH "@SENDMAIL_PATH@"
 
diff --git a/data/org.gnome.evolution-data-server.gschema.xml.in 
b/data/org.gnome.evolution-data-server.gschema.xml.in
index 7e2c9b85c..98defd45a 100644
--- a/data/org.gnome.evolution-data-server.gschema.xml.in
+++ b/data/org.gnome.evolution-data-server.gschema.xml.in
@@ -71,5 +71,15 @@
       <_summary>An OAuth2 client secret to use to connect to Outlook servers, instead of the one provided 
during build time</_summary>
       <_description>User-specified OAuth2 client secret for Outlook servers. Empty string means to use the 
one provided during build time. Change of this requires restart.</_description>
     </key>
+    <key name="oauth2-yahoo-client-id" type="s">
+      <default>''</default>
+      <_summary>An OAuth2 client ID to use to connect to Yahoo! servers, instead of the one provided during 
build time</_summary>
+      <_description>User-specified OAuth2 client ID for Yahoo! servers. Empty string means to use the one 
provided during build time. Change of this requires restart.</_description>
+    </key>
+    <key name="oauth2-yahoo-client-secret" type="s">
+      <default>''</default>
+      <_summary>An OAuth2 client secret to use to connect to Yahoo! servers, instead of the one provided 
during build time</_summary>
+      <_description>User-specified OAuth2 client secret for Yahoo! servers. Empty string means to use the 
one provided during build time. Change of this requires restart.</_description>
+    </key>
   </schema>
 </schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cc6e39487..9a25ab509 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -117,6 +117,7 @@ src/camel/camel-sasl-popb4smtp.c
 src/camel/camel-sasl-xoauth2.c
 src/camel/camel-sasl-xoauth2-google.c
 src/camel/camel-sasl-xoauth2-outlook.c
+src/camel/camel-sasl-xoauth2-yahoo.c
 src/camel/camel-search-private.c
 src/camel/camel-service.c
 src/camel/camel-session.c
@@ -198,6 +199,7 @@ src/libedataserver/e-client.c
 src/libedataserver/e-oauth2-service.c
 src/libedataserver/e-oauth2-service-google.c
 src/libedataserver/e-oauth2-service-outlook.c
+src/libedataserver/e-oauth2-service-yahoo.c
 src/libedataserver/e-soup-session.c
 src/libedataserver/e-source.c
 src/libedataserver/e-source-credentials-provider-impl.c
diff --git a/src/camel/CMakeLists.txt b/src/camel/CMakeLists.txt
index 6f3e970b7..2ba609b8e 100644
--- a/src/camel/CMakeLists.txt
+++ b/src/camel/CMakeLists.txt
@@ -107,6 +107,7 @@ set(SOURCES
        camel-sasl-xoauth2.c
        camel-sasl-xoauth2-google.c
        camel-sasl-xoauth2-outlook.c
+       camel-sasl-xoauth2-yahoo.c
        camel-sasl.c
        camel-search-private.c
        camel-search-sql-sexp.c
@@ -248,6 +249,7 @@ set(HEADERS
        camel-sasl-xoauth2.h
        camel-sasl-xoauth2-google.h
        camel-sasl-xoauth2-outlook.h
+       camel-sasl-xoauth2-yahoo.h
        camel-sasl.h
        camel-search-private.h
        camel-search-sql-sexp.h
diff --git a/src/camel/camel-sasl-xoauth2-yahoo.c b/src/camel/camel-sasl-xoauth2-yahoo.c
new file mode 100644
index 000000000..75ec2ae81
--- /dev/null
+++ b/src/camel/camel-sasl-xoauth2-yahoo.c
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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 "camel-sasl-xoauth2-yahoo.h"
+
+static CamelServiceAuthType sasl_xoauth2_yahoo_auth_type = {
+       N_("OAuth2 (Yahoo!)"),
+       N_("This option will use an OAuth 2.0 access token to connect to the Yahoo! server"),
+       "Yahoo",
+       FALSE
+};
+
+G_DEFINE_TYPE (CamelSaslXOAuth2Yahoo, camel_sasl_xoauth2_yahoo, CAMEL_TYPE_SASL_XOAUTH2)
+
+static void
+camel_sasl_xoauth2_yahoo_class_init (CamelSaslXOAuth2YahooClass *klass)
+{
+       CamelSaslClass *sasl_class;
+
+       sasl_class = CAMEL_SASL_CLASS (klass);
+       sasl_class->auth_type = &sasl_xoauth2_yahoo_auth_type;
+}
+
+static void
+camel_sasl_xoauth2_yahoo_init (CamelSaslXOAuth2Yahoo *sasl)
+{
+}
diff --git a/src/camel/camel-sasl-xoauth2-yahoo.h b/src/camel/camel-sasl-xoauth2-yahoo.h
new file mode 100644
index 000000000..5b03e7bf3
--- /dev/null
+++ b/src/camel/camel-sasl-xoauth2-yahoo.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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/>.
+ */
+
+#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
+#error "Only <camel/camel.h> can be included directly."
+#endif
+
+#ifndef CAMEL_SASL_XOAUTH2_YAHOO_H
+#define CAMEL_SASL_XOAUTH2_YAHOO_H
+
+#include <camel/camel-sasl-xoauth2.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_SASL_XOAUTH2_YAHOO \
+       (camel_sasl_xoauth2_yahoo_get_type ())
+#define CAMEL_SASL_XOAUTH2_YAHOO(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), CAMEL_TYPE_SASL_XOAUTH2_YAHOO, CamelSaslXOAuth2Yahoo))
+#define CAMEL_SASL_XOAUTH2_YAHOO_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), CAMEL_TYPE_SASL_XOAUTH2_YAHOO, CamelSaslXOAuth2YahooClass))
+#define CAMEL_IS_SASL_XOAUTH2_YAHOO(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), CAMEL_TYPE_SASL_XOAUTH2_YAHOO))
+#define CAMEL_IS_SASL_XOAUTH2_YAHOO_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), CAMEL_TYPE_SASL_XOAUTH2_YAHOO))
+#define CAMEL_SASL_XOAUTH2_YAHOO_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), CAMEL_TYPE_SASL_XOAUTH2_YAHOO, CamelSaslXOAuth2YahooClass))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelSaslXOAuth2Yahoo CamelSaslXOAuth2Yahoo;
+typedef struct _CamelSaslXOAuth2YahooClass CamelSaslXOAuth2YahooClass;
+typedef struct _CamelSaslXOAuth2YahooPrivate CamelSaslXOAuth2YahooPrivate;
+
+struct _CamelSaslXOAuth2Yahoo {
+       CamelSaslXOAuth2 parent;
+       CamelSaslXOAuth2YahooPrivate *priv;
+};
+
+struct _CamelSaslXOAuth2YahooClass {
+       CamelSaslXOAuth2Class parent_class;
+};
+
+GType          camel_sasl_xoauth2_yahoo_get_type       (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* CAMEL_SASL_XOAUTH2_YAHOO_H */
diff --git a/src/camel/camel-sasl.c b/src/camel/camel-sasl.c
index a824f9412..0a09c5559 100644
--- a/src/camel/camel-sasl.c
+++ b/src/camel/camel-sasl.c
@@ -34,6 +34,7 @@
 #include "camel-sasl-xoauth2.h"
 #include "camel-sasl-xoauth2-google.h"
 #include "camel-sasl-xoauth2-outlook.h"
+#include "camel-sasl-xoauth2-yahoo.h"
 #include "camel-sasl.h"
 #include "camel-service.h"
 
@@ -131,6 +132,7 @@ sasl_build_class_table (void)
        g_type_ensure (CAMEL_TYPE_SASL_XOAUTH2);
        g_type_ensure (CAMEL_TYPE_SASL_XOAUTH2_GOOGLE);
        g_type_ensure (CAMEL_TYPE_SASL_XOAUTH2_OUTLOOK);
+       g_type_ensure (CAMEL_TYPE_SASL_XOAUTH2_YAHOO);
 
        class_table = g_hash_table_new_full (
                (GHashFunc) g_str_hash,
diff --git a/src/camel/camel.h b/src/camel/camel.h
index 6733085be..0df1baf22 100644
--- a/src/camel/camel.h
+++ b/src/camel/camel.h
@@ -111,6 +111,7 @@
 #include <camel/camel-sasl-xoauth2.h>
 #include <camel/camel-sasl-xoauth2-google.h>
 #include <camel/camel-sasl-xoauth2-outlook.h>
+#include <camel/camel-sasl-xoauth2-yahoo.h>
 #include <camel/camel-service.h>
 #include <camel/camel-session.h>
 #include <camel/camel-settings.h>
diff --git a/src/libedataserver/CMakeLists.txt b/src/libedataserver/CMakeLists.txt
index 15c38624c..b196ae26a 100644
--- a/src/libedataserver/CMakeLists.txt
+++ b/src/libedataserver/CMakeLists.txt
@@ -68,6 +68,7 @@ set(SOURCES
        e-oauth2-service-base.c
        e-oauth2-service-google.c
        e-oauth2-service-outlook.c
+       e-oauth2-service-yahoo.c
        e-oauth2-services.c
        e-operation-pool.c
        e-proxy.c
@@ -158,6 +159,7 @@ set(HEADERS
        e-oauth2-service-base.h
        e-oauth2-service-google.h
        e-oauth2-service-outlook.h
+       e-oauth2-service-yahoo.h
        e-oauth2-services.h
        e-operation-pool.h
        e-proxy.h
diff --git a/src/libedataserver/e-oauth2-service-yahoo.c b/src/libedataserver/e-oauth2-service-yahoo.c
new file mode 100644
index 000000000..329a38c41
--- /dev/null
+++ b/src/libedataserver/e-oauth2-service-yahoo.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2021 Red Hat (www.redhat.com)
+ *
+ * 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 "e-oauth2-service.h"
+#include "e-oauth2-service-base.h"
+
+#include "e-oauth2-service-yahoo.h"
+
+/* https://developer.yahoo.com/oauth2/guide/openid_connect/getting_started.html */
+
+/* Forward Declarations */
+static void e_oauth2_service_yahoo_oauth2_service_init (EOAuth2ServiceInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (EOAuth2ServiceYahoo, e_oauth2_service_yahoo, E_TYPE_OAUTH2_SERVICE_BASE,
+       G_IMPLEMENT_INTERFACE (E_TYPE_OAUTH2_SERVICE, e_oauth2_service_yahoo_oauth2_service_init))
+
+static gboolean
+eos_yahoo_guess_can_process (EOAuth2Service *service,
+                             const gchar *protocol,
+                             const gchar *hostname)
+{
+       return hostname &&
+               e_util_utf8_strstrcase (hostname, ".yahoo.com");
+}
+
+static const gchar *
+eos_yahoo_get_name (EOAuth2Service *service)
+{
+       return "Yahoo";
+}
+
+static const gchar *
+eos_yahoo_get_display_name (EOAuth2Service *service)
+{
+       /* Translators: This is a user-visible string, display name of an OAuth2 service. */
+       return C_("OAuth2Service", "Yahoo!");
+}
+
+static const gchar *
+eos_yahoo_read_settings (EOAuth2Service *service,
+                        const gchar *key_name)
+{
+       G_LOCK_DEFINE_STATIC (user_settings);
+       gchar *value;
+
+       G_LOCK (user_settings);
+
+       value = g_object_get_data (G_OBJECT (service), key_name);
+       if (!value) {
+               GSettings *settings;
+
+               settings = g_settings_new ("org.gnome.evolution-data-server");
+               value = g_settings_get_string (settings, key_name);
+               g_object_unref (settings);
+
+               if (value && *value) {
+                       g_object_set_data_full (G_OBJECT (service), key_name, value, g_free);
+               } else {
+                       g_free (value);
+                       value = (gchar *) "";
+
+                       g_object_set_data (G_OBJECT (service), key_name, value);
+               }
+       }
+
+       G_UNLOCK (user_settings);
+
+       return value;
+}
+
+static const gchar *
+eos_yahoo_get_client_id (EOAuth2Service *service,
+                        ESource *source)
+{
+       const gchar *client_id;
+
+       client_id = eos_yahoo_read_settings (service, "oauth2-yahoo-client-id");
+
+       if (client_id && *client_id)
+               return client_id;
+
+       return YAHOO_CLIENT_ID;
+}
+
+static const gchar *
+eos_yahoo_get_client_secret (EOAuth2Service *service,
+                            ESource *source)
+{
+       const gchar *client_secret;
+
+       client_secret = eos_yahoo_read_settings (service, "oauth2-yahoo-client-secret");
+
+       if (client_secret && *client_secret)
+               return client_secret;
+
+       return YAHOO_CLIENT_SECRET;
+}
+
+static const gchar *
+eos_yahoo_get_authentication_uri (EOAuth2Service *service,
+                                 ESource *source)
+{
+       return "https://api.login.yahoo.com/oauth2/request_auth";;
+}
+
+static const gchar *
+eos_yahoo_get_refresh_uri (EOAuth2Service *service,
+                          ESource *source)
+{
+       return "https://api.login.yahoo.com/oauth2/get_token";;
+}
+
+static const gchar *
+eos_yahoo_get_redirect_uri (EOAuth2Service *service,
+                           ESource *source)
+{
+       return "https://wiki.gnome.org/Apps/Evolution/YahooOAuth2/";;
+}
+
+static void
+eos_yahoo_prepare_authentication_uri_query (EOAuth2Service *service,
+                                           ESource *source,
+                                           GHashTable *uri_query)
+{
+       const gchar *YAHOO_SCOPE =
+               /* Mail */
+               "mail-w "
+               /* Calendar */
+               "ycal-w "
+               /* Contacts */
+               "sdct-w";
+       gchar *nonce_str;
+       guint64 nonce_val;
+
+       g_return_if_fail (uri_query != NULL);
+
+       nonce_val = getpid () + g_get_real_time () + g_get_monotonic_time() + g_random_int () + g_random_int 
();
+       nonce_str = g_strdup_printf ("%" G_GUINT64_FORMAT "d", nonce_val);
+
+       e_oauth2_service_util_set_to_form (uri_query, "scope", YAHOO_SCOPE);
+       e_oauth2_service_util_set_to_form (uri_query, "nonce", nonce_str);
+
+       g_free (nonce_str);
+}
+
+static gboolean
+eos_yahoo_extract_authorization_code (EOAuth2Service *service,
+                                     ESource *source,
+                                     const gchar *page_title,
+                                     const gchar *page_uri,
+                                     const gchar *page_content,
+                                     gchar **out_authorization_code)
+{
+       g_return_val_if_fail (out_authorization_code != NULL, FALSE);
+
+       *out_authorization_code = NULL;
+
+       if (page_uri && *page_uri) {
+               SoupURI *suri;
+
+               suri = soup_uri_new (page_uri);
+               if (suri) {
+                       const gchar *query = soup_uri_get_query (suri);
+                       gboolean known = FALSE;
+
+                       if (query && *query) {
+                               GHashTable *params;
+
+                               params = soup_form_decode (query);
+                               if (params) {
+                                       const gchar *response;
+
+                                       response = g_hash_table_lookup (params, "code");
+                                       if (response) {
+                                               *out_authorization_code = g_strdup (response);
+                                               known = TRUE;
+                                       }
+
+                                       g_hash_table_destroy (params);
+                               }
+                       }
+
+                       soup_uri_free (suri);
+
+                       if (known)
+                               return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
+static void
+e_oauth2_service_yahoo_oauth2_service_init (EOAuth2ServiceInterface *iface)
+{
+       iface->guess_can_process = eos_yahoo_guess_can_process;
+       iface->get_name = eos_yahoo_get_name;
+       iface->get_display_name = eos_yahoo_get_display_name;
+       iface->get_client_id = eos_yahoo_get_client_id;
+       iface->get_client_secret = eos_yahoo_get_client_secret;
+       iface->get_authentication_uri = eos_yahoo_get_authentication_uri;
+       iface->get_refresh_uri = eos_yahoo_get_refresh_uri;
+       iface->get_redirect_uri = eos_yahoo_get_redirect_uri;
+       iface->prepare_authentication_uri_query = eos_yahoo_prepare_authentication_uri_query;
+       iface->extract_authorization_code = eos_yahoo_extract_authorization_code;
+}
+
+static void
+e_oauth2_service_yahoo_class_init (EOAuth2ServiceYahooClass *klass)
+{
+}
+
+static void
+e_oauth2_service_yahoo_init (EOAuth2ServiceYahoo *oauth2_yahoo)
+{
+}
diff --git a/src/libedataserver/e-oauth2-service-yahoo.h b/src/libedataserver/e-oauth2-service-yahoo.h
new file mode 100644
index 000000000..d41a15529
--- /dev/null
+++ b/src/libedataserver/e-oauth2-service-yahoo.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Red Hat (www.redhat.com)
+ *
+ * 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/>.
+ */
+
+#if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
+#error "Only <libedataserver/libedataserver.h> should be included directly."
+#endif
+
+#ifndef E_OAUTH2_SERVICE_YAHOO_H
+#define E_OAUTH2_SERVICE_YAHOO_H
+
+#include <libedataserver/e-oauth2-service-base.h>
+
+/* Standard GObject macros */
+#define E_TYPE_OAUTH2_SERVICE_YAHOO \
+       (e_oauth2_service_yahoo_get_type ())
+#define E_OAUTH2_SERVICE_YAHOO(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), E_TYPE_OAUTH2_SERVICE_YAHOO, EOAuth2ServiceYahoo))
+#define E_OAUTH2_SERVICE_YAHOO_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), E_TYPE_OAUTH2_SERVICE_YAHOO, EOAuth2ServiceYahooClass))
+#define E_IS_OAUTH2_SERVICE_YAHOO(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), E_TYPE_OAUTH2_SERVICE_YAHOO))
+#define E_IS_OAUTH2_SERVICE_YAHOO_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), E_TYPE_OAUTH2_SERVICE_YAHOO))
+#define E_OAUTH2_SERVICE_YAHOO_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), E_TYPE_OAUTH2_SERVICE_YAHOO, EOAuth2ServiceYahooClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EOAuth2ServiceYahoo EOAuth2ServiceYahoo;
+typedef struct _EOAuth2ServiceYahooClass EOAuth2ServiceYahooClass;
+
+struct _EOAuth2ServiceYahoo {
+       EOAuth2ServiceBase parent;
+};
+
+struct _EOAuth2ServiceYahooClass {
+       EOAuth2ServiceBaseClass parent_class;
+};
+
+GType          e_oauth2_service_yahoo_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* E_OAUTH2_SERVICE_YAHOO_H */
diff --git a/src/libedataserver/e-oauth2-services.c b/src/libedataserver/e-oauth2-services.c
index 6c0aa100c..838b007d6 100644
--- a/src/libedataserver/e-oauth2-services.c
+++ b/src/libedataserver/e-oauth2-services.c
@@ -37,6 +37,7 @@
 /* Known built-in implementations */
 #include "e-oauth2-service-google.h"
 #include "e-oauth2-service-outlook.h"
+#include "e-oauth2-service-yahoo.h"
 
 #include "e-oauth2-services.h"
 
@@ -136,6 +137,7 @@ e_oauth2_services_class_init (EOAuth2ServicesClass *klass)
        /* Ensure built-in service types are registered */
        g_type_ensure (E_TYPE_OAUTH2_SERVICE_GOOGLE);
        g_type_ensure (E_TYPE_OAUTH2_SERVICE_OUTLOOK);
+       g_type_ensure (E_TYPE_OAUTH2_SERVICE_YAHOO);
 }
 
 static void
diff --git a/src/libedataserver/libedataserver.h b/src/libedataserver/libedataserver.h
index cee5b6054..34e71cbf3 100644
--- a/src/libedataserver/libedataserver.h
+++ b/src/libedataserver/libedataserver.h
@@ -42,6 +42,7 @@
 #include <libedataserver/e-oauth2-service-base.h>
 #include <libedataserver/e-oauth2-service-google.h>
 #include <libedataserver/e-oauth2-service-outlook.h>
+#include <libedataserver/e-oauth2-service-yahoo.h>
 #include <libedataserver/e-oauth2-services.h>
 #include <libedataserver/e-operation-pool.h>
 #include <libedataserver/e-proxy.h>
diff --git a/src/modules/yahoo-backend/module-yahoo-backend.c 
b/src/modules/yahoo-backend/module-yahoo-backend.c
index 2d988706d..636b40aa3 100644
--- a/src/modules/yahoo-backend/module-yahoo-backend.c
+++ b/src/modules/yahoo-backend/module-yahoo-backend.c
@@ -44,8 +44,8 @@
 #define YAHOO_SMTP_SECURITY_METHOD     METHOD (SSL_ON_ALTERNATE_PORT)
 
 /* WebDAV Configuration Details */
-#define YAHOO_WEBDAV_URL               "https://caldav.calendar.yahoo.com/dav/";
-
+#define YAHOO_CALDAV_URL               "https://caldav.calendar.yahoo.com/dav/";
+#define YAHOO_CARDDAV_URL              "https://carddav.address.yahoo.com/dav/";
 
 typedef struct _EYahooBackend EYahooBackend;
 typedef struct _EYahooBackendClass EYahooBackendClass;
@@ -99,7 +99,7 @@ yahoo_backend_authenticate_sync (EBackend *backend,
        g_return_val_if_fail (E_IS_COLLECTION_BACKEND (backend), E_SOURCE_AUTHENTICATION_ERROR);
 
        return e_webdav_collection_backend_discover_sync (E_WEBDAV_COLLECTION_BACKEND (backend),
-               YAHOO_WEBDAV_URL, YAHOO_WEBDAV_URL, credentials,
+               YAHOO_CALDAV_URL, YAHOO_CARDDAV_URL, credentials,
                out_certificate_pem, out_certificate_errors, cancellable, error);
 }
 


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