[gnome-online-accounts/wip/rishi/libsecret-workaround: 3/3] backend, daemon: ...
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/libsecret-workaround: 3/3] backend, daemon: ...
- Date: Fri, 14 Jul 2017 13:06:05 +0000 (UTC)
commit 38b449a904693cd9ef5de4be5f85fe8b1026a686
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Jul 3 18:18:13 2017 +0200
backend, daemon: ...
https://bugzilla.gnome.org/show_bug.cgi?id=784944
src/daemon/Makefile.am | 2 +
src/daemon/goadaemon.c | 72 ++++++++++++++++++++++++++----
src/daemon/goadaemon.h | 1 +
src/daemon/main.c | 3 +-
src/goabackend/Makefile.am | 4 ++
src/goabackend/goaexchangeprovider.c | 27 +++++++++---
src/goabackend/goafacebookprovider.c | 2 +
src/goabackend/goaflickrprovider.c | 2 +
src/goabackend/goafoursquareprovider.c | 2 +
src/goabackend/goagoogleprovider.c | 2 +
src/goabackend/goaimapsmtpprovider.c | 37 +++++++++++++---
src/goabackend/goakerberosprovider.c | 27 +++++++++---
src/goabackend/goalastfmprovider.c | 14 ++++++-
src/goabackend/goamediaserverprovider.c | 3 +
src/goabackend/goaoauth2provider.c | 22 +++++++--
src/goabackend/goaoauth2provider.h | 2 +
src/goabackend/goaoauthprovider.c | 22 +++++++--
src/goabackend/goaoauthprovider.h | 2 +
src/goabackend/goaowncloudprovider.c | 29 +++++++++---
src/goabackend/goapocketprovider.c | 2 +
src/goabackend/goaprovider-priv.h | 7 +++
src/goabackend/goaprovider.c | 47 ++++++++++++++++++--
src/goabackend/goatelepathyprovider.c | 3 +
src/goabackend/goatodoistprovider.c | 2 +
src/goabackend/goautils.c | 33 +++++++++-----
src/goabackend/goautils.h | 15 +++++--
src/goabackend/goawindowsliveprovider.c | 2 +
27 files changed, 318 insertions(+), 68 deletions(-)
---
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 5f9a231..b9807bb 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -34,6 +34,7 @@ goa_daemon_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(REST_CFLAGS) \
+ $(SECRET_CFLAGS) \
$(NULL)
goa_daemon_LDADD = \
@@ -42,6 +43,7 @@ goa_daemon_LDADD = \
$(top_builddir)/src/goabackend/libgoa-backend-1.0.la \
$(GTK_LIBS) \
$(REST_LIBS) \
+ $(SECRET_LIBS) \
$(NULL)
clean-local :
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index af9913f..4635cc6 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -24,6 +24,7 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <rest/rest-proxy.h>
+#include <libsecret/secret.h>
#include <libsoup/soup.h>
#include "goadaemon.h"
@@ -51,6 +52,9 @@ struct _GoaDaemon
GQueue *ensure_credentials_queue;
gboolean ensure_credentials_running;
+ SecretService *secret_service;
+ gchar *secret_service_bus_name;
+
guint config_timeout_id;
guint credentials_timeout_id;
};
@@ -58,7 +62,8 @@ struct _GoaDaemon
enum
{
PROP_0,
- PROP_CONNECTION
+ PROP_CONNECTION,
+ PROP_SECRET_SERVICE_BUS_NAME
};
static void on_file_monitor_changed (GFileMonitor *monitor,
@@ -147,9 +152,6 @@ goa_daemon_constructed (GObject *object)
G_OBJECT_CLASS (goa_daemon_parent_class)->constructed (object);
- /* prime the list of accounts */
- goa_daemon_reload_configuration (self);
-
/* Export objects */
g_dbus_object_manager_server_set_connection (self->object_manager, self->connection);
}
@@ -182,6 +184,8 @@ goa_daemon_finalize (GObject *object)
}
g_free (self->home_conf_file_path);
+ g_free (self->secret_service_bus_name);
+ g_clear_object (&self->secret_service);
g_object_unref (self->manager);
g_object_unref (self->object_manager);
g_object_unref (self->connection);
@@ -201,6 +205,10 @@ goa_daemon_set_property (GObject *object, guint prop_id, const GValue *value, GP
self->connection = G_DBUS_CONNECTION (g_value_dup_object (value));
break;
+ case PROP_SECRET_SERVICE_BUS_NAME:
+ self->secret_service_bus_name = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -390,12 +398,39 @@ goa_daemon_class_init (GoaDaemonClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_SECRET_SERVICE_BUS_NAME,
+ g_param_spec_string ("secret-service-bus-name",
+ "Secret service bus name",
+ "The D-Bus service name of the secret service",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_WRITABLE));
}
static gboolean
goa_daemon_initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
{
- return TRUE;
+ GoaDaemon *self = GOA_DAEMON (initable);
+ gboolean ret_val = FALSE;
+
+ self->secret_service = secret_service_open_sync (SECRET_TYPE_SERVICE,
+ self->secret_service_bus_name,
+ SECRET_SERVICE_OPEN_SESSION,
+ cancellable,
+ error);
+ if (self->secret_service == NULL)
+ goto out;
+
+ /* prime the list of accounts */
+ goa_daemon_reload_configuration (self);
+
+ ret_val = TRUE;
+
+ out:
+ return ret_val;
}
static void
@@ -405,13 +440,22 @@ goa_daemon_initable_iface_init (GInitableIface *iface)
}
GoaDaemon *
-goa_daemon_new (GDBusConnection *connection, GCancellable *cancellable, GError **error)
+goa_daemon_new (GDBusConnection *connection,
+ const gchar *secret_service_bus_name,
+ GCancellable *cancellable,
+ GError **error)
{
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
+ g_return_val_if_fail (secret_service_bus_name != NULL && secret_service_bus_name[0] != '\0', NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return GOA_DAEMON (g_initable_new (GOA_TYPE_DAEMON, cancellable, error, "connection", connection, NULL));
+ return GOA_DAEMON (g_initable_new (GOA_TYPE_DAEMON,
+ cancellable,
+ error,
+ "connection", connection,
+ "secret-service-bus-name", secret_service_bus_name,
+ NULL));
}
@@ -597,7 +641,7 @@ add_config_file (GoaDaemon *self,
needs_update = g_key_file_remove_group (key_file, groups[n], NULL);
error = NULL;
- if (!goa_utils_delete_credentials_for_id_sync (provider, id, NULL, &error))
+ if (!goa_utils_delete_credentials_for_id_sync (self->secret_service, provider, id, NULL,
&error))
{
g_warning ("Unable to clean-up stale keyring entries: %s", error->message);
g_error_free (error);
@@ -712,7 +756,14 @@ goa_daemon_update_account_object (GoaDaemon *self,
goa_account_set_is_temporary (account, is_temporary);
error = NULL;
- if (!goa_provider_build_object (provider, object, key_file, group, self->connection, just_added, &error))
+ if (!goa_provider_build_object (provider,
+ object,
+ key_file,
+ group,
+ self->connection,
+ self->secret_service,
+ just_added,
+ &error))
{
g_warning ("Error parsing account: %s (%s, %d)",
error->message, g_quark_to_string (error->domain), error->code);
@@ -1478,7 +1529,7 @@ on_account_handle_remove (GoaAccount *account,
}
error = NULL;
- if (!goa_utils_delete_credentials_for_account_sync (provider, account, NULL, &error))
+ if (!goa_utils_delete_credentials_for_account_sync (self->secret_service, provider, account, NULL, &error))
{
g_dbus_method_invocation_take_error (invocation, error);
goto out;
@@ -1657,6 +1708,7 @@ ensure_credentials_queue_check (GoaDaemon *self)
goa_provider_ensure_credentials (provider,
data->object,
+ self->secret_service,
NULL, /* GCancellable */
ensure_credentials_queue_collector,
task);
diff --git a/src/daemon/goadaemon.h b/src/daemon/goadaemon.h
index 88e737c..87b84d2 100644
--- a/src/daemon/goadaemon.h
+++ b/src/daemon/goadaemon.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GoaDaemon, goa_daemon, GOA, DAEMON, GObject);
GoaDaemon *goa_daemon_new (GDBusConnection *connection,
+ const gchar *secret_service_bus_name,
GCancellable *cancellable,
GError **error);
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 22d114b..6118f77 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -26,6 +26,7 @@
#include <libintl.h>
#include "goadaemon.h"
+#include "goabackend/goautils.h"
/* ---------------------------------------------------------------------------------------------------- */
@@ -53,7 +54,7 @@ on_bus_acquired (GDBusConnection *connection,
g_debug ("Connected to the session bus");
error = NULL;
- the_daemon = goa_daemon_new (connection, NULL, &error);
+ the_daemon = goa_daemon_new (connection, GOA_SECRET_SERVICE_BUS_NAME, NULL, &error);
if (error != NULL)
{
g_warning ("Unable to initialize GoaDaemon: %s (%s, %d)",
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index 40b76dc..5369593 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -162,13 +162,17 @@ libgoawebextension_la_SOURCES = \
$(NULL)
libgoawebextension_la_CFLAGS = \
+ $(GLIB_CFLAGS) \
$(REST_CFLAGS) \
+ $(SECRET_CFLAGS) \
$(WEBKIT_GTK_CFLAGS) \
$(NULL)
libgoawebextension_la_LIBADD = \
libgoa-backend-1.0.la \
+ $(GLIB_LIBS) \
$(REST_LIBS) \
+ $(SECRET_LIBS) \
$(WEBKIT_GTK_LIBS) \
$(NULL)
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index e67bb36..2b134a6 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -18,6 +18,7 @@
#include "config.h"
#include <glib/gi18n-lib.h>
+#include <libsecret/secret.h>
#include "goaewsclient.h"
#include "goaprovider.h"
@@ -79,6 +80,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -97,6 +99,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -109,10 +112,12 @@ build_object (GoaProvider *provider,
g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (password_based),
G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
goa_object_skeleton_set_password_based (object, password_based);
- g_signal_connect (password_based,
- "handle-get-password",
- G_CALLBACK (on_handle_get_password),
- NULL);
+ g_signal_connect_data (password_based,
+ "handle-get-password",
+ G_CALLBACK (on_handle_get_password),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
}
account = goa_object_get_account (GOA_OBJECT (object));
@@ -198,6 +203,7 @@ build_object (GoaProvider *provider,
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -212,7 +218,14 @@ ensure_credentials_sync (GoaProvider *provider,
gchar *username = NULL;
gchar *password = NULL;
- if (!goa_utils_get_credentials (provider, object, "password", &username, &password, cancellable, error))
+ if (!goa_utils_get_credentials (secret_service,
+ provider,
+ object,
+ "password",
+ &username,
+ &password,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -668,6 +681,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
AddAccountData data;
@@ -846,6 +860,7 @@ on_handle_get_password (GoaPasswordBased *interface,
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
const gchar *account_id;
const gchar *method_name;
const gchar *provider_type;
@@ -863,7 +878,7 @@ on_handle_get_password (GoaPasswordBased *interface,
provider = goa_provider_get_for_provider_type (provider_type);
error = NULL;
- if (!goa_utils_get_credentials (provider, object, "password", NULL, &password, NULL, &error))
+ if (!goa_utils_get_credentials (secret_service, provider, object, "password", NULL, &password, NULL,
&error))
{
g_dbus_method_invocation_take_error (invocation, error);
goto out;
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index 208d839..089c4a7 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -276,6 +276,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -290,6 +291,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index 0f2ab53..5e46866 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -289,6 +289,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -302,6 +303,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goafoursquareprovider.c b/src/goabackend/goafoursquareprovider.c
index 7dc115d..9d4359c 100644
--- a/src/goabackend/goafoursquareprovider.c
+++ b/src/goabackend/goafoursquareprovider.c
@@ -280,6 +280,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -293,6 +294,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index 42a177a..b1d18cc 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -276,6 +276,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -300,6 +301,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goaimapsmtpprovider.c b/src/goabackend/goaimapsmtpprovider.c
index 8a2677e..8301087 100644
--- a/src/goabackend/goaimapsmtpprovider.c
+++ b/src/goabackend/goaimapsmtpprovider.c
@@ -19,6 +19,7 @@
#include "config.h"
#include <glib/gi18n-lib.h>
+#include <libsecret/secret.h>
#include "goaimapauthlogin.h"
#include "goamailclient.h"
@@ -92,6 +93,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -136,6 +138,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -148,10 +151,12 @@ build_object (GoaProvider *provider,
g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (password_based),
G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
goa_object_skeleton_set_password_based (object, password_based);
- g_signal_connect (password_based,
- "handle-get-password",
- G_CALLBACK (on_handle_get_password),
- NULL);
+ g_signal_connect_data (password_based,
+ "handle-get-password",
+ G_CALLBACK (on_handle_get_password),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
}
account = goa_object_get_account (GOA_OBJECT (object));
@@ -287,6 +292,7 @@ get_tls_type_from_string_id (const gchar *str)
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -324,7 +330,14 @@ ensure_credentials_sync (GoaProvider *provider,
ret = FALSE;
- if (!goa_utils_get_credentials (provider, object, "imap-password", NULL, &imap_password, cancellable,
error))
+ if (!goa_utils_get_credentials (secret_service,
+ provider,
+ object,
+ "imap-password",
+ NULL,
+ &imap_password,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -377,7 +390,14 @@ ensure_credentials_sync (GoaProvider *provider,
if (!goa_util_lookup_keyfile_boolean (object, "SmtpUseAuth"))
goto smtp_done;
- if (!goa_utils_get_credentials (provider, object, "smtp-password", NULL, &smtp_password, cancellable,
error))
+ if (!goa_utils_get_credentials (secret_service,
+ provider,
+ object,
+ "smtp-password",
+ NULL,
+ &smtp_password,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -1198,6 +1218,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
AddAccountData data;
@@ -1228,6 +1249,7 @@ refresh_account (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
imap_auth = NULL;
@@ -1613,6 +1635,7 @@ on_handle_get_password (GoaPasswordBased *interface,
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
const gchar *account_id;
const gchar *method_name;
const gchar *provider_type;
@@ -1632,7 +1655,7 @@ on_handle_get_password (GoaPasswordBased *interface,
provider = goa_provider_get_for_provider_type (provider_type);
error = NULL;
- if (!goa_utils_get_credentials (provider, object, id, NULL, &password, NULL, &error))
+ if (!goa_utils_get_credentials (secret_service, provider, object, id, NULL, &password, NULL, &error))
{
g_dbus_method_invocation_take_error (invocation, error);
goto out;
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index 2d9db95..a18097a 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -27,6 +27,7 @@
#include "goaidentitymanagererror.h"
#include <gcr/gcr.h>
+#include <libsecret/secret.h>
#include "org.gnome.Identity.h"
@@ -272,6 +273,7 @@ on_account_signed_in (GoaProvider *provider,
static gboolean
get_ticket_sync (GoaKerberosProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gboolean is_interactive,
GCancellable *cancellable,
GError **error)
@@ -311,7 +313,8 @@ get_ticket_sync (GoaKerberosProvider *self,
password = NULL;
lookup_error = NULL;
- credentials = goa_utils_lookup_credentials_sync (GOA_PROVIDER (self),
+ credentials = goa_utils_lookup_credentials_sync (secret_service,
+ GOA_PROVIDER (self),
object,
cancellable,
&lookup_error);
@@ -395,12 +398,14 @@ notify_is_temporary_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
static gboolean
on_handle_get_ticket (GoaTicketing *interface,
- GDBusMethodInvocation *invocation)
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
GoaObject *object;
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
gboolean got_ticket;
const gchar *id;
const gchar *method_name;
@@ -418,6 +423,7 @@ on_handle_get_ticket (GoaTicketing *interface,
error = NULL;
got_ticket = get_ticket_sync (GOA_KERBEROS_PROVIDER (provider),
object,
+ secret_service,
TRUE /* Allow interaction */,
NULL,
&error);
@@ -437,6 +443,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -453,6 +460,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -471,10 +479,12 @@ build_object (GoaProvider *provider,
ticketing = goa_ticketing_skeleton_new ();
- g_signal_connect (ticketing,
- "handle-get-ticket",
- G_CALLBACK (on_handle_get_ticket),
- NULL);
+ g_signal_connect_data (ticketing,
+ "handle-get-ticket",
+ G_CALLBACK (on_handle_get_ticket),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
goa_object_skeleton_set_ticketing (object, ticketing);
@@ -802,6 +812,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
GoaKerberosProvider *self = GOA_KERBEROS_PROVIDER (provider);
@@ -812,10 +823,12 @@ refresh_account (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
got_ticket = get_ticket_sync (self,
object,
+ secret_service,
TRUE /* Allow interaction */,
NULL,
&ticket_error);
@@ -1368,6 +1381,7 @@ dbus_proxy_reload_properties_sync (GDBusProxy *proxy,
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -1405,6 +1419,7 @@ ensure_credentials_sync (GoaProvider *provider,
g_mutex_unlock (&identity_manager_mutex);
ticket_synced = get_ticket_sync (GOA_KERBEROS_PROVIDER (provider),
object,
+ secret_service,
FALSE /* Don't allow interaction */,
cancellable,
&lookup_error);
diff --git a/src/goabackend/goalastfmprovider.c b/src/goabackend/goalastfmprovider.c
index ac07e66..1b24216 100644
--- a/src/goabackend/goalastfmprovider.c
+++ b/src/goabackend/goalastfmprovider.c
@@ -102,6 +102,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -118,6 +119,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -250,6 +252,7 @@ lastfm_login_sync (GoaProvider *provider,
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -258,7 +261,14 @@ ensure_credentials_sync (GoaProvider *provider,
gchar *password = NULL;
gboolean ret = FALSE;
- if (!goa_utils_get_credentials (provider, object, "password", &username, &password, cancellable, error))
+ if (!goa_utils_get_credentials (secret_service,
+ provider,
+ object,
+ "password",
+ &username,
+ &password,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -753,6 +763,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
AddAccountData data;
@@ -769,6 +780,7 @@ refresh_account (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
ret = FALSE;
diff --git a/src/goabackend/goamediaserverprovider.c b/src/goabackend/goamediaserverprovider.c
index 030ad46..2cacc5d 100644
--- a/src/goabackend/goamediaserverprovider.c
+++ b/src/goabackend/goamediaserverprovider.c
@@ -90,6 +90,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -110,6 +111,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -156,6 +158,7 @@ out:
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 564ba64..6c26796 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -1275,6 +1275,7 @@ goa_oauth2_provider_refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (provider);
@@ -1290,6 +1291,7 @@ goa_oauth2_provider_refresh_account (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
ret = FALSE;
@@ -1376,6 +1378,7 @@ free_mutex (GMutex *mutex)
* goa_oauth2_provider_get_access_token_sync:
* @self: A #GoaOAuth2Provider.
* @object: A #GoaObject.
+ * @secret_service: A #SecretService.
* @force_refresh: If set to %TRUE, forces a refresh of the access token, if possible.
* @out_access_token_expires_in: (out): Return location for how many seconds the returned token is valid for
(0 if unknown) or %NULL.
* @cancellable: (allow-none): A #GCancellable or %NULL.
@@ -1406,6 +1409,7 @@ free_mutex (GMutex *mutex)
gchar *
goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *self,
GoaObject *object,
+ SecretService *secret_service,
gboolean force_refresh,
gint *out_access_token_expires_in,
GCancellable *cancellable,
@@ -1458,7 +1462,8 @@ goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *self,
g_mutex_lock (lock);
/* First, get the credentials from the keyring */
- credentials = goa_utils_lookup_credentials_sync (GOA_PROVIDER (self),
+ credentials = goa_utils_lookup_credentials_sync (secret_service,
+ GOA_PROVIDER (self),
object,
cancellable,
error);
@@ -1609,6 +1614,7 @@ goa_oauth2_provider_build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -1627,10 +1633,12 @@ goa_oauth2_provider_build_object (GoaProvider *provider,
g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (oauth2_based),
G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
goa_object_skeleton_set_oauth2_based (object, oauth2_based);
- g_signal_connect (oauth2_based,
- "handle-get-access-token",
- G_CALLBACK (on_handle_get_access_token),
- NULL);
+ g_signal_connect_data (oauth2_based,
+ "handle-get-access-token",
+ G_CALLBACK (on_handle_get_access_token),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
out:
g_object_unref (oauth2_based);
@@ -1642,6 +1650,7 @@ goa_oauth2_provider_build_object (GoaProvider *provider,
static gboolean
goa_oauth2_provider_ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -1661,6 +1670,7 @@ goa_oauth2_provider_ensure_credentials_sync (GoaProvider *provider,
again:
access_token = goa_oauth2_provider_get_access_token_sync (self,
object,
+ secret_service,
force_refresh,
&access_token_expires_in,
cancellable,
@@ -1766,6 +1776,7 @@ on_handle_get_access_token (GoaOAuth2Based *interface,
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
const gchar *id;
const gchar *method_name;
const gchar *provider_type;
@@ -1789,6 +1800,7 @@ on_handle_get_access_token (GoaOAuth2Based *interface,
error = NULL;
access_token = goa_oauth2_provider_get_access_token_sync (GOA_OAUTH2_PROVIDER (provider),
object,
+ secret_service,
FALSE, /* force_refresh */
&access_token_expires_in,
NULL, /* GCancellable* */
diff --git a/src/goabackend/goaoauth2provider.h b/src/goabackend/goaoauth2provider.h
index 76bc78f..8af8fc5 100644
--- a/src/goabackend/goaoauth2provider.h
+++ b/src/goabackend/goaoauth2provider.h
@@ -24,6 +24,7 @@
#define __GOA_OAUTH2_PROVIDER_H__
#include <gio/gio.h>
+#include <libsecret/secret.h>
#include "goabackend/goaprovider.h"
#include "goabackend/goaprovider-priv.h"
@@ -48,6 +49,7 @@ gchar *goa_oauth2_provider_get_identity_sync (GoaOAuth2Provider
GError **error);
gchar *goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
GoaObject *object,
+ SecretService *secret_service,
gboolean force_refresh,
gint
*out_access_token_expires_in,
GCancellable *cancellable,
diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
index 08b998e..3512c2d 100644
--- a/src/goabackend/goaoauthprovider.c
+++ b/src/goabackend/goaoauthprovider.c
@@ -1110,6 +1110,7 @@ goa_oauth_provider_refresh_account (GoaProvider *_provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
GoaOAuthProvider *provider = GOA_OAUTH_PROVIDER (_provider);
@@ -1131,6 +1132,7 @@ goa_oauth_provider_refresh_account (GoaProvider *_provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
access_token = NULL;
@@ -1242,6 +1244,7 @@ free_mutex (GMutex *mutex)
* goa_oauth_provider_get_access_token_sync:
* @provider: A #GoaOAuthProvider.
* @object: A #GoaObject.
+ * @secret_service: A #SecretService.
* @force_refresh: If set to %TRUE, forces a refresh of the access token, if possible.
* @out_access_token_secret: (out): The secret for the return access token.
* @out_access_token_expires_in: (out): Return location for how many seconds the returned token is valid for
(0 if unknown) or %NULL.
@@ -1273,6 +1276,7 @@ free_mutex (GMutex *mutex)
gchar *
goa_oauth_provider_get_access_token_sync (GoaOAuthProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gboolean force_refresh,
gchar **out_access_token_secret,
gint *out_access_token_expires_in,
@@ -1332,7 +1336,8 @@ goa_oauth_provider_get_access_token_sync (GoaOAuthProvider *provider,
g_mutex_lock (lock);
/* First, get the credentials from the keyring */
- credentials = goa_utils_lookup_credentials_sync (GOA_PROVIDER (provider),
+ credentials = goa_utils_lookup_credentials_sync (secret_service,
+ GOA_PROVIDER (provider),
object,
cancellable,
error);
@@ -1491,6 +1496,7 @@ goa_oauth_provider_build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -1512,10 +1518,12 @@ goa_oauth_provider_build_object (GoaProvider *provider,
g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (oauth_based),
G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
goa_object_skeleton_set_oauth_based (object, oauth_based);
- g_signal_connect (oauth_based,
- "handle-get-access-token",
- G_CALLBACK (on_handle_get_access_token),
- NULL);
+ g_signal_connect_data (oauth_based,
+ "handle-get-access-token",
+ G_CALLBACK (on_handle_get_access_token),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
out:
g_object_unref (oauth_based);
@@ -1528,6 +1536,7 @@ goa_oauth_provider_build_object (GoaProvider *provider,
static gboolean
goa_oauth_provider_ensure_credentials_sync (GoaProvider *_provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -1549,6 +1558,7 @@ goa_oauth_provider_ensure_credentials_sync (GoaProvider *_provider,
again:
access_token = goa_oauth_provider_get_access_token_sync (provider,
object,
+ secret_service,
force_refresh,
&access_token_secret,
&access_token_expires_in,
@@ -1631,6 +1641,7 @@ on_handle_get_access_token (GoaOAuthBased *interface,
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
const gchar *id;
const gchar *method_name;
const gchar *provider_type;
@@ -1656,6 +1667,7 @@ on_handle_get_access_token (GoaOAuthBased *interface,
error = NULL;
access_token = goa_oauth_provider_get_access_token_sync (GOA_OAUTH_PROVIDER (provider),
object,
+ secret_service,
FALSE, /* force_refresh */
&access_token_secret,
&access_token_expires_in,
diff --git a/src/goabackend/goaoauthprovider.h b/src/goabackend/goaoauthprovider.h
index d4ffa3c..854298d 100644
--- a/src/goabackend/goaoauthprovider.h
+++ b/src/goabackend/goaoauthprovider.h
@@ -25,6 +25,7 @@
#include <goabackend/goaprovider.h>
#include <goabackend/goaprovider-priv.h>
+#include <libsecret/secret.h>
#include <rest/rest-proxy-call.h>
#include <webkitdom/webkitdom.h>
@@ -126,6 +127,7 @@ gchar *goa_oauth_provider_parse_request_token_error (GoaOAuthProvider
RestProxyCall *call);
gchar *goa_oauth_provider_get_access_token_sync (GoaOAuthProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gboolean force_refresh,
gchar
**out_access_token_secret,
gint
*out_access_token_expires_in,
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 95c38f8..a8e10ba 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
-
+#include <libsecret/secret.h>
#include <libsoup/soup.h>
#include "goahttpclient.h"
@@ -141,6 +141,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -165,6 +166,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
@@ -177,10 +179,12 @@ build_object (GoaProvider *provider,
g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (password_based),
G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
goa_object_skeleton_set_password_based (object, password_based);
- g_signal_connect (password_based,
- "handle-get-password",
- G_CALLBACK (on_handle_get_password),
- NULL);
+ g_signal_connect_data (password_based,
+ "handle-get-password",
+ G_CALLBACK (on_handle_get_password),
+ g_object_ref (secret_service),
+ (GClosureNotify) g_object_unref,
+ 0);
}
account = goa_object_get_account (GOA_OBJECT (object));
@@ -253,6 +257,7 @@ build_object (GoaProvider *provider,
static gboolean
ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -265,7 +270,14 @@ ensure_credentials_sync (GoaProvider *provider,
gchar *uri = NULL;
gchar *uri_webdav = NULL;
- if (!goa_utils_get_credentials (provider, object, "password", &username, &password, cancellable, error))
+ if (!goa_utils_get_credentials (secret_service,
+ provider,
+ object,
+ "password",
+ &username,
+ &password,
+ cancellable,
+ error))
{
if (error != NULL)
{
@@ -811,6 +823,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
AddAccountData data;
@@ -832,6 +845,7 @@ refresh_account (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
dialog = gtk_dialog_new_with_buttons (NULL,
@@ -1040,6 +1054,7 @@ on_handle_get_password (GoaPasswordBased *interface,
GoaAccount *account;
GoaProvider *provider;
GError *error;
+ SecretService *secret_service = SECRET_SERVICE (user_data);
const gchar *account_id;
const gchar *method_name;
const gchar *provider_type;
@@ -1057,7 +1072,7 @@ on_handle_get_password (GoaPasswordBased *interface,
provider = goa_provider_get_for_provider_type (provider_type);
error = NULL;
- if (!goa_utils_get_credentials (provider, object, "password", NULL, &password, NULL, &error))
+ if (!goa_utils_get_credentials (secret_service, provider, object, "password", NULL, &password, NULL,
&error))
{
g_dbus_method_invocation_take_error (invocation, error);
goto out;
diff --git a/src/goabackend/goapocketprovider.c b/src/goabackend/goapocketprovider.c
index 8356b02..493cb2b 100644
--- a/src/goabackend/goapocketprovider.c
+++ b/src/goabackend/goapocketprovider.c
@@ -346,6 +346,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -359,6 +360,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goaprovider-priv.h b/src/goabackend/goaprovider-priv.h
index 4244e01..7fc74d1 100644
--- a/src/goabackend/goaprovider-priv.h
+++ b/src/goabackend/goaprovider-priv.h
@@ -28,6 +28,7 @@
#include <goabackend/goaprovider.h>
#include <goabackend/goabackendenums.h>
#include <gtk/gtk.h>
+#include <libsecret/secret.h>
G_BEGIN_DECLS
@@ -75,6 +76,7 @@ struct _GoaProviderClass
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error);
/* virtual but with default implementation */
@@ -83,10 +85,12 @@ struct _GoaProviderClass
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error);
gboolean (*ensure_credentials_sync) (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error);
@@ -133,11 +137,13 @@ gboolean goa_provider_build_object (GoaProvider
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error);
void goa_provider_ensure_credentials (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -149,6 +155,7 @@ gboolean goa_provider_ensure_credentials_finish (GoaProvider
gboolean goa_provider_ensure_credentials_sync (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error);
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index c59122a..84c248b 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -66,6 +66,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static gboolean goa_provider_ensure_credentials_sync_real (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error);
@@ -75,6 +76,7 @@ static gboolean goa_provider_build_object_real (GoaProvider *self,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error);
@@ -534,13 +536,29 @@ goa_provider_refresh_account (GoaProvider *self,
GtkWindow *parent,
GError **error)
{
+ SecretService *secret_service = NULL;
+ gboolean ret = FALSE;
+
g_return_val_if_fail (GOA_IS_PROVIDER (self), FALSE);
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object) && goa_object_peek_account (object) != NULL, FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return GOA_PROVIDER_GET_CLASS (self)->refresh_account (self, client, object, parent, error);
+ /* TODO: use asynchronous variant */
+ secret_service = secret_service_open_sync (SECRET_TYPE_SERVICE,
+ GOA_SECRET_SERVICE_BUS_NAME,
+ SECRET_SERVICE_OPEN_SESSION,
+ NULL,
+ error);
+ if (secret_service == NULL)
+ goto out;
+
+ ret = GOA_PROVIDER_GET_CLASS (self)->refresh_account (self, client, object, parent, secret_service, error);
+
+ out:
+ g_clear_object (&secret_service);
+ return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -634,6 +652,7 @@ goa_provider_show_account_real (GoaProvider *provider,
* @key_file: The #GKeyFile with configuation data.
* @group: The group in @key_file to get data from.
* @connection: The #GDBusConnection used by the daemon to connect to the message bus.
+ * @secret_service: A #SecretService.
* @just_added: Whether the account was newly created or being updated.
* @error: Return location for error or %NULL.
*
@@ -659,6 +678,7 @@ goa_provider_build_object (GoaProvider *self,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -667,12 +687,14 @@ goa_provider_build_object (GoaProvider *self,
g_return_val_if_fail (key_file != NULL, FALSE);
g_return_val_if_fail (group != NULL, FALSE);
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), FALSE);
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return GOA_PROVIDER_GET_CLASS (self)->build_object (self,
object,
key_file,
group,
connection,
+ secret_service,
just_added,
error);
}
@@ -682,15 +704,17 @@ goa_provider_build_object (GoaProvider *self,
typedef struct
{
GoaObject *object;
+ SecretService *secret_service;
gint expires_in;
} EnsureCredentialsData;
static EnsureCredentialsData *
-ensure_credentials_data_new (GoaObject *object)
+ensure_credentials_data_new (GoaObject *object, SecretService *secret_service)
{
EnsureCredentialsData *data;
data = g_new0 (EnsureCredentialsData, 1);
data->object = g_object_ref (object);
+ data->secret_service = g_object_ref (secret_service);
return data;
}
@@ -698,6 +722,7 @@ static void
ensure_credentials_data_free (EnsureCredentialsData *data)
{
g_object_unref (data->object);
+ g_object_unref (data->secret_service);
g_free (data);
}
@@ -715,6 +740,7 @@ ensure_credentials_in_thread_func (GTask *task,
error = NULL;
if (!goa_provider_ensure_credentials_sync (GOA_PROVIDER (object),
data->object,
+ data->secret_service,
&data->expires_in,
cancellable,
&error))
@@ -728,6 +754,7 @@ ensure_credentials_in_thread_func (GTask *task,
* goa_provider_ensure_credentials:
* @self: A #GoaProvider.
* @object: A #GoaObject with a #GoaAccount interface.
+ * @secret_service: A #SecretService.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @callback: The function to call when the request is satisfied.
* @user_data: Pointer to pass to @callback.
@@ -747,6 +774,7 @@ ensure_credentials_in_thread_func (GTask *task,
void
goa_provider_ensure_credentials (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -758,7 +786,9 @@ goa_provider_ensure_credentials (GoaProvider *self,
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_task_data (task, ensure_credentials_data_new (object), (GDestroyNotify)
ensure_credentials_data_free);
+ g_task_set_task_data (task,
+ ensure_credentials_data_new (object, secret_service),
+ (GDestroyNotify) ensure_credentials_data_free);
g_task_set_source_tag (task, goa_provider_ensure_credentials);
g_task_run_in_thread (task, ensure_credentials_in_thread_func);
@@ -818,6 +848,7 @@ goa_provider_ensure_credentials_finish (GoaProvider *self,
* goa_provider_ensure_credentials_sync:
* @self: A #GoaProvider.
* @object: A #GoaObject with a #GoaAccount interface.
+ * @secret_service: A #SecretService.
* @out_expires_in: (out): Return location for how long the expired credentials are good for (0 if unknown)
or %NULL.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
@@ -830,6 +861,7 @@ goa_provider_ensure_credentials_finish (GoaProvider *self,
gboolean
goa_provider_ensure_credentials_sync (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -869,7 +901,12 @@ goa_provider_ensure_credentials_sync (GoaProvider *self,
goto out;
}
- ret = GOA_PROVIDER_GET_CLASS (self)->ensure_credentials_sync (self, object, out_expires_in, cancellable,
error);
+ ret = GOA_PROVIDER_GET_CLASS (self)->ensure_credentials_sync (self,
+ object,
+ secret_service,
+ out_expires_in,
+ cancellable,
+ error);
out:
if (!ret && error != NULL && *error == NULL)
@@ -890,6 +927,7 @@ goa_provider_ensure_credentials_sync (GoaProvider *self,
static gboolean
goa_provider_ensure_credentials_sync_real (GoaProvider *self,
GoaObject *object,
+ SecretService *secret_service,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
@@ -908,6 +946,7 @@ goa_provider_build_object_real (GoaProvider *self,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
diff --git a/src/goabackend/goatelepathyprovider.c b/src/goabackend/goatelepathyprovider.c
index 97234dc..6776108 100644
--- a/src/goabackend/goatelepathyprovider.c
+++ b/src/goabackend/goatelepathyprovider.c
@@ -590,6 +590,7 @@ refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
+ SecretService *secret_service,
GError **error)
{
return edit_connection_parameters (object, parent, error);
@@ -706,6 +707,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -722,6 +724,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goatodoistprovider.c b/src/goabackend/goatodoistprovider.c
index c758a83..e6b35b5 100644
--- a/src/goabackend/goatodoistprovider.c
+++ b/src/goabackend/goatodoistprovider.c
@@ -257,6 +257,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -270,6 +271,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index f384d0c..865df9e 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -19,7 +19,6 @@
#include "config.h"
#include <glib/gi18n-lib.h>
-#include <libsecret/secret.h>
#ifdef GOA_TELEPATHY_ENABLED
#include <telepathy-glib/telepathy-glib.h>
@@ -337,24 +336,27 @@ goa_utils_set_dialog_title (GoaProvider *provider, GtkDialog *dialog, gboolean a
}
gboolean
-goa_utils_delete_credentials_for_account_sync (GoaProvider *provider,
+goa_utils_delete_credentials_for_account_sync (SecretService *secret_service,
+ GoaProvider *provider,
GoaAccount *object,
GCancellable *cancellable,
GError **error)
{
const gchar *id;
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
g_return_val_if_fail (GOA_IS_ACCOUNT (object), FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
id = goa_account_get_id (object);
- return goa_utils_delete_credentials_for_id_sync (provider, id, cancellable, error);
+ return goa_utils_delete_credentials_for_id_sync (secret_service, provider, id, cancellable, error);
}
gboolean
-goa_utils_delete_credentials_for_id_sync (GoaProvider *provider,
+goa_utils_delete_credentials_for_id_sync (SecretService *secret_service,
+ GoaProvider *provider,
const gchar *id,
GCancellable *cancellable,
GError **error)
@@ -362,7 +364,9 @@ goa_utils_delete_credentials_for_id_sync (GoaProvider *provider,
gboolean ret = FALSE;
gchar *password_key = NULL;
GError *sec_error = NULL;
+ GHashTable *attributes = NULL;
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), FALSE);
g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
g_return_val_if_fail (id != NULL && id[0] != '\0', FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
@@ -373,11 +377,11 @@ goa_utils_delete_credentials_for_id_sync (GoaProvider *provider,
goa_provider_get_credentials_generation (provider),
id);
- secret_password_clear_sync (&secret_password_schema,
- cancellable,
- &sec_error,
- "goa-identity", password_key,
- NULL);
+ attributes = secret_attributes_build (&secret_password_schema, "goa-identity", password_key, NULL);
+ if (attributes == NULL)
+ goto out;
+
+ secret_service_clear_sync (secret_service, &secret_password_schema, attributes, cancellable, &sec_error);
if (sec_error != NULL)
{
g_warning ("secret_password_clear_sync() failed: %s", sec_error->message);
@@ -393,12 +397,14 @@ goa_utils_delete_credentials_for_id_sync (GoaProvider *provider,
ret = TRUE;
out:
+ g_clear_pointer (&attributes, (GDestroyNotify) g_hash_table_unref);
g_free (password_key);
return ret;
}
GVariant *
-goa_utils_lookup_credentials_sync (GoaProvider *provider,
+goa_utils_lookup_credentials_sync (SecretService *secret_service,
+ GoaProvider *provider,
GoaObject *object,
GCancellable *cancellable,
GError **error)
@@ -409,6 +415,7 @@ goa_utils_lookup_credentials_sync (GoaProvider *provider,
const gchar *id;
GError *sec_error = NULL;
+ g_return_val_if_fail (SECRET_IS_SERVICE (secret_service), NULL);
g_return_val_if_fail (GOA_IS_PROVIDER (provider), NULL);
g_return_val_if_fail (GOA_IS_OBJECT (object) && goa_object_peek_account (object) != NULL, FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
@@ -934,7 +941,8 @@ goa_utils_set_error_ssl (GError **err, GTlsCertificateFlags flags)
}
gboolean
-goa_utils_get_credentials (GoaProvider *provider,
+goa_utils_get_credentials (SecretService *secret_service,
+ GoaProvider *provider,
GoaObject *object,
const gchar *id,
gchar **out_username,
@@ -948,7 +956,8 @@ goa_utils_get_credentials (GoaProvider *provider,
gchar *username = NULL;
gchar *password = NULL;
- credentials = goa_utils_lookup_credentials_sync (provider,
+ credentials = goa_utils_lookup_credentials_sync (secret_service,
+ provider,
object,
cancellable,
error);
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 757318d..a4edc40 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -26,6 +26,7 @@
#include <gio/gio.h>
#include <glib.h>
#include <gtk/gtk.h>
+#include <libsecret/secret.h>
#include <libsoup/soup.h>
#include "goaprovider.h"
@@ -34,6 +35,8 @@ G_BEGIN_DECLS
#define GOA_OAUTH2_ACCESS_DENIED "access_denied"
+#define GOA_SECRET_SERVICE_BUS_NAME "org.freedesktop.secrets"
+
#define GOA_SETTINGS_SCHEMA "org.gnome.online-accounts"
#define GOA_SETTINGS_WHITELISTED_PROVIDERS "whitelisted-providers"
@@ -62,17 +65,20 @@ gchar *goa_utils_data_input_stream_read_line (GDataInputStream *strea
void goa_utils_set_dialog_title (GoaProvider *provider, GtkDialog *dialog, gboolean add_account);
-gboolean goa_utils_delete_credentials_for_account_sync (GoaProvider *provider,
+gboolean goa_utils_delete_credentials_for_account_sync (SecretService *secret_service,
+ GoaProvider *provider,
GoaAccount *account,
GCancellable *cancellable,
GError **error);
-gboolean goa_utils_delete_credentials_for_id_sync (GoaProvider *provider,
+gboolean goa_utils_delete_credentials_for_id_sync (SecretService *secret_service,
+ GoaProvider *provider,
const gchar *id,
GCancellable *cancellable,
GError **error);
-GVariant *goa_utils_lookup_credentials_sync (GoaProvider *provider,
+GVariant *goa_utils_lookup_credentials_sync (SecretService *secret_service,
+ GoaProvider *provider,
GoaObject *object,
GCancellable *cancellable,
GError **error);
@@ -108,7 +114,8 @@ void goa_utils_set_error_soup (GError **err, SoupMessage *msg);
void goa_utils_set_error_ssl (GError **err, GTlsCertificateFlags flags);
-gboolean goa_utils_get_credentials (GoaProvider *provider,
+gboolean goa_utils_get_credentials (SecretService *secret_service,
+ GoaProvider *provider,
GoaObject *object,
const gchar *id,
gchar **username,
diff --git a/src/goabackend/goawindowsliveprovider.c b/src/goabackend/goawindowsliveprovider.c
index 5ee7112..dfa2731 100644
--- a/src/goabackend/goawindowsliveprovider.c
+++ b/src/goabackend/goawindowsliveprovider.c
@@ -258,6 +258,7 @@ build_object (GoaProvider *provider,
GKeyFile *key_file,
const gchar *group,
GDBusConnection *connection,
+ SecretService *secret_service,
gboolean just_added,
GError **error)
{
@@ -274,6 +275,7 @@ build_object (GoaProvider *provider,
key_file,
group,
connection,
+ secret_service,
just_added,
error))
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]