Commit 34093e8e authored by Debarshi Ray's avatar Debarshi Ray

Add a whitelist for providers

The whitelist is a GSetting where you can either list the names of the
providers that should be enabled or use 'all' to have everything.

Bump minimum intltool version to 0.50.1 for GSettings XML support.

Modelled off gnome-settings-daemon whitelist.

Fixes: https://bugzilla.gnome.org/729173
parent 0fe2a9f5
......@@ -61,6 +61,7 @@ AC_DEFINE(GOA_MICRO_VERSION,
# Initialization
#
GLIB_GSETTINGS
GNOME_DEBUG_CHECK
GNOME_COMPILE_WARNINGS([maximum])
GNOME_MAINTAINER_MODE_DEFINES
......@@ -423,7 +424,7 @@ fi
# Internationalization
#
IT_PROG_INTLTOOL
IT_PROG_INTLTOOL([0.50.1])
GETTEXT_PACKAGE=gnome-online-accounts
AC_SUBST([GETTEXT_PACKAGE])
AM_GLIB_GNU_GETTEXT
......@@ -483,6 +484,7 @@ data/icons/24x24/Makefile
data/icons/32x32/Makefile
data/icons/48x48/Makefile
data/icons/256x256/Makefile
data/org.gnome.online-accounts.gschema.xml
src/Makefile
src/goa/Makefile
src/goa/goa-1.0.pc
......
......@@ -6,6 +6,12 @@ SUBDIRS = icons
cssdir = $(pkgdatadir)
css_DATA = goawebview.css
gsettings_in_files = org.gnome.online-accounts.gschema.xml.in
gsettings_SCHEMAS = $(gsettings_in_files:.xml.in=.xml)
@INTLTOOL_XML_RULE@
@GSETTINGS_RULES@
servicedir = $(datadir)/dbus-1/services
service_in_files = org.gnome.OnlineAccounts.service.in
service_DATA = $(service_in_files:.service.in=.service)
......@@ -15,11 +21,13 @@ $(service_DATA): $(service_in_files) Makefile
EXTRA_DIST = \
$(css_DATA) \
$(gsettings_in_files) \
$(service_in_files) \
dbus-interfaces.xml \
$(NULL)
DISTCLEANFILES = \
$(gsettings_SCHEMAS) \
org.gnome.OnlineAccounts.service \
$(NULL)
......
<schemalist gettext-domain="@GETTEXT_PACKAGE@">
<schema id="org.gnome.online-accounts" path="/org/gnome/online-accounts/">
<key name="whitelisted-providers" type="as">
<default>['all']</default>
<summary>List of providers that are allowed to be loaded</summary>
<description>
A list of strings representing the providers that are allowed to be loaded (default: 'all'). This is only evaluated on startup.
</description>
</key>
</schema>
</schemalist>
[encoding: UTF-8]
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
data/org.gnome.online-accounts.gschema.xml.in
src/daemon/goadaemon.c
src/goabackend/goaewsclient.c
src/goabackend/goaexchangeprovider.c
......
......@@ -751,53 +751,109 @@ goa_provider_ensure_extension_points_registered (void)
}
}
static void
ensure_builtins_loaded (void)
{
static gsize once_init_value = 0;
goa_provider_ensure_extension_points_registered ();
/* ---------------------------------------------------------------------------------------------------- */
if (g_once_init_enter (&once_init_value))
{
/* The order is in which the providers' types are created is
* important because it affects the order in which they are
* returned by goa_provider_get_all.
*/
static struct
{
const gchar *name;
GType (*get_type) (void);
} ordered_builtins_map[] = {
/* The order is in which the providers' types are created is
* important because it affects the order in which they are
* returned by goa_provider_get_all.
*/
#ifdef GOA_GOOGLE_ENABLED
g_type_ensure (GOA_TYPE_GOOGLE_PROVIDER);
{ GOA_GOOGLE_NAME, goa_google_provider_get_type },
#endif
#ifdef GOA_OWNCLOUD_ENABLED
g_type_ensure (GOA_TYPE_OWNCLOUD_PROVIDER);
{ GOA_OWNCLOUD_NAME, goa_owncloud_provider_get_type },
#endif
#ifdef GOA_FACEBOOK_ENABLED
g_type_ensure (GOA_TYPE_FACEBOOK_PROVIDER);
{ GOA_FACEBOOK_NAME, goa_facebook_provider_get_type },
#endif
#ifdef GOA_FLICKR_ENABLED
g_type_ensure (GOA_TYPE_FLICKR_PROVIDER);
{ GOA_FLICKR_NAME, goa_flickr_provider_get_type },
#endif
#ifdef GOA_WINDOWS_LIVE_ENABLED
g_type_ensure (GOA_TYPE_WINDOWS_LIVE_PROVIDER);
{ GOA_WINDOWS_LIVE_NAME, goa_windows_live_provider_get_type },
#endif
#ifdef GOA_POCKET_ENABLED
g_type_ensure (GOA_TYPE_POCKET_PROVIDER);
{ GOA_POCKET_NAME, goa_pocket_provider_get_type },
#endif
#ifdef GOA_EXCHANGE_ENABLED
g_type_ensure (GOA_TYPE_EXCHANGE_PROVIDER);
{ GOA_EXCHANGE_NAME, goa_exchange_provider_get_type },
#endif
#ifdef GOA_IMAP_SMTP_ENABLED
g_type_ensure (GOA_TYPE_IMAP_SMTP_PROVIDER);
{ GOA_IMAP_SMTP_NAME, goa_imap_smtp_provider_get_type },
#endif
#ifdef GOA_KERBEROS_ENABLED
g_type_ensure (GOA_TYPE_KERBEROS_PROVIDER);
{ GOA_KERBEROS_NAME, goa_kerberos_provider_get_type },
#endif
#ifdef GOA_YAHOO_ENABLED
g_type_ensure (GOA_TYPE_YAHOO_PROVIDER);
{ GOA_YAHOO_NAME, goa_yahoo_provider_get_type },
#endif
#ifdef GOA_TELEPATHY_ENABLED
g_type_ensure (GOA_TYPE_TELEPATHY_FACTORY);
{ GOA_TELEPATHY_NAME, goa_telepathy_factory_get_type },
#endif
{ NULL, NULL }
};
static void
ensure_builtins_loaded (void)
{
static gsize once_init_value = 0;
goa_provider_ensure_extension_points_registered ();
if (g_once_init_enter (&once_init_value))
{
GSettings *settings;
gchar **whitelisted_providers;
guint i;
guint j;
gboolean all = FALSE;
settings = g_settings_new (GOA_SETTINGS_SCHEMA);
whitelisted_providers = g_settings_get_strv (settings, GOA_SETTINGS_WHITELISTED_PROVIDERS);
/* Enable everything if there is 'all'. */
for (i = 0; whitelisted_providers[i] != NULL; i++)
{
if (g_strcmp0 (whitelisted_providers[i], "all") == 0)
{
g_debug ("Loading all providers: ");
for (j = 0; ordered_builtins_map[j].name != NULL; j++)
{
g_debug (" - %s", ordered_builtins_map[j].name);
g_type_ensure ((*ordered_builtins_map[j].get_type) ());
}
all = TRUE;
break;
}
}
if (all)
goto cleanup;
/* Otherwise try them one by one. */
g_debug ("Loading whitelisted providers: ");
for (i = 0; ordered_builtins_map[i].name != NULL; i++)
{
for (j = 0; whitelisted_providers[j] != NULL; j++)
{
if (g_strcmp0 (whitelisted_providers[j], ordered_builtins_map[i].name) == 0)
{
g_debug (" - %s", ordered_builtins_map[j].name);
g_type_ensure ((*ordered_builtins_map[i].get_type) ());
break;
}
}
}
cleanup:
g_strfreev (whitelisted_providers);
g_object_unref (settings);
g_once_init_leave (&once_init_value, 1);
}
}
......
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2012, 2013 Red Hat, Inc.
* Copyright (C) 2012, 2013, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -32,6 +32,9 @@ G_BEGIN_DECLS
#define GOA_OAUTH2_ACCESS_DENIED "access_denied"
#define GOA_SETTINGS_SCHEMA "org.gnome.online-accounts"
#define GOA_SETTINGS_WHITELISTED_PROVIDERS "whitelisted-providers"
typedef gpointer (*GoaPeekInterfaceFunc) (GoaObject *);
void goa_utils_initialize_client_factory (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment