Release 2.0.2
[profile/ivi/libgsignon-glib.git] / libgsignon-glib / signon-identity.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 libgsignon-glib
5  *
6  * Copyright (C) 2009-2010 Nokia Corporation.
7  * Copyright (C) 2012-2013 Intel Corporation.
8  *
9  * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
10  * Contact: Jussi Laako <jussi.laako@linux.intel.com>
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * version 2.1 as published by the Free Software Foundation.
15  *
16  * This library is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24  * 02110-1301 USA
25  */
26
27 #ifndef _SIGNON_IDENTITY_H_
28 #define _SIGNON_IDENTITY_H_
29
30 #include <libgsignon-glib/signon-auth-session.h>
31 #include <libgsignon-glib/signon-identity-info.h>
32 #include <glib-object.h>
33
34 G_BEGIN_DECLS
35
36 #define SIGNON_TYPE_IDENTITY             (signon_identity_get_type ())
37 #define SIGNON_IDENTITY(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_IDENTITY, SignonIdentity))
38 #define SIGNON_IDENTITY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_IDENTITY, SignonIdentityClass))
39 #define SIGNON_IS_IDENTITY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_IDENTITY))
40 #define SIGNON_IS_IDENTITY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_IDENTITY))
41 #define SIGNON_IDENTITY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_IDENTITY, SignonIdentityClass))
42
43 typedef struct _SignonIdentityClass SignonIdentityClass;
44 typedef struct _SignonIdentityPrivate SignonIdentityPrivate;
45 typedef struct _SignonIdentity SignonIdentity;
46
47 /**
48  * SignonIdentityClass:
49  * @parent_class: reference to a parent class
50  *
51  * Opaque struct. Use the accessor functions below.
52  */
53 struct _SignonIdentityClass
54 {
55     GObjectClass parent_class;
56 };
57
58 /**
59  * SignonIdentity:
60  *
61  * Opaque struct. Use the accessor functions below.
62  */
63 struct _SignonIdentity
64 {
65     GObject parent_instance;
66     SignonIdentityPrivate *priv;
67 };
68
69 /**
70  * SignonIdentityVoidCb:
71  * @self: the #SignonIdentity.
72  * @error: a #GError if an error occurred, or %NULL otherwise.
73  * @user_data: the user data that was passed when installing this callback.
74  *
75  * Generic callback to be passed to several #SignonIdentity methods.
76  */
77 typedef void (*SignonIdentityVoidCb) (SignonIdentity *self,
78                                       const GError *error,
79                                       gpointer user_data);
80
81 /**
82  * SignonIdentityRemovedCb:
83  *
84  * Callback to be passed to signon_identity_remove().
85  */
86 typedef SignonIdentityVoidCb SignonIdentityRemovedCb;
87 /**
88  * SignonIdentitySignedOutCb:
89  *
90  * Callback to be passed to signon_identity_signout().
91  */
92 typedef SignonIdentityVoidCb SignonIdentitySignedOutCb;
93 /**
94  * SignonIdentityReferenceAddedCb:
95  *
96  * Callback to be passed to signon_identity_add_reference().
97  */
98 typedef SignonIdentityVoidCb SignonIdentityReferenceAddedCb;
99 /**
100  * SignonIdentityReferenceRemovedCb:
101  *
102  * Callback to be passed to signon_identity_remove_reference().
103  */
104 typedef SignonIdentityVoidCb SignonIdentityReferenceRemovedCb;
105
106 GType signon_identity_get_type (void) G_GNUC_CONST;
107
108 SignonIdentity *signon_identity_new_from_db (guint32 id,
109                                              const gchar *application_context);
110 SignonIdentity *signon_identity_new (const gchar *application_context);
111
112 const GError *signon_identity_get_last_error (SignonIdentity *identity);
113
114 SignonAuthSession *signon_identity_create_session(SignonIdentity *self,
115                                                   const gchar *method,
116                                                   GError **error);
117
118 /**
119  * SignonIdentityStoreCredentialsCb:
120  * @self: the #SignonIdentity.
121  * @id: the numeric ID of the identity in the database.
122  * @error: a #GError if an error occurred, or %NULL otherwise.
123  * @user_data: the user data that was passed when installing this callback.
124  *
125  * Callback to be passed to signon_identity_store_credentials_with_args() or
126  * signon_identity_store_credentials_with_info().
127  */
128 typedef void (*SignonIdentityStoreCredentialsCb) (SignonIdentity *self,
129                                                   guint32 id,
130                                                   const GError *error,
131                                                   gpointer user_data);
132
133 void signon_identity_store_credentials_with_info(SignonIdentity *self,
134                                                  const SignonIdentityInfo *info,
135                                                  SignonIdentityStoreCredentialsCb cb,
136                                                  gpointer user_data);
137
138 void signon_identity_store_credentials_with_args(SignonIdentity *self,
139                         const gchar *username,
140                         const gchar *secret,
141                         const gboolean store_secret,
142                         const GHashTable *methods,
143                         const gchar *caption,
144                         const gchar* const *realms,
145                         const SignonSecurityContext *owner,
146                         const SignonSecurityContextList *access_control_list,
147                         SignonIdentityType type,
148                         SignonIdentityStoreCredentialsCb cb,
149                         gpointer user_data);
150
151 /**
152  * SignonIdentityVerifyCb:
153  * @self: the #SignonIdentity.
154  * @valid: whether the secret is valid.
155  * @error: a #GError if an error occurred, or %NULL otherwise.
156  * @user_data: the user data that was passed when installing this callback.
157  *
158  * Callback to be passed to signon_identity_verify_secret().
159  */
160 typedef void (*SignonIdentityVerifyCb) (SignonIdentity *self,
161                                         gboolean valid,
162                                         const GError *error,
163                                         gpointer user_data);
164
165 void signon_identity_verify_secret(SignonIdentity *self,
166                                    const gchar *secret,
167                                    SignonIdentityVerifyCb cb,
168                                    gpointer user_data);
169
170 /**
171  * SignonIdentityInfoCb:
172  * @self: the #SignonIdentity.
173  * @info: the #SignonIdentityInfo for @self.
174  * @error: a #GError if an error occurred, or %NULL otherwise.
175  * @user_data: the user data that was passed when installing this callback.
176  *
177  * Callback to be passed to signon_identity_query_info().
178  */
179 typedef void (*SignonIdentityInfoCb) (SignonIdentity *self,
180                                       const SignonIdentityInfo *info,
181                                       const GError *error,
182                                       gpointer user_data);
183
184 void signon_identity_query_info(SignonIdentity *self,
185                                 SignonIdentityInfoCb cb,
186                                 gpointer user_data);
187
188 void signon_identity_remove(SignonIdentity *self,
189                             SignonIdentityRemovedCb cb,
190                             gpointer user_data);
191
192 void signon_identity_signout(SignonIdentity *self,
193                              SignonIdentitySignedOutCb cb,
194                              gpointer user_data);
195
196 void signon_identity_add_reference(SignonIdentity *self,
197                                    const gchar *reference,
198                                    SignonIdentityReferenceAddedCb cb,
199                                    gpointer user_data);
200
201 void signon_identity_remove_reference(SignonIdentity *self,
202                                       const gchar *reference,
203                                       SignonIdentityReferenceRemovedCb cb,
204                                       gpointer user_data);
205
206 /**
207  * SignonIdentitySessionReadyCb:
208  * @self: the #SignonAuthSession.
209  * @error: a #GError if an error occurred, or %NULL otherwise.
210  * @connection: a #GDBusConnection for the session.
211  * @bus_name: a D-Bus bus name for the session.
212  * @object_path: a D-Bus object path for the session.
213  *
214  * Callback to be passed to signon_identity_get_auth_session().
215  */
216 typedef void (*SignonIdentitySessionReadyCb) (SignonAuthSession *self,
217                                               GError *error,
218                                               GDBusConnection *connection,
219                                               const gchar *bus_name,
220                                               const gchar *object_path);
221 void signon_identity_get_auth_session(SignonIdentity *self,
222                                       SignonAuthSession *session,
223                                       const gchar *method,
224                                       SignonIdentitySessionReadyCb cb);
225                                          
226
227 G_END_DECLS
228
229 #endif /* _SIGNON_IDENTITY_H_ */