[epiphany/gnome-keyring: 6/6] pdm-dialog.c: Make password adding async.
- From: Priit Laes <plaes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-keyring: 6/6] pdm-dialog.c: Make password adding async.
- Date: Fri, 31 Jul 2009 16:25:32 +0000 (UTC)
commit 259cfa30bd8991a3e57bd6f200df2b8ae0b71a37
Author: Priit Laes <plaes plaes org>
Date: Wed Jul 29 11:23:41 2009 +0300
pdm-dialog.c: Make password adding async.
Signed-off-by: Priit Laes <plaes plaes org>
src/pdm-dialog.c | 125 +++++++++++++++++++++++++++++++----------------------
1 files changed, 73 insertions(+), 52 deletions(-)
---
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 0ec0210..a175404 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -72,6 +72,13 @@ struct PdmActionInfo
gboolean filled;
};
+typedef struct PdmCallBackData PdmCallBackData;
+struct PdmCallBackData
+{
+ guint key;
+ GtkListStore *store;
+};
+
#define EPHY_PDM_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_PDM_DIALOG, PdmDialogPrivate))
struct PdmDialogPrivate
@@ -1355,44 +1362,21 @@ pdm_dialog_passwords_destruct (PdmActionInfo *info)
}
static void
-pdm_dialog_password_add (PdmActionInfo *info,
- gpointer data)
+pdm_dialog_password_add_item_attrs_cb (GnomeKeyringResult result,
+ GnomeKeyringAttributeList *attributes,
+ gpointer data)
{
- GnomeKeyringResult result;
- GnomeKeyringItemInfo *kinfo;
+ EphyPasswordInfo *pinfo;
+ PdmCallBackData *cbdata;
GnomeKeyringAttribute *attribute;
- GnomeKeyringAttributeList *attributes;
gchar *user, *host, *protocol;
- EphyPasswordInfo *pinfo;
- GtkListStore *store;
GtkTreeIter iter;
- guint key_id = GPOINTER_TO_UINT(data);
int i;
- /*
- * We have the item id of the password. We will have to check if this
- * password entry is of the right type and then can proceed to get the
- * the private information. Seahorse is treating every protocol that
- * starts with http as Web Access and we will do the same here.
- */
-
- /* Get the type of the key_id */
- result = gnome_keyring_item_get_info_full_sync (GNOME_KEYRING_DEFAULT,
- key_id,
- GNOME_KEYRING_ITEM_INFO_BASICS,
- &kinfo);
-
if (result != GNOME_KEYRING_RESULT_OK)
- goto out;
-
- if (gnome_keyring_item_info_get_type (kinfo) != GNOME_KEYRING_ITEM_NETWORK_PASSWORD)
- goto out_info_free;
+ return;
- /* Get the attributes to check protocol */
- result = gnome_keyring_item_get_attributes_sync (GNOME_KEYRING_DEFAULT,
- key_id, &attributes);
- if (result != GNOME_KEYRING_RESULT_OK)
- goto out_info_free;
+ cbdata = (PdmCallBackData *)data;
user = host = protocol = NULL;
attribute = (GnomeKeyringAttribute *) attributes->data;
@@ -1404,32 +1388,69 @@ pdm_dialog_password_add (PdmActionInfo *info,
user = g_strdup (attribute[i].value.string);
else if (strcmp (attribute[i].name, "protocol") == 0)
protocol = attribute[i].value.string;
+ }
}
- }
if (!protocol || strncmp("http", protocol, 4) != 0)
- goto out_attr_free;
+ return;
- pinfo = ephy_password_info_new (key_id);
+ pinfo = ephy_password_info_new (cbdata->key);
if (!pinfo)
- goto out_attr_free;
-
- store = GTK_LIST_STORE (info->model);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store,
- &iter,
- COL_PASSWORDS_HOST, host,
- COL_PASSWORDS_USER, user,
- COL_PASSWORDS_PASS, NULL,
- COL_PASSWORDS_DATA, pinfo,
- -1);
-
-out_attr_free:
- gnome_keyring_attribute_list_free (attributes);
-out_info_free:
- gnome_keyring_item_info_free (kinfo);
-out:
- return;
+ return;
+
+ gtk_list_store_append (cbdata->store, &iter);
+ gtk_list_store_set (cbdata->store, &iter,
+ COL_PASSWORDS_HOST, host,
+ COL_PASSWORDS_USER, user,
+ COL_PASSWORDS_PASS, NULL,
+ COL_PASSWORDS_DATA, pinfo,
+ -1);
+}
+
+static void
+pdm_dialog_password_add_item_info_cb (GnomeKeyringResult result,
+ GnomeKeyringItemInfo *info,
+ gpointer data)
+{
+ if (result != GNOME_KEYRING_RESULT_OK)
+ return;
+
+ if (gnome_keyring_item_info_get_type (info) == GNOME_KEYRING_ITEM_NETWORK_PASSWORD) {
+ PdmCallBackData *cbdata = (PdmCallBackData *)data;
+ gnome_keyring_item_get_attributes (GNOME_KEYRING_DEFAULT,
+ cbdata->key,
+ (GnomeKeyringOperationGetAttributesCallback) pdm_dialog_password_add_item_attrs_cb,
+ g_memdup (cbdata, sizeof (PdmCallBackData)),
+ (GDestroyNotify) g_free);
+
+ }
+
+}
+
+static void
+pdm_dialog_password_add (PdmActionInfo *info,
+ gpointer data)
+{
+ PdmCallBackData *cbdata;
+ guint key_id = GPOINTER_TO_UINT(data);
+
+ /*
+ * We have the item id of the password. We will have to check if this
+ * password entry is of the right type and then can proceed to get the
+ * the private information. Seahorse is treating every protocol that
+ * starts with http as Web Access and we will do the same here.
+ */
+
+ cbdata = g_malloc (sizeof(PdmCallBackData *));
+ cbdata->key = key_id;
+ cbdata->store = GTK_LIST_STORE (info->model);
+
+ /* Get the type of the key_id */
+ gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
+ key_id,
+ GNOME_KEYRING_ITEM_INFO_BASICS,
+ (GnomeKeyringOperationGetItemInfoCallback) pdm_dialog_password_add_item_info_cb,
+ cbdata,
+ (GDestroyNotify) g_free);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]