diff --git a/docs/reference/libsecret/libsecret-sections.txt b/docs/reference/libsecret/libsecret-sections.txt
index 805ee22..d53e2db 100644
--- a/docs/reference/libsecret/libsecret-sections.txt
+++ b/docs/reference/libsecret/libsecret-sections.txt
@@ -3,9 +3,13 @@
secret/secret-unstable.h
SecretCollection
SecretCollectionClass
+SecretCollectionFlags
secret_collection_new
secret_collection_new_finish
secret_collection_new_sync
+secret_collection_load_items
+secret_collection_load_items_finish
+secret_collection_load_items_sync
secret_collection_create
secret_collection_create_finish
secret_collection_create_sync
@@ -14,6 +18,7 @@ secret_collection_delete_finish
secret_collection_delete_sync
secret_collection_get_created
secret_collection_get_service
+secret_collection_get_flags
secret_collection_get_items
secret_collection_get_label
secret_collection_set_label
@@ -29,8 +34,10 @@ SECRET_COLLECTION_GET_CLASS
SECRET_IS_COLLECTION
SECRET_IS_COLLECTION_CLASS
SECRET_TYPE_COLLECTION
+SECRET_TYPE_COLLECTION_FLAGS
SecretCollectionPrivate
secret_collection_get_type
+secret_collection_flags_get_type
@@ -183,9 +190,9 @@ secret_service_get_session_path
secret_service_ensure_session
secret_service_ensure_session_finish
secret_service_ensure_session_sync
-secret_service_ensure_collections
-secret_service_ensure_collections_finish
-secret_service_ensure_collections_sync
+secret_service_load_collections
+secret_service_load_collections_finish
+secret_service_load_collections_sync
SecretSearchFlags
secret_service_search
secret_service_search_finish
diff --git a/library/secret-collection.c b/library/secret-collection.c
index 95e8b22..cdf87b2 100644
--- a/library/secret-collection.c
+++ b/library/secret-collection.c
@@ -16,6 +16,7 @@
#include "secret-collection.h"
#include "secret-dbus-generated.h"
+#include "secret-enum-types.h"
#include "secret-item.h"
#include "secret-paths.h"
#include "secret-private.h"
@@ -55,9 +56,20 @@
* The class for #SecretCollection.
*/
+/**
+ * SecretCollectionFlags:
+ * @SECRET_COLLECTION_NONE: no flags for initializing the #SecretCollection
+ * @SECRET_COLLECTION_LOAD_ITEMS: load items while initializing the
+ * #SecretCollection
+ *
+ * Flags which determine which parts of the #SecretCollection proxy are initialized
+ * during a secret_collection_new() or secret_collection_new_sync() operation.
+ */
+
enum {
PROP_0,
PROP_SERVICE,
+ PROP_FLAGS,
PROP_ITEMS,
PROP_LABEL,
PROP_LOCKED,
@@ -70,6 +82,7 @@ struct _SecretCollectionPrivate {
SecretService *service;
GCancellable *cancellable;
gboolean constructing;
+ SecretCollectionFlags init_flags;
/* Protected by mutex */
GMutex mutex;
@@ -141,6 +154,9 @@ secret_collection_set_property (GObject *obj,
g_object_add_weak_pointer (G_OBJECT (self->pv->service),
(gpointer *)&self->pv->service);
break;
+ case PROP_FLAGS:
+ self->pv->init_flags = g_value_get_flags (value);
+ break;
case PROP_LABEL:
secret_collection_set_label (self, g_value_get_string (value),
self->pv->cancellable, on_set_label,
@@ -164,6 +180,9 @@ secret_collection_get_property (GObject *obj,
case PROP_SERVICE:
g_value_set_object (value, self->pv->service);
break;
+ case PROP_FLAGS:
+ g_value_set_flags (value, secret_collection_get_flags (self));
+ break;
case PROP_ITEMS:
g_value_take_boxed (value, secret_collection_get_items (self));
break;
@@ -245,175 +264,33 @@ collection_update_items (SecretCollection *self,
g_object_notify (G_OBJECT (self), "items");
}
-typedef struct {
- GCancellable *cancellable;
- GHashTable *items;
- gint items_loading;
-} ItemsClosure;
-
-static void
-items_closure_free (gpointer data)
-{
- ItemsClosure *closure = data;
- g_clear_object (&closure->cancellable);
- g_hash_table_unref (closure->items);
- g_slice_free (ItemsClosure, closure);
-}
-
-static void
-on_load_item (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
- ItemsClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
- SecretCollection *self = SECRET_COLLECTION (g_async_result_get_source_object (user_data));
- const gchar *path;
- GError *error = NULL;
- SecretItem *item;
-
- closure->items_loading--;
-
- item = secret_item_new_finish (result, &error);
-
- if (error != NULL)
- g_simple_async_result_take_error (res, error);
-
- if (item != NULL) {
- path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (item));
- g_hash_table_insert (closure->items, g_strdup (path), item);
- }
-
- if (closure->items_loading == 0) {
- collection_update_items (self, closure->items);
- g_simple_async_result_complete_in_idle (res);
- }
-
- g_object_unref (self);
- g_object_unref (res);
-}
-
-static void
-collection_load_items_async (SecretCollection *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- ItemsClosure *closure;
- SecretItem *item;
- GSimpleAsyncResult *res;
- const gchar *path;
- GVariant *paths;
- GVariantIter iter;
-
- paths = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self), "Items");
- g_return_if_fail (paths != NULL);
-
- res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
- collection_load_items_async);
- closure = g_slice_new0 (ItemsClosure);
- closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
- closure->items = items_table_new ();
- g_simple_async_result_set_op_res_gpointer (res, closure, items_closure_free);
-
- g_variant_iter_init (&iter, paths);
- while (g_variant_iter_loop (&iter, "&o", &path)) {
- item = collection_lookup_item (self, path);
-
- /* No such collection yet create a new one */
- if (item == NULL) {
- secret_item_new (self->pv->service, path, SECRET_ITEM_NONE,
- cancellable, on_load_item, g_object_ref (res));
- closure->items_loading++;
-
- } else {
- g_hash_table_insert (closure->items, g_strdup (path), item);
- }
- }
-
- if (closure->items_loading == 0) {
- collection_update_items (self, closure->items);
- g_simple_async_result_complete_in_idle (res);
- }
-
- g_variant_unref (paths);
- g_object_unref (res);
-}
-
-static gboolean
-collection_load_items_finish (SecretCollection *self,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
- return FALSE;
-
- return TRUE;
-}
-
-
-static gboolean
-collection_load_items_sync (SecretCollection *self,
- GCancellable *cancellable,
- GError **error)
-{
- SecretItem *item;
- GHashTable *items;
- GVariant *paths;
- GVariantIter iter;
- const gchar *path;
- gboolean ret = TRUE;
-
- paths = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self), "Items");
- g_return_val_if_fail (paths != NULL, FALSE);
-
- items = items_table_new ();
-
- g_variant_iter_init (&iter, paths);
- while (g_variant_iter_next (&iter, "&o", &path)) {
- item = collection_lookup_item (self, path);
-
- /* No such collection yet create a new one */
- if (item == NULL) {
- item = secret_item_new_sync (self->pv->service, path,
- SECRET_ITEM_NONE,
- cancellable, error);
- if (item == NULL) {
- ret = FALSE;
- break;
- }
- }
-
- g_hash_table_insert (items, g_strdup (path), item);
- }
-
- if (ret)
- collection_update_items (self, items);
-
- g_hash_table_unref (items);
- g_variant_unref (paths);
- return ret;
-}
-
static void
handle_property_changed (SecretCollection *self,
const gchar *property_name,
GVariant *value)
{
- if (g_str_equal (property_name, "Label"))
+ gboolean perform;
+
+ if (g_str_equal (property_name, "Label")) {
g_object_notify (G_OBJECT (self), "label");
- else if (g_str_equal (property_name, "Locked"))
+ } else if (g_str_equal (property_name, "Locked")) {
g_object_notify (G_OBJECT (self), "locked");
- else if (g_str_equal (property_name, "Created"))
+ } else if (g_str_equal (property_name, "Created")) {
g_object_notify (G_OBJECT (self), "created");
- else if (g_str_equal (property_name, "Modified"))
+ } else if (g_str_equal (property_name, "Modified")) {
g_object_notify (G_OBJECT (self), "modified");
- else if (g_str_equal (property_name, "Items") && !self->pv->constructing)
- collection_load_items_async (self, self->pv->cancellable, NULL, NULL);
+ } else if (g_str_equal (property_name, "Items") && !self->pv->constructing) {
+ g_mutex_lock (&self->pv->mutex);
+ perform = self->pv->items != NULL;
+ g_mutex_unlock (&self->pv->mutex);
+
+ if (perform)
+ secret_collection_load_items (self, self->pv->cancellable, NULL, NULL);
+ }
}
static void
@@ -542,6 +419,17 @@ secret_collection_class_init (SecretCollectionClass *klass)
g_param_spec_object ("service", "Service", "Secret Service",
SECRET_TYPE_SERVICE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ /**
+ * SecretCollection:flags:
+ *
+ * A set of flags describing which parts of the secret collection have
+ * been initialized.
+ */
+ g_object_class_install_property (gobject_class, PROP_FLAGS,
+ g_param_spec_flags ("flags", "Flags", "Collection flags",
+ secret_collection_flags_get_type (), SECRET_COLLECTION_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
/**
* SecretCollection:items:
*
@@ -622,8 +510,10 @@ secret_collection_initable_init (GInitable *initable,
self = SECRET_COLLECTION (initable);
- if (!collection_load_items_sync (self, cancellable, error))
- return FALSE;
+ if (self->pv->init_flags & SECRET_COLLECTION_LOAD_ITEMS) {
+ if (!secret_collection_load_items_sync (self, cancellable, error))
+ return FALSE;
+ }
self->pv->constructing = FALSE;
return TRUE;
@@ -658,7 +548,7 @@ on_init_items (GObject *source,
SecretCollection *self = SECRET_COLLECTION (source);
GError *error = NULL;
- if (!collection_load_items_finish (self, result, &error))
+ if (!secret_collection_load_items_finish (self, result, &error))
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
@@ -687,9 +577,12 @@ on_init_base (GObject *source,
g_dbus_proxy_get_object_path (proxy));
g_simple_async_result_complete (res);
+ } else if (self->pv->init_flags & SECRET_COLLECTION_LOAD_ITEMS) {
+ secret_collection_load_items (self, closure->cancellable,
+ on_init_items, g_object_ref (res));
+
} else {
- collection_load_items_async (self, closure->cancellable,
- on_init_items, g_object_ref (res));
+ g_simple_async_result_complete (res);
}
g_object_unref (res);
@@ -749,6 +642,7 @@ secret_collection_async_initable_iface (GAsyncInitableIface *iface)
* secret_collection_new:
* @service: a secret service object
* @collection_path: the D-Bus path of the collection
+ * @flags: options for the collection initialization
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* @user_data: data to be passed to the callback
@@ -760,6 +654,7 @@ secret_collection_async_initable_iface (GAsyncInitableIface *iface)
void
secret_collection_new (SecretService *service,
const gchar *collection_path,
+ SecretCollectionFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -781,6 +676,7 @@ secret_collection_new (SecretService *service,
"g-object-path", collection_path,
"g-interface-name", SECRET_COLLECTION_INTERFACE,
"service", service,
+ "flags", flags,
NULL);
}
@@ -820,6 +716,7 @@ secret_collection_new_finish (GAsyncResult *result,
* secret_collection_new_sync:
* @service: a secret service object
* @collection_path: the D-Bus path of the collection
+ * @flags: options for the collection initialization
* @cancellable: optional cancellation object
* @error: location to place an error on failure
*
@@ -834,6 +731,7 @@ secret_collection_new_finish (GAsyncResult *result,
SecretCollection *
secret_collection_new_sync (SecretService *service,
const gchar *collection_path,
+ SecretCollectionFlags flags,
GCancellable *cancellable,
GError **error)
{
@@ -855,9 +753,218 @@ secret_collection_new_sync (SecretService *service,
"g-object-path", collection_path,
"g-interface-name", SECRET_COLLECTION_INTERFACE,
"service", service,
+ "flags", flags,
NULL);
}
+typedef struct {
+ GCancellable *cancellable;
+ GHashTable *items;
+ gint items_loading;
+} ItemsClosure;
+
+static void
+items_closure_free (gpointer data)
+{
+ ItemsClosure *closure = data;
+ g_clear_object (&closure->cancellable);
+ g_hash_table_unref (closure->items);
+ g_slice_free (ItemsClosure, closure);
+}
+
+static void
+on_load_item (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
+ ItemsClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+ SecretCollection *self = SECRET_COLLECTION (g_async_result_get_source_object (user_data));
+ const gchar *path;
+ GError *error = NULL;
+ SecretItem *item;
+
+ closure->items_loading--;
+
+ item = secret_item_new_finish (result, &error);
+
+ if (error != NULL)
+ g_simple_async_result_take_error (res, error);
+
+ if (item != NULL) {
+ path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (item));
+ g_hash_table_insert (closure->items, g_strdup (path), item);
+ }
+
+ if (closure->items_loading == 0) {
+ collection_update_items (self, closure->items);
+ g_simple_async_result_complete_in_idle (res);
+ }
+
+ g_object_unref (self);
+ g_object_unref (res);
+}
+
+/**
+ * secret_collection_load_items:
+ * @self: the secret collection
+ * @cancellable: optional cancellation object
+ * @callback: called when the operation completes
+ * @user_data: data to be passed to the callback
+ *
+ * Ensure that the #SecretCollection proxy has loaded all the items present
+ * in the Secret Service. This affects the result of
+ * secret_collection_get_items().
+ *
+ * You can also pass the %SECRET_COLLECTION_LOAD_ITEMS to
+ * secret_collection_new() in order to ensure that the collections have been
+ * loaded by the time you get the #SecretCollection proxy.
+ *
+ * This method will return immediately and complete asynchronously.
+ */
+void
+secret_collection_load_items (SecretCollection *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ ItemsClosure *closure;
+ SecretItem *item;
+ GSimpleAsyncResult *res;
+ const gchar *path;
+ GVariant *paths;
+ GVariantIter iter;
+
+ g_return_if_fail (SECRET_IS_COLLECTION (self));
+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
+ paths = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self), "Items");
+ g_return_if_fail (paths != NULL);
+
+ res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+ secret_collection_load_items);
+ closure = g_slice_new0 (ItemsClosure);
+ closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
+ closure->items = items_table_new ();
+ g_simple_async_result_set_op_res_gpointer (res, closure, items_closure_free);
+
+ g_variant_iter_init (&iter, paths);
+ while (g_variant_iter_loop (&iter, "&o", &path)) {
+ item = collection_lookup_item (self, path);
+
+ /* No such collection yet create a new one */
+ if (item == NULL) {
+ secret_item_new (self->pv->service, path, SECRET_ITEM_NONE,
+ cancellable, on_load_item, g_object_ref (res));
+ closure->items_loading++;
+
+ } else {
+ g_hash_table_insert (closure->items, g_strdup (path), item);
+ }
+ }
+
+ if (closure->items_loading == 0) {
+ collection_update_items (self, closure->items);
+ g_simple_async_result_complete_in_idle (res);
+ }
+
+ g_variant_unref (paths);
+ g_object_unref (res);
+}
+
+/**
+ * secret_collection_load_items_finish:
+ * @self: the secret collection
+ * @result: the asynchronous result passed to the callback
+ * @error: location to place an error on failure
+ *
+ * Complete an asynchronous operation to ensure that the #SecretCollection proxy
+ * has loaded all the items present in the Secret Service.
+ *
+ * Returns: whether the load was successful or not
+ */
+gboolean
+secret_collection_load_items_finish (SecretCollection *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (SECRET_IS_COLLECTION (self), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
+ secret_collection_load_items), FALSE);
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
+ return FALSE;
+
+ return TRUE;
+}
+
+/**
+ * secret_collection_load_items_sync:
+ * @self: the secret collection
+ * @cancellable: optional cancellation object
+ * @error: location to place an error on failure
+ *
+ * Ensure that the #SecretCollection proxy has loaded all the items present
+ * in the Secret Service. This affects the result of
+ * secret_collection_get_items().
+ *
+ * You can also pass the %SECRET_COLLECTION_LOAD_ITEMS to
+ * secret_collection_new_sync() in order to ensure that the items have been
+ * loaded by the time you get the #SecretCollection proxy.
+ *
+ * This method may block indefinitely and should not be used in user interface
+ * threads.
+ *
+ * Returns: whether the load was successful or not
+ */
+gboolean
+secret_collection_load_items_sync (SecretCollection *self,
+ GCancellable *cancellable,
+ GError **error)
+{
+ SecretItem *item;
+ GHashTable *items;
+ GVariant *paths;
+ GVariantIter iter;
+ const gchar *path;
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail (SECRET_IS_COLLECTION (self), FALSE);
+ g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ paths = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self), "Items");
+ g_return_val_if_fail (paths != NULL, FALSE);
+
+ items = items_table_new ();
+
+ g_variant_iter_init (&iter, paths);
+ while (g_variant_iter_next (&iter, "&o", &path)) {
+ item = collection_lookup_item (self, path);
+
+ /* No such collection yet create a new one */
+ if (item == NULL) {
+ item = secret_item_new_sync (self->pv->service, path,
+ SECRET_ITEM_NONE,
+ cancellable, error);
+ if (item == NULL) {
+ ret = FALSE;
+ break;
+ }
+ }
+
+ g_hash_table_insert (items, g_strdup (path), item);
+ }
+
+ if (ret)
+ collection_update_items (self, items);
+
+ g_hash_table_unref (items);
+ g_variant_unref (paths);
+ return ret;
+}
+
/**
* secret_collection_refresh:
* @self: the collection
@@ -922,7 +1029,8 @@ on_create_path (GObject *source,
path = secret_service_create_collection_path_finish (service, result, &error);
if (error == NULL) {
- secret_collection_new (service, path, closure->cancellable,
+ secret_collection_new (service, path, SECRET_COLLECTION_LOAD_ITEMS,
+ closure->cancellable,
on_create_collection, g_object_ref (res));
} else {
g_simple_async_result_take_error (res, error);
@@ -1082,7 +1190,9 @@ secret_collection_create_sync (SecretService *service,
if (path == NULL)
return NULL;
- collection = secret_collection_new_sync (service, path, cancellable, error);
+ collection = secret_collection_new_sync (service, path,
+ SECRET_COLLECTION_LOAD_ITEMS,
+ cancellable, error);
g_free (path);
return collection;
@@ -1220,6 +1330,35 @@ secret_collection_get_service (SecretCollection *self)
return self->pv->service;
}
+/**
+ * secret_collection_get_flags:
+ * @self: the secret collection proxy
+ *
+ * Get the flags representing what features of the #SecretCollection proxy
+ * have been initialized.
+ *
+ * Use secret_collection_load_items() to initialize further features
+ * and change the flags.
+ *
+ * Returns: the flags for features initialized
+ */
+SecretCollectionFlags
+secret_collection_get_flags (SecretCollection *self)
+{
+ SecretCollectionFlags flags = 0;
+
+ g_return_val_if_fail (SECRET_IS_COLLECTION (self), SECRET_COLLECTION_NONE);
+
+ g_mutex_lock (&self->pv->mutex);
+
+ if (self->pv->items)
+ flags |= SECRET_COLLECTION_LOAD_ITEMS;
+
+ g_mutex_unlock (&self->pv->mutex);
+
+ return flags;
+}
+
/**
* secret_collection_get_items:
* @self: a collection
diff --git a/library/secret-collection.h b/library/secret-collection.h
index 9f9b617..89fb111 100644
--- a/library/secret-collection.h
+++ b/library/secret-collection.h
@@ -25,6 +25,11 @@
G_BEGIN_DECLS
+typedef enum {
+ SECRET_COLLECTION_NONE = 0,
+ SECRET_COLLECTION_LOAD_ITEMS = 1 << 1,
+} SecretCollectionFlags;
+
#define SECRET_TYPE_COLLECTION (secret_collection_get_type ())
#define SECRET_COLLECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), SECRET_TYPE_COLLECTION, SecretCollection))
#define SECRET_COLLECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), SECRET_TYPE_COLLECTION, SecretCollectionClass))
@@ -53,6 +58,7 @@ GType secret_collection_get_type (void) G_GNUC_CON
void secret_collection_new (SecretService *service,
const gchar *collection_path,
+ SecretCollectionFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -62,6 +68,20 @@ SecretCollection * secret_collection_new_finish (GAsyncResult *re
SecretCollection * secret_collection_new_sync (SecretService *service,
const gchar *collection_path,
+ SecretCollectionFlags flags,
+ GCancellable *cancellable,
+ GError **error);
+
+void secret_collection_load_items (SecretCollection *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean secret_collection_load_items_finish (SecretCollection *self,
+ GAsyncResult *result,
+ GError **error);
+
+gboolean secret_collection_load_items_sync (SecretCollection *self,
GCancellable *cancellable,
GError **error);
@@ -98,6 +118,8 @@ gboolean secret_collection_delete_sync (SecretCollection
SecretService * secret_collection_get_service (SecretCollection *self);
+SecretCollectionFlags secret_collection_get_flags (SecretCollection *self);
+
GList * secret_collection_get_items (SecretCollection *self);
gchar * secret_collection_get_label (SecretCollection *self);
diff --git a/library/secret-methods.c b/library/secret-methods.c
index aeeb614..d0e2558 100644
--- a/library/secret-methods.c
+++ b/library/secret-methods.c
@@ -1532,7 +1532,8 @@ on_read_alias_path (GObject *source,
/* No collection loaded, but valid path, load */
} else {
- secret_collection_new (self, collection_path, read->cancellable,
+ secret_collection_new (self, collection_path, SECRET_COLLECTION_NONE,
+ read->cancellable,
on_read_alias_collection, g_object_ref (async));
}
}
@@ -1662,6 +1663,7 @@ secret_service_read_alias_sync (SecretService *self,
/* No collection loaded, but valid path, load */
if (collection == NULL) {
collection = secret_collection_new_sync (self, collection_path,
+ SECRET_COLLECTION_LOAD_ITEMS,
cancellable, error);
}
}
diff --git a/library/secret-service.c b/library/secret-service.c
index 9a6eb16..4a2a273 100644
--- a/library/secret-service.c
+++ b/library/secret-service.c
@@ -54,7 +54,7 @@
* represent those collections while initializing a #SecretService then pass
* the %SECRET_SERVICE_LOAD_COLLECTIONS flag to the secret_service_get() or
* secret_service_new() functions. In order to establish a session on an already
- * existing #SecretService, use the secret_service_ensure_collections() function.
+ * existing #SecretService, use the secret_service_load_collections() function.
* To access the list of collections use secret_service_get_collections().
*
* Certain actions on the Secret Service require user prompting to complete,
@@ -306,7 +306,7 @@ handle_property_changed (SecretService *self,
g_mutex_unlock (&self->pv->mutex);
if (perform)
- secret_service_ensure_collections (self, self->pv->cancellable, NULL, NULL);
+ secret_service_load_collections (self, self->pv->cancellable, NULL, NULL);
}
g_variant_unref (value);
@@ -455,7 +455,7 @@ secret_service_class_init (SecretServiceClass *klass)
*
* To load the collections, specify the %SECRET_SERVICE_LOAD_COLLECTIONS
* initialization flag when calling the secret_service_get() or
- * secret_service_new() functions. Or call the secret_service_ensure_collections()
+ * secret_service_new() functions. Or call the secret_service_load_collections()
* method.
*/
g_object_class_install_property (object_class, PROP_COLLECTIONS,
@@ -489,22 +489,22 @@ service_ensure_for_flags_sync (SecretService *self,
return FALSE;
if (flags & SECRET_SERVICE_LOAD_COLLECTIONS)
- if (!secret_service_ensure_collections_sync (self, cancellable, error))
+ if (!secret_service_load_collections_sync (self, cancellable, error))
return FALSE;
return TRUE;
}
static void
-on_ensure_collections (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
+on_load_collections (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
SecretService *self = SECRET_SERVICE (source);
GError *error = NULL;
- if (!secret_service_ensure_collections_finish (self, result, &error))
+ if (!secret_service_load_collections_finish (self, result, &error))
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
@@ -526,8 +526,8 @@ on_ensure_session (GObject *source,
g_simple_async_result_complete (res);
} else if (closure->flags & SECRET_SERVICE_LOAD_COLLECTIONS) {
- secret_service_ensure_collections (self, closure->cancellable,
- on_ensure_collections, g_object_ref (res));
+ secret_service_load_collections (self, closure->cancellable,
+ on_load_collections, g_object_ref (res));
} else {
g_simple_async_result_complete_in_idle (res);
@@ -550,8 +550,8 @@ service_ensure_for_flags_async (SecretService *self,
on_ensure_session, g_object_ref (res));
else if (closure->flags & SECRET_SERVICE_LOAD_COLLECTIONS)
- secret_service_ensure_collections (self, closure->cancellable,
- on_ensure_collections, g_object_ref (res));
+ secret_service_load_collections (self, closure->cancellable,
+ on_load_collections, g_object_ref (res));
else
g_simple_async_result_complete_in_idle (res);
@@ -973,7 +973,7 @@ secret_service_new_sync (GType service_gtype,
* Get the flags representing what features of the #SecretService proxy
* have been initialized.
*
- * Use secret_service_ensure_session() or secret_service_ensure_collections()
+ * Use secret_service_ensure_session() or secret_service_load_collections()
* to initialize further features and change the flags.
*
* Returns: the flags for features initialized
@@ -1006,7 +1006,7 @@ secret_service_get_flags (SecretService *self)
*
* If the %SECRET_SERVICE_LOAD_COLLECTIONS flag was not specified when
* initializing #SecretService proxy object, then this method will return
- * %NULL. Use secret_service_ensure_collections() to load the collections.
+ * %NULL. Use secret_service_load_collections() to load the collections.
*
* Returns: (transfer full) (element-type Secret.Collection) (allow-none): a
* list of the collections in the secret service
@@ -1379,7 +1379,7 @@ on_ensure_collection (GObject *source,
}
/**
- * secret_service_ensure_collections:
+ * secret_service_load_collections:
* @self: the secret service
* @cancellable: optional cancellation object
* @callback: called when the operation completes
@@ -1396,10 +1396,10 @@ on_ensure_collection (GObject *source,
* This method will return immediately and complete asynchronously.
*/
void
-secret_service_ensure_collections (SecretService *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+secret_service_load_collections (SecretService *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
EnsureClosure *closure;
SecretCollection *collection;
@@ -1415,7 +1415,7 @@ secret_service_ensure_collections (SecretService *self,
g_return_if_fail (paths != NULL);
res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
- secret_service_ensure_collections);
+ secret_service_load_collections);
closure = g_slice_new0 (EnsureClosure);
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
closure->collections = collections_table_new ();
@@ -1427,7 +1427,7 @@ secret_service_ensure_collections (SecretService *self,
/* No such collection yet create a new one */
if (collection == NULL) {
- secret_collection_new (self, path, cancellable,
+ secret_collection_new (self, path, SECRET_COLLECTION_LOAD_ITEMS, cancellable,
on_ensure_collection, g_object_ref (res));
closure->collections_loading++;
} else {
@@ -1445,7 +1445,7 @@ secret_service_ensure_collections (SecretService *self,
}
/**
- * secret_service_ensure_collections_finish:
+ * secret_service_load_collections_finish:
* @self: the secret service
* @result: the asynchronous result passed to the callback
* @error: location to place an error on failure
@@ -1456,14 +1456,14 @@ secret_service_ensure_collections (SecretService *self,
* Returns: whether the load was successful or not
*/
gboolean
-secret_service_ensure_collections_finish (SecretService *self,
- GAsyncResult *result,
- GError **error)
+secret_service_load_collections_finish (SecretService *self,
+ GAsyncResult *result,
+ GError **error)
{
g_return_val_if_fail (SECRET_IS_SERVICE (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
- secret_service_ensure_collections), FALSE);
+ secret_service_load_collections), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
@@ -1472,7 +1472,7 @@ secret_service_ensure_collections_finish (SecretService *self,
}
/**
- * secret_service_ensure_collections_sync:
+ * secret_service_load_collections_sync:
* @self: the secret service
* @cancellable: optional cancellation object
* @error: location to place an error on failure
@@ -1491,9 +1491,9 @@ secret_service_ensure_collections_finish (SecretService *self,
* Returns: whether the load was successful or not
*/
gboolean
-secret_service_ensure_collections_sync (SecretService *self,
- GCancellable *cancellable,
- GError **error)
+secret_service_load_collections_sync (SecretService *self,
+ GCancellable *cancellable,
+ GError **error)
{
SecretCollection *collection;
GHashTable *collections;
@@ -1517,7 +1517,9 @@ secret_service_ensure_collections_sync (SecretService *self,
/* No such collection yet create a new one */
if (collection == NULL) {
- collection = secret_collection_new_sync (self, path, cancellable, error);
+ collection = secret_collection_new_sync (self, path,
+ SECRET_COLLECTION_LOAD_ITEMS,
+ cancellable, error);
if (collection == NULL) {
ret = FALSE;
break;
diff --git a/library/secret-service.h b/library/secret-service.h
index 01de1df..6fae768 100644
--- a/library/secret-service.h
+++ b/library/secret-service.h
@@ -137,16 +137,16 @@ const gchar * secret_service_ensure_session_sync (SecretService
GCancellable *cancellable,
GError **error);
-void secret_service_ensure_collections (SecretService *self,
+void secret_service_load_collections (SecretService *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-gboolean secret_service_ensure_collections_finish (SecretService *self,
+gboolean secret_service_load_collections_finish (SecretService *self,
GAsyncResult *result,
GError **error);
-gboolean secret_service_ensure_collections_sync (SecretService *self,
+gboolean secret_service_load_collections_sync (SecretService *self,
GCancellable *cancellable,
GError **error);
diff --git a/library/tests/test-collection.c b/library/tests/test-collection.c
index b3bc1c8..85acf8c 100644
--- a/library/tests/test-collection.c
+++ b/library/tests/test-collection.c
@@ -88,7 +88,8 @@ test_new_sync (Test *test,
GError *error = NULL;
SecretCollection *collection;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
g_assert_cmpstr (g_dbus_proxy_get_object_path (G_DBUS_PROXY (collection)), ==, collection_path);
@@ -106,7 +107,8 @@ test_new_async (Test *test,
SecretCollection *collection;
GAsyncResult *result = NULL;
- secret_collection_new (test->service, collection_path, NULL, on_async_result, &result);
+ secret_collection_new (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, on_async_result, &result);
g_assert (result == NULL);
egg_test_wait ();
@@ -129,7 +131,8 @@ test_new_sync_noexist (Test *test,
GError *error = NULL;
SecretCollection *collection;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (collection == NULL);
}
@@ -143,7 +146,8 @@ test_new_async_noexist (Test *test,
SecretCollection *collection;
GAsyncResult *result = NULL;
- secret_collection_new (test->service, collection_path, NULL, on_async_result, &result);
+ secret_collection_new (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, on_async_result, &result);
g_assert (result == NULL);
egg_test_wait ();
@@ -211,7 +215,8 @@ test_properties (Test *test,
gboolean locked;
gchar *label;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (secret_collection_get_locked (collection) == FALSE);
@@ -281,7 +286,8 @@ test_items (Test *test,
GError *error = NULL;
GList *items;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_LOAD_ITEMS, NULL, &error);
g_assert_no_error (error);
items = secret_collection_get_items (collection);
@@ -312,7 +318,8 @@ test_items_empty (Test *test,
GError *error = NULL;
GList *items;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_LOAD_ITEMS, NULL, &error);
g_assert_no_error (error);
items = secret_collection_get_items (collection);
@@ -336,7 +343,9 @@ test_items_empty_async (Test *test,
GError *error = NULL;
GList *items;
- secret_collection_new (test->service, collection_path, NULL, on_async_result, &result);
+ secret_collection_new (test->service, collection_path,
+ SECRET_COLLECTION_LOAD_ITEMS,
+ NULL, on_async_result, &result);
g_assert (result == NULL);
egg_test_wait ();
@@ -366,7 +375,8 @@ test_set_label_sync (Test *test,
gboolean ret;
gchar *label;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
label = secret_collection_get_label (collection);
@@ -395,7 +405,8 @@ test_set_label_async (Test *test,
gboolean ret;
gchar *label;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
label = secret_collection_get_label (collection);
@@ -429,7 +440,8 @@ test_set_label_prop (Test *test,
guint sigs = 2;
gchar *label;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
label = secret_collection_get_label (collection);
@@ -458,7 +470,8 @@ test_delete_sync (Test *test,
GError *error = NULL;
gboolean ret;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
ret = secret_collection_delete_sync (collection, NULL, &error);
@@ -467,7 +480,8 @@ test_delete_sync (Test *test,
g_object_unref (collection);
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (collection == NULL);
}
@@ -482,7 +496,8 @@ test_delete_async (Test *test,
GError *error = NULL;
gboolean ret;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
secret_collection_delete (collection, NULL, on_async_result, &result);
@@ -497,7 +512,8 @@ test_delete_async (Test *test,
g_object_unref (collection);
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (collection == NULL);
}
diff --git a/library/tests/test-item.c b/library/tests/test-item.c
index bf29584..d0c55c0 100644
--- a/library/tests/test-item.c
+++ b/library/tests/test-item.c
@@ -166,7 +166,8 @@ test_create_sync (Test *test,
GHashTable *attributes;
SecretValue *value;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
@@ -204,7 +205,8 @@ test_create_async (Test *test,
GHashTable *attributes;
SecretValue *value;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
diff --git a/library/tests/test-methods.c b/library/tests/test-methods.c
index b7a5ccc..0cefcd4 100644
--- a/library/tests/test-methods.c
+++ b/library/tests/test-methods.c
@@ -397,7 +397,8 @@ test_lock_sync (Test *test,
GList *objects;
gboolean ret;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
objects = g_list_append (NULL, collection);
@@ -426,7 +427,8 @@ test_unlock_sync (Test *test,
GList *objects;
gboolean ret;
- collection = secret_collection_new_sync (test->service, collection_path, NULL, &error);
+ collection = secret_collection_new_sync (test->service, collection_path,
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
objects = g_list_append (NULL, collection);
@@ -922,7 +924,8 @@ test_set_alias_sync (Test *test,
g_assert_no_error (error);
g_assert (blah == NULL);
- collection = secret_collection_new_sync (test->service, "/org/freedesktop/secrets/collection/english", NULL, &error);
+ collection = secret_collection_new_sync (test->service, "/org/freedesktop/secrets/collection/english",
+ SECRET_COLLECTION_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (SECRET_IS_COLLECTION (collection));
diff --git a/library/tests/test-service.c b/library/tests/test-service.c
index ec6d797..e78fbe6 100644
--- a/library/tests/test-service.c
+++ b/library/tests/test-service.c
@@ -479,7 +479,7 @@ test_ensure_sync (Test *test,
flags = secret_service_get_flags (service);
g_assert_cmpuint (flags, ==, SECRET_SERVICE_NONE);
- ret = secret_service_ensure_collections_sync (service, NULL, &error);
+ ret = secret_service_load_collections_sync (service, NULL, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
@@ -517,12 +517,12 @@ test_ensure_async (Test *test,
flags = secret_service_get_flags (service);
g_assert_cmpuint (flags, ==, SECRET_SERVICE_NONE);
- secret_service_ensure_collections (service, NULL, on_complete_get_result, &result);
+ secret_service_load_collections (service, NULL, on_complete_get_result, &result);
g_assert (result == NULL);
egg_test_wait ();
- ret = secret_service_ensure_collections_finish (service, result, &error);
+ ret = secret_service_load_collections_finish (service, result, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
g_object_unref (result);