[epiphany] lib: Move auth data query/store methods from ephy-profile-utils to a new file



commit 2499031072e275e68ad8dc1cb9bd0a53397a5e5a
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Sat Mar 9 13:57:09 2013 +0100

    lib: Move auth data query/store methods from ephy-profile-utils to a new file
    
    Move to ephy-form-auth-data and renamed accordingly.

 embed/ephy-embed-single.c   |    2 +-
 embed/ephy-web-view.c       |   38 ++++----
 lib/Makefile.am             |    2 +
 lib/ephy-form-auth-data.c   |  251 +++++++++++++++++++++++++++++++++++++++++++
 lib/ephy-form-auth-data.h   |   59 ++++++++++
 lib/ephy-profile-migrator.c |   29 +++---
 lib/ephy-profile-utils.c    |  232 ---------------------------------------
 lib/ephy-profile-utils.h    |   33 ------
 po/POTFILES.in              |    2 +-
 9 files changed, 348 insertions(+), 300 deletions(-)
---
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index c5ac9b8..0c01a73 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -27,8 +27,8 @@
 #include "ephy-embed-shell.h"
 #include "ephy-embed-type-builtins.h"
 #include "ephy-file-helpers.h"
+#include "ephy-form-auth-data.h"
 #include "ephy-prefs.h"
-#include "ephy-profile-utils.h"
 #include "ephy-request-about.h"
 #include "ephy-settings.h"
 #include "ephy-signal-accumulator.h"
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index c5dc5a9..d862333 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -36,10 +36,10 @@
 #include "ephy-favicon-helpers.h"
 #include "ephy-file-helpers.h"
 #include "ephy-file-monitor.h"
+#include "ephy-form-auth-data.h"
 #include "ephy-history-service.h"
 #include "ephy-overview.h"
 #include "ephy-prefs.h"
-#include "ephy-profile-utils.h"
 #include "ephy-settings.h"
 #include "ephy-string.h"
 #include "ephy-web-app-utils.h"
@@ -594,12 +594,12 @@ store_password (GtkInfoBar *info_bar, gint response_id, gpointer data)
   }
 
   LOG ("Response is GTK_RESPONSE_YES - saving!");
-  _ephy_profile_utils_store_form_auth_data (uri,
-                                            name_field_name,
-                                            password_field_name,
-                                            name_field_value,
-                                            password_field_value,
-                                            NULL, NULL);
+  ephy_form_auth_data_store (uri,
+                             name_field_name,
+                             password_field_name,
+                             name_field_value,
+                             password_field_value,
+                             NULL, NULL);
 
   /* Update internal caching */
   host = ephy_string_get_host_name (uri);
@@ -730,12 +730,12 @@ form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
        store_data->name_value,
        store_data->password_value);
 
-  _ephy_profile_utils_query_form_auth_data (store_data->uri,
-                                            store_data->name_field,
-                                            store_data->password_field,
-                                            (EphyQueryFormDataCallback)should_store_cb,
-                                            store_data,
-                                            NULL);
+  ephy_form_auth_data_query (store_data->uri,
+                             store_data->name_field,
+                             store_data->password_field,
+                             should_store_cb,
+                             store_data,
+                             NULL);
 
   soup_uri_free (uri);
 
@@ -777,12 +777,12 @@ pre_fill_form (WebKitDOMNode *username_node,
       fill_data->username_node = g_object_ref (username_node);
       fill_data->password_node = g_object_ref (password_node);
 
-      _ephy_profile_utils_query_form_auth_data (uri_str,
-                                                data->form_username,
-                                                data->form_password,
-                                                (EphyQueryFormDataCallback)fill_form_cb,
-                                                fill_data,
-                                                fill_data_free);
+      ephy_form_auth_data_query (uri_str,
+                                 data->form_username,
+                                 data->form_password,
+                                 fill_form_cb,
+                                 fill_data,
+                                 fill_data_free);
       g_free (uri_str);
     }
     g_free (username_field_name);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e7d039b..3457f37 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,6 +8,7 @@ NOINST_H_FILES = \
        ephy-favicon-helpers.h                  \
        ephy-file-chooser.h                     \
        ephy-file-helpers.h                     \
+       ephy-form-auth-data.h                   \
        ephy-gui.h                              \
        ephy-langs.h                            \
        ephy-node-filter.h                      \
@@ -45,6 +46,7 @@ libephymisc_la_SOURCES = \
        ephy-favicon-helpers.c                  \
        ephy-file-chooser.c                     \
        ephy-file-helpers.c                     \
+       ephy-form-auth-data.c                   \
        ephy-gui.c                              \
        ephy-initial-state.c                    \
        ephy-langs.c                            \
diff --git a/lib/ephy-form-auth-data.c b/lib/ephy-form-auth-data.c
new file mode 100644
index 0000000..b1bf50c
--- /dev/null
+++ b/lib/ephy-form-auth-data.c
@@ -0,0 +1,251 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
+/*
+ *  Copyright © 2013 Igalia S.L.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ephy-form-auth-data.h"
+
+#include <glib/gi18n.h>
+#include <libsoup/soup.h>
+
+const SecretSchema *
+ephy_form_auth_data_get_password_schema (void)
+{
+  static const SecretSchema schema = {
+    "org.epiphany.FormPassword", SECRET_SCHEMA_NONE,
+    {
+      { URI_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
+      { FORM_USERNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
+      { FORM_PASSWORD_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
+      { USERNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
+      { "NULL", 0 },
+    }
+  };
+  return &schema;
+}
+
+static void
+normalize_and_prepare_uri (SoupURI *uri)
+{
+  g_assert (uri != NULL);
+
+  /* We normalize https? schemes here so that we use passwords
+   * we stored in https sites in their http counterparts, and
+   * vice-versa. */
+  if (uri->scheme == SOUP_URI_SCHEME_HTTPS)
+    soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
+
+  soup_uri_set_path (uri, "/");
+}
+
+static GHashTable *
+ephy_form_auth_data_get_secret_attributes_table (const char *uri,
+                                                 const char *field_username,
+                                                 const char *field_password,
+                                                 const char *username)
+{
+  return secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA,
+                                  URI_KEY, uri,
+                                  FORM_USERNAME_KEY, field_username,
+                                  FORM_PASSWORD_KEY, field_password,
+                                  username ? USERNAME_KEY : NULL, username,
+                                  NULL);
+}
+
+static void
+store_form_password_cb (SecretService *service,
+                        GAsyncResult *res,
+                        GSimpleAsyncResult *async)
+{
+  GError *error = NULL;
+
+  secret_service_store_finish (service, res, &error);
+  if (error != NULL)
+    g_simple_async_result_take_error (async, error);
+
+  g_simple_async_result_complete (async);
+  g_object_unref (async);
+}
+
+void
+ephy_form_auth_data_store (const char *uri,
+                           const char *form_username,
+                           const char *form_password,
+                           const char *username,
+                           const char *password,
+                           GAsyncReadyCallback callback,
+                           gpointer userdata)
+{
+  SoupURI *fake_uri;
+  char *fake_uri_str;
+  SecretValue *value;
+  GHashTable *attributes;
+  char *label;
+  GSimpleAsyncResult *res;
+
+  g_return_if_fail (uri);
+  g_return_if_fail (form_username);
+  g_return_if_fail (form_password);
+  g_return_if_fail (username);
+  g_return_if_fail (password);
+
+  fake_uri = soup_uri_new (uri);
+  g_return_if_fail (fake_uri);
+
+  res = g_simple_async_result_new (NULL, callback, userdata, ephy_form_auth_data_store);
+
+  normalize_and_prepare_uri (fake_uri);
+  fake_uri_str = soup_uri_to_string (fake_uri, FALSE);
+  value = secret_value_new (password, -1, "text/plain");
+  attributes = ephy_form_auth_data_get_secret_attributes_table (fake_uri_str, form_username,
+                                                                form_password, username);
+  /* Translators: The first %s is the username and the second one is the
+   * hostname where this is happening. Example: gnome gmail com and
+   * mail.google.com.
+   */
+  label = g_strdup_printf (_("Password for %s in a form in %s"),
+                           username, fake_uri_str);
+  secret_service_store (NULL, EPHY_FORM_PASSWORD_SCHEMA,
+                        attributes, NULL, label, value,
+                        NULL,
+                        (GAsyncReadyCallback)store_form_password_cb,
+                        g_object_ref (res));
+
+  g_free (label);
+  secret_value_unref (value);
+  g_hash_table_unref (attributes);
+  soup_uri_free (fake_uri);
+  g_free (fake_uri_str);
+  g_object_unref (res);
+}
+
+
+gboolean
+ephy_form_auth_data_store_finish (GAsyncResult *result,
+                                  GError **error)
+{
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+  g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, ephy_form_auth_data_store), FALSE);
+
+  return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
+}
+
+typedef struct
+{
+  EphyFormAuthDataQueryCallback callback;
+  gpointer data;
+  GDestroyNotify destroy_data;
+} EphyFormAuthDataQueryClosure;
+
+static void
+ephy_form_auth_data_query_closure_free (EphyFormAuthDataQueryClosure *closure)
+{
+  if (closure->destroy_data)
+    closure->destroy_data (closure->data);
+
+  g_slice_free (EphyFormAuthDataQueryClosure, closure);
+}
+
+static void
+search_form_data_cb (SecretService *service,
+                     GAsyncResult *res,
+                     EphyFormAuthDataQueryClosure *closure)
+{
+  GList *results;
+  SecretItem *item;
+  const char* username = NULL, *password = NULL;
+  SecretValue *value = NULL;
+  GHashTable *attributes = NULL;
+  GError *error = NULL;
+
+  results = secret_service_search_finish (service, res, &error);
+  if (error) {
+    g_warning ("Couldn't retrieve form data: %s", error->message);
+    g_error_free (error);
+    goto out;
+  }
+
+  if (!results)
+    goto out;
+
+  item = (SecretItem*)results->data;
+  attributes = secret_item_get_attributes (item);
+  username = g_hash_table_lookup (attributes, USERNAME_KEY);
+  value = secret_item_get_secret (item);
+  password = secret_value_get (value, NULL);
+
+  g_list_free_full (results, (GDestroyNotify)g_object_unref);
+
+out:
+  if (closure->callback)
+    closure->callback (username, password, closure->data);
+
+  if (value)
+    secret_value_unref (value);
+  if (attributes)
+    g_hash_table_unref (attributes);
+
+  ephy_form_auth_data_query_closure_free (closure);
+}
+
+void
+ephy_form_auth_data_query (const char *uri,
+                           const char *form_username,
+                           const char *form_password,
+                           EphyFormAuthDataQueryCallback callback,
+                           gpointer user_data,
+                           GDestroyNotify destroy_data)
+{
+  SoupURI *key;
+  char *key_str;
+  EphyFormAuthDataQueryClosure *closure;
+  GHashTable *attributes;
+
+  g_return_if_fail (uri);
+  g_return_if_fail (form_username);
+  g_return_if_fail (form_password);
+
+  key = soup_uri_new (uri);
+  g_return_if_fail (key);
+
+  normalize_and_prepare_uri (key);
+
+  key_str = soup_uri_to_string (key, FALSE);
+
+  attributes = ephy_form_auth_data_get_secret_attributes_table (key_str, form_username,
+                                                                form_password, NULL);
+
+  closure = g_slice_new0 (EphyFormAuthDataQueryClosure);
+  closure->callback = callback;
+  closure->data = user_data;
+  closure->destroy_data = destroy_data;
+
+  secret_service_search (NULL,
+                         EPHY_FORM_PASSWORD_SCHEMA,
+                         attributes,
+                         SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
+                         NULL, (GAsyncReadyCallback)search_form_data_cb,
+                         closure);
+
+  g_hash_table_unref (attributes);
+  soup_uri_free (key);
+  g_free (key_str);
+}
+
diff --git a/lib/ephy-form-auth-data.h b/lib/ephy-form-auth-data.h
new file mode 100644
index 0000000..5bd3bfd
--- /dev/null
+++ b/lib/ephy-form-auth-data.h
@@ -0,0 +1,59 @@
+/*
+ *  Copyright © 2013 Igalia S.L.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef EPHY_FORM_AUTH_DATA_H
+#define EPHY_FORM_AUTH_DATA_H
+
+#define SECRET_API_SUBJECT_TO_CHANGE
+
+#include <glib.h>
+#include <libsecret/secret.h>
+
+#define URI_KEY           "uri"
+#define FORM_USERNAME_KEY "form_username"
+#define FORM_PASSWORD_KEY "form_password"
+#define USERNAME_KEY      "username"
+
+void ephy_form_auth_data_store                (const char *uri,
+                                               const char *form_username,
+                                               const char *form_password,
+                                               const char *username,
+                                               const char *password,
+                                               GAsyncReadyCallback callback,
+                                               gpointer userdata);
+
+gboolean ephy_form_auth_data_store_finish     (GAsyncResult *result,
+                                               GError **error);
+
+typedef void (*EphyFormAuthDataQueryCallback) (const char *username,
+                                               const char *password,
+                                               gpointer user_data);
+
+void ephy_form_auth_data_query                (const char *uri,
+                                               const char *form_username,
+                                               const char *form_password,
+                                               EphyFormAuthDataQueryCallback callback,
+                                               gpointer user_data,
+                                               GDestroyNotify destroy_data);
+
+const SecretSchema *ephy_form_auth_data_get_password_schema (void) G_GNUC_CONST;
+
+#define EPHY_FORM_PASSWORD_SCHEMA ephy_form_auth_data_get_password_schema ()
+
+#endif
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index d89dfa9..c3a6913 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -34,6 +34,7 @@
 
 #include "ephy-debug.h"
 #include "ephy-file-helpers.h"
+#include "ephy-form-auth-data.h"
 #include "ephy-history-service.h"
 #include "ephy-profile-utils.h"
 #include "ephy-settings.h"
@@ -296,12 +297,12 @@ parse_and_decrypt_signons (const char *signons,
           !g_str_equal (form_password, "*")) {
         char *u = soup_uri_to_string (uri, FALSE);
         /* We skip the '*' at the beginning of form_password. */
-        _ephy_profile_utils_store_form_auth_data (u,
-                                                  form_username,
-                                                  form_password+1,
-                                                  username,
-                                                  password,
-                                                  NULL, NULL);
+        ephy_form_auth_data_store (u,
+                                   form_username,
+                                   form_password+1,
+                                   username,
+                                   password,
+                                   NULL, NULL);
         g_free (u);
       } else if (!handle_forms && realm &&
                  username && password &&
@@ -837,7 +838,7 @@ store_form_auth_data_cb (GObject *object,
 {
   GError *error = NULL;
 
-  _ephy_profile_utils_store_form_auth_data_finish (res, &error);
+  ephy_form_auth_data_store_finish (res, &error);
   if (error) {
     g_warning ("Couldn't store a form password: %s", error->message);
     g_error_free (error);
@@ -897,13 +898,13 @@ load_collection_items_cb (SecretCollection *collection,
       secret_item_load_secret_sync (item, NULL, NULL);
       secret = secret_item_get_secret (item);
       password = secret_value_get (secret, NULL);
-      _ephy_profile_utils_store_form_auth_data (actual_server,
-                                                form_username,
-                                                form_password,
-                                                username,
-                                                password,
-                                                (GAsyncReadyCallback)store_form_auth_data_cb,
-                                                g_hash_table_ref (attributes));
+      ephy_form_auth_data_store (actual_server,
+                                 form_username,
+                                 form_password,
+                                 username,
+                                 password,
+                                 (GAsyncReadyCallback)store_form_auth_data_cb,
+                                 g_hash_table_ref (attributes));
       g_free (actual_server);
       secret_value_unref (secret);
       g_hash_table_unref (t);
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 5a8f1a3..5d295e5 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -25,27 +25,8 @@
 #include "ephy-debug.h"
 #include "ephy-file-helpers.h"
 
-#include <glib/gi18n.h>
-#include <libsoup/soup.h>
-
 #define PROFILE_MIGRATION_FILE ".migrated"
 
-const SecretSchema*
-ephy_profile_get_form_password_schema (void)
-{
-  static const SecretSchema schema = {
-    "org.epiphany.FormPassword", SECRET_SCHEMA_NONE,
-    {
-      { URI_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
-      { FORM_USERNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
-      { FORM_PASSWORD_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
-      { USERNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
-      { "NULL", 0 },
-    }
-  };
-  return &schema;
-}
-
 int
 ephy_profile_utils_get_migration_version ()
 {
@@ -105,219 +86,6 @@ ephy_profile_utils_set_migration_version (int version)
   return result;
 }
 
-static void
-normalize_and_prepare_uri (SoupURI *uri)
-{
-  g_return_if_fail (uri != NULL);
-
-  /* We normalize https? schemes here so that we use passwords
-   * we stored in https sites in their http counterparts, and
-   * vice-versa. */
-  if (uri->scheme == SOUP_URI_SCHEME_HTTPS)
-    soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
-
-  soup_uri_set_path (uri, "/");
-}
-
-static GHashTable *
-ephy_profile_utils_get_attributes_table (const char *uri,
-                                         const char *field_username,
-                                         const char *field_password,
-                                         const char *username)
-{
-  return secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA,
-                                  URI_KEY, uri,
-                                  FORM_USERNAME_KEY, field_username,
-                                  FORM_PASSWORD_KEY, field_password,
-                                  username ? USERNAME_KEY : NULL, username,
-                                  NULL);
-}
-
-static void
-store_form_password_cb (SecretService *service,
-                        GAsyncResult *res,
-                        GSimpleAsyncResult *async)
-{
-  GError *error = NULL;
-
-  secret_service_store_finish (service, res, &error);
-  if (error != NULL)
-    g_simple_async_result_take_error (async, error);
-
-  g_simple_async_result_complete (async);
-  g_object_unref (async);
-}
-
-void
-_ephy_profile_utils_store_form_auth_data (const char *uri,
-                                          const char *form_username,
-                                          const char *form_password,
-                                          const char *username,
-                                          const char *password,
-                                          GAsyncReadyCallback callback,
-                                          gpointer userdata)
-{
-  SoupURI *fake_uri;
-  char *fake_uri_str;
-  SecretValue *value;
-  GHashTable *attributes;
-  char *label;
-  GSimpleAsyncResult *res;
-
-  g_return_if_fail (uri);
-  g_return_if_fail (form_username);
-  g_return_if_fail (form_password);
-  g_return_if_fail (username);
-  g_return_if_fail (password);
-
-  fake_uri = soup_uri_new (uri);
-
-  if (fake_uri == NULL)
-    return;
-
-  res = g_simple_async_result_new (NULL, callback, userdata,
-                                   _ephy_profile_utils_store_form_auth_data);
-
-  normalize_and_prepare_uri (fake_uri);
-  fake_uri_str = soup_uri_to_string (fake_uri, FALSE);
-  value = secret_value_new (password, -1, "text/plain");
-  attributes = ephy_profile_utils_get_attributes_table (fake_uri_str, form_username,
-                                                        form_password, username);
-  /* Translators: The first %s is the username and the second one is the
-   * hostname where this is happening. Example: gnome gmail com and
-   * mail.google.com.
-   */
-  label = g_strdup_printf (_("Password for %s in a form in %s"),
-                           username, fake_uri_str);
-  secret_service_store (NULL, EPHY_FORM_PASSWORD_SCHEMA,
-                        attributes, NULL, label, value,
-                        NULL,
-                        (GAsyncReadyCallback)store_form_password_cb,
-                        g_object_ref (res));
-
-  g_free (label);
-  secret_value_unref (value);
-  g_hash_table_unref (attributes);
-  soup_uri_free (fake_uri);
-  g_free (fake_uri_str);
-  g_object_unref (res);
-}
-
-
-gboolean
-_ephy_profile_utils_store_form_auth_data_finish (GAsyncResult *result,
-                                                 GError **error)
-{
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-  g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, 
_ephy_profile_utils_store_form_auth_data), FALSE);
-
-  return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
-}
-
-typedef struct
-{
-  EphyQueryFormDataCallback callback;
-  gpointer data;
-  GDestroyNotify destroy_data;
-} EphyProfileQueryClosure;
-
-static void
-ephy_profile_query_closure_free (EphyProfileQueryClosure *closure)
-{
-  if (closure->destroy_data)
-    closure->destroy_data (closure->data);
-
-  g_slice_free (EphyProfileQueryClosure, closure);
-}
-
-static void
-search_form_data_cb (SecretService *service,
-                     GAsyncResult *res,
-                     EphyProfileQueryClosure *closure)
-{
-  GList *results;
-  SecretItem *item;
-  const char* username = NULL, *password = NULL;
-  SecretValue *value = NULL;
-  GHashTable *attributes = NULL;
-  GError *error = NULL;
-
-  results = secret_service_search_finish (service, res, &error);
-  if (error) {
-    g_warning ("Couldn't retrieve form data: %s", error->message);
-    g_error_free (error);
-    goto out;
-  }
-
-  if (!results)
-    goto out;
-
-  item = (SecretItem*)results->data;
-  attributes = secret_item_get_attributes (item);
-  username = g_hash_table_lookup (attributes, USERNAME_KEY);
-  value = secret_item_get_secret (item);
-  password = secret_value_get (value, NULL);
-
-  g_list_free_full (results, (GDestroyNotify)g_object_unref);
-
-out:
-  if (closure->callback)
-    closure->callback (username, password, closure->data);
-
-  if (value)
-    secret_value_unref (value);
-  if (attributes)
-    g_hash_table_unref (attributes);
-
-  ephy_profile_query_closure_free (closure);
-}
-
-void
-_ephy_profile_utils_query_form_auth_data (const char *uri,
-                                          const char *form_username,
-                                          const char *form_password,
-                                          EphyQueryFormDataCallback callback,
-                                          gpointer data,
-                                          GDestroyNotify destroy_data)
-{
-  SoupURI *key;
-  char *key_str;
-  EphyProfileQueryClosure *closure;
-  GHashTable *attributes;
-
-  g_return_if_fail (uri);
-  g_return_if_fail (form_username);
-  g_return_if_fail (form_password);
-
-  key = soup_uri_new (uri);
-  g_return_if_fail (key);
-
-  normalize_and_prepare_uri (key);
-
-  key_str = soup_uri_to_string (key, FALSE);
-
-  attributes = ephy_profile_utils_get_attributes_table (key_str, form_username,
-                                                        form_password, NULL);
-
-  closure = g_slice_new0 (EphyProfileQueryClosure);
-  closure->callback = callback;
-  closure->data = data;
-  closure->destroy_data = destroy_data;
-
-  LOG ("Querying Keyring: %s", key_str);
-
-  secret_service_search (NULL,
-                         EPHY_FORM_PASSWORD_SCHEMA,
-                         attributes,
-                         SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS,
-                         NULL, (GAsyncReadyCallback)search_form_data_cb,
-                         closure);
-
-  g_hash_table_unref (attributes);
-  soup_uri_free (key);
-  g_free (key_str);
-}
-
 #define EPHY_PROFILE_MIGRATOR "ephy-profile-migrator"
 
 gboolean
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index ec3905b..72d32e4 100644
--- a/lib/ephy-profile-utils.h
+++ b/lib/ephy-profile-utils.h
@@ -20,15 +20,7 @@
 #ifndef EPHY_PROFILE_UTILS_H
 #define EPHY_PROFILE_UTILS_H
 
-#define SECRET_API_SUBJECT_TO_CHANGE
-
 #include <glib.h>
-#include <libsecret/secret.h>
-
-#define URI_KEY           "uri"
-#define FORM_USERNAME_KEY "form_username"
-#define FORM_PASSWORD_KEY "form_password"
-#define USERNAME_KEY      "username"
 
 #define EPHY_PROFILE_MIGRATION_VERSION 9
 
@@ -42,29 +34,4 @@ gboolean ephy_profile_utils_set_migration_version (int version);
 
 gboolean ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run, gboolean debug);
 
-void _ephy_profile_utils_store_form_auth_data            (const char *uri,
-                                                         const char *form_username,
-                                                         const char *form_password,
-                                                         const char *username,
-                                                         const char *password,
-                                                         GAsyncReadyCallback callback,
-                                                         gpointer userdata);
-
-gboolean _ephy_profile_utils_store_form_auth_data_finish (GAsyncResult *result,
-                                                         GError **error);
-
-typedef void (*EphyQueryFormDataCallback)                (const char *username, const char *password, 
gpointer user_data);
-
-void
-_ephy_profile_utils_query_form_auth_data                 (const char *uri,
-                                                         const char *form_username,
-                                                         const char *form_password,
-                                                         EphyQueryFormDataCallback callback,
-                                                         gpointer data,
-                                                         GDestroyNotify destroy_data);
-
-const SecretSchema *ephy_profile_get_form_password_schema (void) G_GNUC_CONST;
-
-#define EPHY_FORM_PASSWORD_SCHEMA ephy_profile_get_form_password_schema ()
-
 #endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5551d77..87e9932 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -16,12 +16,12 @@ embed/ephy-request-about.c
 embed/ephy-web-view.c
 lib/ephy-file-chooser.c
 lib/ephy-file-helpers.c
+lib/ephy-form-auth-data.c
 lib/ephy-gui.c
 lib/ephy-langs.c
 lib/ephy-node.c
 lib/ephy-nss-glue.c
 lib/ephy-profile-migrator.c
-lib/ephy-profile-utils.c
 lib/ephy-string.c
 lib/ephy-time-helpers.c
 lib/ephy-zoom.h


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]