mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
crypto: drop pretense of notmuch_crypto_context_t
notmuch_crypto_context_t was introduced (i think) as some sort of abstraction layer to make notmuch somewhat independent of GMime. But it isn't even useful for GMime 3.0 or later -- we can drop the pretense that it's some sort of abstraction in this case, and just call it what it is, GMimeCryptoContext, which is useful for building against older versions of GMime. This also renames _notmuch_crypto_get_context() to _notmuch_crypto_get_gmime_context().
This commit is contained in:
parent
88f2a72ef1
commit
3e9857a0b9
3 changed files with 16 additions and 17 deletions
16
crypto.c
16
crypto.c
|
@ -21,10 +21,10 @@
|
||||||
#include "notmuch-client.h"
|
#include "notmuch-client.h"
|
||||||
#if (GMIME_MAJOR_VERSION < 3)
|
#if (GMIME_MAJOR_VERSION < 3)
|
||||||
/* Create a GPG context (GMime 2.6) */
|
/* Create a GPG context (GMime 2.6) */
|
||||||
static notmuch_crypto_context_t *
|
static GMimeCryptoContext *
|
||||||
create_gpg_context (_notmuch_crypto_t *crypto)
|
create_gpg_context (_notmuch_crypto_t *crypto)
|
||||||
{
|
{
|
||||||
notmuch_crypto_context_t *gpgctx;
|
GMimeCryptoContext *gpgctx;
|
||||||
|
|
||||||
if (crypto->gpgctx)
|
if (crypto->gpgctx)
|
||||||
return crypto->gpgctx;
|
return crypto->gpgctx;
|
||||||
|
@ -44,10 +44,10 @@ create_gpg_context (_notmuch_crypto_t *crypto)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a PKCS7 context (GMime 2.6) */
|
/* Create a PKCS7 context (GMime 2.6) */
|
||||||
static notmuch_crypto_context_t *
|
static GMimeCryptoContext *
|
||||||
create_pkcs7_context (_notmuch_crypto_t *crypto)
|
create_pkcs7_context (_notmuch_crypto_t *crypto)
|
||||||
{
|
{
|
||||||
notmuch_crypto_context_t *pkcs7ctx;
|
GMimeCryptoContext *pkcs7ctx;
|
||||||
|
|
||||||
if (crypto->pkcs7ctx)
|
if (crypto->pkcs7ctx)
|
||||||
return crypto->pkcs7ctx;
|
return crypto->pkcs7ctx;
|
||||||
|
@ -67,7 +67,7 @@ create_pkcs7_context (_notmuch_crypto_t *crypto)
|
||||||
}
|
}
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *protocol;
|
const char *protocol;
|
||||||
notmuch_crypto_context_t *(*get_context) (_notmuch_crypto_t *crypto);
|
GMimeCryptoContext *(*get_context) (_notmuch_crypto_t *crypto);
|
||||||
} protocols[] = {
|
} protocols[] = {
|
||||||
{
|
{
|
||||||
.protocol = "application/pgp-signature",
|
.protocol = "application/pgp-signature",
|
||||||
|
@ -89,10 +89,10 @@ static const struct {
|
||||||
|
|
||||||
/* for the specified protocol return the context pointer (initializing
|
/* for the specified protocol return the context pointer (initializing
|
||||||
* if needed) */
|
* if needed) */
|
||||||
notmuch_crypto_context_t *
|
GMimeCryptoContext *
|
||||||
_notmuch_crypto_get_context (_notmuch_crypto_t *crypto, const char *protocol)
|
_notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protocol)
|
||||||
{
|
{
|
||||||
notmuch_crypto_context_t *cryptoctx = NULL;
|
GMimeCryptoContext *cryptoctx = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (! protocol) {
|
if (! protocol) {
|
||||||
|
|
|
@ -171,7 +171,7 @@ set_signature_list_destructor (mime_node_t *node)
|
||||||
/* Verify a signed mime node (GMime 2.6) */
|
/* Verify a signed mime node (GMime 2.6) */
|
||||||
static void
|
static void
|
||||||
node_verify (mime_node_t *node, GMimeObject *part,
|
node_verify (mime_node_t *node, GMimeObject *part,
|
||||||
g_mime_3_unused(notmuch_crypto_context_t *cryptoctx))
|
g_mime_3_unused(GMimeCryptoContext *cryptoctx))
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ node_verify (mime_node_t *node, GMimeObject *part,
|
||||||
/* Decrypt and optionally verify an encrypted mime node (GMime 2.6) */
|
/* Decrypt and optionally verify an encrypted mime node (GMime 2.6) */
|
||||||
static void
|
static void
|
||||||
node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,
|
node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,
|
||||||
g_mime_3_unused(notmuch_crypto_context_t *cryptoctx))
|
g_mime_3_unused(GMimeCryptoContext *cryptoctx))
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GMimeDecryptResult *decrypt_result = NULL;
|
GMimeDecryptResult *decrypt_result = NULL;
|
||||||
|
@ -227,7 +227,7 @@ static mime_node_t *
|
||||||
_mime_node_create (mime_node_t *parent, GMimeObject *part)
|
_mime_node_create (mime_node_t *parent, GMimeObject *part)
|
||||||
{
|
{
|
||||||
mime_node_t *node = talloc_zero (parent, mime_node_t);
|
mime_node_t *node = talloc_zero (parent, mime_node_t);
|
||||||
notmuch_crypto_context_t *cryptoctx = NULL;
|
GMimeCryptoContext *cryptoctx = NULL;
|
||||||
|
|
||||||
/* Set basic node properties */
|
/* Set basic node properties */
|
||||||
node->part = part;
|
node->part = part;
|
||||||
|
@ -265,7 +265,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
|
||||||
|| (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify)) {
|
|| (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify)) {
|
||||||
GMimeContentType *content_type = g_mime_object_get_content_type (part);
|
GMimeContentType *content_type = g_mime_object_get_content_type (part);
|
||||||
const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol");
|
const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol");
|
||||||
cryptoctx = _notmuch_crypto_get_context (node->ctx->crypto, protocol);
|
cryptoctx = _notmuch_crypto_get_gmime_context (node->ctx->crypto, protocol);
|
||||||
if (!cryptoctx)
|
if (!cryptoctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
#include "gmime-extra.h"
|
#include "gmime-extra.h"
|
||||||
|
|
||||||
typedef GMimeCryptoContext notmuch_crypto_context_t;
|
|
||||||
/* This is automatically included only since gmime 2.6.10 */
|
/* This is automatically included only since gmime 2.6.10 */
|
||||||
#include <gmime/gmime-pkcs7-context.h>
|
#include <gmime/gmime-pkcs7-context.h>
|
||||||
|
|
||||||
|
@ -76,8 +75,8 @@ typedef struct _notmuch_crypto {
|
||||||
bool verify;
|
bool verify;
|
||||||
bool decrypt;
|
bool decrypt;
|
||||||
#if (GMIME_MAJOR_VERSION < 3)
|
#if (GMIME_MAJOR_VERSION < 3)
|
||||||
notmuch_crypto_context_t* gpgctx;
|
GMimeCryptoContext* gpgctx;
|
||||||
notmuch_crypto_context_t* pkcs7ctx;
|
GMimeCryptoContext* pkcs7ctx;
|
||||||
const char *gpgpath;
|
const char *gpgpath;
|
||||||
#endif
|
#endif
|
||||||
} _notmuch_crypto_t;
|
} _notmuch_crypto_t;
|
||||||
|
@ -182,8 +181,8 @@ void
|
||||||
notmuch_exit_if_unsupported_format (void);
|
notmuch_exit_if_unsupported_format (void);
|
||||||
|
|
||||||
#if (GMIME_MAJOR_VERSION <3)
|
#if (GMIME_MAJOR_VERSION <3)
|
||||||
notmuch_crypto_context_t *
|
GMimeCryptoContext *
|
||||||
_notmuch_crypto_get_context (_notmuch_crypto_t *crypto, const char *protocol);
|
_notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protocol);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue