aboutsummaryrefslogtreecommitdiffstats
path: root/smime/gui/component.c
blob: 1b27f2d3d2bc2c8d0186bbce4559c26e3fd6c32e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Authors: Chris Toshok <toshok@ximian.com>
 *
 *  Copyright (C) 2004 Novell, Inc. (www.novell.com)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 *
 */


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <libgnome/gnome-i18n.h>
#include "e-cert-db.h"
#include "e-util/e-passwords.h"
#include "pk11func.h"

static gboolean
smime_pk11_passwd (ECertDB *db, PK11SlotInfo* slot, gboolean retry, char **passwd, gpointer arg)
{
    char *prompt;
    char *slot_name = g_strdup (PK11_GetSlotName (slot));

    g_strchomp (slot_name);

    prompt = g_strdup_printf (_("Enter the password for `%s'"), slot_name);
    g_free (slot_name);

    *passwd = e_passwords_ask_password (_("Enter password"), NULL, NULL,
                        prompt, TRUE,
                        E_PASSWORDS_DO_NOT_REMEMBER, NULL,
                        NULL);

    g_free (prompt);

    /* this should return FALSE if they canceled. */
    return TRUE;
}

void
smime_component_init (void)
{
    static gboolean init_done = FALSE;
    if (init_done)
        return;

    init_done = TRUE;
    g_signal_connect (e_cert_db_peek (),
              "pk11_passwd",
              G_CALLBACK (smime_pk11_passwd), NULL);
}