[gnome-online-accounts/wip/kerberos] Remove EnsurePermanent
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/kerberos] Remove EnsurePermanent
- Date: Mon, 20 Aug 2012 17:37:48 +0000 (UTC)
commit bce277ff30b104443ba026a2d0afe2df624f2673
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Aug 20 19:26:45 2012 +0200
Remove EnsurePermanent
Since IsTemporary is a D-Bus property, we already get a GDBus
generated GObject property for it, and corresponding accessor methods.
So one can just use goa_accout_set_is_temporary (account, FALSE),
which is much better than the whole asynchronous method dance and its
associated tround trip.
The SessionId is now set or unset in the notify handler for the
property.
https://bugzilla.gnome.org/show_bug.cgi?id=679253
data/dbus-interfaces.xml | 11 +--
src/daemon/goadaemon.c | 71 +----------
src/goabackend/goaexchangeprovider.c | 2 +
src/goabackend/goafacebookprovider.c | 2 +
src/goabackend/goagoogleprovider.c | 2 +
src/goabackend/goakerberosprovider.c | 33 +++++
src/goabackend/goaprovider.c | 209 ++-----------------------------
src/goabackend/goaprovider.h | 19 +---
src/goabackend/goatwitterprovider.c | 2 +
src/goabackend/goautils.c | 104 +++++++++++++++-
src/goabackend/goautils.h | 4 +
src/goabackend/goawindowsliveprovider.c | 2 +
src/goabackend/goayahooprovider.c | 2 +
13 files changed, 168 insertions(+), 295 deletions(-)
---
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index d1800c5..6101478 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -83,7 +83,7 @@
Accounts are permanant by default unless created with "IsTemporary"
"true" detail.
-->
- <property name="IsTemporary" type="b" access="read"/>
+ <property name="IsTemporary" type="b" access="readwrite"/>
<!-- AttentionNeeded: Set to %TRUE if the account is in need of attention.
@@ -202,15 +202,6 @@
<method name="EnsureCredentials">
<arg name="expires_in" type="i" direction="out"/>
</method>
-
- <!--
- EnsurePermanent:
-
- Ensures an account is permanent. See the
- #org.gnome.OnlineAccounts.Account:IsPermanent property
- for more information on what that details.
- -->
- <method name="EnsurePermanent"/>
</interface>
<!--
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index 5c6c18b..b4ca4bc 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -80,10 +80,6 @@ static gboolean on_account_handle_ensure_credentials (GoaAccount *acc
GDBusMethodInvocation *invocation,
gpointer user_data);
-static gboolean on_account_handle_ensure_permanent (GoaAccount *account,
- GDBusMethodInvocation *invocation,
- gpointer user_data);
-
static void goa_daemon_reload_configuration (GoaDaemon *daemon);
static void on_notification_closed (NotifyNotification *notification,
@@ -503,7 +499,7 @@ update_account_object (GoaDaemon *daemon,
goa_account_set_presentation_identity (account, presentation_identity);
error = NULL;
- if (!goa_provider_build_object (provider, object, key_file, group, just_added, &error))
+ if (!goa_provider_build_object (provider, object, key_file, group, daemon->connection, just_added, &error))
{
goa_warning ("Error parsing account: %s (%s, %d)",
error->message, g_quark_to_string (error->domain), error->code);
@@ -638,10 +634,6 @@ process_config_entries (GoaDaemon *daemon,
"handle-ensure-credentials",
G_CALLBACK (on_account_handle_ensure_credentials),
daemon);
- g_signal_connect (goa_object_peek_account (GOA_OBJECT (object)),
- "handle-ensure-permanent",
- G_CALLBACK (on_account_handle_ensure_permanent),
- daemon);
}
g_object_unref (object);
g_free (group);
@@ -676,9 +668,6 @@ process_config_entries (GoaDaemon *daemon,
g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
G_CALLBACK (on_account_handle_ensure_credentials),
daemon);
- g_signal_handlers_disconnect_by_func (goa_object_peek_account (object),
- G_CALLBACK (on_account_handle_ensure_permanent),
- daemon);
g_warn_if_fail (g_dbus_object_manager_server_unexport (daemon->object_manager, object_path));
}
g_object_unref (object);
@@ -1304,61 +1293,3 @@ on_account_handle_ensure_credentials (GoaAccount *account,
out:
return TRUE; /* invocation was handled */
}
-
-static void
-ensure_permanent_cb (GoaProvider *provider,
- GAsyncResult *res,
- gpointer user_data)
-{
- EnsureData *data = user_data;
- GError *error;
-
- error= NULL;
- if (!goa_provider_ensure_permanent_finish (provider, res, &error))
- {
- g_dbus_method_invocation_return_gerror (data->invocation, error);
- g_error_free (error);
- }
- else
- {
- GoaAccount *account;
- account = goa_object_peek_account (data->object);
-
- goa_account_complete_ensure_permanent (account, data->invocation);
- }
- ensure_data_unref (data);
-}
-
-static gboolean
-on_account_handle_ensure_permanent (GoaAccount *account,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- GoaDaemon *daemon = GOA_DAEMON (user_data);
- GoaProvider *provider;
- GoaObject *object;
-
- object = GOA_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (account)));
- provider = goa_provider_get_for_provider_type (goa_account_get_provider_type (account));
- if (provider == NULL)
- {
- g_dbus_method_invocation_return_error (invocation,
- GOA_ERROR,
- GOA_ERROR_FAILED,
- "Unsupported account type %s for id %s (no provider)",
- goa_account_get_provider_type (account),
- goa_account_get_id (account));
- goto out;
- }
-
- goa_provider_ensure_permanent (provider,
- object,
- NULL, /* GCancellable */
- (GAsyncReadyCallback)
- ensure_permanent_cb,
- ensure_data_new (daemon, object, invocation));
-
- out:
- return TRUE; /* invocation was handled */
-}
-
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index 7473bc2..219997c 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -89,6 +89,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -116,6 +117,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index 40fcebb..37121ec 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -281,6 +281,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -296,6 +297,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index 270ef65..7a65d28 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -315,6 +315,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -344,6 +345,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index b0e92ad..fd340aa 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -681,6 +681,32 @@ out:
return ret;
}
+static void
+notify_is_temporary_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
+{
+ GoaAccount *account;
+ gboolean is_temporary;
+
+ /* Toggle IsTemporary */
+ goa_util_account_notify_property_cb (object, pspec, "IsTemporary");
+
+ account = GOA_ACCOUNT (object);
+ g_object_get (account, "is-temporary", &is_temporary, NULL);
+
+ /* Set/unset SessionId */
+ if (is_temporary)
+ {
+ GDBusConnection *connection;
+ const gchar *guid;
+
+ connection = G_DBUS_CONNECTION (user_data);
+ guid = g_dbus_connection_get_guid (connection);
+ goa_utils_keyfile_set_string (account, "SessionId", guid);
+ }
+ else
+ goa_utils_keyfile_remove_key (account, "SessionId");
+}
+
static gboolean
on_handle_get_ticket (GoaTicketing *interface,
GDBusMethodInvocation *invocation)
@@ -716,6 +742,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -730,6 +757,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
@@ -764,6 +792,11 @@ build_object (GoaProvider *provider,
goa_account_set_ticketing_disabled (account, !ticketing_enabled);
g_signal_connect (account,
+ "notify::is-temporary",
+ G_CALLBACK (notify_is_temporary_cb),
+ connection);
+
+ g_signal_connect (account,
"notify::ticketing-disabled",
G_CALLBACK (goa_util_account_notify_property_cb),
"TicketingEnabled");
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 908063b..95dac35 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -51,15 +51,11 @@ static gboolean goa_provider_ensure_credentials_sync_real (GoaProvider *provid
GCancellable *cancellable,
GError **error);
-static gboolean goa_provider_ensure_permanent_sync_real (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GError **error);
-
static gboolean goa_provider_build_object_real (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error);
@@ -70,7 +66,6 @@ static void goa_provider_show_account_real (GoaProvider *provider,
GtkGrid *left,
GtkGrid *right);
-static void goa_util_remove_keyfile_key (GoaAccount *account, const gchar *key);
static guint goa_provider_get_credentials_generation_real (GoaProvider *provider);
static GIcon *goa_provider_get_provider_icon_default (GoaProvider *provider,
@@ -88,7 +83,6 @@ goa_provider_class_init (GoaProviderClass *klass)
{
klass->build_object = goa_provider_build_object_real;
klass->ensure_credentials_sync = goa_provider_ensure_credentials_sync_real;
- klass->ensure_permanent_sync = goa_provider_ensure_permanent_sync_real;
klass->show_account = goa_provider_show_account_real;
klass->get_credentials_generation = goa_provider_get_credentials_generation_real;
klass->get_provider_icon = goa_provider_get_provider_icon_default;
@@ -334,6 +328,7 @@ goa_provider_show_account_real (GoaProvider *provider,
* @object: The #GoaObjectSkeleton that is being built.
* @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.
* @just_added: Whether the account was newly created or being updated.
* @error: Return location for error or %NULL.
*
@@ -358,6 +353,7 @@ goa_provider_build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -365,8 +361,15 @@ goa_provider_build_object (GoaProvider *provider,
g_return_val_if_fail (GOA_IS_OBJECT_SKELETON (object) && goa_object_peek_account (GOA_OBJECT (object)) != NULL, FALSE);
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 (error == NULL || *error == NULL, FALSE);
- return GOA_PROVIDER_GET_CLASS (provider)->build_object (provider, object, key_file, group, just_added, error);
+ return GOA_PROVIDER_GET_CLASS (provider)->build_object (provider,
+ object,
+ key_file,
+ group,
+ connection,
+ just_added,
+ error);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -531,131 +534,6 @@ goa_provider_ensure_credentials_sync (GoaProvider *provider,
/* ---------------------------------------------------------------------------------------------------- */
-static void
-ensure_permanent_in_thread_func (GSimpleAsyncResult *simple,
- GoaProvider *provider,
- GCancellable *cancellable)
-{
- GoaObject *object;
- GError *error;
-
- object = g_simple_async_result_get_op_res_gpointer (simple);
-
- error = NULL;
- if (!goa_provider_ensure_permanent_sync (provider,
- object,
- cancellable,
- &error))
- g_simple_async_result_take_error (simple, error);
-}
-
-
-/**
- * goa_provider_ensure_permanent:
- * @provider: A #GoaProvider.
- * @object: A #GoaObject with a #GoaAccount interface.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: The function to call when the request is satisfied.
- * @user_data: Pointer to pass to @callback.
- *
- * Ensures that credentials for @object will be reacquired on login.
- *
- * When the result is ready, @callback will be called in the the <link
- * linkend="g-main-context-push-thread-default">thread-default main
- * loop</link> this function was called from. You can then call
- * goa_provider_ensure_permanent_finish() to get the result
- * of the operation.
- *
- * This is a virtual method where the default implementation does
- * all the necessary work. A subclass may chain up to this default
- * implementation.
- */
-void
-goa_provider_ensure_permanent (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (GOA_IS_PROVIDER (provider));
- g_return_if_fail (GOA_IS_OBJECT (object));
- g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
-
- simple = g_simple_async_result_new (G_OBJECT (provider),
- callback,
- user_data,
- goa_provider_ensure_permanent);
- g_simple_async_result_set_op_res_gpointer (simple,
- g_object_ref (object),
- (GDestroyNotify)
- g_object_unref);
- g_simple_async_result_run_in_thread (simple,
- (GSimpleAsyncThreadFunc)
- ensure_permanent_in_thread_func,
- G_PRIORITY_DEFAULT,
- cancellable);
- g_object_unref (simple);
-}
-
-/**
- * goa_provider_ensure_permanent_finish:
- * @provider: A #GoaProvider.
- * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to goa_provider_ensure_credentials().
- * @error: Return location for error or %NULL.
- *
- * Finishes an operation started with goa_provider_ensure_permanent().
- *
- * Returns: %TRUE if the account for the passed #GoaObject is now permanent, %FALSE if @error is set.
- */
-gboolean
-goa_provider_ensure_permanent_finish (GoaProvider *provider,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-
- g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == goa_provider_ensure_permanent);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- return TRUE;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-/**
- * goa_provider_ensure_permanent_sync:
- * @provider: A #GoaProvider.
- * @object: A #GoaObject with a #GoaAccount interface.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL.
- *
- * Like goa_provider_ensure_permanent() but blocks the
- * calling thread until an answer is received.
- *
- * Returns: %TRUE if the credentials for the passed #GoaObject are valid, %FALSE if @error is set.
- */
-gboolean
-goa_provider_ensure_permanent_sync (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GError **error)
-{
- g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
- g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return GOA_PROVIDER_GET_CLASS (provider)->ensure_permanent_sync (provider, object, cancellable, error);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
static gboolean
goa_provider_ensure_credentials_sync_real (GoaProvider *provider,
GoaObject *object,
@@ -672,24 +550,11 @@ goa_provider_ensure_credentials_sync_real (GoaProvider *provider,
}
static gboolean
-goa_provider_ensure_permanent_sync_real (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GError **error)
-{
- GoaAccount *account;
-
- account = goa_object_peek_account (object);
- goa_util_remove_keyfile_key (account, "SessionId");
-
- return TRUE;
-}
-
-static gboolean
goa_provider_build_object_real (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -1004,56 +869,6 @@ goa_util_lookup_keyfile_boolean (GoaObject *object,
/* ---------------------------------------------------------------------------------------------------- */
static void
-goa_util_remove_keyfile_key (GoaAccount *account, const gchar *key)
-{
- GError *error;
- GKeyFile *key_file;
- gchar *contents;
- gchar *group;
- gchar *path;
- gsize length;
-
- contents = NULL;
-
- path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
- group = g_strdup_printf ("Account %s", goa_account_get_id (account));
-
- key_file = g_key_file_new ();
- error = NULL;
- if (!g_key_file_load_from_file (key_file,
- path,
- G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
- &error))
- {
- goa_warning ("Error loading keyfile %s: %s (%s, %d)",
- path,
- error->message,
- g_quark_to_string (error->domain),
- error->code);
- g_error_free (error);
- goto out;
- }
-
- g_key_file_remove_key (key_file, group, key, NULL);
- contents = g_key_file_to_data (key_file, &length, NULL);
-
- error = NULL;
- if (!g_file_set_contents (path, contents, length, &error))
- {
- g_prefix_error (&error, "Error writing key-value-file %s: ", path);
- goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
- goto out;
- }
-
- out:
- g_free (contents);
- g_key_file_free (key_file);
- g_free (group);
- g_free (path);
-}
-
-static void
goa_util_set_keyfile_boolean (GoaAccount *account, const gchar *key, gboolean value)
{
GError *error;
diff --git a/src/goabackend/goaprovider.h b/src/goabackend/goaprovider.h
index 0dcee5e..cc58d7e 100644
--- a/src/goabackend/goaprovider.h
+++ b/src/goabackend/goaprovider.h
@@ -93,6 +93,7 @@ struct _GoaProviderClass
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error);
/* virtual but with default implementation */
@@ -101,10 +102,6 @@ struct _GoaProviderClass
gint *out_expires_in,
GCancellable *cancellable,
GError **error);
- gboolean (*ensure_permanent_sync) (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GError **error);
void (*show_account) (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
@@ -144,21 +141,9 @@ gboolean goa_provider_build_object (GoaProvider *provid
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error);
-
-void goa_provider_ensure_permanent (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean goa_provider_ensure_permanent_finish (GoaProvider *provider,
- GAsyncResult *res,
- GError **error);
-gboolean goa_provider_ensure_permanent_sync (GoaProvider *provider,
- GoaObject *object,
- GCancellable *cancellable,
- GError **error);
void goa_provider_ensure_credentials (GoaProvider *provider,
GoaObject *object,
GCancellable *cancellable,
diff --git a/src/goabackend/goatwitterprovider.c b/src/goabackend/goatwitterprovider.c
index c1ef907..3895e6f 100644
--- a/src/goabackend/goatwitterprovider.c
+++ b/src/goabackend/goatwitterprovider.c
@@ -218,6 +218,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -229,6 +230,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 0ed8fa0..69d8bf5 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -17,7 +17,8 @@
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Author: Debarshi Ray <debarshir gnome org>
+ * Authors: Debarshi Ray <debarshir gnome org>
+ * Ray Strode <rstrode redhat com>
*/
#include "config.h"
@@ -26,6 +27,7 @@
#include <libsecret/secret.h>
#include "goaprovider.h"
+#include "goalogging.h"
#include "goautils.h"
static const SecretSchema secret_password_schema =
@@ -298,3 +300,103 @@ goa_utils_store_credentials_for_object_sync (GoaProvider *provider,
id = goa_account_get_id (goa_object_peek_account (object));
return goa_utils_store_credentials_for_id_sync (provider, id, credentials, cancellable, error);
}
+
+void
+goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key)
+{
+ GError *error;
+ GKeyFile *key_file;
+ gchar *contents;
+ gchar *group;
+ gchar *path;
+ gsize length;
+
+ contents = NULL;
+
+ path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
+ group = g_strdup_printf ("Account %s", goa_account_get_id (account));
+
+ key_file = g_key_file_new ();
+ error = NULL;
+ if (!g_key_file_load_from_file (key_file,
+ path,
+ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error))
+ {
+ goa_warning ("Error loading keyfile %s: %s (%s, %d)",
+ path,
+ error->message,
+ g_quark_to_string (error->domain),
+ error->code);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_key_file_remove_key (key_file, group, key, NULL);
+ contents = g_key_file_to_data (key_file, &length, NULL);
+
+ error = NULL;
+ if (!g_file_set_contents (path, contents, length, &error))
+ {
+ g_prefix_error (&error, "Error writing key-value-file %s: ", path);
+ goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
+ g_error_free (error);
+ goto out;
+ }
+
+ out:
+ g_free (contents);
+ g_key_file_free (key_file);
+ g_free (group);
+ g_free (path);
+}
+
+void
+goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value)
+{
+ GError *error;
+ GKeyFile *key_file;
+ gchar *contents;
+ gchar *group;
+ gchar *path;
+ gsize length;
+
+ contents = NULL;
+
+ path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
+ group = g_strdup_printf ("Account %s", goa_account_get_id (account));
+
+ key_file = g_key_file_new ();
+ error = NULL;
+ if (!g_key_file_load_from_file (key_file,
+ path,
+ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error))
+ {
+ goa_warning ("Error loading keyfile %s: %s (%s, %d)",
+ path,
+ error->message,
+ g_quark_to_string (error->domain),
+ error->code);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_key_file_set_string (key_file, group, key, value);
+ contents = g_key_file_to_data (key_file, &length, NULL);
+
+ error = NULL;
+ if (!g_file_set_contents (path, contents, length, &error))
+ {
+ g_prefix_error (&error, "Error writing key-value-file %s: ", path);
+ goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
+ g_error_free (error);
+ goto out;
+ }
+
+ out:
+ g_free (contents);
+ g_key_file_free (key_file);
+ g_free (group);
+ g_free (path);
+}
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 406de34..0418fb7 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -65,6 +65,10 @@ gboolean goa_utils_store_credentials_for_object_sync (GoaProvider *pr
GCancellable *cancellable,
GError **error);
+void goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key);
+
+void goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value);
+
G_END_DECLS
#endif /* __GOA_UTILS_H__ */
diff --git a/src/goabackend/goawindowsliveprovider.c b/src/goabackend/goawindowsliveprovider.c
index 70432c4..03c1670 100644
--- a/src/goabackend/goawindowsliveprovider.c
+++ b/src/goabackend/goawindowsliveprovider.c
@@ -263,6 +263,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -280,6 +281,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
diff --git a/src/goabackend/goayahooprovider.c b/src/goabackend/goayahooprovider.c
index 2620e24..dc6d011 100644
--- a/src/goabackend/goayahooprovider.c
+++ b/src/goabackend/goayahooprovider.c
@@ -282,6 +282,7 @@ build_object (GoaProvider *provider,
GoaObjectSkeleton *object,
GKeyFile *key_file,
const gchar *group,
+ GDBusConnection *connection,
gboolean just_added,
GError **error)
{
@@ -294,6 +295,7 @@ build_object (GoaProvider *provider,
object,
key_file,
group,
+ connection,
just_added,
error))
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]