gsignond first release 0.0.1
[profile/ivi/gsignond.git] / include / gsignond / gsignond-secret-storage.h
1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4  * This file is part of gsignond
5  *
6  * Copyright (C) 2012 Intel Corporation.
7  *
8  * Contact: Imran Zaman <imran.zaman@linux.intel.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23  * 02110-1301 USA
24  */
25
26 #ifndef __GSIGNOND_SECRET_STORAGE_H__
27 #define __GSIGNOND_SECRET_STORAGE_H__
28
29 #include <glib.h>
30 #include <glib-object.h>
31
32 #include <gsignond/gsignond-config.h>
33 #include <gsignond/gsignond-credentials.h>
34
35 G_BEGIN_DECLS
36
37 /*
38  * Type macros.
39  */
40 #define GSIGNOND_TYPE_SECRET_STORAGE   \
41                                        (gsignond_secret_storage_get_type ())
42 #define GSIGNOND_SECRET_STORAGE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
43                                            GSIGNOND_TYPE_SECRET_STORAGE, \
44                                            GSignondSecretStorage))
45 #define GSIGNOND_IS_SECRET_STORAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
46                                            GSIGNOND_TYPE_SECRET_STORAGE))
47 #define GSIGNOND_SECRET_STORAGE_CLASS(klass) \
48                                             (G_TYPE_CHECK_CLASS_CAST ((klass), \
49                                              GSIGNOND_TYPE_SECRET_STORAGE, \
50                                              GSignondSecretStorageClass))
51 #define GSIGNOND_IS_SECRET_STORAGE_CLASS(klass) \
52                                             (G_TYPE_CHECK_CLASS_TYPE ((klass), \
53                                              GSIGNOND_TYPE_SECRET_STORAGE))
54 #define GSIGNOND_SECRET_STORAGE_GET_CLASS(obj) \
55                                             (G_TYPE_INSTANCE_GET_CLASS ((obj), \
56                                              GSIGNOND_TYPE_SECRET_STORAGE, \
57                                              GSignondSecretStorageClass))
58
59 typedef struct _GSignondSecretStoragePrivate GSignondSecretStoragePrivate;
60
61 typedef struct {
62     GObject parent_instance;
63
64     /*< private >*/
65     GSignondConfig *config;
66     GSignondSecretStoragePrivate *priv;
67 } GSignondSecretStorage;
68
69 typedef struct {
70     GObjectClass parent_class;
71
72     /**
73      * open_db:
74      *
75      * See #gsignond_secret_storage_open_db.
76      */
77     gboolean
78     (*open_db) (GSignondSecretStorage *self);
79
80     /**
81      * close_db:
82      *
83      * See #gsignond_secret_storage_close_db.
84      */
85     gboolean
86     (*close_db) (GSignondSecretStorage *self);
87
88     /**
89      * clear_db:
90      *
91      * See #gsignond_secret_storage_clear_db.
92      */
93     gboolean
94     (*clear_db) (GSignondSecretStorage *self);
95
96     /**
97      * is_open_db:
98      *
99      * See #gsignond_secret_storage_is_open_db.
100      */
101     gboolean
102     (*is_open_db) (GSignondSecretStorage *self);
103
104     /**
105      * load_credentials:
106      *
107      * See #gsignond_secret_storage_load_credentials.
108      */
109     GSignondCredentials*
110     (*load_credentials) (
111             GSignondSecretStorage *self,
112             const guint32 id);
113
114     /**
115      * update_credentials:
116      *
117      * See #gsignond_secret_storage_update_credentials.
118      */
119     gboolean
120     (*update_credentials) (
121             GSignondSecretStorage *self,
122             GSignondCredentials* creds);
123
124     /**
125      * remove_credentials:
126      *
127      * See #gsignond_secret_storage_remove_credentials.
128      */
129     gboolean
130     (*remove_credentials) (
131             GSignondSecretStorage *self,
132             const guint32 id);
133
134     /**
135      * check_credentials:
136      *
137      * See #gsignond_secret_storage_check_credentials.
138      */
139     gboolean
140     (*check_credentials) (
141             GSignondSecretStorage *self,
142             GSignondCredentials* creds);
143
144     /**
145      * load_data:
146      *
147      * See #gsignond_secret_storage_load_data.
148      *
149      */
150     GHashTable*
151     (*load_data) (
152             GSignondSecretStorage *self,
153             const guint32 id,
154             const guint32 method);
155
156     /**
157      * update_data:
158      *
159      * See #gsignond_secret_storage_update_data.
160      */
161     gboolean
162     (*update_data) (
163             GSignondSecretStorage *self,
164             const guint32 id,
165             const guint32 method,
166             GHashTable *data);
167
168     /**
169      * remove_data:
170      *
171      * See #gsignond_secret_storage_remove_data.
172      */
173     gboolean
174     (*remove_data) (
175             GSignondSecretStorage *self,
176             const guint32 id,
177             const guint32 method);
178
179 } GSignondSecretStorageClass;
180
181 /* used by GSIGNOND_TYPE_SECRET_STORAGE */
182 GType
183 gsignond_secret_storage_get_type (void);
184
185 gboolean
186 gsignond_secret_storage_open_db (GSignondSecretStorage *self);
187
188 gboolean
189 gsignond_secret_storage_close_db (GSignondSecretStorage *self);
190
191 gboolean
192 gsignond_secret_storage_clear_db (GSignondSecretStorage *self);
193
194 gboolean
195 gsignond_secret_storage_is_open_db (GSignondSecretStorage *self);
196
197 GSignondCredentials*
198 gsignond_secret_storage_load_credentials (
199         GSignondSecretStorage *self,
200         const guint32 id);
201
202 gboolean
203 gsignond_secret_storage_update_credentials (
204         GSignondSecretStorage *self,
205         GSignondCredentials* creds);
206
207 gboolean
208 gsignond_secret_storage_remove_credentials (
209         GSignondSecretStorage *self,
210         const guint32 id);
211
212 gboolean
213 gsignond_secret_storage_check_credentials (
214         GSignondSecretStorage *self,
215         GSignondCredentials* creds);
216
217 GHashTable*
218 gsignond_secret_storage_load_data (
219         GSignondSecretStorage *self,
220         const guint32 id,
221         const guint32 method);
222
223 gboolean
224 gsignond_secret_storage_update_data (
225         GSignondSecretStorage *self,
226         const guint32 id,
227         const guint32 method,
228         GHashTable *data);
229
230 gboolean
231 gsignond_secret_storage_remove_data (
232         GSignondSecretStorage *self,
233         const guint32 id,
234         const guint32 method);
235
236 void
237 gsignond_secret_storage_set_last_error (GSignondSecretStorage *self,
238                                         GError *error);
239
240 const GError*
241 gsignond_secret_storage_get_last_error (GSignondSecretStorage *self);
242
243 void
244 gsignond_secret_storage_clear_last_error (GSignondSecretStorage *self);
245
246
247 G_END_DECLS
248
249 #endif /* __GSIGNOND_SECRET_STORAGE_H__ */