/* GSecret - GLib wrapper for Secret Service * * Copyright 2011 Collabora Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2 of the licence or (at * your option) any later version. * * See the included COPYING file for more information. */ #include "config.h" #include "gsecret-private.h" #include "gsecret-types.h" #include GQuark gsecret_error_get_quark (void) { static volatile gsize initialized = 0; static GQuark quark = 0; if (g_once_init_enter (&initialized)) { quark = g_quark_from_static_string ("gsecret-error"); g_once_init_leave (&initialized, 1); } return quark; } GSecretParams * _gsecret_params_new (GCancellable *cancellable, GVariant *in) { GSecretParams *params; params = g_slice_new0 (GSecretParams); params->cancellable = cancellable ? g_object_ref (cancellable) : NULL; params->in = g_variant_ref_sink (in); return params; } void _gsecret_params_free (gpointer data) { GSecretParams *params = data; g_clear_object (¶ms->cancellable); if (params->in) g_variant_unref (params->in); if (params->out) g_variant_unref (params->out); g_slice_free (GSecretParams, params); } gchar * _gsecret_util_parent_path (const gchar *path) { const gchar *pos; g_return_val_if_fail (path != NULL, NULL); pos = strrchr (path, '/'); g_return_val_if_fail (pos != NULL, NULL); g_return_val_if_fail (pos != path, NULL); pos--; return g_strndup (path, pos - path); } GVariant * _gsecret_util_variant_for_attributes (GHashTable *attributes) { GHashTableIter iter; GVariantBuilder builder; const gchar *name; const gchar *value; g_return_val_if_fail (attributes != NULL, NULL); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}")); g_hash_table_iter_init (&iter, attributes); while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&value)) g_variant_builder_add (&builder, "{ss}", name, value); return g_variant_builder_end (&builder); }