213
get_info_full_cb (GnomeKeyringResult result,
214
GnomeKeyringItemInfo *info,
217
if (result != GNOME_KEYRING_RESULT_OK)
220
if (gnome_keyring_item_info_get_type (info) == GNOME_KEYRING_ITEM_NETWORK_PASSWORD)
221
gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
222
GPOINTER_TO_UINT (data),
227
got_network_passwords_list_cb (GnomeKeyringResult result,
233
if (result != GNOME_KEYRING_RESULT_OK)
236
for (l = list; l != NULL; l = l->next)
237
gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
238
GPOINTER_TO_UINT (l->data),
239
GNOME_KEYRING_ITEM_INFO_BASICS,
240
(GnomeKeyringOperationGetItemInfoCallback) get_info_full_cb,
246
_ephy_pdm_delete_all_passwords ()
248
gnome_keyring_list_item_ids (GNOME_KEYRING_DEFAULT,
249
got_network_passwords_list_cb,
211
_ephy_pdm_delete_all_passwords (void)
213
GHashTable *attributes;
215
attributes = secret_attributes_build (SECRET_SCHEMA_COMPAT_NETWORK, NULL);
216
secret_service_clear (NULL, SECRET_SCHEMA_COMPAT_NETWORK,
218
(GAsyncReadyCallback)secret_service_clear_finish,
220
g_hash_table_unref (attributes);
1191
1163
/* "Passwords" tab */
1193
passwords_data_func_get_item_cb (GnomeKeyringResult result,
1194
GnomeKeyringItemInfo *info,
1165
passwords_data_func_get_item_cb (SecretItem *item,
1166
GAsyncResult *result,
1171
GtkTreeModel *model;
1172
GError *error = NULL;
1197
1173
GtkTreeRowReference *rowref = (GtkTreeRowReference *)data;
1199
if (result == GNOME_KEYRING_RESULT_OK) {
1202
GtkTreeModel *model;
1204
if (!gtk_tree_row_reference_valid (rowref))
1207
path = gtk_tree_row_reference_get_path (rowref);
1208
model = gtk_tree_row_reference_get_model (rowref);
1210
if (path != NULL && gtk_tree_model_get_iter (model, &iter, path)) {
1211
EphyPasswordInfo *epinfo;
1214
gtk_tree_model_get_value (model, &iter, COL_PASSWORDS_DATA, &val);
1215
epinfo = g_value_get_boxed (&val);
1216
epinfo->secret = gnome_keyring_memory_strdup (gnome_keyring_item_info_get_secret (info));
1218
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1219
COL_PASSWORDS_DATA, epinfo,
1220
COL_PASSWORDS_PASSWORD, epinfo->secret, -1);
1221
g_value_unset (&val);
1175
secret_item_load_secret_finish (item, result, &error);
1177
g_warning ("Couldn't load password for site: %s", error->message);
1178
g_error_free (error);
1182
if (!gtk_tree_row_reference_valid (rowref))
1185
path = gtk_tree_row_reference_get_path (rowref);
1186
model = gtk_tree_row_reference_get_model (rowref);
1188
if (path != NULL && gtk_tree_model_get_iter (model, &iter, path)) {
1189
SecretValue *secret = secret_item_get_secret (item);
1190
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
1191
COL_PASSWORDS_PASSWORD, secret_value_get (secret, NULL),
1227
1197
passwords_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
1228
1198
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
1230
GValue val = { 0, };
1231
EphyPasswordInfo *info;
1233
1203
if (!gtk_tree_view_column_get_visible (tree_column))
1236
gtk_tree_model_get_value (model, iter, COL_PASSWORDS_DATA, &val);
1237
info = g_value_get_boxed (&val);
1206
gtk_tree_model_get (model, iter, COL_PASSWORDS_DATA, &item, -1);
1207
value = secret_item_get_secret (item);
1239
if (info->secret == NULL) {
1209
/* Value has not been loaded yet, do now. */
1240
1211
GtkTreePath *path;
1241
1212
GtkTreeRowReference *rowref;
1243
1214
path = gtk_tree_model_get_path (model, iter);
1244
1215
rowref = gtk_tree_row_reference_new (model, path);
1246
gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
1248
GNOME_KEYRING_ITEM_INFO_SECRET,
1249
(GnomeKeyringOperationGetItemInfoCallback) passwords_data_func_get_item_cb,
1251
(GDestroyNotify) gtk_tree_row_reference_free);
1252
gtk_tree_path_free (path);
1254
g_value_unset (&val);
1217
secret_item_load_secret (item, NULL,
1218
(GAsyncReadyCallback)passwords_data_func_get_item_cb,
1221
secret_value_unref (value);
1436
pdm_dialog_password_add_item_attrs_cb (GnomeKeyringResult result,
1437
GnomeKeyringAttributeList *attributes,
1415
pdm_dialog_password_add (PdmActionInfo *info,
1440
EphyPasswordInfo *pinfo;
1441
PdmCallBackData *cbdata;
1442
GnomeKeyringAttribute *attribute;
1418
SecretItem *item = (SecretItem*)data;
1443
1420
gchar *user, *host, *protocol;
1447
if (result != GNOME_KEYRING_RESULT_OK)
1450
cbdata = (PdmCallBackData *)data;
1452
user = host = protocol = NULL;
1453
attribute = (GnomeKeyringAttribute *) attributes->data;
1454
for (i = 0; i < attributes->len; ++i) {
1455
if (attribute[i].type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
1456
if (strcmp (attribute[i].name, "server") == 0)
1457
host = g_strdup (attribute[i].value.string);
1458
else if (strcmp (attribute[i].name, "user") == 0)
1459
user = g_strdup (attribute[i].value.string);
1460
else if (strcmp (attribute[i].name, "protocol") == 0)
1461
protocol = attribute[i].value.string;
1421
GHashTable *attributes;
1423
attributes = secret_item_get_attributes (item);
1425
protocol = g_hash_table_lookup (attributes, "protocol");
1464
1426
if (!protocol || strncmp("http", protocol, 4) != 0)
1467
pinfo = ephy_password_info_new (cbdata->key);
1429
user = g_hash_table_lookup (attributes, "user");
1430
host = g_hash_table_lookup (attributes, "server");
1471
gtk_list_store_append (cbdata->store, &iter);
1472
gtk_list_store_set (cbdata->store, &iter,
1432
gtk_list_store_append (GTK_LIST_STORE (info->model), &iter);
1433
gtk_list_store_set (GTK_LIST_STORE (info->model), &iter,
1473
1434
COL_PASSWORDS_HOST, host,
1474
1435
COL_PASSWORDS_USER, user,
1475
1436
COL_PASSWORDS_PASSWORD, NULL,
1476
COL_PASSWORDS_DATA, pinfo,
1437
COL_PASSWORDS_DATA, item,
1481
pdm_dialog_password_add_item_info_cb (GnomeKeyringResult result,
1482
GnomeKeyringItemInfo *info,
1485
if (result != GNOME_KEYRING_RESULT_OK)
1488
if (gnome_keyring_item_info_get_type (info) == GNOME_KEYRING_ITEM_NETWORK_PASSWORD) {
1489
PdmCallBackData *cbdata = (PdmCallBackData *)data;
1490
gnome_keyring_item_get_attributes (GNOME_KEYRING_DEFAULT,
1492
(GnomeKeyringOperationGetAttributesCallback) pdm_dialog_password_add_item_attrs_cb,
1493
g_memdup (cbdata, sizeof (PdmCallBackData)),
1494
(GDestroyNotify) g_free);
1501
pdm_dialog_password_add (PdmActionInfo *info,
1504
PdmCallBackData *cbdata;
1505
guint key_id = GPOINTER_TO_UINT(data);
1508
* We have the item id of the password. We will have to check if this
1509
* password entry is of the right type and then can proceed to get the
1510
* the private information. Seahorse is treating every protocol that
1511
* starts with http as Web Access and we will do the same here.
1514
cbdata = g_malloc (sizeof (PdmCallBackData));
1515
cbdata->key = key_id;
1516
cbdata->store = GTK_LIST_STORE (info->model);
1518
/* Get the type of the key_id */
1519
gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
1521
GNOME_KEYRING_ITEM_INFO_BASICS,
1522
(GnomeKeyringOperationGetItemInfoCallback) pdm_dialog_password_add_item_info_cb,
1524
(GDestroyNotify) g_free);
1528
pdm_dialog_password_remove_dummy_cb (GnomeKeyringResult result,
1440
g_hash_table_unref (attributes);
1534
1444
pdm_dialog_password_remove (PdmActionInfo *info,
1537
EphyPasswordInfo *pinfo = (EphyPasswordInfo *) data;
1447
SecretItem *item = SECRET_ITEM (data);
1539
gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
1541
(GnomeKeyringOperationDoneCallback) pdm_dialog_password_remove_dummy_cb,
1449
/* We don't really do anything when the item is deleted, so
1450
just directly call finish(). The method signature fits well
1452
secret_item_delete (item, NULL,
1453
(GAsyncReadyCallback)secret_item_delete_finish, NULL);
1546
1456
/* common routines */