peer to peer dbus support added
[platform/upstream/libgsignon-glib.git] / libsignon-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 libsignon-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 <libsignon-glib/signon-auth-session.h>
31 #include <libsignon-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  *
50  * Opaque struct. Use the accessor functions below.
51  */
52 struct _SignonIdentityClass
53 {
54     GObjectClass parent_class;
55 };
56
57 /**
58  * SignonIdentity:
59  *
60  * Opaque struct. Use the accessor functions below.
61  */
62 struct _SignonIdentity
63 {
64     GObject parent_instance;
65     SignonIdentityPrivate *priv;
66 };
67
68 /**
69  * SignonIdentityVoidCb:
70  * @self: the #SignonIdentity.
71  * @error: a #GError if an error occurred, or %NULL otherwise.
72  * @user_data: the user data that was passed when installing this callback.
73  *
74  * Generic callback to be passed to several #SignonIdentity methods.
75  */
76 typedef void (*SignonIdentityVoidCb) (SignonIdentity *self,
77                                       const GError *error,
78                                       gpointer user_data);
79
80 /**
81  * SignonIdentityRemovedCb:
82  *
83  * Callback to be passed to signon_identity_remove().
84  */
85 typedef SignonIdentityVoidCb SignonIdentityRemovedCb;
86 /**
87  * SignonIdentitySignedOutCb:
88  *
89  * Callback to be passed to signon_identity_signout().
90  */
91 typedef SignonIdentityVoidCb SignonIdentitySignedOutCb;
92 /**
93  * SignonIdentityReferenceAddedCb:
94  *
95  * Callback to be passed to signon_identity_add_reference().
96  */
97 typedef SignonIdentityVoidCb SignonIdentityReferenceAddedCb;
98 /**
99  * SignonIdentityReferenceRemovedCb:
100  *
101  * Callback to be passed to signon_identity_remove_reference().
102  */
103 typedef SignonIdentityVoidCb SignonIdentityReferenceRemovedCb;
104
105 GType signon_identity_get_type (void) G_GNUC_CONST;
106
107 SignonIdentity *signon_identity_new_from_db (guint32 id,
108                                              const gchar *application_context);
109 SignonIdentity *signon_identity_new (const gchar *application_context);
110
111 const GError *signon_identity_get_last_error (SignonIdentity *identity);
112
113 SignonAuthSession *signon_identity_create_session(SignonIdentity *self,
114                                                   const gchar *method,
115                                                   GError **error);
116
117 /**
118  * SignonIdentityStoreCredentialsCb:
119  * @self: the #SignonIdentity.
120  * @id: the numeric ID of the identity in the database.
121  * @error: a #GError if an error occurred, or %NULL otherwise.
122  * @user_data: the user data that was passed when installing this callback.
123  *
124  * Callback to be passed to signon_identity_store_credentials_with_args() or
125  * signon_identity_store_credentials_with_info().
126  */
127 typedef void (*SignonIdentityStoreCredentialsCb) (SignonIdentity *self,
128                                                   guint32 id,
129                                                   const GError *error,
130                                                   gpointer user_data);
131
132 void signon_identity_store_credentials_with_info(SignonIdentity *self,
133                                                  const SignonIdentityInfo *info,
134                                                  SignonIdentityStoreCredentialsCb cb,
135                                                  gpointer user_data);
136
137 void signon_identity_store_credentials_with_args(SignonIdentity *self,
138                         const gchar *username,
139                         const gchar *secret,
140                         const gboolean store_secret,
141                         const GHashTable *methods,
142                         const gchar *caption,
143                         const gchar* const *realms,
144                         const SignonSecurityContext *owner,
145                         const SignonSecurityContextList *access_control_list,
146                         SignonIdentityType type,
147                         SignonIdentityStoreCredentialsCb cb,
148                         gpointer user_data);
149
150 /**
151  * SignonIdentityVerifyCb:
152  * @self: the #SignonIdentity.
153  * @valid: whether the secret is valid.
154  * @error: a #GError if an error occurred, or %NULL otherwise.
155  * @user_data: the user data that was passed when installing this callback.
156  *
157  * Callback to be passed to signon_identity_verify_secret().
158  */
159 typedef void (*SignonIdentityVerifyCb) (SignonIdentity *self,
160                                         gboolean valid,
161                                         const GError *error,
162                                         gpointer user_data);
163
164 void signon_identity_verify_secret(SignonIdentity *self,
165                                    const gchar *secret,
166                                    SignonIdentityVerifyCb cb,
167                                    gpointer user_data);
168
169 /**
170  * SignonIdentityInfoCb:
171  * @self: the #SignonIdentity.
172  * @info: the #SignonIdentityInfo for @self.
173  * @error: a #GError if an error occurred, or %NULL otherwise.
174  * @user_data: the user data that was passed when installing this callback.
175  *
176  * Callback to be passed to signon_identity_query_info().
177  */
178 typedef void (*SignonIdentityInfoCb) (SignonIdentity *self,
179                                       const SignonIdentityInfo *info,
180                                       const GError *error,
181                                       gpointer user_data);
182
183 void signon_identity_query_info(SignonIdentity *self,
184                                 SignonIdentityInfoCb cb,
185                                 gpointer user_data);
186
187 void signon_identity_remove(SignonIdentity *self,
188                             SignonIdentityRemovedCb cb,
189                             gpointer user_data);
190
191 void signon_identity_signout(SignonIdentity *self,
192                              SignonIdentitySignedOutCb cb,
193                              gpointer user_data);
194
195 void signon_identity_add_reference(SignonIdentity *self,
196                                    const gchar *reference,
197                                    SignonIdentityReferenceAddedCb cb,
198                                    gpointer user_data);
199
200 void signon_identity_remove_reference(SignonIdentity *self,
201                                       const gchar *reference,
202                                       SignonIdentityReferenceRemovedCb cb,
203                                       gpointer user_data);
204
205 typedef void (*SignonIdentitySessionReadyCb) (SignonAuthSession *self,
206                                               GError *error,
207                                               GDBusConnection *connection,
208                                               const gchar *bus_name,
209                                               const gchar *object_path);
210 void signon_identity_get_auth_session(SignonIdentity *self,
211                                       SignonAuthSession *session,
212                                       const gchar *method,
213                                       SignonIdentitySessionReadyCb cb);
214                                          
215
216 G_END_DECLS
217
218 #endif /* _SIGNON_IDENTITY_H_ */