Git init
[profile/ivi/libsoup2.4.git] / libsoup / soup-password-manager.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * soup-password-manager.c: HTTP auth password manager interface
4  *
5  * Copyright (C) 2008 Red Hat, Inc.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #define LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY
13
14 #include "soup-password-manager.h"
15 #include "soup-session-feature.h"
16
17 GType
18 soup_password_manager_get_type (void)
19 {
20   static volatile gsize g_define_type_id__volatile = 0;
21   if (g_once_init_enter (&g_define_type_id__volatile))
22     {
23       GType g_define_type_id =
24         g_type_register_static_simple (G_TYPE_INTERFACE,
25                                        g_intern_static_string ("SoupPasswordManager"),
26                                        sizeof (SoupPasswordManagerInterface),
27                                        (GClassInitFunc)NULL,
28                                        0,
29                                        (GInstanceInitFunc)NULL,
30                                        (GTypeFlags) 0);
31       g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
32       g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
33       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
34     }
35   return g_define_type_id__volatile;
36 }
37
38 /**
39  * soup_password_manager_get_passwords_async:
40  * @password_manager: the #SoupPasswordManager
41  * @msg: the #SoupMessage being authenticated
42  * @auth: the #SoupAuth being authenticated
43  * @retrying: whether or not this is a re-attempt to authenticate
44  * @async_context: (allow-none): the #GMainContext to invoke @callback in
45  * @cancellable: a #GCancellable, or %NULL
46  * @callback: callback to invoke after fetching passwords
47  * @user_data: data for @callback
48  *
49  * Asynchronously attempts to look up saved passwords for @auth/@msg
50  * and then calls @callback after updating @auth with the information.
51  * Also registers @auth with @password_manager so that if the caller
52  * calls soup_auth_save_password() on it, the password will be saved.
53  *
54  * #SoupPasswordManager does not actually use the @retrying flag itself;
55  * it just passes its value on to @callback.
56  * 
57  * If @cancellable is cancelled, @callback will still be invoked.
58  *
59  * Since: 2.28
60  **/
61 void
62 soup_password_manager_get_passwords_async (SoupPasswordManager  *password_manager,
63                                            SoupMessage          *msg,
64                                            SoupAuth             *auth,
65                                            gboolean              retrying,
66                                            GMainContext         *async_context,
67                                            GCancellable         *cancellable,
68                                            SoupPasswordManagerCallback callback,
69                                            gpointer              user_data)
70 {
71         SOUP_PASSWORD_MANAGER_GET_CLASS (password_manager)->
72                 get_passwords_async (password_manager, msg, auth, retrying,
73                                      async_context, cancellable,
74                                      callback, user_data);
75 }
76
77 /**
78  * soup_password_manager_get_passwords_sync:
79  * @password_manager: the #SoupPasswordManager
80  * @msg: the #SoupMessage being authenticated
81  * @auth: the #SoupAuth being authenticated
82  * @cancellable: a #GCancellable, or %NULL
83  *
84  * Synchronously attempts to look up saved passwords for @auth/@msg
85  * and updates @auth with the information. Also registers @auth with
86  * @password_manager so that if the caller calls
87  * soup_auth_save_password() on it, the password will be saved.
88  *
89  * Since: 2.28
90  **/
91 void
92 soup_password_manager_get_passwords_sync (SoupPasswordManager  *password_manager,
93                                           SoupMessage          *msg,
94                                           SoupAuth             *auth,
95                                           GCancellable         *cancellable)
96 {
97         SOUP_PASSWORD_MANAGER_GET_CLASS (password_manager)->
98                 get_passwords_sync (password_manager, msg, auth, cancellable);
99 }