|
Packit |
79f644 |
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
Packit |
79f644 |
/*
|
|
Packit |
79f644 |
* Copyright © 2011 – 2017 Red Hat, Inc.
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
79f644 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
79f644 |
* License as published by the Free Software Foundation; either
|
|
Packit |
79f644 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
79f644 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
79f644 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
79f644 |
* Lesser General Public License for more details.
|
|
Packit |
79f644 |
*
|
|
Packit |
79f644 |
* You should have received a copy of the GNU Lesser General
|
|
Packit |
79f644 |
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
79f644 |
*/
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#include "config.h"
|
|
Packit |
79f644 |
#include <glib/gi18n-lib.h>
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#include <rest/oauth-proxy.h>
|
|
Packit |
79f644 |
#include <json-glib/json-glib.h>
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#include "goaprovider.h"
|
|
Packit |
79f644 |
#include "goaprovider-priv.h"
|
|
Packit |
79f644 |
#include "goaoauth2provider.h"
|
|
Packit |
79f644 |
#include "goagoogleprovider.h"
|
|
Packit |
79f644 |
#include "goaobjectskeletonutils.h"
|
|
Packit |
79f644 |
#include "goarestproxy.h"
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
struct _GoaGoogleProvider
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
GoaOAuth2Provider parent_instance;
|
|
Packit |
79f644 |
};
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
G_DEFINE_TYPE_WITH_CODE (GoaGoogleProvider, goa_google_provider, GOA_TYPE_OAUTH2_PROVIDER,
|
|
Packit |
79f644 |
goa_provider_ensure_extension_points_registered ();
|
|
Packit |
79f644 |
g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME,
|
|
Packit |
79f644 |
g_define_type_id,
|
|
Packit |
79f644 |
GOA_GOOGLE_NAME,
|
|
Packit |
79f644 |
0));
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_provider_type (GoaProvider *provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return GOA_GOOGLE_NAME;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static gchar *
|
|
Packit |
79f644 |
get_provider_name (GoaProvider *provider,
|
|
Packit |
79f644 |
GoaObject *object)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return g_strdup (_("Google"));
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static GoaProviderGroup
|
|
Packit |
79f644 |
get_provider_group (GoaProvider *provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return GOA_PROVIDER_GROUP_BRANDED;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static GoaProviderFeatures
|
|
Packit |
79f644 |
get_provider_features (GoaProvider *provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return GOA_PROVIDER_FEATURE_BRANDED |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_MAIL |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_CALENDAR |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_CONTACTS |
|
|
Packit |
79f644 |
#ifdef GOA_TELEPATHY_ENABLED
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_CHAT |
|
|
Packit |
79f644 |
#endif
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_DOCUMENTS |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_PHOTOS |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_FILES |
|
|
Packit |
79f644 |
GOA_PROVIDER_FEATURE_PRINTERS;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_authorization_uri (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return "https://accounts.google.com/o/oauth2/auth";
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_token_uri (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return "https://accounts.google.com/o/oauth2/token";
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_redirect_uri (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return "http://localhost";
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_scope (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return /* Read-only access to the user's email address */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/userinfo.email "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Name and picture */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/userinfo.profile "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Calendar API (CalDAV and GData) */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/calendar "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Contacts API (GData) */
|
|
Packit |
79f644 |
"https://www.google.com/m8/feeds/ "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Contacts API (CardDAV) - undocumented */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/carddav "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Drive API */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/drive "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Documents List Data API */
|
|
Packit |
79f644 |
"https://docs.googleusercontent.com/ "
|
|
Packit |
79f644 |
"https://spreadsheets.google.com/feeds/ "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google PicasaWeb API (GData) */
|
|
Packit |
79f644 |
"https://picasaweb.google.com/data/ "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* GMail IMAP and SMTP access */
|
|
Packit |
79f644 |
"https://mail.google.com/ "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Cloud Print */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/cloudprint "
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
#ifdef GOA_TELEPATHY_ENABLED
|
|
Packit |
79f644 |
/* Google Talk */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/googletalk "
|
|
Packit |
79f644 |
#endif
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Google Tasks - undocumented */
|
|
Packit |
79f644 |
"https://www.googleapis.com/auth/tasks";
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static guint
|
|
Packit |
79f644 |
get_credentials_generation (GoaProvider *provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return 10;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_client_id (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return GOA_GOOGLE_CLIENT_ID;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static const gchar *
|
|
Packit |
79f644 |
get_client_secret (GoaOAuth2Provider *oauth2_provider)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
return GOA_GOOGLE_CLIENT_SECRET;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static gchar *
|
|
Packit |
79f644 |
get_identity_sync (GoaOAuth2Provider *oauth2_provider,
|
|
Packit |
79f644 |
const gchar *access_token,
|
|
Packit |
79f644 |
gchar **out_presentation_identity,
|
|
Packit |
79f644 |
GCancellable *cancellable,
|
|
Packit |
79f644 |
GError **error)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
GError *identity_error = NULL;
|
|
Packit |
79f644 |
RestProxy *proxy = NULL;
|
|
Packit |
79f644 |
RestProxyCall *call = NULL;
|
|
Packit |
79f644 |
JsonParser *parser = NULL;
|
|
Packit |
79f644 |
JsonObject *json_object;
|
|
Packit |
79f644 |
gchar *ret = NULL;
|
|
Packit |
79f644 |
gchar *email = NULL;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* TODO: cancellable */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
proxy = goa_rest_proxy_new ("https://www.googleapis.com/oauth2/v2/userinfo", FALSE);
|
|
Packit |
79f644 |
call = rest_proxy_new_call (proxy);
|
|
Packit |
79f644 |
rest_proxy_call_set_method (call, "GET");
|
|
Packit |
79f644 |
rest_proxy_call_add_param (call, "access_token", access_token);
|
|
Packit |
79f644 |
rest_proxy_call_add_param (call, "fields", "email");
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
if (!rest_proxy_call_sync (call, error))
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
if (rest_proxy_call_get_status_code (call) != 200)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
g_set_error (error,
|
|
Packit |
79f644 |
GOA_ERROR,
|
|
Packit |
79f644 |
GOA_ERROR_FAILED,
|
|
Packit |
79f644 |
_("Expected status 200 when requesting your identity, instead got status %d (%s)"),
|
|
Packit |
79f644 |
rest_proxy_call_get_status_code (call),
|
|
Packit |
79f644 |
rest_proxy_call_get_status_message (call));
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
parser = json_parser_new ();
|
|
Packit |
79f644 |
if (!json_parser_load_from_data (parser,
|
|
Packit |
79f644 |
rest_proxy_call_get_payload (call),
|
|
Packit |
79f644 |
rest_proxy_call_get_payload_length (call),
|
|
Packit |
79f644 |
&identity_error))
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
g_warning ("json_parser_load_from_data() failed: %s (%s, %d)",
|
|
Packit |
79f644 |
identity_error->message,
|
|
Packit |
79f644 |
g_quark_to_string (identity_error->domain),
|
|
Packit |
79f644 |
identity_error->code);
|
|
Packit |
79f644 |
g_set_error (error,
|
|
Packit |
79f644 |
GOA_ERROR,
|
|
Packit |
79f644 |
GOA_ERROR_FAILED,
|
|
Packit |
79f644 |
_("Could not parse response"));
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
json_object = json_node_get_object (json_parser_get_root (parser));
|
|
Packit |
79f644 |
if (!json_object_has_member (json_object, "email"))
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
g_warning ("Did not find email in JSON data");
|
|
Packit |
79f644 |
g_set_error (error,
|
|
Packit |
79f644 |
GOA_ERROR,
|
|
Packit |
79f644 |
GOA_ERROR_FAILED,
|
|
Packit |
79f644 |
_("Could not parse response"));
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
email = g_strdup (json_object_get_string_member (json_object, "email"));
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
ret = email;
|
|
Packit |
79f644 |
email = NULL;
|
|
Packit |
79f644 |
if (out_presentation_identity != NULL)
|
|
Packit |
79f644 |
*out_presentation_identity = g_strdup (ret); /* for now: use email as presentation identity */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
out:
|
|
Packit |
79f644 |
g_clear_object (&parser);
|
|
Packit |
79f644 |
g_clear_error (&identity_error);
|
|
Packit |
79f644 |
g_clear_object (&call);
|
|
Packit |
79f644 |
g_clear_object (&proxy);
|
|
Packit |
79f644 |
g_free (email);
|
|
Packit |
79f644 |
return ret;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static gboolean
|
|
Packit |
79f644 |
is_identity_node (GoaOAuth2Provider *oauth2_provider, WebKitDOMHTMLInputElement *element)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
gboolean ret = FALSE;
|
|
Packit |
79f644 |
gchar *element_type = NULL;
|
|
Packit |
79f644 |
gchar *id = NULL;
|
|
Packit |
79f644 |
gchar *name = NULL;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
g_object_get (element, "type", &element_type, NULL);
|
|
Packit |
79f644 |
if (g_strcmp0 (element_type, "email") != 0)
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
id = webkit_dom_element_get_id (WEBKIT_DOM_ELEMENT (element));
|
|
Packit |
79f644 |
if (g_strcmp0 (id, "identifierId") != 0)
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
name = webkit_dom_html_input_element_get_name (element);
|
|
Packit |
79f644 |
if (g_strcmp0 (name, "identifier") != 0)
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
ret = TRUE;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
out:
|
|
Packit |
79f644 |
g_free (element_type);
|
|
Packit |
79f644 |
g_free (id);
|
|
Packit |
79f644 |
g_free (name);
|
|
Packit |
79f644 |
return ret;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static gboolean
|
|
Packit |
79f644 |
build_object (GoaProvider *provider,
|
|
Packit |
79f644 |
GoaObjectSkeleton *object,
|
|
Packit |
79f644 |
GKeyFile *key_file,
|
|
Packit |
79f644 |
const gchar *group,
|
|
Packit |
79f644 |
GDBusConnection *connection,
|
|
Packit |
79f644 |
gboolean just_added,
|
|
Packit |
79f644 |
GError **error)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
GoaAccount *account = NULL;
|
|
Packit |
79f644 |
GoaMail *mail = NULL;
|
|
Packit |
79f644 |
gchar *uri_caldav;
|
|
Packit |
79f644 |
gchar *uri_drive;
|
|
Packit |
79f644 |
gboolean ret = FALSE;
|
|
Packit |
79f644 |
gboolean mail_enabled;
|
|
Packit |
79f644 |
gboolean calendar_enabled;
|
|
Packit |
79f644 |
gboolean contacts_enabled;
|
|
Packit |
79f644 |
gboolean chat_enabled;
|
|
Packit |
79f644 |
gboolean documents_enabled;
|
|
Packit |
79f644 |
gboolean files_enabled;
|
|
Packit |
79f644 |
gboolean photos_enabled;
|
|
Packit |
79f644 |
gboolean printers_enabled;
|
|
Packit |
79f644 |
const gchar *email_address;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Chain up */
|
|
Packit |
79f644 |
if (!GOA_PROVIDER_CLASS (goa_google_provider_parent_class)->build_object (provider,
|
|
Packit |
79f644 |
object,
|
|
Packit |
79f644 |
key_file,
|
|
Packit |
79f644 |
group,
|
|
Packit |
79f644 |
connection,
|
|
Packit |
79f644 |
just_added,
|
|
Packit |
79f644 |
error))
|
|
Packit |
79f644 |
goto out;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
account = goa_object_get_account (GOA_OBJECT (object));
|
|
Packit |
79f644 |
email_address = goa_account_get_identity (account);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Email */
|
|
Packit |
79f644 |
mail = goa_object_get_mail (GOA_OBJECT (object));
|
|
Packit |
79f644 |
mail_enabled = g_key_file_get_boolean (key_file, group, "MailEnabled", NULL);
|
|
Packit |
79f644 |
if (mail_enabled)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
if (mail == NULL)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
mail = goa_mail_skeleton_new ();
|
|
Packit |
79f644 |
g_object_set (G_OBJECT (mail),
|
|
Packit |
79f644 |
"email-address", email_address,
|
|
Packit |
79f644 |
"imap-supported", TRUE,
|
|
Packit |
79f644 |
"imap-host", "imap.gmail.com",
|
|
Packit |
79f644 |
"imap-user-name", email_address,
|
|
Packit |
79f644 |
"imap-use-ssl", TRUE,
|
|
Packit |
79f644 |
"smtp-supported", TRUE,
|
|
Packit |
79f644 |
"smtp-host", "smtp.gmail.com",
|
|
Packit |
79f644 |
"smtp-user-name", email_address,
|
|
Packit |
79f644 |
"smtp-use-auth", TRUE,
|
|
Packit |
79f644 |
"smtp-auth-xoauth2", TRUE,
|
|
Packit |
79f644 |
"smtp-use-ssl", TRUE,
|
|
Packit |
79f644 |
"smtp-use-tls", TRUE,
|
|
Packit |
79f644 |
NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_set_mail (object, mail);
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
else
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
if (mail != NULL)
|
|
Packit |
79f644 |
goa_object_skeleton_set_mail (object, NULL);
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Calendar */
|
|
Packit |
79f644 |
calendar_enabled = g_key_file_get_boolean (key_file, group, "CalendarEnabled", NULL);
|
|
Packit |
79f644 |
uri_caldav = g_strconcat ("https://apidata.googleusercontent.com/caldav/v2/", email_address, "/user", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_calendar (object, uri_caldav, calendar_enabled, FALSE);
|
|
Packit |
79f644 |
g_free (uri_caldav);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Contacts */
|
|
Packit |
79f644 |
contacts_enabled = g_key_file_get_boolean (key_file, group, "ContactsEnabled", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_contacts (object,
|
|
Packit |
79f644 |
"https://www.googleapis.com/.well-known/carddav",
|
|
Packit |
79f644 |
contacts_enabled,
|
|
Packit |
79f644 |
FALSE);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Chat */
|
|
Packit |
79f644 |
chat_enabled = g_key_file_get_boolean (key_file, group, "ChatEnabled", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_chat (object, chat_enabled);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Documents */
|
|
Packit |
79f644 |
documents_enabled = g_key_file_get_boolean (key_file, group, "DocumentsEnabled", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_documents (object, documents_enabled);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Photos */
|
|
Packit |
79f644 |
photos_enabled = g_key_file_get_boolean (key_file, group, "PhotosEnabled", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_photos (object, photos_enabled);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Files */
|
|
Packit |
79f644 |
files_enabled = g_key_file_get_boolean (key_file, group, "FilesEnabled", NULL);
|
|
Packit |
79f644 |
uri_drive = g_strconcat ("google-drive://", email_address, "/", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_files (object, uri_drive, files_enabled, FALSE);
|
|
Packit |
79f644 |
g_free (uri_drive);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* Printers */
|
|
Packit |
79f644 |
printers_enabled = g_key_file_get_boolean (key_file, group, "PrintersEnabled", NULL);
|
|
Packit |
79f644 |
goa_object_skeleton_attach_printers (object, printers_enabled);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
if (just_added)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
goa_account_set_mail_disabled (account, !mail_enabled);
|
|
Packit |
79f644 |
goa_account_set_calendar_disabled (account, !calendar_enabled);
|
|
Packit |
79f644 |
goa_account_set_contacts_disabled (account, !contacts_enabled);
|
|
Packit |
79f644 |
goa_account_set_chat_disabled (account, !chat_enabled);
|
|
Packit |
79f644 |
goa_account_set_documents_disabled (account, !documents_enabled);
|
|
Packit |
79f644 |
goa_account_set_photos_disabled (account, !photos_enabled);
|
|
Packit |
79f644 |
goa_account_set_files_disabled (account, !files_enabled);
|
|
Packit |
79f644 |
goa_account_set_printers_disabled (account, !printers_enabled);
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::mail-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "MailEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::calendar-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "CalendarEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::contacts-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "ContactsEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::chat-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "ChatEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::documents-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "DocumentsEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::photos-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "PhotosEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::files-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "FilesEnabled");
|
|
Packit |
79f644 |
g_signal_connect (account,
|
|
Packit |
79f644 |
"notify::printers-disabled",
|
|
Packit |
79f644 |
G_CALLBACK (goa_util_account_notify_property_cb),
|
|
Packit |
79f644 |
(gpointer) "PrintersEnabled");
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
ret = TRUE;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
out:
|
|
Packit |
79f644 |
g_clear_object (&mail);
|
|
Packit |
79f644 |
g_clear_object (&account);
|
|
Packit |
79f644 |
return ret;
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static void
|
|
Packit |
79f644 |
add_account_key_values (GoaOAuth2Provider *oauth2_provider,
|
|
Packit |
79f644 |
GVariantBuilder *builder)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "MailEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "CalendarEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "ContactsEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "ChatEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "DocumentsEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "PhotosEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "FilesEnabled", "true");
|
|
Packit |
79f644 |
g_variant_builder_add (builder, "{ss}", "PrintersEnabled", "true");
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
/* ---------------------------------------------------------------------------------------------------- */
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static void
|
|
Packit |
79f644 |
goa_google_provider_init (GoaGoogleProvider *self)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
}
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
static void
|
|
Packit |
79f644 |
goa_google_provider_class_init (GoaGoogleProviderClass *klass)
|
|
Packit |
79f644 |
{
|
|
Packit |
79f644 |
GoaProviderClass *provider_class;
|
|
Packit |
79f644 |
GoaOAuth2ProviderClass *oauth2_class;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
provider_class = GOA_PROVIDER_CLASS (klass);
|
|
Packit |
79f644 |
provider_class->get_provider_type = get_provider_type;
|
|
Packit |
79f644 |
provider_class->get_provider_name = get_provider_name;
|
|
Packit |
79f644 |
provider_class->get_provider_group = get_provider_group;
|
|
Packit |
79f644 |
provider_class->get_provider_features = get_provider_features;
|
|
Packit |
79f644 |
provider_class->build_object = build_object;
|
|
Packit |
79f644 |
provider_class->get_credentials_generation = get_credentials_generation;
|
|
Packit |
79f644 |
|
|
Packit |
79f644 |
oauth2_class = GOA_OAUTH2_PROVIDER_CLASS (klass);
|
|
Packit |
79f644 |
oauth2_class->get_authorization_uri = get_authorization_uri;
|
|
Packit |
79f644 |
oauth2_class->get_client_id = get_client_id;
|
|
Packit |
79f644 |
oauth2_class->get_client_secret = get_client_secret;
|
|
Packit |
79f644 |
oauth2_class->get_identity_sync = get_identity_sync;
|
|
Packit |
79f644 |
oauth2_class->get_redirect_uri = get_redirect_uri;
|
|
Packit |
79f644 |
oauth2_class->get_scope = get_scope;
|
|
Packit |
79f644 |
oauth2_class->is_identity_node = is_identity_node;
|
|
Packit |
79f644 |
oauth2_class->get_token_uri = get_token_uri;
|
|
Packit |
79f644 |
oauth2_class->add_account_key_values = add_account_key_values;
|
|
Packit |
79f644 |
}
|