~carifio/seahorse/seahorse-remove-broken-help-buttons

« back to all changes in this revision

Viewing changes to pgp/seahorse-pgp-keysets.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-07-22 09:20:59 UTC
  • mto: (3.2.1 sid) (1.4.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 59.
  • Revision ID: james.westby@ubuntu.com-20080722092059-q336t49r9uaveij3
Tags: upstream-2.23.5
ImportĀ upstreamĀ versionĀ 2.23.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Seahorse
 
3
 * 
 
4
 * Copyright (C) 2008 Stefan Walter
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or modify 
 
7
 * it under the terms of the GNU Lesser General Public License as
 
8
 * published by the Free Software Foundation; either version 2.1 of
 
9
 * the License, or (at your option) any later version.
 
10
 *  
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *  
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
19
 * 02111-1307, USA.  
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include "seahorse-gconf.h"
 
25
#include "seahorse-key.h"
 
26
 
 
27
#include "seahorse-pgp-module.h"
 
28
#include "seahorse-pgp-keysets.h"
 
29
 
 
30
/* -----------------------------------------------------------------------------
 
31
 * COMMON KEYSETS 
 
32
 */
 
33
 
 
34
static void
 
35
pgp_signers_gconf_notify (GConfClient *client, guint id, GConfEntry *entry, 
 
36
                          SeahorseSet *skset)
 
37
{
 
38
    /* Default key changed, refresh */
 
39
    seahorse_set_refresh (skset);
 
40
}
 
41
 
 
42
static gboolean 
 
43
pgp_signers_match (SeahorseObject *obj, gpointer data)
 
44
{
 
45
    SeahorseKey *key, *defkey;
 
46
    
 
47
    if (!SEAHORSE_IS_KEY (obj))
 
48
            return FALSE;
 
49
    
 
50
    key = SEAHORSE_KEY (obj);
 
51
    defkey = seahorse_context_get_default_key (SCTX_APP ());
 
52
    
 
53
    /* Default key overrides all, and becomes the only signer available*/
 
54
    if (defkey && seahorse_key_get_keyid (key) != seahorse_key_get_keyid (defkey))
 
55
        return FALSE;
 
56
    
 
57
    return TRUE;
 
58
}
 
59
 
 
60
SeahorseSet*     
 
61
seahorse_keyset_pgp_signers_new ()
 
62
{
 
63
    SeahorseObjectPredicate *pred = g_new0(SeahorseObjectPredicate, 1);
 
64
    SeahorseSet *skset;
 
65
    
 
66
    pred->location = SEAHORSE_LOCATION_LOCAL;
 
67
    pred->id = SEAHORSE_PGP;
 
68
    pred->usage = SEAHORSE_USAGE_PRIVATE_KEY;
 
69
    pred->flags = SKEY_FLAG_CAN_SIGN;
 
70
    pred->nflags = SKEY_FLAG_EXPIRED | SKEY_FLAG_REVOKED | SKEY_FLAG_DISABLED;
 
71
    pred->custom = pgp_signers_match;
 
72
    
 
73
    skset = seahorse_set_new_full (pred);
 
74
    g_object_set_data_full (G_OBJECT (skset), "pgp-signers-predicate", pred, g_free);
 
75
    
 
76
    seahorse_gconf_notify_lazy (SEAHORSE_DEFAULT_KEY, 
 
77
                                (GConfClientNotifyFunc)pgp_signers_gconf_notify, 
 
78
                                skset, skset);
 
79
    return skset;
 
80
}