From f9b7406f1dbc712cb1b4f40f0e729a25cf24f27c Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 16 Apr 2001 19:01:46 +0000 Subject: Go back to doing the utf8 conversion by hand so that we don't depend on 2001-04-16 Jeffrey Stedfast * camel-pgp-context.c (pgp_verify): Go back to doing the utf8 conversion by hand so that we don't depend on gal. svn path=/trunk/; revision=9387 --- camel/ChangeLog | 3 +++ camel/camel-pgp-context.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 803cd825da..d7ff60cc16 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,8 @@ 2001-04-16 Jeffrey Stedfast + * camel-pgp-context.c (pgp_verify): Go back to doing the utf8 + conversion by hand so that we don't depend on gal. + * Makefile.am: Remove the EXTRA_GNOME_CFLAGS include. * camel-store.c (camel_mkdir_hier): Convenience function that it diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index 0ac877c004..d6a725458a 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -29,9 +29,9 @@ #include "camel-stream-fs.h" #include "camel-stream-mem.h" -#include /* for _() macro */ +#include "camel-charset-map.h" -#include +#include /* for _() macro */ #include #include @@ -52,6 +52,9 @@ #include #include +#include +#include + #define d(x) struct _CamelPgpContextPrivate { @@ -963,9 +966,45 @@ pgp_verify (CamelCipherContext *ctx, CamelStream *istream, } if (diagnostics) { - char *desc; + char *locale, *desc, *outbuf; + size_t inlen, outlen; + iconv_t cd; + + inlen = strlen (diagnostics); + outlen = inlen * 4; + + desc = outbuf = g_new (unsigned char, outlen + 1); + + locale = camel_charset_locale_name (); + if (!locale) + locale = g_strdup ("iso-8859-1"); + + cd = iconv_open ("UTF-8", locale); + g_free (locale); + if (cd != (iconv_t) -1) { + const char *inbuf; + size_t len; + + inbuf = diagnostics; + len = iconv (cd, &inbuf, &inlen, &outbuf, &outlen); + iconv_close (cd); + + desc[len] = '\0'; + } else { + const char *inptr, *inend; + unicode_char_t c; + + inptr = diagnostics; + inend = inptr + inlen; + + while (inptr && inptr < inend) { + inptr = unicode_get_utf8 (inptr, &c); + *outbuf++ = c & 0xff; + } + + *outbuf = '\0'; + } - desc = e_utf8_from_locale_string (diagnostics); camel_cipher_validity_set_description (valid, desc); g_free (desc); } -- cgit v1.2.3