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

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * Seahorse
 *
 * Copyright (C) 2004 Stefan Walter
 *
 * 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 Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/** 
 * Extensions to GPGME for not yet or 'won't support' features.
 */

#ifndef __SEAHORSE_GPGMEX_H__
#define __SEAHORSE_GPGMEX_H__

#include "config.h"
#include <gpgme.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#include "seahorse-validity.h"

/* -----------------------------------------------------------------------------
 * ERROR HANDLING 
 */

#define GPG_IS_OK(e)        (gpgme_err_code (e) == GPG_ERR_NO_ERROR)
#define GPG_OK              (gpgme_error (GPG_ERR_NO_ERROR))
#define GPG_E(e)            (gpgme_error (e))

#define SEAHORSE_GPGME_ERROR  (seahorse_gpgme_error_domain ())

GQuark      seahorse_gpgme_error_domain    (void);

void        seahorse_gpgme_to_error        (gpgme_error_t gerr, GError** err);

/* -----------------------------------------------------------------------------
 * DATA ALLOCATION
 */
 
/* 
 * GTK/Glib use a model where if allocation fails, the program exits. These 
 * helper functions extend certain GPGME calls to provide the same behavior.
 */
 
gpgme_data_t        gpgmex_data_new          ();

void                gpgmex_data_release      (gpgme_data_t data);

int                 gpgmex_data_write_all    (gpgme_data_t data, const void* buffer, size_t len);

gpgme_data_t        gpgmex_data_new_from_mem (const char *buffer, size_t size,
                                              gboolean copy);

/* -----------------------------------------------------------------------------
 * KEY ALLOCATION
 */
 
/*
 * Functions for allocating keys we find from sources other than 
 * GPGME, like servers for example. 
 * 
 * Yes, we allocate gpgme_key_t structures and use them. The structure 
 * is open, we play by the rules and don't use fields we're asked not 
 * to. Of course we should never pass these structures to GPGME functions
 * like gpgme_key_unref etc....
 */

enum {
    GPGMEX_KEY_REVOKED  = 0x01,
    GPGMEX_KEY_DISABLED = 0x02
};

/* A photo id from a key */
typedef struct _gpgmex_photo_id {
    struct _gpgmex_photo_id *next;
    
    guint uid;            /* The actual uid used with gpgpme_op_edit */
    GdkPixbuf *photo;     /* The photo itself */
} *gpgmex_photo_id_t;
    
gpgme_key_t gpgmex_key_alloc         ();

void        gpgmex_key_add_subkey    (gpgme_key_t key,
                                      const char *fpr,
                                      unsigned int flags,
                                      long int timestamp,
                                      long int expires,
                                      unsigned int length,
                                      gpgme_pubkey_algo_t algo);

void        gpgmex_key_add_uid       (gpgme_key_t key,
                                      const char *uid,
                                      unsigned int flags);

void        gpgmex_key_copy_subkey   (gpgme_key_t key,
                                      gpgme_subkey_t subkey);

void        gpgmex_key_copy_uid      (gpgme_key_t key,
                                      gpgme_user_id_t uid);                                      
                                      
int         gpgmex_key_is_gpgme      (gpgme_key_t key);

void        gpgmex_key_ref           (gpgme_key_t key);

void        gpgmex_key_unref         (gpgme_key_t key);

void        gpgmex_combine_keys      (gpgme_key_t k, gpgme_key_t key);

void        gpgmex_free_keys         (gpgme_key_t* keys);

gpgmex_photo_id_t 
            gpgmex_photo_id_alloc    (guint uid);
            
void        gpgmex_photo_id_free     (gpgmex_photo_id_t photoid);

void        gpgmex_photo_id_free_all (gpgmex_photo_id_t photoid);


/* -----------------------------------------------------------------------------
 * EXTRA FUNCTIONALITY
 */

gpgme_error_t gpgmex_op_export_secret  (gpgme_ctx_t ctx, 
                                        const char *pattern,
                                        gpgme_data_t keydata);

gpgme_error_t gpgmex_op_num_uids       (gpgme_ctx_t ctx, 
                                        const char *pattern,
                                        guint *number);

SeahorseValidity    gpgmex_validity_to_seahorse    (gpgme_validity_t validity);

#endif /* __SEAHORSE_GPGMEX_H__ */