1 /* libsecret - GLib wrapper for Secret Service
3 * Copyright 2011 Collabora Ltd.
4 * Copyright 2012 Red Hat Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2.1 of the licence or (at
9 * your option) any later version.
11 * See the included COPYING file for more information.
13 * Author: Stef Walter <stefw@gnome.org>
16 #if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
17 #error "Only <libsecret/secret.h> can be included directly."
20 #ifndef __SECRET_SERVICE_H__
21 #define __SECRET_SERVICE_H__
25 #include "secret-prompt.h"
26 #include "secret-schema.h"
27 #include "secret-types.h"
28 #include "secret-value.h"
33 SECRET_SERVICE_NONE = 0,
34 SECRET_SERVICE_OPEN_SESSION = 1 << 1,
35 SECRET_SERVICE_LOAD_COLLECTIONS = 1 << 2,
39 SECRET_SEARCH_NONE = 0,
40 SECRET_SEARCH_ALL = 1 << 1,
41 SECRET_SEARCH_UNLOCK = 1 << 2,
42 SECRET_SEARCH_LOAD_SECRETS = 1 << 3,
45 #define SECRET_TYPE_SERVICE (secret_service_get_type ())
46 #define SECRET_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), SECRET_TYPE_SERVICE, SecretService))
47 #define SECRET_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), SECRET_TYPE_SERVICE, SecretServiceClass))
48 #define SECRET_IS_SERVICE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), SECRET_TYPE_SERVICE))
49 #define SECRET_IS_SERVICE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), SECRET_TYPE_SERVICE))
50 #define SECRET_SERVICE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), SECRET_TYPE_SERVICE, SecretServiceClass))
52 typedef struct _SecretCollection SecretCollection;
53 typedef struct _SecretService SecretService;
54 typedef struct _SecretServiceClass SecretServiceClass;
55 typedef struct _SecretServicePrivate SecretServicePrivate;
57 struct _SecretService {
61 SecretServicePrivate *pv;
64 struct _SecretServiceClass {
65 GDBusProxyClass parent_class;
67 GType collection_gtype;
70 GVariant * (* prompt_sync) (SecretService *self,
72 GCancellable *cancellable,
73 const GVariantType *return_type,
76 void (* prompt_async) (SecretService *self,
78 GCancellable *cancellable,
79 GAsyncReadyCallback callback,
82 GVariant * (* prompt_finish) (SecretService *self,
84 const GVariantType *return_type,
91 GType secret_service_get_type (void) G_GNUC_CONST;
93 void secret_service_get (SecretServiceFlags flags,
94 GCancellable *cancellable,
95 GAsyncReadyCallback callback,
98 SecretService * secret_service_get_finish (GAsyncResult *result,
101 SecretService * secret_service_get_sync (SecretServiceFlags flags,
102 GCancellable *cancellable,
105 void secret_service_disconnect (void);
107 void secret_service_new (GType service_gtype,
108 const gchar *service_bus_name,
109 SecretServiceFlags flags,
110 GCancellable *cancellable,
111 GAsyncReadyCallback callback,
114 SecretService * secret_service_new_finish (GAsyncResult *result,
117 SecretService * secret_service_new_sync (GType service_gtype,
118 const gchar *service_bus_name,
119 SecretServiceFlags flags,
120 GCancellable *cancellable,
123 SecretServiceFlags secret_service_get_flags (SecretService *self);
125 const gchar * secret_service_get_session_algorithms (SecretService *self);
127 GList * secret_service_get_collections (SecretService *self);
129 void secret_service_ensure_session (SecretService *self,
130 GCancellable *cancellable,
131 GAsyncReadyCallback callback,
134 gboolean secret_service_ensure_session_finish (SecretService *self,
135 GAsyncResult *result,
138 gboolean secret_service_ensure_session_sync (SecretService *self,
139 GCancellable *cancellable,
142 void secret_service_load_collections (SecretService *self,
143 GCancellable *cancellable,
144 GAsyncReadyCallback callback,
147 gboolean secret_service_load_collections_finish (SecretService *self,
148 GAsyncResult *result,
151 gboolean secret_service_load_collections_sync (SecretService *self,
152 GCancellable *cancellable,
155 GVariant * secret_service_prompt_sync (SecretService *self,
156 SecretPrompt *prompt,
157 GCancellable *cancellable,
158 const GVariantType *return_type,
161 void secret_service_prompt (SecretService *self,
162 SecretPrompt *prompt,
163 GCancellable *cancellable,
164 GAsyncReadyCallback callback,
167 GVariant * secret_service_prompt_finish (SecretService *self,
168 GAsyncResult *result,
169 const GVariantType *return_type,
172 void secret_service_search (SecretService *service,
173 const SecretSchema *schema,
174 GHashTable *attributes,
175 SecretSearchFlags flags,
176 GCancellable *cancellable,
177 GAsyncReadyCallback callback,
180 GList * secret_service_search_finish (SecretService *service,
181 GAsyncResult *result,
184 GList * secret_service_search_sync (SecretService *service,
185 const SecretSchema *schema,
186 GHashTable *attributes,
187 SecretSearchFlags flags,
188 GCancellable *cancellable,
191 void secret_service_lock (SecretService *service,
193 GCancellable *cancellable,
194 GAsyncReadyCallback callback,
197 gint secret_service_lock_finish (SecretService *service,
198 GAsyncResult *result,
202 gint secret_service_lock_sync (SecretService *service,
204 GCancellable *cancellable,
208 void secret_service_unlock (SecretService *service,
210 GCancellable *cancellable,
211 GAsyncReadyCallback callback,
214 gint secret_service_unlock_finish (SecretService *service,
215 GAsyncResult *result,
219 gint secret_service_unlock_sync (SecretService *service,
221 GCancellable *cancellable,
225 void secret_service_store (SecretService *service,
226 const SecretSchema *schema,
227 GHashTable *attributes,
228 const gchar *collection,
231 GCancellable *cancellable,
232 GAsyncReadyCallback callback,
235 gboolean secret_service_store_finish (SecretService *service,
236 GAsyncResult *result,
239 gboolean secret_service_store_sync (SecretService *service,
240 const SecretSchema *schema,
241 GHashTable *attributes,
242 const gchar *collection,
245 GCancellable *cancellable,
248 void secret_service_lookup (SecretService *service,
249 const SecretSchema *schema,
250 GHashTable *attributes,
251 GCancellable *cancellable,
252 GAsyncReadyCallback callback,
255 SecretValue * secret_service_lookup_finish (SecretService *service,
256 GAsyncResult *result,
259 SecretValue * secret_service_lookup_sync (SecretService *service,
260 const SecretSchema *schema,
261 GHashTable *attributes,
262 GCancellable *cancellable,
265 void secret_service_remove (SecretService *service,
266 const SecretSchema *schema,
267 GHashTable *attributes,
268 GCancellable *cancellable,
269 GAsyncReadyCallback callback,
272 gboolean secret_service_remove_finish (SecretService *service,
273 GAsyncResult *result,
276 gboolean secret_service_remove_sync (SecretService *service,
277 const SecretSchema *schema,
278 GHashTable *attributes,
279 GCancellable *cancellable,
282 void secret_service_set_alias (SecretService *service,
284 SecretCollection *collection,
285 GCancellable *cancellable,
286 GAsyncReadyCallback callback,
289 gboolean secret_service_set_alias_finish (SecretService *service,
290 GAsyncResult *result,
293 gboolean secret_service_set_alias_sync (SecretService *service,
295 SecretCollection *collection,
296 GCancellable *cancellable,
301 #endif /* __SECRET_SERVICE_H___ */