~ubuntu-branches/ubuntu/trusty/gnome-keyring/trusty-updates

« back to all changes in this revision

Viewing changes to daemon/gpg-agent/gkd-gpg-agent-ops.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-08-24 10:32:10 UTC
  • mfrom: (1.1.80)
  • Revision ID: package-import@ubuntu.com-20120824103210-g4880o16ruf5dq0y
Tags: 3.5.90-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
323
323
        g_free (method);
324
324
}
325
325
 
326
 
static void
327
 
save_unlock_options (GcrPrompt *prompt)
328
 
{
329
 
        GSettings *settings;
330
 
 
331
 
        settings = gkd_gpg_agent_settings ();
332
 
 
333
 
        if (gcr_prompt_get_choice_chosen (prompt))
334
 
                g_settings_set_string (settings, "gpg-cache-method", GCR_UNLOCK_OPTION_ALWAYS);
335
 
}
336
 
 
337
326
static GcrPrompt *
338
327
open_password_prompt (GckSession *session,
339
328
                      const gchar *keyid,
406
395
                 const gchar *prompt_text, const gchar *description, gboolean confirm)
407
396
{
408
397
        GckBuilder builder = GCK_BUILDER_INIT;
 
398
        GSettings *settings;
409
399
        GckAttributes *attrs;
410
400
        gchar *password = NULL;
411
401
        GcrPrompt *prompt;
412
402
        gboolean chosen;
413
403
        GError *error = NULL;
 
404
        gint lifetime;
 
405
        gchar *method;
414
406
 
415
407
        g_assert (GCK_IS_SESSION (session));
416
408
 
431
423
        }
432
424
 
433
425
        if (password != NULL && keyid != NULL) {
 
426
                settings = gkd_gpg_agent_settings ();
434
427
 
435
428
                /* Load up the save options */
436
429
                chosen = gcr_prompt_get_choice_chosen (prompt);
437
430
 
438
 
                if (chosen)
 
431
                if (chosen) {
 
432
                        g_settings_set_string (settings, "gpg-cache-method", GCR_UNLOCK_OPTION_ALWAYS);
439
433
                        gck_builder_add_string (&builder, CKA_G_COLLECTION, "login");
440
 
                else
 
434
 
 
435
                } else {
 
436
                        method = g_settings_get_string (settings, "gpg-cache-method");
 
437
                        lifetime = g_settings_get_int (settings, "gpg-cache-ttl");
 
438
 
 
439
                        if (g_strcmp0 (method, GCR_UNLOCK_OPTION_IDLE) == 0) {
 
440
                                gck_builder_add_boolean (&builder, CKA_GNOME_TRANSIENT, TRUE);
 
441
                                gck_builder_add_ulong (&builder, CKA_G_DESTRUCT_IDLE, lifetime);
 
442
 
 
443
                        } else if (g_strcmp0 (method, GCR_UNLOCK_OPTION_TIMEOUT) == 0) {
 
444
                                gck_builder_add_boolean (&builder, CKA_GNOME_TRANSIENT, TRUE);
 
445
                                gck_builder_add_ulong (&builder, CKA_G_DESTRUCT_AFTER, lifetime);
 
446
 
 
447
                        } else if (g_strcmp0 (method, GCR_UNLOCK_OPTION_SESSION)){
 
448
                                g_message ("Unsupported gpg-cache-method setting: %s", method);
 
449
                        }
 
450
 
441
451
                        gck_builder_add_string (&builder, CKA_G_COLLECTION, "session");
 
452
                        g_free (method);
 
453
                }
442
454
 
443
455
                /* Now actually save the password */
444
456
                attrs = gck_attributes_ref_sink (gck_builder_end (&builder));
445
457
                do_save_password (session, keyid, description, password, attrs);
446
458
                gck_attributes_unref (attrs);
447
 
 
448
 
                save_unlock_options (prompt);
449
459
        }
450
460
 
451
461
        g_clear_object (&prompt);