Identity: add constructors compatible with libsignon-glib
[platform/upstream/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 SignonIdentity *signon_identity_new ();
110
111 SignonIdentity *signon_identity_new_with_context_from_db (guint32 id,
112                                                           const gchar *application_context);
113 SignonIdentity *signon_identity_new_with_context (const gchar *application_context);
114
115 const GError *signon_identity_get_last_error (SignonIdentity *identity);
116
117 SignonAuthSession *signon_identity_create_session(SignonIdentity *self,
118                                                   const gchar *method,
119                                                   GError **error);
120
121 /**
122  * SignonIdentityStoreCredentialsCb:
123  * @self: the #SignonIdentity.
124  * @id: the numeric ID of the identity in the database.
125  * @error: a #GError if an error occurred, or %NULL otherwise.
126  * @user_data: the user data that was passed when installing this callback.
127  *
128  * Callback to be passed to signon_identity_store_credentials_with_args() or
129  * signon_identity_store_credentials_with_info().
130  */
131 typedef void (*SignonIdentityStoreCredentialsCb) (SignonIdentity *self,
132                                                   guint32 id,
133                                                   const GError *error,
134                                                   gpointer user_data);
135
136 void signon_identity_store_credentials_with_info(SignonIdentity *self,
137                                                  const SignonIdentityInfo *info,
138                                                  SignonIdentityStoreCredentialsCb cb,
139                                                  gpointer user_data);
140
141 void signon_identity_store_credentials_with_args(SignonIdentity *self,
142                         const gchar *username,
143                         const gchar *secret,
144                         const gboolean store_secret,
145                         const GHashTable *methods,
146                         const gchar *caption,
147                         const gchar* const *realms,
148                         const SignonSecurityContext *owner,
149                         const SignonSecurityContextList *access_control_list,
150                         SignonIdentityType type,
151                         SignonIdentityStoreCredentialsCb cb,
152                         gpointer user_data);
153
154 /**
155  * SignonIdentityVerifyCb:
156  * @self: the #SignonIdentity.
157  * @valid: whether the secret is valid.
158  * @error: a #GError if an error occurred, or %NULL otherwise.
159  * @user_data: the user data that was passed when installing this callback.
160  *
161  * Callback to be passed to signon_identity_verify_secret().
162  */
163 typedef void (*SignonIdentityVerifyCb) (SignonIdentity *self,
164                                         gboolean valid,
165                                         const GError *error,
166                                         gpointer user_data);
167
168 void signon_identity_verify_secret(SignonIdentity *self,
169                                    const gchar *secret,
170                                    SignonIdentityVerifyCb cb,
171                                    gpointer user_data);
172
173 /**
174  * SignonIdentityInfoCb:
175  * @self: the #SignonIdentity.
176  * @info: the #SignonIdentityInfo for @self.
177  * @error: a #GError if an error occurred, or %NULL otherwise.
178  * @user_data: the user data that was passed when installing this callback.
179  *
180  * Callback to be passed to signon_identity_query_info().
181  */
182 typedef void (*SignonIdentityInfoCb) (SignonIdentity *self,
183                                       const SignonIdentityInfo *info,
184                                       const GError *error,
185                                       gpointer user_data);
186
187 void signon_identity_query_info(SignonIdentity *self,
188                                 SignonIdentityInfoCb cb,
189                                 gpointer user_data);
190
191 void signon_identity_remove(SignonIdentity *self,
192                             SignonIdentityRemovedCb cb,
193                             gpointer user_data);
194
195 void signon_identity_signout(SignonIdentity *self,
196                              SignonIdentitySignedOutCb cb,
197                              gpointer user_data);
198
199 void signon_identity_add_reference(SignonIdentity *self,
200                                    const gchar *reference,
201                                    SignonIdentityReferenceAddedCb cb,
202                                    gpointer user_data);
203
204 void signon_identity_remove_reference(SignonIdentity *self,
205                                       const gchar *reference,
206                                       SignonIdentityReferenceRemovedCb cb,
207                                       gpointer user_data);
208
209 /**
210  * SignonIdentitySessionReadyCb:
211  * @self: the #SignonAuthSession.
212  * @error: a #GError if an error occurred, or %NULL otherwise.
213  * @connection: a #GDBusConnection for the session.
214  * @bus_name: a D-Bus bus name for the session.
215  * @object_path: a D-Bus object path for the session.
216  *
217  * Callback to be passed to signon_identity_get_auth_session().
218  */
219 typedef void (*SignonIdentitySessionReadyCb) (SignonAuthSession *self,
220                                               GError *error,
221                                               GDBusConnection *connection,
222                                               const gchar *bus_name,
223                                               const gchar *object_path);
224 void signon_identity_get_auth_session(SignonIdentity *self,
225                                       SignonAuthSession *session,
226                                       const gchar *method,
227                                       SignonIdentitySessionReadyCb cb);
228                                          
229
230 G_END_DECLS
231
232 #endif /* _SIGNON_IDENTITY_H_ */