diff options
author | Xan Lopez <xan@gnome.org> | 2009-12-15 19:17:25 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2009-12-15 19:17:25 +0800 |
commit | efb097c929407bb264b90d31feadac34c31a85e7 (patch) | |
tree | 19078b19e4ffdb3dfd898ab659da0dbf8325ec9b | |
parent | 4956cb6e958f0640b2864719f4c87118b563447f (diff) | |
download | gsoc2013-epiphany-efb097c929407bb264b90d31feadac34c31a85e7.tar.gz gsoc2013-epiphany-efb097c929407bb264b90d31feadac34c31a85e7.tar.zst gsoc2013-epiphany-efb097c929407bb264b90d31feadac34c31a85e7.zip |
ephy-embed-single: add a function to update the form auth cache with a new entry
-rw-r--r-- | embed/ephy-embed-single.c | 53 | ||||
-rw-r--r-- | embed/ephy-embed-single.h | 6 |
2 files changed, 47 insertions, 12 deletions
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index 12e3c8874..5e7f6a2d9 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -143,7 +143,6 @@ get_attr_cb (GnomeKeyringResult result, { int i = 0; GnomeKeyringAttribute *attribute; - EphyEmbedSinglePrivate *priv = single->priv; char *server = NULL, *username = NULL; if (result != GNOME_KEYRING_RESULT_OK) @@ -171,21 +170,11 @@ get_attr_cb (GnomeKeyringResult result, * the time */ const char *form_username, *form_password; GHashTable *t; - GSList *l; - EphyEmbedSingleFormAuthData *form_data; SoupURI *uri = soup_uri_new (server); t = soup_form_decode (uri->query); form_username = g_hash_table_lookup (t, FORM_USERNAME_KEY); form_password = g_hash_table_lookup (t, FORM_PASSWORD_KEY); - - form_data = form_auth_data_new (form_username, form_password, username); - l = g_hash_table_lookup (priv->form_auth_data, - uri->host); - l = g_slist_append (l, form_data); - g_hash_table_replace (priv->form_auth_data, - g_strdup (uri->host), - l); - + ephy_embed_single_add_form_auth (single, uri->host, form_username, form_password, username); soup_uri_free (uri); g_hash_table_destroy (t); } @@ -627,3 +616,43 @@ ephy_embed_single_get_form_auth (EphyEmbedSingle *single, return g_hash_table_lookup (priv->form_auth_data, uri); } + +/** + * ephy_embed_single_add_form_auth: + * @single: an #EphyEmbedSingle + * @uri: URI of the page + * @form_username: name of the username input field + * @form_password: name of the password input field + * @username: username + * + * Adds a new entry to the local cache of form auth data stored in + * @single. + * + **/ +void +ephy_embed_single_add_form_auth (EphyEmbedSingle *single, + const char *uri, + const char *form_username, + const char *form_password, + const char *username) +{ + EphyEmbedSingleFormAuthData *form_data; + EphyEmbedSinglePrivate *priv; + GSList *l; + + g_return_if_fail (EPHY_IS_EMBED_SINGLE (single)); + g_return_if_fail (uri); + g_return_if_fail (form_username); + g_return_if_fail (form_password); + g_return_if_fail (username); + + priv = single->priv; + + form_data = form_auth_data_new (form_username, form_password, username); + l = g_hash_table_lookup (priv->form_auth_data, + uri); + l = g_slist_append (l, form_data); + g_hash_table_replace (priv->form_auth_data, + g_strdup (uri), + l); +} diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index 6b7f36ce8..321010503 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.h @@ -100,6 +100,12 @@ gboolean ephy_embed_single_get_network_status (EphyEmbedSingle *single); GSList * ephy_embed_single_get_form_auth (EphyEmbedSingle *single, const char *uri); +void ephy_embed_single_add_form_auth (EphyEmbedSingle *single, + const char *uri, + const char *form_username, + const char *form_password, + const char *username); + G_END_DECLS #endif |