aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdm-dialog.c
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2010-09-05 21:31:45 +0800
committerXan Lopez <xan@gnome.org>2010-09-05 21:31:45 +0800
commit479f0a9a7ec095a8457e7d5b70695207e81f40c6 (patch)
treed612bd5475542f2c0e71d9dbdf5ba1a478cb5bf7 /src/pdm-dialog.c
parent3f5372159fd33c6315acb4b9da048372ca21f586 (diff)
downloadgsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar.gz
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar.bz2
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar.lz
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar.xz
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.tar.zst
gsoc2013-epiphany-479f0a9a7ec095a8457e7d5b70695207e81f40c6.zip
pdm-dialog: do not crash when clearing the passwords from prefs dialog
The code (wrongly) assumed we could only be called from withing the PDM dialog. Do some refactoring to make it more generic. Bug #606933
Diffstat (limited to 'src/pdm-dialog.c')
-rw-r--r--src/pdm-dialog.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index a91047bdf..7824627b5 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -224,27 +224,44 @@ clear_all_cookies (SoupCookieJar *jar)
}
static void
-pdm_dialog_password_remove_cb (GnomeKeyringResult result,
- gpointer data)
+get_info_full_cb (GnomeKeyringResult result,
+ GnomeKeyringItemInfo *info,
+ gpointer data)
{
- GtkTreeRowReference *rowref = (GtkTreeRowReference *)data;
+ if (result != GNOME_KEYRING_RESULT_OK)
+ return;
- if (result == GNOME_KEYRING_RESULT_OK) {
- GtkTreeIter iter;
- GtkTreePath *path;
- GtkTreeModel *model;
+ if (gnome_keyring_item_info_get_type (info) == GNOME_KEYRING_ITEM_NETWORK_PASSWORD)
+ gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
+ GPOINTER_TO_UINT (data),
+ NULL, NULL, NULL);
+}
- if (!gtk_tree_row_reference_valid (rowref))
- return;
+static void
+got_network_passwords_list_cb (GnomeKeyringResult result,
+ GList *list,
+ gpointer data)
+{
+ GList *l;
- path = gtk_tree_row_reference_get_path (rowref);
- model = gtk_tree_row_reference_get_model (rowref);
+ if (result != GNOME_KEYRING_RESULT_OK)
+ return;
- if (path != NULL && gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
- gtk_tree_path_free (path);
- }
- }
+ for (l = list; l != NULL; l = l->next)
+ gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
+ GPOINTER_TO_UINT (l->data),
+ GNOME_KEYRING_ITEM_INFO_BASICS,
+ (GnomeKeyringOperationGetItemInfoCallback) get_info_full_cb,
+ l->data,
+ NULL);
+}
+
+static void
+_ephy_pdm_delete_all_passwords ()
+{
+ gnome_keyring_list_item_ids (GNOME_KEYRING_DEFAULT,
+ got_network_passwords_list_cb,
+ NULL, NULL);
}
static void
@@ -282,35 +299,15 @@ clear_all_dialog_response_cb (GtkDialog *dialog,
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_passwords)))
{
- GtkTreeIter iter;
- PdmDialog *pdialog = EPHY_PDM_DIALOG (checkbuttons->dialog);
- PdmActionInfo *pinfo = pdialog->priv->passwords;
-
- gboolean valid = gtk_tree_model_get_iter_first (pinfo->model, &iter);
-
- while (valid) {
- GtkTreePath *path;
- EphyPasswordInfo *info;
- GtkTreeRowReference *row;
-
- path = gtk_tree_model_get_path (pinfo->model, &iter);
- row = gtk_tree_row_reference_new (pinfo->model, path);
-
- gtk_tree_model_get (pinfo->model, &iter,
- COL_PASSWORDS_DATA, &info,
- -1);
-
- gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
- info->keyring_id,
- (GnomeKeyringOperationDoneCallback) pdm_dialog_password_remove_cb,
- row,
- (GDestroyNotify) gtk_tree_row_reference_free);
-
- valid = gtk_tree_model_iter_next (pinfo->model, &iter);
-
- g_slice_free (EphyPasswordInfo, info);
- gtk_tree_path_free (path);
+ /* Clear UI if we are the PDM dialog */
+ if (EPHY_IS_PDM_DIALOG (checkbuttons->dialog))
+ {
+ PdmDialog *pdialog = EPHY_PDM_DIALOG (checkbuttons->dialog);
+ PdmActionInfo *pinfo = pdialog->priv->passwords;
+ gtk_list_store_clear (GTK_LIST_STORE (pinfo->model));
}
+
+ _ephy_pdm_delete_all_passwords ();
}
if (gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cache)))