1 /* libsecret - GLib wrapper for Secret Service
2  *
3  * Copyright 2011 Collabora Ltd.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2.1 of the licence or (at
8  * your option) any later version.
9  *
10  * See the included COPYING file for more information.
11  *
12  * Author: Stef Walter <stefw@gnome.org>
13  */
14 
15 #ifndef __SECRET_PRIVATE_H__
16 #define __SECRET_PRIVATE_H__
17 
18 #include <gio/gio.h>
19 
20 #include "secret-item.h"
21 #include "secret-service.h"
22 #include "secret-value.h"
23 
24 G_BEGIN_DECLS
25 
26 typedef struct {
27 	GAsyncResult *result;
28 	GMainContext *context;
29 	GMainLoop *loop;
30 } SecretSync;
31 
32 typedef struct _SecretSession SecretSession;
33 
34 #define              SECRET_ALIAS_PREFIX                      "/org/freedesktop/secrets/aliases/"
35 
36 #define              SECRET_SERVICE_PATH                      "/org/freedesktop/secrets"
37 
38 #define              SECRET_SERVICE_BUS_NAME                  "org.freedesktop.secrets"
39 
40 #define              SECRET_ITEM_INTERFACE                    "org.freedesktop.Secret.Item"
41 #define              SECRET_COLLECTION_INTERFACE              "org.freedesktop.Secret.Collection"
42 #define              SECRET_PROMPT_INTERFACE                  "org.freedesktop.Secret.Prompt"
43 #define              SECRET_SERVICE_INTERFACE                 "org.freedesktop.Secret.Service"
44 
45 #define              SECRET_SIGNAL_COLLECTION_CREATED "CollectionCreated"
46 #define              SECRET_SIGNAL_COLLECTION_CHANGED "CollectionChanged"
47 #define              SECRET_SIGNAL_COLLECTION_DELETED "CollectionDeleted"
48 #define              SECRET_SIGNAL_ITEM_CREATED       "ItemCreated"
49 #define              SECRET_SIGNAL_ITEM_CHANGED       "ItemChanged"
50 #define              SECRET_SIGNAL_ITEM_DELETED       "ItemDeleted"
51 #define              SECRET_PROMPT_SIGNAL_COMPLETED   "Completed"
52 
53 #define              SECRET_PROPERTIES_INTERFACE              "org.freedesktop.DBus.Properties"
54 
55 SecretSync *         _secret_sync_new                         (void);
56 
57 void                 _secret_sync_free                        (gpointer data);
58 
59 G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSync, _secret_sync_free)
60 
61 void                 _secret_sync_on_result                   (GObject *source,
62                                                                GAsyncResult *result,
63                                                                gpointer user_data);
64 
65 SecretPrompt *       _secret_prompt_instance                  (SecretService *service,
66                                                                const gchar *prompt_path);
67 
68 void                 _secret_util_strip_remote_error          (GError **error);
69 
70 gboolean             _secret_util_propagate_error             (GSimpleAsyncResult *async,
71                                                                GError **error);
72 
73 gchar *              _secret_util_parent_path                 (const gchar *path);
74 
75 gboolean             _secret_util_empty_path                  (const gchar *path);
76 
77 gchar *              _secret_util_collection_to_path          (const gchar *collection);
78 
79 gint                 _secret_util_array_index_of              (GVariant *array,
80                                                                GVariant *value);
81 
82 GType                _secret_list_get_type                    (void) G_GNUC_CONST;
83 
84 GVariant *           _secret_attributes_to_variant            (GHashTable *attributes,
85                                                                const gchar *schema_name);
86 
87 GHashTable *         _secret_attributes_for_variant           (GVariant *variant);
88 
89 GHashTable *         _secret_attributes_copy                  (GHashTable *attributes);
90 
91 gboolean             _secret_attributes_validate              (const SecretSchema *schema,
92                                                                GHashTable *attributes,
93                                                                const gchar *pretty_function,
94                                                                gboolean matching);
95 
96 GVariant *           _secret_util_variant_for_properties      (GHashTable *properties);
97 
98 void                 _secret_util_get_properties              (GDBusProxy *proxy,
99                                                                gpointer result_tag,
100                                                                GCancellable *cancellable,
101                                                                GAsyncReadyCallback callback,
102                                                                gpointer user_data);
103 
104 gboolean             _secret_util_get_properties_finish       (GDBusProxy *proxy,
105                                                                gpointer result_tag,
106                                                                GAsyncResult *result,
107                                                                GError **error);
108 
109 void                 _secret_util_set_property                (GDBusProxy *proxy,
110                                                                const gchar *property,
111                                                                GVariant *value,
112                                                                gpointer result_tag,
113                                                                GCancellable *cancellable,
114                                                                GAsyncReadyCallback callback,
115                                                                gpointer user_data);
116 
117 gboolean             _secret_util_set_property_finish         (GDBusProxy *proxy,
118                                                                gpointer result_tag,
119                                                                GAsyncResult *result,
120                                                                GError **error);
121 
122 gboolean             _secret_util_set_property_sync           (GDBusProxy *proxy,
123                                                                const gchar *property,
124                                                                GVariant *value,
125                                                                GCancellable *cancellable,
126                                                                GError **error);
127 
128 gboolean             _secret_util_have_cached_properties      (GDBusProxy *proxy);
129 
130 SecretSession *      _secret_service_get_session              (SecretService *self);
131 
132 void                 _secret_service_take_session             (SecretService *self,
133                                                                SecretSession *session);
134 
135 void                 _secret_service_delete_path              (SecretService *self,
136                                                                const gchar *object_path,
137                                                                gboolean is_an_item,
138                                                                GCancellable *cancellable,
139                                                                GAsyncReadyCallback callback,
140                                                                gpointer user_data);
141 
142 gboolean             _secret_service_delete_path_finish       (SecretService *self,
143                                                                GAsyncResult *result,
144                                                                GError **error);
145 
146 void                 _secret_service_search_for_paths_variant (SecretService *self,
147                                                                GVariant *attributes,
148                                                                GCancellable *cancellable,
149                                                                GAsyncReadyCallback callback,
150                                                                gpointer user_data);
151 
152 SecretItem *         _secret_service_find_item_instance       (SecretService *self,
153                                                                const gchar *item_path);
154 
155 SecretCollection *   _secret_service_find_collection_instance (SecretService *self,
156                                                                const gchar *collection_path);
157 
158 SecretValue *        _secret_service_decode_get_secrets_first (SecretService *self,
159                                                                GVariant *out);
160 
161 GHashTable *         _secret_service_decode_get_secrets_all   (SecretService *self,
162                                                                GVariant *out);
163 
164 void                 _secret_service_xlock_paths_async        (SecretService *self,
165                                                                const gchar *method,
166                                                                const gchar **paths,
167                                                                GCancellable *cancellable,
168                                                                GAsyncReadyCallback callback,
169                                                                gpointer user_data);
170 
171 gint                 _secret_service_xlock_paths_finish       (SecretService *self,
172                                                                GAsyncResult *result,
173                                                                gchar ***xlocked,
174                                                                GError **error);
175 
176 void                 _secret_service_create_item_dbus_path_finish_raw  (GAsyncResult *result,
177                                                                         GError **error);
178 
179 GHashTable *         _secret_collection_properties_new        (const gchar *label);
180 
181 SecretItem *         _secret_collection_find_item_instance    (SecretCollection *self,
182                                                                const gchar *item_path);
183 
184 gchar *              _secret_value_unref_to_password          (SecretValue *value);
185 
186 gchar *              _secret_value_unref_to_string            (SecretValue *value);
187 
188 void                 _secret_session_free                     (gpointer data);
189 
190 G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSession, _secret_session_free)
191 
192 const gchar *        _secret_session_get_algorithms           (SecretSession *session);
193 
194 const gchar *        _secret_session_get_path                 (SecretSession *session);
195 
196 void                 _secret_session_open                     (SecretService *service,
197                                                                GCancellable *cancellable,
198                                                                GAsyncReadyCallback callback,
199                                                                gpointer user_data);
200 
201 gboolean             _secret_session_open_finish              (GAsyncResult *result,
202                                                                GError **error);
203 
204 GVariant *           _secret_session_encode_secret            (SecretSession *session,
205                                                                SecretValue *value);
206 
207 SecretValue *        _secret_session_decode_secret            (SecretSession *session,
208                                                                GVariant *encoded);
209 
210 void                 _secret_item_set_cached_secret           (SecretItem *self,
211                                                                SecretValue *value);
212 
213 const SecretSchema * _secret_schema_ref_if_nonstatic          (const SecretSchema *schema);
214 
215 void                 _secret_schema_unref_if_nonstatic        (const SecretSchema *schema);
216 
217 G_END_DECLS
218 
219 #endif /* __SECRET_PRIVATE_H___ */
220