Refresh upstream 2.1.0 release
[profile/ivi/libgsignon-glib.git] / libgsignon-glib / signon-auth-session.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 Canonical Ltd.
8  * Copyright (C) 2012-2014 Intel Corporation.
9  *
10  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
11  * Contact: Jussi Laako <jussi.laako@linux.intel.com>
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public License
15  * version 2.1 as published by the Free Software Foundation.
16  *
17  * This library is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25  * 02110-1301 USA
26  */
27
28 #ifndef SIGNONAUTHSESSION_H_
29 #define SIGNONAUTHSESSION_H_
30
31 #include <gio/gio.h>
32 #include <glib-object.h>
33 #include <libgsignon-glib/signon-types.h>
34
35 G_BEGIN_DECLS
36
37 /*
38  * Useful session data keys
39  */
40 /**
41  * SIGNON_SESSION_DATA_USERNAME:
42  *
43  * Username.
44  */
45 #define SIGNON_SESSION_DATA_USERNAME      "UserName"
46 /**
47  * SIGNON_SESSION_DATA_SECRET:
48  *
49  * Secret.
50  */
51 #define SIGNON_SESSION_DATA_SECRET        "Secret"
52 /**
53  * SIGNON_SESSION_DATA_REALM:
54  *
55  * Realm.
56  */
57 #define SIGNON_SESSION_DATA_REALM         "Realm"
58 /**
59  * SIGNON_SESSION_DATA_PROXY:
60  *
61  * Proxy.
62  */
63 #define SIGNON_SESSION_DATA_PROXY         "NetworkProxy"
64
65 /**
66  * SignonSessionDataUiPolicy:
67  * @SIGNON_POLICY_DEFAULT: The plugin can decide when to show UI.
68  * @SIGNON_POLICY_REQUEST_PASSWORD: Force the user to enter the password.
69  * @SIGNON_POLICY_NO_USER_INTERACTION: No UI elements will be shown to the user.
70  * @SIGNON_POLICY_VALIDATION: UI elements can be shown to the user only when
71  * CAPTCHA-like security measures are required.
72  *
73  * UI policy for the signon process, passed to the UI plugin.
74  */
75 typedef enum {
76     SIGNON_POLICY_DEFAULT = 0,
77     SIGNON_POLICY_REQUEST_PASSWORD,
78     SIGNON_POLICY_NO_USER_INTERACTION,
79     SIGNON_POLICY_VALIDATION,
80 } SignonSessionDataUiPolicy;
81 /**
82  * SIGNON_SESSION_DATA_UI_POLICY:
83  * @see_also: #SignonSessionDataUiPolicy
84  *
85  * Policy for the signon process.
86  */
87 #define SIGNON_SESSION_DATA_UI_POLICY     "UiPolicy"
88 /**
89  * SIGNON_SESSION_DATA_CAPTION:
90  *
91  * Caption for the UI dialog.
92  */
93 #define SIGNON_SESSION_DATA_CAPTION       "Caption"
94 /**
95  * SIGNON_SESSION_DATA_TIMEOUT:
96  *
97  * Network timeout, in milliseconds (uint32).
98  */
99 #define SIGNON_SESSION_DATA_TIMEOUT       "NetworkTimeout"
100 /**
101  * SIGNON_SESSION_DATA_WINDOW_ID:
102  *
103  * Platform-specific window id (for dialog transiency) - uint32.
104  */
105 #define SIGNON_SESSION_DATA_WINDOW_ID     "WindowId"
106 /**
107  * SIGNON_SESSION_DATA_RENEW_TOKEN:
108  *
109  * Requests the signon plugin to obtain a new token (boolean).
110  */
111 #define SIGNON_SESSION_DATA_RENEW_TOKEN   "RenewToken"
112
113
114 #define SIGNON_TYPE_AUTH_SESSION                 (signon_auth_session_get_type ())
115 #define SIGNON_AUTH_SESSION(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSession))
116 #define SIGNON_AUTH_SESSION_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass))
117 #define SIGNON_IS_AUTH_SESSION(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_AUTH_SESSION))
118 #define SIGNON_IS_AUTH_SESSION_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_AUTH_SESSION))
119 #define SIGNON_AUTH_SESSION_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass))
120
121 typedef struct _SignonAuthSessionPrivate SignonAuthSessionPrivate;
122 typedef struct _SignonAuthSessionClass   SignonAuthSessionClass;
123
124 /**
125  * SignonAuthSession:
126  *
127  * Opaque struct. Use the accessor functions below.
128  */
129 struct _SignonAuthSession {
130     GObject parent;
131
132     SignonAuthSessionPrivate *priv;
133 };
134
135 /**
136  * SignonAuthSessionClass:
137  * @parent: reference to the parent class
138  *
139  * Opaque struct. Use the accessor functions below.
140  */
141 struct _SignonAuthSessionClass {
142     GObjectClass parent;
143 };
144
145 GType signon_auth_session_get_type (void) G_GNUC_CONST;
146
147 SignonAuthSession *signon_auth_session_new(gint id,
148                                            const gchar *method_name,
149                                            GError **err);
150
151 SignonAuthSession *
152 signon_auth_session_new_for_identity(SignonIdentity *identity,
153                                      const gchar *method_name,
154                                      GError **err);
155
156 const gchar *signon_auth_session_get_method (SignonAuthSession *self);
157
158 typedef void (*SignonAuthSessionQueryAvailableMechanismsCb) (
159                     SignonAuthSession* self,
160                     gchar **mechanisms,
161                     const GError *error,
162                     gpointer user_data);
163
164 G_GNUC_DEPRECATED
165 typedef SignonAuthSessionQueryAvailableMechanismsCb
166     SignonAuthSessionQueryAvailableMethodsCb;
167
168 void signon_auth_session_query_available_mechanisms(SignonAuthSession *self,
169                                                     const gchar **wanted_mechanisms,
170                                                     SignonAuthSessionQueryAvailableMechanismsCb cb,
171                                                     gpointer user_data);
172
173 #ifndef SIGNON_DISABLE_DEPRECATED
174 typedef void (*SignonAuthSessionProcessCb) (SignonAuthSession *self,
175                                             GHashTable *session_data,
176                                             const GError *error,
177                                             gpointer user_data);
178 SIGNON_DEPRECATED_FOR(signon_auth_session_process_async)
179 void signon_auth_session_process(SignonAuthSession *self,
180                                 GHashTable *session_data,
181                                 const gchar *mechanism,
182                                 SignonAuthSessionProcessCb cb,
183                                 gpointer user_data);
184 #endif
185 void signon_auth_session_process_async (SignonAuthSession *self,
186                                         GVariant *session_data,
187                                         const gchar *mechanism,
188                                         GCancellable *cancellable,
189                                         GAsyncReadyCallback callback,
190                                         gpointer user_data);
191 GVariant *signon_auth_session_process_finish (SignonAuthSession *self,
192                                               GAsyncResult *res,
193                                               GError **error);
194
195 void signon_auth_session_cancel(SignonAuthSession *self);
196
197 G_END_DECLS
198
199 #endif //SIGNONAUTHSESSIONIMPL_H_