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 147 148 149 150 151
|
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
/*
* gpgme low-level stuff for gmime/balsa
* Copyright (C) 2011 Albrecht Dreß <albrecht.dress@arcor.de>
*
* 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, 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef LIBBALSA_GPGME_H_
#define LIBBALSA_GPGME_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gpgme.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gmime/gmime.h>
#include "libbalsa-gpgme-cb.h"
#include "gmime-gpgme-signature.h"
G_BEGIN_DECLS
#define GPG_ERR_MULT_SIGNATURES GPG_ERR_USER_13
#define GPG_ERR_KEY_SELECTION GPG_ERR_USER_14
#define GPG_ERR_NOT_SIGNED GPG_ERR_USER_15
#define GPGME_ERROR_QUARK (g_quark_from_static_string("gmime-gpgme"))
struct _gpg_capabilities {
const gchar *gpg_path; /**< OpenPGP engine path */
gboolean export_filter_uid; /**< OpenPGP engine supports the 'keep-uid=...' export-filter option. */
gboolean export_filter_subkey; /**< OpenPGP engine supports the 'drop-subkey=...' export-filter option. */
};
typedef struct _gpg_capabilities gpg_capabilities;
/** Callback to select a key from a list
* Parameters:
* - user name
* - key selection mode
* - list of available keys (gpgme_key_t data elements)
* - protocol
* - parent window
* Return: the key the user selected, or NULL if the operation shall be cancelled
*/
typedef gpgme_key_t(*lbgpgme_select_key_cb) (const gchar *,
lb_key_sel_md_t,
GList *,
gpgme_protocol_t,
GtkWindow *);
/** Callback to ask the user whether a key with low trust shall be accepted
* Parameters:
* - recipient user name (email address)
* - the key with insufficient trust
* - parent window
* Return: TRUE to accept the key, FALSE to reject it
*/
typedef gboolean(*lbgpgme_accept_low_trust_cb) (const gchar *,
gpgme_key_t,
GtkWindow *);
void libbalsa_gpgme_init(gpgme_passphrase_cb_t get_passphrase,
lbgpgme_select_key_cb select_key_cb,
lbgpgme_accept_low_trust_cb accept_low_trust);
const gchar *libbalsa_gpgme_protocol_name(gpgme_protocol_t protocol);
gboolean libbalsa_gpgme_check_crypto_engine(gpgme_protocol_t protocol);
const gpg_capabilities *libbalsa_gpgme_gpg_capabilities(void);
gpgme_ctx_t libbalsa_gpgme_new_with_proto(gpgme_protocol_t protocol,
gpgme_passphrase_cb_t callback,
GtkWindow *parent,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gpgme_ctx_t libbalsa_gpgme_temp_with_proto(gpgme_protocol_t protocol,
gchar **home_dir,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
GMimeGpgmeSigstat *libbalsa_gpgme_verify(GMimeStream * content,
GMimeStream * sig_plain,
gpgme_protocol_t protocol,
gboolean singlepart_mode,
GError ** error)
G_GNUC_WARN_UNUSED_RESULT;
gpgme_hash_algo_t libbalsa_gpgme_sign(const gchar * userid,
GMimeStream * istream,
GMimeStream * ostream,
gpgme_protocol_t protocol,
gboolean singlepart_mode,
GtkWindow * parent, GError ** error);
gboolean libbalsa_gpgme_encrypt(GPtrArray * recipients,
const char *sign_for,
GMimeStream * istream,
GMimeStream * ostream,
gpgme_protocol_t protocol,
gboolean singlepart_mode,
gboolean trust_all_keys,
GtkWindow * parent, GError ** error);
GMimeGpgmeSigstat *libbalsa_gpgme_decrypt(GMimeStream * crypted,
GMimeStream * plain,
gpgme_protocol_t protocol,
GtkWindow * parent,
GError ** error)
G_GNUC_WARN_UNUSED_RESULT;
gchar *libbalsa_gpgme_get_pubkey(gpgme_protocol_t protocol,
const gchar *name,
GtkWindow *parent,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gchar *libbalsa_gpgme_get_seckey(gpgme_protocol_t protocol,
const gchar *name,
GtkWindow *parent,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
void libbalsa_gpgme_set_error(GError **error,
gpgme_error_t gpgme_err,
const gchar *format,
...)
G_GNUC_PRINTF(3, 4);
G_END_DECLS
#endif /* LIBBALSA_GPGME_H_ */
|