[gnome-online-accounts/wip/whitelist: 3/3] Add a whitelist for providers
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/whitelist: 3/3] Add a whitelist for providers
- Date: Thu, 29 May 2014 15:57:00 +0000 (UTC)
commit 62a492587a3cecc83989dc22cfde7c5b391ec73d
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 29 14:21:26 2014 +0200
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.
Fixes: https://bugzilla.gnome.org/729173
configure.ac | 4 +-
data/Makefile.am | 8 ++
data/org.gnome.online-accounts.gschema.xml.in | 11 +++
po/POTFILES.in | 1 +
src/goabackend/goaprovider.c | 88 +++++++++++++++++++++---
src/goabackend/goautils.h | 5 +-
6 files changed, 104 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b21139d..7d41151 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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([$INTLTOOL_REQUIRED])
+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
diff --git a/data/Makefile.am b/data/Makefile.am
index 49004b8..cb30eb8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -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)
diff --git a/data/org.gnome.online-accounts.gschema.xml.in b/data/org.gnome.online-accounts.gschema.xml.in
new file mode 100644
index 0000000..e42845a
--- /dev/null
+++ b/data/org.gnome.online-accounts.gschema.xml.in
@@ -0,0 +1,11 @@
+<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>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b39e8f2..988aadf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
[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
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 2a6af1c..2f2d99f 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -760,44 +760,110 @@ ensure_builtins_loaded (void)
if (g_once_init_enter (&once_init_value))
{
+ GSettings *settings;
+ gchar **whitelisted_providers;
+ guint i;
+ gboolean all = FALSE;
+ gboolean exchange = FALSE;
+ gboolean facebook = FALSE;
+ gboolean flickr = FALSE;
+ gboolean google = FALSE;
+ gboolean imap_smtp = FALSE;
+ gboolean kerberos = FALSE;
+ gboolean owncloud = FALSE;
+ gboolean pocket = FALSE;
+ gboolean telepathy = FALSE;
+ gboolean windows_live = FALSE;
+ gboolean yahoo = FALSE;
+
+ settings = g_settings_new (GOA_SETTINGS_SCHEMA);
+ whitelisted_providers = g_settings_get_strv (settings, GOA_SETTINGS_WHITELISTED_PROVIDERS);
+
+ g_debug ("Value of %s:%s:", GOA_SETTINGS_SCHEMA, GOA_SETTINGS_WHITELISTED_PROVIDERS);
+ for (i = 0; whitelisted_providers[i] != NULL; i++)
+ {
+ g_debug (" - %s", whitelisted_providers[i]);
+ if (g_strcmp0 (whitelisted_providers[i], "all") == 0)
+ {
+ all = TRUE;
+ break;
+ }
+
+ if (g_strcmp0 (whitelisted_providers[i], GOA_EXCHANGE_NAME) == 0)
+ exchange = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_FACEBOOK_NAME) == 0)
+ facebook = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_FLICKR_NAME) == 0)
+ flickr = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_GOOGLE_NAME) == 0)
+ google = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_IMAP_SMTP_NAME) == 0)
+ imap_smtp = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_KERBEROS_NAME) == 0)
+ kerberos = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_OWNCLOUD_NAME) == 0)
+ owncloud = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_POCKET_NAME) == 0)
+ pocket = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_TELEPATHY_NAME) == 0)
+ telepathy = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_WINDOWS_LIVE_NAME) == 0)
+ windows_live = TRUE;
+ if (g_strcmp0 (whitelisted_providers[i], GOA_YAHOO_NAME) == 0)
+ yahoo = TRUE;
+ }
+
/* 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);
+ if (all || google)
+ g_type_ensure (GOA_TYPE_GOOGLE_PROVIDER);
#endif
#ifdef GOA_OWNCLOUD_ENABLED
- g_type_ensure (GOA_TYPE_OWNCLOUD_PROVIDER);
+ if (all || owncloud)
+ g_type_ensure (GOA_TYPE_OWNCLOUD_PROVIDER);
#endif
#ifdef GOA_FACEBOOK_ENABLED
- g_type_ensure (GOA_TYPE_FACEBOOK_PROVIDER);
+ if (all || facebook)
+ g_type_ensure (GOA_TYPE_FACEBOOK_PROVIDER);
#endif
#ifdef GOA_FLICKR_ENABLED
- g_type_ensure (GOA_TYPE_FLICKR_PROVIDER);
+ if (all || flickr)
+ g_type_ensure (GOA_TYPE_FLICKR_PROVIDER);
#endif
#ifdef GOA_WINDOWS_LIVE_ENABLED
- g_type_ensure (GOA_TYPE_WINDOWS_LIVE_PROVIDER);
+ if (all || windows_live)
+ g_type_ensure (GOA_TYPE_WINDOWS_LIVE_PROVIDER);
#endif
#ifdef GOA_POCKET_ENABLED
- g_type_ensure (GOA_TYPE_POCKET_PROVIDER);
+ if (all || pocket)
+ g_type_ensure (GOA_TYPE_POCKET_PROVIDER);
#endif
#ifdef GOA_EXCHANGE_ENABLED
- g_type_ensure (GOA_TYPE_EXCHANGE_PROVIDER);
+ if (all || exchange)
+ g_type_ensure (GOA_TYPE_EXCHANGE_PROVIDER);
#endif
#ifdef GOA_IMAP_SMTP_ENABLED
- g_type_ensure (GOA_TYPE_IMAP_SMTP_PROVIDER);
+ if (all || imap_smtp)
+ g_type_ensure (GOA_TYPE_IMAP_SMTP_PROVIDER);
#endif
#ifdef GOA_KERBEROS_ENABLED
- g_type_ensure (GOA_TYPE_KERBEROS_PROVIDER);
+ if (all || kerberos)
+ g_type_ensure (GOA_TYPE_KERBEROS_PROVIDER);
#endif
#ifdef GOA_YAHOO_ENABLED
- g_type_ensure (GOA_TYPE_YAHOO_PROVIDER);
+ if (all || yahoo)
+ g_type_ensure (GOA_TYPE_YAHOO_PROVIDER);
#endif
#ifdef GOA_TELEPATHY_ENABLED
- g_type_ensure (GOA_TYPE_TELEPATHY_FACTORY);
+ if (all || telepathy)
+ g_type_ensure (GOA_TYPE_TELEPATHY_FACTORY);
#endif
+ g_strfreev (whitelisted_providers);
+ g_object_unref (settings);
g_once_init_leave (&once_init_value, 1);
}
}
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 3e2e104..4c6a10e 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -1,6 +1,6 @@
/* -*- 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]