/**
* secret_service_search:
* @self: the secret service
+ * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): search for items matching these attributes
* @flags: search option flags
* @cancellable: optional cancellation object
*/
void
secret_service_search (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
SecretSearchFlags flags,
GCancellable *cancellable,
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+ /* Warnings raised already */
+ if (schema != NULL && !_secret_attributes_validate (schema, attributes))
+ return;
+
res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
secret_service_search);
closure = g_slice_new0 (SearchClosure);
closure->flags = flags;
g_simple_async_result_set_op_res_gpointer (res, closure, search_closure_free);
- secret_service_search_for_paths (self, attributes, cancellable,
+ secret_service_search_for_paths (self, schema, attributes, cancellable,
on_search_paths, g_object_ref (res));
g_object_unref (res);
/**
* secret_service_search_sync:
* @self: the secret service
+ * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): search for items matching these attributes
* @flags: search option flags
* @cancellable: optional cancellation object
*/
GList *
secret_service_search_sync (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
SecretSearchFlags flags,
GCancellable *cancellable,
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- if (!secret_service_search_for_paths_sync (self, attributes, cancellable,
+ /* Warnings raised already */
+ if (schema != NULL && !_secret_attributes_validate (schema, attributes))
+ return NULL;
+
+ if (!secret_service_search_for_paths_sync (self, schema, attributes, cancellable,
&unlocked_paths, &locked_paths, error))
return NULL;
/**
* secret_service_search_for_paths:
* @self: the secret service
+ * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): search for items matching these attributes
* @cancellable: optional cancellation object
* @callback: called when the operation completes
*/
void
secret_service_search_for_paths (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ const gchar *schema_name = NULL;
+
g_return_if_fail (SECRET_IS_SERVICE (self));
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
- _secret_service_search_for_paths_variant (self, _secret_attributes_to_variant (attributes, NULL),
+ /* Warnings raised already */
+ if (schema != NULL && !_secret_attributes_validate (schema, attributes))
+ return;
+
+ if (schema != NULL && !(schema->flags & SECRET_SCHEMA_DONT_MATCH_NAME))
+ schema_name = schema->name;
+
+ _secret_service_search_for_paths_variant (self, _secret_attributes_to_variant (attributes, schema_name),
cancellable, callback, user_data);
}
/**
* secret_service_search_for_paths_sync:
* @self: the secret service
+ * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): search for items matching these attributes
* @cancellable: optional cancellation object
* @unlocked: (out) (transfer full) (array zero-terminated=1) (allow-none):
*/
gboolean
secret_service_search_for_paths_sync (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
gchar ***unlocked,
gchar ***locked,
GError **error)
{
+ const gchar *schema_name = NULL;
gchar **dummy = NULL;
GVariant *response;
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ /* Warnings raised already */
+ if (schema != NULL && !_secret_attributes_validate (schema, attributes))
+ return FALSE;
+
+ if (schema != NULL && !(schema->flags & SECRET_SCHEMA_DONT_MATCH_NAME))
+ schema_name = schema->name;
+
response = g_dbus_proxy_call_sync (G_DBUS_PROXY (self), "SearchItems",
g_variant_new ("(@a{ss})",
- _secret_attributes_to_variant (attributes, NULL)),
+ _secret_attributes_to_variant (attributes, schema_name)),
G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error);
if (response != NULL) {
G_BEGIN_DECLS
void secret_service_search_for_paths (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
GAsyncReadyCallback callback,
GError **error);
gboolean secret_service_search_for_paths_sync (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
GCancellable *cancellable,
gchar ***unlocked,
GError **error);
void secret_service_search (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
SecretSearchFlags flags,
GCancellable *cancellable,
GError **error);
GList * secret_service_search_sync (SecretService *self,
+ const SecretSchema *schema,
GHashTable *attributes,
SecretSearchFlags flags,
GCancellable *cancellable,
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- items = secret_service_search_sync (test->service, attributes, SECRET_SEARCH_NONE,
- NULL, &error);
+ items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
+ SECRET_SEARCH_NONE, NULL, &error);
g_assert_no_error (error);
g_hash_table_unref (attributes);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- secret_service_search (test->service, attributes, SECRET_SEARCH_NONE, NULL,
+ secret_service_search (test->service, &MOCK_SCHEMA, attributes,
+ SECRET_SEARCH_NONE, NULL,
on_complete_get_result, &result);
g_hash_table_unref (attributes);
g_assert (result == NULL);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- items = secret_service_search_sync (test->service, attributes, SECRET_SEARCH_ALL,
- NULL, &error);
+ items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
+ SECRET_SEARCH_ALL, NULL, &error);
g_assert_no_error (error);
g_hash_table_unref (attributes);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- secret_service_search (test->service, attributes, SECRET_SEARCH_ALL, NULL,
+ secret_service_search (test->service, &MOCK_SCHEMA, attributes,
+ SECRET_SEARCH_ALL, NULL,
on_complete_get_result, &result);
g_hash_table_unref (attributes);
g_assert (result == NULL);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- items = secret_service_search_sync (test->service, attributes,
+ items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK,
NULL, &error);
g_assert_no_error (error);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- secret_service_search (test->service, attributes,
+ secret_service_search (test->service, &MOCK_SCHEMA, attributes,
SECRET_SEARCH_ALL | SECRET_SEARCH_UNLOCK, NULL,
on_complete_get_result, &result);
g_hash_table_unref (attributes);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- items = secret_service_search_sync (test->service, attributes,
+ items = secret_service_search_sync (test->service, &MOCK_SCHEMA, attributes,
SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS,
NULL, &error);
g_assert_no_error (error);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- secret_service_search (test->service, attributes,
+ secret_service_search (test->service, &MOCK_SCHEMA, attributes,
SECRET_SEARCH_ALL | SECRET_SEARCH_LOAD_SECRETS, NULL,
on_complete_get_result, &result);
g_hash_table_unref (attributes);
g_hash_table_insert (attributes, "string", "seventeen");
g_hash_table_insert (attributes, "number", "17");
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
- &paths, NULL, &error);
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes,
+ NULL, &paths, NULL, &error);
g_hash_table_unref (attributes);
g_assert (ret == TRUE);
g_hash_table_insert (attributes, "string", "seventeen");
g_hash_table_insert (attributes, "number", "17");
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
- &paths, NULL, &error);
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes,
+ NULL, &paths, NULL, &error);
g_hash_table_unref (attributes);
g_assert (ret == TRUE);
g_hash_table_insert (attributes, "string", "seventeen");
g_hash_table_insert (attributes, "number", "17");
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
- &paths, NULL, &error);
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes,
+ NULL, &paths, NULL, &error);
g_hash_table_unref (attributes);
g_assert (ret == TRUE);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
- &unlocked, &locked, &error);
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes, NULL,
+ &unlocked, &locked, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- secret_service_search_for_paths (test->service, attributes, NULL,
+ secret_service_search_for_paths (test->service, &MOCK_SCHEMA, attributes, NULL,
on_complete_get_result, &result);
egg_test_wait ();
attributes = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (attributes, "number", "1");
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes, NULL,
&paths, NULL, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
g_assert_cmpstr (paths[0], ==, "/org/freedesktop/secrets/collection/english/1");
g_strfreev (paths);
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes, NULL,
NULL, &paths, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
g_assert_cmpstr (paths[0], ==, "/org/freedesktop/secrets/collection/spanish/10");
g_strfreev (paths);
- ret = secret_service_search_for_paths_sync (test->service, attributes, NULL,
+ ret = secret_service_search_for_paths_sync (test->service, &MOCK_SCHEMA, attributes, NULL,
NULL, NULL, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
- secret_service_search_for_paths (test->service, attributes, NULL,
+ secret_service_search_for_paths (test->service, &MOCK_SCHEMA, attributes, NULL,
on_complete_get_result, &result);
egg_test_wait ();
g_assert (G_IS_ASYNC_RESULT (result));
g_strfreev (paths);
g_clear_object (&result);
- secret_service_search_for_paths (test->service, attributes, NULL,
+ secret_service_search_for_paths (test->service, &MOCK_SCHEMA, attributes, NULL,
on_complete_get_result, &result);
egg_test_wait ();
g_assert (G_IS_ASYNC_RESULT (result));
g_strfreev (paths);
g_clear_object (&result);
- secret_service_search_for_paths (test->service, attributes, NULL,
+ secret_service_search_for_paths (test->service, &MOCK_SCHEMA, attributes, NULL,
on_complete_get_result, &result);
egg_test_wait ();
g_assert (G_IS_ASYNC_RESULT (result));