aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-09-28 04:20:56 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-09-28 04:20:56 +0800
commit7352689ab7e6cfa835d52035f76756879306cfa9 (patch)
treeece92aafcc46ee9be4a6dcde5273aaedca7517b4
parente2e5e8d754f24a9f5c1ed0434c83dcd486a356eb (diff)
downloadgsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar.gz
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar.bz2
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar.lz
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar.xz
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.tar.zst
gsoc2013-evolution-7352689ab7e6cfa835d52035f76756879306cfa9.zip
** Fixes part of bug #474000
2007-09-27 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #474000 * addressbook/importers/evolution-ldif-importer.c: Remove redundant Base64 codec implementation. Use GLib's. * mail/em-format-html.c (efh_format_headers): * mail/em-migrate.c (upgrade_passwords_1_2): * plugins/face/face.c: Use GLib's Base64 API instead of Camel's. svn path=/trunk/; revision=34325
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/importers/evolution-ldif-importer.c100
-rw-r--r--mail/ChangeLog8
-rw-r--r--mail/em-format-html.c20
-rw-r--r--mail/em-migrate.c7
-rw-r--r--plugins/face/ChangeLog7
-rw-r--r--plugins/face/face.c2
7 files changed, 45 insertions, 106 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index eab43048ab..e1bc214532 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-27 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #474000
+
+ * importers/evolution-ldif-importer.c:
+ Remove redundant Base64 codec implementation. Use GLib's.
+
2007-09-27 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fix for bug #461195
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 63c8f3a049..5080557c17 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -116,93 +116,6 @@ ldif_fields[] = {
};
static int num_ldif_fields = sizeof(ldif_fields) / sizeof (ldif_fields[0]);
-static unsigned char base64_rank[256] = {
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
- 255, 0, 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,255,255,255,255,255,
- 255, 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,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-};
-
-/**
- * base64_decode_step: decode a chunk of base64 encoded data
- * @in: input stream
- * @len: max length of data to decode
- * @out: output stream
- * @state: holds the number of bits that are stored in @save
- * @save: leftover bits that have not yet been decoded
- *
- * Decodes a chunk of base64 encoded data
- **/
-static int
-base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save)
-{
- register unsigned char *inptr, *outptr;
- unsigned char *inend, c;
- register unsigned int v;
- int i;
-
- inend = in+len;
- outptr = out;
-
- /* convert 4 base64 bytes to 3 normal bytes */
- v=*save;
- i=*state;
- inptr = in;
- while (inptr<inend) {
- c = base64_rank[*inptr++];
- if (c != 0xff) {
- v = (v<<6) | c;
- i++;
- if (i==4) {
- *outptr++ = v>>16;
- *outptr++ = v>>8;
- *outptr++ = v;
- i=0;
- }
- }
- }
-
- *save = v;
- *state = i;
-
- /* quick scan back for '=' on the end somewhere */
- /* fortunately we can drop 1 output char for each trailing = (upto 2) */
- i=2;
- while (inptr>in && i) {
- inptr--;
- if (base64_rank[*inptr] != 0xff) {
- if (*inptr == '=')
- outptr--;
- i--;
- }
- }
-
- /* if i!= 0 then there is a truncation error! */
- return outptr-out;
-}
-
-static int
-base64_decode_simple (char *data, int len)
-{
- int state = 0;
- unsigned int save = 0;
-
- return base64_decode_step ((unsigned char *)data, len,
- (unsigned char *)data, &state, &save);
-}
-
static GString *
getValue( char **src )
{
@@ -224,11 +137,14 @@ getValue( char **src )
}
if (need_base64) {
- int new_len;
- /* it's base64 encoded */
- dest = g_string_erase (dest, 0, 2);
- new_len = base64_decode_simple (dest->str, strlen (dest->str));
- dest = g_string_truncate (dest, new_len);
+ guchar *data;
+ gsize length;
+
+ /* XXX g_string_assign_len() would be nice here */
+ data = g_base64_decode (dest->str + 2, &length);
+ g_string_truncate (dest, 0);
+ g_string_append_len (dest, (gchar *) data, length);
+ g_free (data);
}
*src = s;
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 54ac99880c..b55544c979 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-27 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #477045
+
+ * em-format-html.c (efh_format_headers):
+ * em-migrate.c (upgrade_passwords_1_2):
+ Use GLib's Base64 API instead of Camel's.
+
2007-09-27 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fix for bug #461195
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index b8e96ae3d9..eb2ae95c3d 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1786,8 +1786,8 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
const char *photo_name = NULL;
CamelInternetAddress *cia = NULL;
gboolean face_decoded = FALSE;
- char *face_header_value = NULL;
- int face_header_len = 0;
+ guchar *face_header_value = NULL;
+ gsize face_header_len = 0;
char *header_sender = NULL, *header_from = NULL, *name;
gboolean mail_from_delegate = FALSE;
@@ -1896,16 +1896,14 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
if (strstr(header->value, "Evolution"))
have_icon = TRUE;
} else if (!g_ascii_strcasecmp (header->name, "Face") && !face_decoded) {
- char *tmp;
-
- face_decoded = TRUE;
- tmp = g_strdup (header->value);
- for (; *tmp == ' '; tmp++);
+ gchar *cp;
- face_header_len = camel_base64_decode_simple (tmp, strlen(tmp));
- tmp[face_header_len] = 0;
-
- face_header_value = tmp;
+ /* Skip over spaces */
+ for (cp = header->name; *cp == ' '; cp++);
+ face_header_value = g_base64_decode (cp, &face_header_len);
+ face_header_value = g_realloc (face_header_value, face_header_len + 1);
+ face_header_value[face_header_len] = 0;
+ face_decoded = TRUE;
} else if (!g_ascii_strcasecmp (header->name, h->name)) {
efh_format_header(emf, stream, part, header, h->flags, charset);
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 6df7e109c1..2fc53ebf5f 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -778,10 +778,13 @@ upgrade_passwords_1_2(void)
if (namep && valuep) {
char *value = e_bconf_hex_decode(valuep);
+ guchar *decoded;
char *p, *new;
- size_t len;
+ gsize len;
- len = camel_base64_decode_simple(namep, strlen(namep));
+ decoded = g_base64_decode (namep, &len);
+ memcpy (namep, decoded, len);
+ g_free (decoded);
namep[len] = 0;
p = namep;
diff --git a/plugins/face/ChangeLog b/plugins/face/ChangeLog
index a86f11a977..11d9b0814d 100644
--- a/plugins/face/ChangeLog
+++ b/plugins/face/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-27 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #474000
+
+ * face.c:
+ Use GLib's Base64 API instead of Camel's.
+
2007-09-14 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #476231
diff --git a/plugins/face/face.c b/plugins/face/face.c
index 9e17fecc43..a747c3710a 100644
--- a/plugins/face/face.c
+++ b/plugins/face/face.c
@@ -98,7 +98,7 @@ void org_gnome_composer_face (EPlugin * ep, EMMenuTargetWidget * t)
d (printf ("\n\a Invalid Image Size. Please choose a 48*48 image\n\a"));
e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-image-size", NULL, NULL);
} else {
- file_contents = camel_base64_encode_simple (file_contents, length);
+ file_contents = g_base64_encode (file_contents, length);
g_file_set_contents (filename, file_contents, -1, &error);
}
}