Index: camel/providers/groupwise/camel-groupwise-utils.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-utils.c	(revision 8054)
+++ camel/providers/groupwise/camel-groupwise-utils.c	(working copy)
@@ -306,7 +306,7 @@ send_as_attachment (EGwConnection *cnc, 
 		if (camel_content_type_is (type, "application", "pgp-signature")) {
 			char *temp_str;
 			int temp_len;
-			temp_str = soup_base64_encode (content->buffer->data, content->buffer->len);
+			temp_str = g_base64_encode (content->buffer->data, content->buffer->len);
 			temp_len = strlen (temp_str);
 			attachment->data = g_strdup (temp_str);
 			attachment->size = temp_len;
@@ -314,7 +314,7 @@ send_as_attachment (EGwConnection *cnc, 
 			temp_str = NULL;
 			temp_len = 0;
 		} else {
-			attachment->data = soup_base64_encode(content->buffer->data, content->buffer->len);
+			attachment->data = g_base64_encode(content->buffer->data, content->buffer->len);
 			attachment->size = strlen (attachment->data);
 		}
 	} else {
@@ -323,7 +323,7 @@ send_as_attachment (EGwConnection *cnc, 
 		if (!strcmp (attachment->contentType, "multipart/digest")) {
 			/* FIXME? */
 		} else {
-			temp_str = soup_base64_encode (content->buffer->data, content->buffer->len);
+			temp_str = g_base64_encode (content->buffer->data, content->buffer->len);
 			temp_len = strlen (temp_str);
 			attachment->data = g_strdup (temp_str);
 			attachment->size = temp_len;
Index: camel/providers/groupwise/camel-groupwise-folder.c
===================================================================
--- camel/providers/groupwise/camel-groupwise-folder.c	(revision 8054)
+++ camel/providers/groupwise/camel-groupwise-folder.c	(working copy)
@@ -1696,7 +1696,7 @@ groupwise_folder_item_to_msg( CamelFolde
 						if (status == E_GW_CONNECTION_STATUS_OK) {
 							char *temp = NULL;
 	
-							temp = soup_base64_decode(t_attach, &len_iter);
+							temp = g_base64_decode(t_attach, &len_iter);
 							gstr = g_string_append_len (gstr, temp, len_iter);
 							g_free (temp);
 							len += len_iter;
@@ -1834,7 +1834,7 @@ groupwise_folder_item_to_msg( CamelFolde
 							int len_iter = 0;
 							char *temp = NULL;
 	
-							temp = soup_base64_decode(t_attach, &len_iter);
+							temp = g_base64_decode(t_attach, &len_iter);
 							gstr = g_string_append_len (gstr, temp, len_iter);
 							g_free (temp);
 							len += len_iter;
Index: servers/exchange/lib/e2k-encoding-utils.c
===================================================================
--- servers/exchange/lib/e2k-encoding-utils.c	(revision 8054)
+++ servers/exchange/lib/e2k-encoding-utils.c	(working copy)
@@ -1,152 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/* Copyright (C) 2001-2004 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * 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 Lesser General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "e2k-encoding-utils.h"
-
-#include <string.h>
-
-static const char *b64_alphabet =
-	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-/**
- * e2k_base64_encode:
- * @data: binary data
- * @len: the length of @data
- *
- * Base64-encodes @len bytes of data at @data.
- *
- * Return value: the base64-encoded representation of @data, which
- * the caller must free.
- **/
-char *
-e2k_base64_encode (const guint8 *data, int len)
-{
-	char *buf, *p;
-
-	p = buf = g_malloc (((len + 2) / 3) * 4 + 1);
-	while (len >= 3) {
-		p[0] = b64_alphabet[ (data[0] >> 2) & 0x3f];
-		p[1] = b64_alphabet[((data[0] << 4) & 0x30) +
-				    ((data[1] >> 4) & 0x0f)];
-		p[2] = b64_alphabet[((data[1] << 2) & 0x3c) +
-				    ((data[2] >> 6) & 0x03)];
-		p[3] = b64_alphabet[  data[2]       & 0x3f];
-
-		data += 3;
-		p += 4;
-		len -= 3;
-	}
-
-	switch (len) {
-	case 2:
-		p[0] = b64_alphabet[ (data[0] >> 2) & 0x3f];
-		p[1] = b64_alphabet[((data[0] << 4) & 0x30) +
-				    ((data[1] >> 4) & 0xf)];
-		p[2] = b64_alphabet[ (data[1] << 2) & 0x3c];
-		p[3] = '=';
-		p += 4;
-		break;
-	case 1:
-		p[0] = b64_alphabet[ (data[0] >> 2) & 0x3f];
-		p[1] = b64_alphabet[ (data[0] << 4) & 0x30];
-		p[2] = '=';
-		p[3] = '=';
-		p += 4;
-		break;
-	}
-
-	*p = '\0';
-	return buf;
-}
-
-static guint8 base64_unphabet[] = {
-	-1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -1, -1,
-	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-	-2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
-	52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-	-1,  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, -1, -1, -1, -1, -1,
-	-1, 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, -1, -1, -1, -1, -1,
-};
-#define E2K_B64_SPACE ((guint8)-2)
-#define E2K_B64_BAD   ((guint8)-1)
-
-/**
- * e2k_base64_decode:
- * @string: base64-encoded data
- *
- * Decodes the base64-encoded data in @string.
- *
- * Return value: the binary data encoded in @string
- **/
-GByteArray *
-e2k_base64_decode (const char *string)
-{
-	GByteArray *rc;
-	int bits, length, qw = 0;
-	guint8 *data;
-
-	rc = g_byte_array_new ();
-
-	length = strlen (string);
-	if (length == 0)
-		return rc;
-
-	g_byte_array_set_size (rc, ((length / 4) + 1) * 3);
-
-	data = rc->data;
-	for (; *string; string++) {
-		if ((unsigned char)*string > 127)
-			break;
-		bits = base64_unphabet[(unsigned char)*string];
-		if (bits == E2K_B64_BAD)
-			break;
-		else if (bits == E2K_B64_SPACE)
-			continue;
-
-		switch (qw++) {
-		case 0:
-			data[0]  = (bits << 2) & 0xfc;
-			break;
-		case 1:
-			data[0] |= (bits >> 4) & 0x03;
-			data[1]  = (bits << 4) & 0xf0;
-			break;
-		case 2:
-			data[1] |= (bits >> 2) & 0x0f;
-			data[2]  = (bits << 6) & 0xc0;
-			break;
-		case 3:
-			data[2] |=  bits       & 0x3f;
-			data += 3;
-			qw = 0;
-			break;
-		}
-	}
-
-	rc->len = data - rc->data;
-	if (qw > 1)
-		rc->len += qw - 1;
-	return rc;
-}
Index: servers/exchange/lib/e2k-encoding-utils.h
===================================================================
--- servers/exchange/lib/e2k-encoding-utils.h	(revision 8054)
+++ servers/exchange/lib/e2k-encoding-utils.h	(working copy)
@@ -1,12 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Copyright (C) 2001-2004 Novell, Inc. */
-
-#ifndef E2K_ENCODING_UTILS_H
-#define E2K_ENCODING_UTILS_H
-
-#include <glib.h>
-
-char       *e2k_base64_encode (const guint8 *data, int len); 
-GByteArray *e2k_base64_decode (const char *string);
-
-#endif /* E2K_ENCODING_UTILS_H */
Index: servers/exchange/lib/Makefile.am
===================================================================
--- servers/exchange/lib/Makefile.am	(revision 8054)
+++ servers/exchange/lib/Makefile.am	(working copy)
@@ -80,8 +80,6 @@ libexchange_la_SOURCES =					\
 	e2k-autoconfig.h					\
 	e2k-context.c						\
 	e2k-context.h						\
-	e2k-encoding-utils.c					\
-	e2k-encoding-utils.h					\
 	e2k-freebusy.c						\
 	e2k-freebusy.h						\
 	e2k-global-catalog.c					\
Index: servers/groupwise/e-gw-item.c
===================================================================
--- servers/groupwise/e-gw-item.c	(revision 8054)
+++ servers/groupwise/e-gw-item.c	(working copy)
@@ -1923,7 +1923,7 @@ e_gw_item_new_from_soap_parameter (const
 
 			if (msg && length) {
 				len = atoi (length);
-				item->priv->message = soup_base64_decode  (msg, &len);
+				item->priv->message = g_base64_decode  (msg, &len);
 				if (!(item->priv->message)) {
 					item->priv->msg_body_id = soup_soap_parameter_get_property (part, "id") ;
 				} 
@@ -3005,7 +3005,7 @@ e_gw_item_set_calendar_item_elements (EG
 	if (priv->message) {
 		char *str;
 		
-		str = soup_base64_encode (priv->message, strlen (priv->message));
+		str = g_base64_encode (priv->message, strlen (priv->message));
 		dtstring = g_strdup_printf ("%d", (int)strlen (str));
 		soup_soap_message_add_attribute (msg, "length", dtstring, NULL, NULL);
 		g_free (dtstring);
@@ -3185,7 +3185,7 @@ e_gw_item_append_to_soap_message (EGwIte
 			char *str ;
 			char *str_len ;
 
-			str = soup_base64_encode (priv->message, strlen (priv->message));
+			str = g_base64_encode (priv->message, strlen (priv->message));
 			//str = g_strdup (priv->message);
 			str_len = g_strdup_printf ("%d", str ? (int)strlen (str) : 0);
 			soup_soap_message_start_element (msg, "part", NULL, NULL);
@@ -3427,7 +3427,7 @@ append_event_changes_to_soap_message (EG
 		if (priv->message) {
 			char *str, *message;
 
-			str = soup_base64_encode (priv->message, strlen (priv->message));
+			str = g_base64_encode (priv->message, strlen (priv->message));
 			message = g_strdup_printf ("%d", (int)strlen (str));
 			soup_soap_message_add_attribute (msg, "length", message, NULL, NULL);
 			g_free (message);
Index: servers/groupwise/e-gw-connection.c
===================================================================
--- servers/groupwise/e-gw-connection.c	(revision 8054)
+++ servers/groupwise/e-gw-connection.c	(working copy)
@@ -2583,7 +2583,7 @@ e_gw_connection_get_attachment (EGwConne
         
 	if (buffer && buf_length) {
 		int len = atoi (buf_length) ;
-		*attachment = soup_base64_decode (buffer,&len) ;
+		*attachment = g_base64_decode (buffer,&len) ;
 		*attach_length = len ;
 	}
 
Index: addressbook/tests/ebook/test-photo.c
===================================================================
--- addressbook/tests/ebook/test-photo.c	(revision 8054)
+++ addressbook/tests/ebook/test-photo.c	(working copy)
@@ -23,8 +23,6 @@ eor7UoAje18FtmLe9eeQT3EXPcglkJRPbv71EWu7
 TleNB84DnjkD0P9VlxT4Nqck9pmn8JuFp2zo0cgCWFi2e7555/NSHXLadso2m3sU0NxlV65HM+\
 VdTW3rgwvsUpSvAFKUoAUxSlAClKUAKUpQB//2Q==";
 
-size_t _evc_base64_decode_simple (char *data, size_t len);
-
 int
 main (int argc, char **argv)
 {
@@ -38,8 +36,7 @@ main (int argc, char **argv)
 	photo = g_new (EContactPhoto, 1);
 	photo->type = E_CONTACT_PHOTO_TYPE_INLINED;
 	photo->data.inlined.mime_type = NULL;
-	photo->data.inlined.data = (guchar*)g_strdup (photo_data);
-	photo->data.inlined.length = _evc_base64_decode_simple ((char*)photo->data.inlined.data, strlen (photo_data));
+	photo->data.inlined.data = g_base64_decode (photo_data, &photo->data.inlined.length);
 
 	/* set the photo */
 	e_contact_set (contact, E_CONTACT_PHOTO, photo);
Index: addressbook/libebook/e-vcard.c
===================================================================
--- addressbook/libebook/e-vcard.c	(revision 8054)
+++ addressbook/libebook/e-vcard.c	(working copy)
@@ -64,12 +64,6 @@ struct _EVCardAttributeParam {
 
 static GObjectClass *parent_class;
 
-static void   _evc_base64_init(void);
-static size_t _evc_base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save);
-static size_t _evc_base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state, unsigned int *save);
-size_t _evc_base64_decode_simple (char *data, size_t len);
-char  *_evc_base64_encode_simple (const char *data, size_t len);
-
 static void
 e_vcard_dispose (GObject *object)
 {
@@ -98,8 +92,6 @@ e_vcard_class_init (EVCardClass *klass)
 	parent_class = g_type_class_ref (G_TYPE_OBJECT);
 
 	object_class->dispose = e_vcard_dispose;
-
-	_evc_base64_init();
 }
 
 static void
@@ -1217,7 +1209,7 @@ e_vcard_attribute_add_value_decoded (EVC
 		g_warning ("can't add_value_decoded with an attribute using RAW encoding.  you must set the ENCODING parameter first");
 		break;
 	case EVC_ENCODING_BASE64: {
-		char *b64_data = _evc_base64_encode_simple (value, len);
+		char *b64_data = g_base64_encode (value, len);
 		GString *decoded = g_string_new_len (value, len);
 
 		/* make sure the decoded list is up to date */
@@ -1787,8 +1779,10 @@ e_vcard_attribute_get_values_decoded (EV
 			break;
 		case EVC_ENCODING_BASE64:
 			for (l = attr->values; l; l = l->next) {
-				char *decoded = g_strdup ((char*)l->data);
-				int len = _evc_base64_decode_simple (decoded, strlen (decoded));
+				guchar *decoded;
+				gsize len;
+
+				decoded = g_base64_decode (l->data, &len);
 				attr->decoded_values = g_list_prepend (attr->decoded_values, g_string_new_len (decoded, len));
 				g_free (decoded);
 			}
@@ -1992,233 +1986,3 @@ e_vcard_attribute_param_get_values (EVCa
 
 	return param->values;
 }
-
-
-
-/* encoding/decoding stuff ripped from camel-mime-utils.c */
-
-static char *_evc_base64_alphabet =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-static unsigned char _evc_base64_rank[256];
-
-static void
-_evc_base64_init(void)
-{
-	int i;
-
-	memset(_evc_base64_rank, 0xff, sizeof(_evc_base64_rank));
-	for (i=0;i<64;i++) {
-		_evc_base64_rank[(unsigned int)_evc_base64_alphabet[i]] = i;
-	}
-	_evc_base64_rank['='] = 0;
-}
-
-/* call this when finished encoding everything, to
-   flush off the last little bit */
-static size_t
-_evc_base64_encode_close(unsigned char *in, size_t inlen, gboolean break_lines, unsigned char *out, int *state, int *save)
-{
-	int c1, c2;
-	unsigned char *outptr = out;
-
-	if (inlen>0)
-		outptr += _evc_base64_encode_step(in, inlen, break_lines, outptr, state, save);
-
-	c1 = ((unsigned char *)save)[1];
-	c2 = ((unsigned char *)save)[2];
-	
-	d(printf("mode = %d\nc1 = %c\nc2 = %c\n",
-		 (int)((char *)save)[0],
-		 (int)((char *)save)[1],
-		 (int)((char *)save)[2]));
-
-	switch (((char *)save)[0]) {
-	case 2:
-		outptr[2] = _evc_base64_alphabet[ ( (c2 &0x0f) << 2 ) ];
-		g_assert(outptr[2] != 0);
-		goto skip;
-	case 1:
-		outptr[2] = '=';
-	skip:
-		outptr[0] = _evc_base64_alphabet[ c1 >> 2 ];
-		outptr[1] = _evc_base64_alphabet[ c2 >> 4 | ( (c1&0x3) << 4 )];
-		outptr[3] = '=';
-		outptr += 4;
-		break;
-	}
-	if (break_lines)
-		*outptr++ = '\n';
-
-	*save = 0;
-	*state = 0;
-
-	return outptr-out;
-}
-
-/*
-  performs an 'encode step', only encodes blocks of 3 characters to the
-  output at a time, saves left-over state in state and save (initialise to
-  0 on first invocation).
-*/
-static size_t
-_evc_base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save)
-{
-	register unsigned char *inptr, *outptr;
-
-	if (len<=0)
-		return 0;
-
-	inptr = in;
-	outptr = out;
-
-	d(printf("we have %d chars, and %d saved chars\n", len, ((char *)save)[0]));
-
-	if (len + ((char *)save)[0] > 2) {
-		unsigned char *inend = in+len-2;
-		register int c1, c2, c3;
-		register int already;
-
-		already = *state;
-
-		switch (((char *)save)[0]) {
-		case 1:	c1 = ((unsigned char *)save)[1]; goto skip1;
-		case 2:	c1 = ((unsigned char *)save)[1];
-			c2 = ((unsigned char *)save)[2]; goto skip2;
-		}
-		
-		/* yes, we jump into the loop, no i'm not going to change it, it's beautiful! */
-		while (inptr < inend) {
-			c1 = *inptr++;
-		skip1:
-			c2 = *inptr++;
-		skip2:
-			c3 = *inptr++;
-			*outptr++ = _evc_base64_alphabet[ c1 >> 2 ];
-			*outptr++ = _evc_base64_alphabet[ c2 >> 4 | ( (c1&0x3) << 4 ) ];
-			*outptr++ = _evc_base64_alphabet[ ( (c2 &0x0f) << 2 ) | (c3 >> 6) ];
-			*outptr++ = _evc_base64_alphabet[ c3 & 0x3f ];
-			/* this is a bit ugly ... */
-			if (break_lines && (++already)>=19) {
-				*outptr++='\n';
-				already = 0;
-			}
-		}
-
-		((char *)save)[0] = 0;
-		len = 2-(inptr-inend);
-		*state = already;
-	}
-
-	d(printf("state = %d, len = %d\n",
-		 (int)((char *)save)[0],
-		 len));
-
-	if (len>0) {
-		register char *saveout;
-
-		/* points to the slot for the next char to save */
-		saveout = & (((char *)save)[1]) + ((char *)save)[0];
-
-		/* len can only be 0 1 or 2 */
-		switch(len) {
-		case 2:	*saveout++ = *inptr++;
-		case 1:	*saveout++ = *inptr++;
-		}
-		((char *)save)[0]+=len;
-	}
-
-	d(printf("mode = %d\nc1 = %c\nc2 = %c\n",
-		 (int)((char *)save)[0],
-		 (int)((char *)save)[1],
-		 (int)((char *)save)[2]));
-
-	return outptr-out;
-}
-
-
-/**
- * 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 size_t
-_evc_base64_decode_step(unsigned char *in, size_t 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 = _evc_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 (_evc_base64_rank[*inptr] != 0xff) {
-			if (*inptr == '=' && outptr>out)
-				outptr--;
-			i--;
-		}
-	}
-
-	/* if i!= 0 then there is a truncation error! */
-	return outptr-out;
-}
-
-char *
-_evc_base64_encode_simple (const char *data, size_t len)
-{
-	unsigned char *out;
-	int state = 0, outlen;
-	int save = 0;
-
-	g_return_val_if_fail (data != NULL, NULL);
-
-	out = g_malloc (len * 4 / 3 + 5);
-	outlen = _evc_base64_encode_close ((unsigned char *)data, len, FALSE,
-				      out, &state, &save);
-	out[outlen] = '\0';
-	return (char *)out;
-}
-
-size_t
-_evc_base64_decode_simple (char *data, size_t len)
-{
-	int state = 0;
-	unsigned int save = 0;
-
-	g_return_val_if_fail (data != NULL, 0);
-
-	return _evc_base64_decode_step ((unsigned char *)data, len,
-					(unsigned char *)data, &state, &save);
-}
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	(revision 8054)
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	(working copy)
@@ -305,7 +305,7 @@ e_cal_backend_groupwise_set_attachments_
 		attach_item->name = g_strdup (filename + strlen(uid) + 1);
 		/* do a base64 encoding so it can be embedded in a soap
 		 * message */
-		encoded_data = soup_base64_encode (file_contents, file_len);
+		encoded_data = g_base64_encode (file_contents, file_len);
 		attach_item->data = encoded_data;
 		attach_item->size = strlen (encoded_data); 
 
