summaryrefslogtreecommitdiff
path: root/libsoup/soup-password-manager.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2009-08-12 10:23:39 -0400
committerDan Winship <danw@gnome.org>2009-08-12 10:24:09 -0400
commitf81520bfd3a971f82c2b69aa9977edc1a33b20aa (patch)
treed4982013c96d9cc4507a9444e09665a866835e9d /libsoup/soup-password-manager.c
parent6060232ca31b0315901d68c1be1526e27513e2a4 (diff)
downloadlibsoup-f81520bfd3a971f82c2b69aa9977edc1a33b20aa.tar.gz
Add SoupPasswordManager and SoupPasswordManagerGNOME
SoupPasswordManager (and some new SoupAuth APIs) provide an interface for saving passwords, and SoupPasswordManagerGNOME provides an implementation of that interface using gnome-keyring.
Diffstat (limited to 'libsoup/soup-password-manager.c')
-rw-r--r--libsoup/soup-password-manager.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/libsoup/soup-password-manager.c b/libsoup/soup-password-manager.c
new file mode 100644
index 00000000..5654dc3e
--- /dev/null
+++ b/libsoup/soup-password-manager.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * soup-password-manager.c: HTTP auth password manager interface
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soup-password-manager.h"
+#include "soup-session-feature.h"
+
+GType
+soup_password_manager_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ GType g_define_type_id =
+ g_type_register_static_simple (G_TYPE_INTERFACE,
+ g_intern_static_string ("SoupPasswordManager"),
+ sizeof (SoupPasswordManagerInterface),
+ (GClassInitFunc)NULL,
+ 0,
+ (GInstanceInitFunc)NULL,
+ (GTypeFlags) 0);
+ g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
+ g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+ return g_define_type_id__volatile;
+}
+
+/**
+ * soup_password_manager_get_passwords_async:
+ * @password_manager: the #SoupPasswordManager
+ * @msg: the #SoupMessage being authenticated
+ * @auth: the #SoupAuth being authenticated
+ * @retrying: whether or not this is a re-attempt to authenticate
+ * @async_context: the #GMainContext to invoke @callback in
+ * @cancellable: a #GCancellable, or %NULL
+ * @callback: callback to invoke after fetching passwords
+ * @user_data: data for @callback
+ *
+ * Asynchronously attempts to look up saved passwords for @auth/@msg
+ * and then calls @callback after updating @auth with the information.
+ * Also registers @auth with @password_manager so that if the caller
+ * calls soup_auth_save_password() on it, the password will be saved.
+ *
+ * #SoupPasswordManager does not actually use the @retrying flag itself;
+ * it just passes its value on to @callback.
+ *
+ * If @cancellable is cancelled, @callback will still be invoked.
+ *
+ * Since: 2.28
+ **/
+void
+soup_password_manager_get_passwords_async (SoupPasswordManager *password_manager,
+ SoupMessage *msg,
+ SoupAuth *auth,
+ gboolean retrying,
+ GMainContext *async_context,
+ GCancellable *cancellable,
+ SoupPasswordManagerCallback callback,
+ gpointer user_data)
+{
+ SOUP_PASSWORD_MANAGER_GET_CLASS (password_manager)->
+ get_passwords_async (password_manager, msg, auth, retrying,
+ async_context, cancellable,
+ callback, user_data);
+}
+
+/**
+ * soup_password_manager_get_passwords_sync:
+ * @password_manager: the #SoupPasswordManager
+ * @msg: the #SoupMessage being authenticated
+ * @auth: the #SoupAuth being authenticated
+ * @cancellable: a #GCancellable, or %NULL
+ *
+ * Synchronously attempts to look up saved passwords for @auth/@msg
+ * and updates @auth with the information. Also registers @auth with
+ * @password_manager so that if the caller calls
+ * soup_auth_save_password() on it, the password will be saved.
+ *
+ * Since: 2.28
+ **/
+void
+soup_password_manager_get_passwords_sync (SoupPasswordManager *password_manager,
+ SoupMessage *msg,
+ SoupAuth *auth,
+ GCancellable *cancellable)
+{
+ SOUP_PASSWORD_MANAGER_GET_CLASS (password_manager)->
+ get_passwords_sync (password_manager, msg, auth, cancellable);
+}