~drbob/+junk/diary-main

« back to all changes in this revision

Viewing changes to src/storage-manager.c

  • Committer: Philip Withnall
  • Date: 2008-05-22 06:36:38 UTC
  • Revision ID: philip@tecnocode.co.uk-20080522063638-azgvqecjpb6uxe88
2008-05-22  Philip Withnall  <philip@tecnocode.co.uk>

        * src/storage-manager.c: Allow the application to close gracefully
        if an encryption key can't be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "storage-manager.h"
33
33
#include "config.h"
34
34
 
 
35
#define ENCRYPTION_KEY_GCONF_PATH "/desktop/pgp/default_key"
 
36
 
35
37
static void diary_storage_manager_init (DiaryStorageManager *self);
36
38
static void diary_storage_manager_finalize (GObject *object);
37
39
static void diary_storage_manager_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
385
387
        guint i;
386
388
        gchar *encryption_key;
387
389
 
388
 
        encryption_key = gconf_client_get_string (diary->gconf_client, "/desktop/pgp/default_key", NULL);
 
390
        encryption_key = gconf_client_get_string (diary->gconf_client, ENCRYPTION_KEY_GCONF_PATH, NULL);
389
391
        if (encryption_key == NULL || encryption_key[0] == '\0')
390
392
                return NULL;
391
393
 
470
472
 
471
473
#ifdef ENABLE_ENCRYPTION
472
474
        encryption_key = get_encryption_key ();
473
 
        if (encryption_key == NULL)
 
475
        if (encryption_key == NULL) {
 
476
                g_warning (_("Error getting encryption key: GConf key \"%s\" invalid or empty."), ENCRYPTION_KEY_GCONF_PATH);
 
477
                if (diary->quitting == TRUE)
 
478
                        diary_quit_real ();
474
479
                return;
 
480
        }
475
481
 
476
482
        /* Encrypt the plain DB file */
477
483
        if (encrypt_database (self, encryption_key, &error) != TRUE) {