diff --git a/ChangeLog b/ChangeLog
index 84b7d7d..38162bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-15  Javier Jardon  <javierjc1982@gmail.com>
+
+	Reviewed by: Jose Dapena Paz  <jdapena@igalia.com>
+
+	* Implementation of TnyStream based in GIO
+	* Use GIO based streams instead of vfs based streams
+	in tinymail GTK.
+	* Remove includes requiring vfs streams wherever they
+	were not needed.
+
 2009-10-15  Carl Simonson <simonsonc@gmail.com>
 
 	Committed by: Sergio Villar Senin <svillar@igalia.com>
diff --git a/Makefile.am b/Makefile.am
index 7e2623e..4632196 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,11 +3,17 @@ SUBDIRS = m4
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS += libtinymail 
-SUBDIRS += libtinymailui 
+SUBDIRS += libtinymailui
+
+if BUILD_GIO
+SUBDIRS += libtinymail-gio
+endif
 
 if BUILD_GNOME
 SUBDIRS += libtinymailui-gnome-keyring
-SUBDIRS += libtinymail-gnomevfs 
+if !BUILD_GIO
+SUBDIRS += libtinymail-gnomevfs
+endif
 endif
 
 if BUILD_UIGTK
@@ -27,8 +33,10 @@ SUBDIRS += libtinymailui-gtkhtml
 endif
 
 if BUILD_MAEMO
+if !BUILD_GIO
 SUBDIRS += libtinymail-gnomevfs
 endif
+endif
 
 SUBDIRS += libtinymail-camel $(PLATFORMDIR) 
 
@@ -72,6 +80,7 @@ DIST_SUBDIRS = \
 	libtinymail \
 	libtinymailui \
 	libtinymail-gnomevfs \
+	libtinymail-gio \
 	libtinymailui-gtk \
 	libtinymail-camel \
 	docs \
diff --git a/configure.ac b/configure.ac
index fabf6a9..156b25f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -414,25 +414,76 @@ fi
 AC_SUBST(LIBTINYMAIL_TP_CFLAGS)
 AC_SUBST(LIBTINYMAIL_TP_LIBS)
 
-dnl ### libtinymail-gnomevfs, a tnystreamiface for gnome-vfs ##
-if test x$build_gnome = xtrue; then
-extragtkpkgs="libgnomeui-2.0 gnome-keyring-1"
-extratnypkgs="gnome-vfs-2.0"
-  PKG_CHECK_MODULES(LIBTINYMAIL_GNOMEVFS, glib-2.0 >= 2.8 gobject-2.0 gnome-vfs-2.0)
-elif test x$build_maemo = xtrue; then
 extragtkpkgs=
-extratnypkgs="gnome-vfs-2.0"
-  PKG_CHECK_MODULES(LIBTINYMAIL_GNOMEVFS, glib-2.0 >= 2.8 gobject-2.0 gnome-vfs-2.0)
-else
-  LIBTINYMAIL_GNOMEVFS_CFLAGS=
-  LIBTINYMAIL_GNOMEVFS_LIBS=
-  extragtkpkgs=
-  extratnypkgs=
+extratnypkgs=
+
+dnl ### libtinymail-gio, a tnystreamiface for gio ##
+build_gio="false"
+PKG_CHECK_MODULES(LIBTINYMAIL_GIO, gio-2.0, [have_gio="true"],
+					    [have_gio="false"])
+AC_ARG_ENABLE(gio,
+AC_HELP_STRING([--enable-gio],
+	       [Build using Gio support (yes, no, auto)]),
+	       [case "${enableval}" in
+		  yes)  enable_gio=true  ;;
+		  no)   enable_gio=false ;;
+		  auto) enable_gio=auto  ;;
+		  *) AC_MSG_ERROR(bad value ${enableval} for --enable-gio) ;;
+	       esac],
+	       [enable_gio=$enable_gio])
+if test x$have_gio = xtrue || test x$enable_gio = xtrue; then
+build_gio="true"
 fi
-
+if test x$enable_gio = xfalse; then
+build_gio="false"
+fi
+if test x$enable_gio = xtrue && test x$have_gio = xfalse; then
+AC_MSG_ERROR(GIO requested but not available)
+fi
+if test x$build_gnome = xtrue && test x$build_gio = xfalse; then
+AC_MSG_ERROR(GIO is required for Gnome port)
+fi
+if test x$build_gio = xtrue; then
+extratnypkgs="$extratnypkgs gio-2.0"
+fi
+AM_CONDITIONAL(BUILD_GIO, test x$build_gio = xtrue)
+AC_SUBST(LIBTINYMAIL_GIO_CFLAGS)
+AC_SUBST(LIBTINYMAIL_GIO_LIBS)
+
+dnl ### libtinymail-gnomevfs, a tnystreamiface for gio ##
+build_gnomevfs="false"
+PKG_CHECK_MODULES(LIBTINYMAIL_GNOMEVFS, glib-2.0 >= 2.8 gobject-2.0 gnome-vfs-2.0, [have_gnomevfs="true"],
+     					    	     	    			   [have_gnomevfs="false"])
+AC_ARG_ENABLE(gnomevfs,
+AC_HELP_STRING([--enable-gnomevfs],
+	       [Build using GnomeVFS support (yes, no, auto)]),
+	       [case "${enableval}" in
+		  yes)  enable_gnomevfs=true  ;;
+		  no)   enable_gnomevfs=false ;;
+		  auto) enable_gnomevfs=auto  ;;
+		  *) AC_MSG_ERROR(bad value ${enableval} for --enable-gnomevfs) ;;
+	       esac],
+	       [enable_gnomevfs=$enable_gnomevfs])
+if test x$have_gnomevfs = xtrue || test x$enable_gnomevfs = xtrue; then
+build_gnomevfs="true"
+fi
+if test x$enable_gnomevfs = xfalse; then
+build_gnomevfs="false"
+fi
+if test x$enable_gnomevfs = xtrue && test x$have_gnomevfs = xfalse; then
+AC_MSG_ERROR(GnomeVFS requested but not available)
+fi
+if test x$build_gnomevfs = xtrue; then
+extratnypkgs="$extratnypkgs gnome-vfs-2.0"
+fi
+AM_CONDITIONAL(BUILD_GNOMEVFS, test x$build_gnomevfs = xtrue)
 AC_SUBST(LIBTINYMAIL_GNOMEVFS_CFLAGS)
 AC_SUBST(LIBTINYMAIL_GNOMEVFS_LIBS)
 
+if test x$build_gnome = xtrue; then
+   extragtkpkgs="libgnomeui-2.0 gnome-keyring-1 gio-2.0"
+fi
+
 dnl ### libtinymailui-gtk, a gtk+ implementation of libtinymail-ui ##
 if test x$build_uigtk = xtrue; then
   PKG_CHECK_MODULES(LIBTINYMAILUI_GTK, glib-2.0 >= 2.8 gobject-2.0 $extragtkpkgs gtk+-2.0)
@@ -651,6 +702,8 @@ libtinymailui-mozembed/libtinymailui-mozembed.pc
 libtinymailui-gnome-keyring/Makefile
 libtinymail-gnomevfs/Makefile
 libtinymail-gnomevfs/libtinymail-gnomevfs.pc
+libtinymail-gio/Makefile
+libtinymail-gio/libtinymail-gio.pc
 libtinymail-gnome-desktop/Makefile
 libtinymail-gnome-desktop/libtinymail-gnome-desktop.pc
 libtinymail-olpc/Makefile
@@ -676,6 +729,8 @@ m4/Makefile
 echo ""
 echo "The following options are selected:"
 echo ""
+echo "  Enable Gio support:          $build_gio"
+echo "  Enable GnomeVFS support:     $build_gnomevfs"
 echo "  Enable GNOME features:       $build_gnome"
 echo "  Enable NetworkManager:       $build_nm"
 echo "  Enable ACAP features:        $build_acap"
diff --git a/libtinymail-camel/camel-lite/config.h.in b/libtinymail-camel/camel-lite/config.h.in
index 4eba370..efbfb5b 100644
--- a/libtinymail-camel/camel-lite/config.h.in
+++ b/libtinymail-camel/camel-lite/config.h.in
@@ -172,6 +172,10 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
 /* Detected mozilla engine version for mozembed */
 #undef MOZEMBED_MOZILLA_VERSION
 
diff --git a/libtinymail-gio/Makefile.am b/libtinymail-gio/Makefile.am
new file mode 100644
index 0000000..060e59c
--- /dev/null
+++ b/libtinymail-gio/Makefile.am
@@ -0,0 +1,33 @@
+INCLUDES = $(LIBTINYMAIL_GIO_CFLAGS) \
+	-I. -I$(top_srcdir) $(EXTRA_CFLAGS) \
+	-I$(top_srcdir)/libtinymail
+
+lib_LTLIBRARIES = libtinymail-gio-1.0.la
+
+libtinymail_gio_1_0_headers =		\
+	tny-gio-input-stream.h		\
+	tny-gio-output-stream.h
+
+libtinymail_gio_1_0_la_SOURCES = 	\
+	$(libtinymail_gio_1_0_headers)	\
+	tny-gio-input-stream.c		\
+	tny-gio-output-stream.c
+
+libtinymail_gio_1_0_la_LIBADD =		\
+	$(LIBTINYMAIL_GIO_LIBS)		\
+	$(top_builddir)/libtinymail/libtinymail-$(API_VERSION).la
+
+libtinymail_gio_1_0_la_LDFLAGS = -export-dynamic \
+	-version-info $(LT_VERSION_INFO) $(LIBTOOL_EXPORT_OPTIONS)
+
+libtinymail_gio_1_0includedir = $(includedir)/libtinymail-gio-$(API_VERSION)
+libtinymail_gio_1_0include_HEADERS = $(libtinymail_gio_1_0_headers)
+
+libtinymail-gio-$(API_VERSION).pc: libtinymail-gio.pc
+	cp $< $@
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libtinymail-gio-$(API_VERSION).pc
+EXTRA_DIST = $(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in)
+
+DISTCLEANFILES = $(pkgconfig_DATA)
diff --git a/libtinymail-gio/libtinymail-gio-1.0.pc b/libtinymail-gio/libtinymail-gio-1.0.pc
new file mode 100644
index 0000000..bf20994
--- /dev/null
+++ b/libtinymail-gio/libtinymail-gio-1.0.pc
@@ -0,0 +1,11 @@
+prefix=/usr/local
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libtinymail-gio
+Description: TinyMail generic library implemented for gio
+Version: 1.0.0
+Requires: libtinymail-1.0 gio-2.0
+Libs: -L${libdir} -ltinymail-gio-1.0
+Cflags: -I${includedir}/libtinymail-gio-1.0
diff --git a/libtinymail-gio/libtinymail-gio.pc.in b/libtinymail-gio/libtinymail-gio.pc.in
new file mode 100644
index 0000000..aaff7f5
--- /dev/null
+++ b/libtinymail-gio/libtinymail-gio.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libtinymail-gio
+Description: TinyMail generic library implemented for gio
+Version: @VERSION@
+Requires: libtinymail-@API_VERSION@ gio-2.0
+Libs: -L${libdir} -ltinymail-gio-@API_VERSION@
+Cflags: -I${includedir}/libtinymail-gio-@API_VERSION@
diff --git a/libtinymail-gio/tny-gio-input-stream.c b/libtinymail-gio/tny-gio-input-stream.c
new file mode 100644
index 0000000..4fc1aa0
--- /dev/null
+++ b/libtinymail-gio/tny-gio-input-stream.c
@@ -0,0 +1,382 @@
+/* libtinymail-gio - The Tiny Mail base library for Gio
+ * Copyright (C) 2009 Javier Jardón <javierjc1982@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with self library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * A Gio to CamelStream mapper.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <tny-gio-input-stream.h>
+
+static GObjectClass *parent_class = NULL;
+
+typedef struct _TnyGioInputStreamPriv TnyGioInputStreamPriv;
+
+struct _TnyGioInputStreamPriv
+{
+        GInputStream *input_stream;
+	gboolean eos;
+	off_t position;		/* current postion in the input stream */
+	off_t bound_start;	/* first valid position */
+	off_t bound_end;	/* first invalid position */
+};
+
+#define TNY_GIO_INPUT_STREAM_GET_PRIVATE(o) \
+	(G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GIO_INPUT_STREAM, TnyGioInputStreamPriv))
+
+
+static gssize
+tny_gio_input_stream_write_to_stream (TnyStream *self, TnyStream *output)
+{
+        g_warning (  "You can't use the tny_stream_write_to_stream API on input "
+		     "streams. This problem indicates a bug in the software");
+
+        return -1;
+}
+
+static gssize
+tny_gio_input_stream_read  (TnyStream *self, char *buffer, gsize n)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+        gssize nread = 0;
+        GError *error = NULL;
+
+	if (priv->bound_end != (~0))
+		n = MIN (priv->bound_end - priv->position, n);
+
+        nread = g_input_stream_read (priv->input_stream, buffer, n, NULL, &error);
+
+        if (nread > 0)
+		priv->position += nread;
+	else if (nread == 0)
+                priv->eos = TRUE;
+
+	return nread;
+}
+
+static gssize
+tny_gio_input_stream_write (TnyStream *self, const char *buffer, gsize n)
+{
+        g_warning (  "You can't use the tny_stream_write API on input "
+		     "streams. This problem indicates a bug in the software");
+
+        return -1;
+}
+
+static gint
+tny_gio_input_stream_close (TnyStream *self)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+	GError *error;
+
+        if (!g_input_stream_close (priv->input_stream, NULL, &error))
+                return -1;
+
+        priv->input_stream = NULL;
+        priv->eos = TRUE;
+
+	return 0;
+}
+
+
+/**
+ * tny_gio_input_stream_set_stream:
+ * @self: A #TnyGioStream instance
+ * @input_stream: the stream to read from
+ *
+ * Set the input stream to play adaptor for
+ *
+ **/
+void
+tny_gio_input_stream_set_stream (TnyGioInputStream *self, GInputStream *input_stream)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+        GError *error;
+
+        if (!input_stream)
+                return;
+
+	if (priv->input_stream) {
+                g_input_stream_close (priv->input_stream, NULL, &error);
+		priv->input_stream = NULL;
+	}
+
+	priv->input_stream = input_stream;
+	priv->eos = FALSE;
+	priv->position = 0;
+
+        g_seekable_seek (G_SEEKABLE (input_stream), priv->position,
+                         G_SEEK_CUR, NULL, &error);
+
+	return;
+}
+
+/**
+ * tny_gio_input_stream_new:
+ * @input_stream: The stream to read from
+ *
+ * Create an adaptor instance between #TnyStream and #Gio input stream
+ *
+ * Return value: a new #TnyStream instance
+ **/
+TnyStream*
+tny_gio_input_stream_new (GInputStream *input_stream)
+{
+	TnyGioInputStream *self = g_object_new (TNY_TYPE_GIO_INPUT_STREAM, NULL);
+
+	tny_gio_input_stream_set_stream (self, input_stream);
+
+	return TNY_STREAM (self);
+}
+
+static void
+tny_gio_input_stream_instance_init (GTypeInstance *instance, gpointer g_class)
+{
+	TnyGioInputStream *self = (TnyGioInputStream *)instance;
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+        priv->input_stream = NULL;
+	priv->eos = FALSE;
+	priv->bound_start = 0;
+	priv->bound_end = (~0);
+	priv->position = 0;
+
+	return;
+}
+
+static void
+tny_gio_input_stream_finalize (GObject *object)
+{
+	TnyGioInputStream *self = (TnyGioInputStream *)object;
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+        GError *error = NULL;
+
+        if (G_LIKELY (priv->input_stream))
+                g_input_stream_close (priv->input_stream, NULL, &error);
+
+	(*parent_class->finalize) (object);
+
+	return;
+}
+
+static gint
+tny_gio_input_flush (TnyStream *self)
+{
+         g_warning (  "You can't use the tny_stream_write_to_stream API on input "
+		     "streams. This problem indicates a bug in the software");
+
+        return -1;
+}
+
+static gboolean
+tny_gio_input_is_eos (TnyStream *self)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+	return priv->eos;
+}
+
+static gint
+tny_gio_input_reset (TnyStream *self)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+	gint retval = 0;
+	GError *error;
+
+	if (priv->input_stream == NULL)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+        if (!g_seekable_seek (G_SEEKABLE (priv->input_stream), 0, G_SEEK_SET, NULL, &error))
+                return -1;
+
+        priv->position = 0;
+	priv->eos = FALSE;
+
+	return 0;
+}
+
+
+
+static off_t
+tny_gio_input_seek (TnySeekable *self, off_t offset, int policy)//TODO
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+        goffset real = 0;
+        GError *error;
+
+	switch (policy) {
+	case SEEK_SET:
+		real = offset;
+		break;
+	case SEEK_CUR:
+		real = priv->position + offset;
+		break;
+	case SEEK_END:
+		if (priv->bound_end == (~0)) {
+			if (!g_seekable_seek (G_SEEKABLE (priv->input_stream), (goffset) offset, G_SEEK_SET, NULL, &error))
+                                return -1;
+                        real = g_seekable_tell (G_SEEKABLE (priv->input_stream));
+			if (real != -1) {
+				if (real<priv->bound_start)
+					real = priv->bound_start;
+				priv->position = real;
+			}
+			return real;
+		}
+		real = priv->bound_end + offset;
+		break;
+	}
+
+	if (priv->bound_end != (~0))
+		real = MIN (real, priv->bound_end);
+	real = MAX (real, priv->bound_start);
+
+        if (!g_seekable_seek (G_SEEKABLE (priv->input_stream), real, G_SEEK_SET, NULL, &error))
+                return -1;
+
+	if (real != priv->position && priv->eos)
+		priv->eos = FALSE;
+
+	priv->position = real;
+
+	return real;
+}
+
+static off_t
+tny_gio_input_tell (TnySeekable *self)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+	return priv->position;
+}
+
+static gint
+tny_gio_input_set_bounds (TnySeekable *self, off_t start, off_t end)
+{
+	TnyGioInputStreamPriv *priv = TNY_GIO_INPUT_STREAM_GET_PRIVATE (self);
+
+	priv->bound_end = end;
+	priv->bound_start = start;
+
+	return 0;
+}
+
+static void
+tny_stream_init (gpointer g, gpointer iface_data)
+{
+	TnyStreamIface *klass = (TnyStreamIface *)g;
+
+	klass->reset= tny_gio_input_reset;
+	klass->flush= tny_gio_input_flush;
+	klass->is_eos= tny_gio_input_is_eos;
+	klass->read= tny_gio_input_stream_read;
+	klass->write= tny_gio_input_stream_write;
+	klass->close= tny_gio_input_stream_close;
+	klass->write_to_stream= tny_gio_input_stream_write_to_stream;
+
+	return;
+}
+
+
+static void
+tny_seekable_init (gpointer g, gpointer iface_data)
+{
+	TnySeekableIface *klass = (TnySeekableIface *)g;
+
+	klass->seek= tny_gio_input_seek;
+	klass->tell= tny_gio_input_tell;
+	klass->set_bounds= tny_gio_input_set_bounds;
+
+	return;
+}
+
+static void
+tny_gio_input_stream_class_init (TnyGioInputStreamClass *class)
+{
+	GObjectClass *object_class;
+
+	parent_class = g_type_class_peek_parent (class);
+	object_class = (GObjectClass*) class;
+
+	object_class->finalize = tny_gio_input_stream_finalize;
+
+	g_type_class_add_private (object_class, sizeof (TnyGioInputStreamPriv));
+
+	return;
+}
+
+static gpointer
+tny_gio_input_stream_register_type (gpointer notused)
+{
+	GType type = 0;
+
+	static const GTypeInfo info =
+		{
+			sizeof (TnyGioInputStreamClass),
+			NULL,   /* base_init */
+			NULL,   /* base_finalize */
+			(GClassInitFunc) tny_gio_input_stream_class_init,   /* class_init */
+			NULL,   /* class_finalize */
+			NULL,   /* class_data */
+			sizeof (TnyGioInputStream),
+			0,      /* n_preallocs */
+			tny_gio_input_stream_instance_init,/* instance_init */
+			NULL
+		};
+
+	static const GInterfaceInfo tny_stream_info =
+		{
+			(GInterfaceInitFunc) tny_stream_init, /* interface_init */
+			NULL,         /* interface_finalize */
+			NULL          /* interface_data */
+		};
+
+	static const GInterfaceInfo tny_seekable_info =
+		{
+			(GInterfaceInitFunc) tny_seekable_init, /* interface_init */
+			NULL,         /* interface_finalize */
+			NULL          /* interface_data */
+		};
+
+	type = g_type_register_static (G_TYPE_OBJECT,
+				       "TnyVfsStream",
+				       &info, 0);
+
+	g_type_add_interface_static (type, TNY_TYPE_STREAM,
+				     &tny_stream_info);
+
+	g_type_add_interface_static (type, TNY_TYPE_SEEKABLE,
+				     &tny_seekable_info);
+
+	return GUINT_TO_POINTER (type);
+}
+
+GType
+tny_gio_input_stream_get_type (void)
+{
+	static GOnce once = G_ONCE_INIT;
+	g_once (&once, tny_gio_input_stream_register_type, NULL);
+	return GPOINTER_TO_UINT (once.retval);
+}
diff --git a/libtinymail-gio/tny-gio-input-stream.h b/libtinymail-gio/tny-gio-input-stream.h
new file mode 100644
index 0000000..4ae989f
--- /dev/null
+++ b/libtinymail-gio/tny-gio-input-stream.h
@@ -0,0 +1,58 @@
+#ifndef TNY_GIO_INPUT_STREAM_H
+#define TNY_GIO_INPUT_STREAM_H
+
+/* libtinymail-gio - The Tiny Mail base library for Gio
+ * Copyright (C) 2009 Javier Jardón <javierjc1982@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with self library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#include <tny-stream.h>
+#include <tny-seekable.h>
+
+G_BEGIN_DECLS
+
+#define TNY_TYPE_GIO_INPUT_STREAM		(tny_gio_input_stream_get_type ())
+#define TNY_GIO_INPUT_STREAM(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_GIO_INPUT_STREAM, TnyGioInputStream))
+#define TNY_GIO_INPUT_STREAM_CLASS(vtable)	(G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_GIO_INPUT_STREAM, TnyGioInputStreamClass))
+#define TNY_IS_GIO_INPUT_STREAM(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TNY_TYPE_GIO_INPUT_STREAM))
+#define TNY_IS_GIO_INPUT_STREAM_CLASS(vtable)	(G_TYPE_CHECK_CLASS_TYPE ((vtable), TNY_TYPE_GIO_INPUT_STREAM))
+#define TNY_GIO_INPUT_STREAM_GET_CLASS(inst)	(G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_GIO_INPUT_STREAM, TnyGioInputStreamClass))
+
+typedef struct _TnyGioInputStream TnyGioInputStream;
+typedef struct _TnyGioInputStreamClass TnyGioInputStreamClass;
+
+struct _TnyGioInputStream
+{
+	GObject parent;
+};
+
+struct _TnyGioInputStreamClass
+{
+	GObjectClass parent;
+};
+
+GType tny_gio_input_stream_get_type (void);
+TnyStream* tny_gio_input_stream_new (GInputStream *input_stream);
+void tny_gio_input_stream_set_stream (TnyGioInputStream *self, GInputStream *input_stream);
+
+G_END_DECLS
+
+#endif
diff --git a/libtinymail-gio/tny-gio-output-stream.c b/libtinymail-gio/tny-gio-output-stream.c
new file mode 100644
index 0000000..191c906
--- /dev/null
+++ b/libtinymail-gio/tny-gio-output-stream.c
@@ -0,0 +1,407 @@
+/* libtinymail-gio - The Tiny Mail base library for Gio
+ * Copyright (C) 2009 Javier Jardón <javierjc1982@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with self library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * A Gio to CamelStream mapper.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <tny-gio-output-stream.h>
+
+static GObjectClass *parent_class = NULL;
+
+typedef struct _TnyGioOutputStreamPriv TnyGioOutputStreamPriv;
+
+struct _TnyGioOutputStreamPriv
+{
+        GOutputStream *output_stream;
+	gboolean eos;
+	off_t position;		/* current postion in the input stream */
+	off_t bound_start;	/* first valid position */
+	off_t bound_end;	/* first invalid position */
+};
+
+#define TNY_GIO_OUTPUT_STREAM_GET_PRIVATE(o) \
+	(G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GIO_OUTPUT_STREAM, TnyGioOutputStreamPriv))
+
+
+static gssize
+tny_gio_output_stream_write_to_stream (TnyStream *self, TnyStream *output)
+{
+	char tmp_buf[4096];
+	gssize total = 0;
+	gssize nb_read;
+	gssize nb_written;
+
+	g_assert (TNY_IS_STREAM (output));
+
+	while (G_UNLIKELY (!tny_stream_is_eos (self))) {
+		nb_read = tny_stream_read (self, tmp_buf, sizeof (tmp_buf));
+		if (G_UNLIKELY (nb_read < 0))
+			return -1;
+		else if (G_LIKELY (nb_read > 0)) {
+			nb_written = 0;
+
+			while (G_LIKELY (nb_written < nb_read))
+			{
+				gssize len = tny_stream_write (output, tmp_buf + nb_written,
+								  nb_read - nb_written);
+				if (G_UNLIKELY (len < 0))
+					return -1;
+				nb_written += len;
+			}
+			total += nb_written;
+		}
+	}
+	return total;
+}
+
+static gssize
+tny_gio_output_stream_read  (TnyStream *self, char *buffer, gsize n)
+{
+        g_warning (  "You can't use the tny_stream_read API on output "
+		     "streams. This problem indicates a bug in the software");
+
+	return -1;
+}
+
+static gssize
+tny_gio_output_stream_write (TnyStream *self, const char *buffer, gsize n)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+        gssize nwritten = 0;
+        GError *error = NULL;
+
+	if (priv->bound_end != (~0))
+		n = MIN (priv->bound_end - priv->position, n);
+
+        nwritten = g_output_stream_write (priv->output_stream, buffer, n, NULL, &error);
+
+	if (nwritten > 0)
+		priv->position += nwritten;
+	else if (nwritten == 0)
+                priv->eos = TRUE;
+
+	return nwritten;
+}
+
+static gint
+tny_gio_output_stream_close (TnyStream *self)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+	GError *error;
+
+        if (!g_output_stream_close (priv->output_stream, NULL, &error))
+                return -1;
+
+        priv->output_stream = NULL;
+        priv->eos = TRUE;
+
+	return 0;
+}
+
+
+/**
+ * tny_gio_output_stream_set_stream:
+ * @self: A #TnyGioStream instance
+ * @output_stream: the stream to write to
+ *
+ * Set the output stream to play adaptor for
+ *
+ **/
+void
+tny_gio_output_stream_set_stream (TnyGioOutputStream *self, GOutputStream *output_stream)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+        GError *error;
+
+        if (!output_stream)
+                return;
+
+	if (priv->output_stream) {
+                g_output_stream_close (priv->output_stream, NULL, &error);
+		priv->output_stream = NULL;
+	}
+
+	priv->output_stream = output_stream;
+	priv->eos = FALSE;
+	priv->position = 0;
+
+        g_seekable_seek (G_SEEKABLE (output_stream), priv->position,
+                         G_SEEK_CUR, NULL, &error);
+
+	return;
+}
+
+/**
+ * tny_gio_output_stream_new:
+ * @output_stream: The stream to read from
+ *
+ * Create an adaptor instance between #TnyStream and #Gio input stream
+ *
+ * Return value: a new #TnyStream instance
+ **/
+TnyStream*
+tny_gio_output_stream_new (GOutputStream *output_stream)
+{
+	TnyGioOutputStream *self = g_object_new (TNY_TYPE_GIO_OUTPUT_STREAM, NULL);
+
+	tny_gio_output_stream_set_stream (self, output_stream);
+
+	return TNY_STREAM (self);
+}
+
+static void
+tny_gio_output_stream_instance_init (GTypeInstance *instance, gpointer g_class)
+{
+	TnyGioOutputStream *self = (TnyGioOutputStream *)instance;
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+        priv->output_stream = NULL;
+	priv->eos = FALSE;
+	priv->bound_start = 0;
+	priv->bound_end = (~0);
+	priv->position = 0;
+
+	return;
+}
+
+static void
+tny_gio_output_stream_finalize (GObject *object)
+{
+	TnyGioOutputStream *self = (TnyGioOutputStream *)object;
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+        GError *error = NULL;
+
+        if (G_LIKELY (priv->output_stream))
+                g_output_stream_close (priv->output_stream, NULL, &error);
+
+	(*parent_class->finalize) (object);
+
+	return;
+}
+
+static gint
+tny_gio_output_flush (TnyStream *self)
+{
+        TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+        GError *error;
+
+        if (!g_output_stream_flush (priv->output_stream, NULL, &error))
+                return -1;
+
+	return 0;
+}
+
+static gboolean
+tny_gio_output_is_eos (TnyStream *self)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+	return priv->eos;
+}
+
+static gint
+tny_gio_output_reset (TnyStream *self)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+	gint retval = 0;
+	GError *error;
+
+	if (priv->output_stream == NULL)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+        if (!g_seekable_seek (G_SEEKABLE (priv->output_stream), 0, G_SEEK_SET, NULL, &error))
+                return -1;
+
+        priv->position = 0;
+	priv->eos = FALSE;
+
+	return 0;
+}
+
+
+
+static off_t
+tny_gio_output_seek (TnySeekable *self, off_t offset, int policy)//TODO
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+        goffset real = 0;
+        GError *error;
+
+	switch (policy) {
+	case SEEK_SET:
+		real = offset;
+		break;
+	case SEEK_CUR:
+		real = priv->position + offset;
+		break;
+	case SEEK_END:
+		if (priv->bound_end == (~0)) {
+		  if (!g_seekable_seek (G_SEEKABLE (priv->output_stream), (goffset) offset, G_SEEK_SET, NULL, &error))
+                                return -1;
+                        real = g_seekable_tell (G_SEEKABLE (priv->output_stream));
+			if (real != -1) {
+				if (real<priv->bound_start)
+					real = priv->bound_start;
+				priv->position = real;
+			}
+			return real;
+		}
+		real = priv->bound_end + offset;
+		break;
+	}
+
+	if (priv->bound_end != (~0))
+		real = MIN (real, priv->bound_end);
+	real = MAX (real, priv->bound_start);
+
+        if (!g_seekable_seek (G_SEEKABLE (priv->output_stream), real, G_SEEK_SET, NULL, &error))
+                return -1;
+
+	if (real != priv->position && priv->eos)
+		priv->eos = FALSE;
+
+	priv->position = real;
+
+	return real;
+}
+
+static off_t
+tny_gio_output_tell (TnySeekable *self)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+	return priv->position;
+}
+
+static gint
+tny_gio_output_set_bounds (TnySeekable *self, off_t start, off_t end)
+{
+	TnyGioOutputStreamPriv *priv = TNY_GIO_OUTPUT_STREAM_GET_PRIVATE (self);
+
+	priv->bound_end = end;
+	priv->bound_start = start;
+
+	return 0;
+}
+
+static void
+tny_stream_init (gpointer g, gpointer iface_data)
+{
+	TnyStreamIface *klass = (TnyStreamIface *)g;
+
+	klass->reset= tny_gio_output_reset;
+	klass->flush= tny_gio_output_flush;
+	klass->is_eos= tny_gio_output_is_eos;
+	klass->read= tny_gio_output_stream_read;
+	klass->write= tny_gio_output_stream_write;
+	klass->close= tny_gio_output_stream_close;
+	klass->write_to_stream= tny_gio_output_stream_write_to_stream;
+
+	return;
+}
+
+
+static void
+tny_seekable_init (gpointer g, gpointer iface_data)
+{
+	TnySeekableIface *klass = (TnySeekableIface *)g;
+
+	klass->seek= tny_gio_output_seek;
+	klass->tell= tny_gio_output_tell;
+	klass->set_bounds= tny_gio_output_set_bounds;
+
+	return;
+}
+
+static void
+tny_gio_output_stream_class_init (TnyGioOutputStreamClass *class)
+{
+	GObjectClass *object_class;
+
+	parent_class = g_type_class_peek_parent (class);
+	object_class = (GObjectClass*) class;
+
+	object_class->finalize = tny_gio_output_stream_finalize;
+
+	g_type_class_add_private (object_class, sizeof (TnyGioOutputStreamPriv));
+
+	return;
+}
+
+static gpointer
+tny_gio_output_stream_register_type (gpointer notused)
+{
+	GType type = 0;
+
+	static const GTypeInfo info =
+		{
+			sizeof (TnyGioOutputStreamClass),
+			NULL,   /* base_init */
+			NULL,   /* base_finalize */
+			(GClassInitFunc) tny_gio_output_stream_class_init,   /* class_init */
+			NULL,   /* class_finalize */
+			NULL,   /* class_data */
+			sizeof (TnyGioOutputStream),
+			0,      /* n_preallocs */
+			tny_gio_output_stream_instance_init,/* instance_init */
+			NULL
+		};
+
+	static const GInterfaceInfo tny_stream_info =
+		{
+			(GInterfaceInitFunc) tny_stream_init, /* interface_init */
+			NULL,         /* interface_finalize */
+			NULL          /* interface_data */
+		};
+
+	static const GInterfaceInfo tny_seekable_info =
+		{
+			(GInterfaceInitFunc) tny_seekable_init, /* interface_init */
+			NULL,         /* interface_finalize */
+			NULL          /* interface_data */
+		};
+
+	type = g_type_register_static (G_TYPE_OBJECT,
+				       "TnyVfsStream",
+				       &info, 0);
+
+	g_type_add_interface_static (type, TNY_TYPE_STREAM,
+				     &tny_stream_info);
+
+	g_type_add_interface_static (type, TNY_TYPE_SEEKABLE,
+				     &tny_seekable_info);
+
+	return GUINT_TO_POINTER (type);
+}
+
+GType
+tny_gio_output_stream_get_type (void)
+{
+	static GOnce once = G_ONCE_INIT;
+	g_once (&once, tny_gio_output_stream_register_type, NULL);
+	return GPOINTER_TO_UINT (once.retval);
+}
diff --git a/libtinymail-gio/tny-gio-output-stream.h b/libtinymail-gio/tny-gio-output-stream.h
new file mode 100644
index 0000000..0dda0bb
--- /dev/null
+++ b/libtinymail-gio/tny-gio-output-stream.h
@@ -0,0 +1,58 @@
+#ifndef TNY_GIO_OUTPUT_STREAM_H
+#define TNY_GIO_OUTPUT_STREAM_H
+
+/* libtinymail-gio - The Tiny Mail base library for Gio
+ * Copyright (C) 2009 Javier Jardón <javierjc1982@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with self library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#include <tny-stream.h>
+#include <tny-seekable.h>
+
+G_BEGIN_DECLS
+
+#define TNY_TYPE_GIO_OUTPUT_STREAM             (tny_gio_output_stream_get_type ())
+#define TNY_GIO_OUTPUT_STREAM(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_GIO_OUTPUT_STREAM, TnyGioOutputStream))
+#define TNY_GIO_OUTPUT_STREAM_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_GIO_OUTPUT_STREAM, TnyGioOutputStreamClass))
+#define TNY_IS_GIO_OUTPUT_STREAM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TNY_TYPE_GIO_OUTPUT_STREAM))
+#define TNY_IS_GIO_OUTPUT_STREAM_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), TNY_TYPE_GIO_OUTPUT_STREAM))
+#define TNY_GIO_OUTPUT_STREAM_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), TNY_TYPE_GIO_OUTPUT_STREAM, TnyGioOutputStreamClass))
+
+typedef struct _TnyGioOutputStream TnyGioOutputStream;
+typedef struct _TnyGioOutputStreamClass TnyGioOutputStreamClass;
+
+struct _TnyGioOutputStream
+{
+	GObject parent;
+};
+
+struct _TnyGioOutputStreamClass
+{
+	GObjectClass parent;
+};
+
+GType tny_gio_output_stream_get_type (void);
+TnyStream* tny_gio_output_stream_new (GOutputStream *output_stream);
+void tny_gio_output_stream_set_stream (TnyGioOutputStream *self, GOutputStream *output_stream);
+
+G_END_DECLS
+
+#endif
diff --git a/libtinymailui-gtk/Makefile.am b/libtinymailui-gtk/Makefile.am
index 1b9ae77..d7d5078 100644
--- a/libtinymailui-gtk/Makefile.am
+++ b/libtinymailui-gtk/Makefile.am
@@ -4,7 +4,7 @@ INCLUDES = -I. -I$(top_srcdir) $(EXTRA_CFLAGS) \
 	-I$(top_srcdir)/libtinymailui 
 
 if BUILD_GNOME
-INCLUDES += -I$(top_srcdir)/libtinymail-gnomevfs -DGNOME
+INCLUDES += -I$(top_srcdir)/libtinymail-gio -DGNOME
 endif
 
 lib_LTLIBRARIES = libtinymailui-gtk-1.0.la
@@ -68,7 +68,7 @@ libtinymailui_gtk_1_0_la_LDFLAGS = -export-dynamic \
 	-version-info $(LT_VERSION_INFO) $(LIBTOOL_EXPORT_OPTIONS)
 
 if BUILD_GNOME
-libtinymailui_gtk_1_0_la_LIBADD += $(top_builddir)/libtinymail-gnomevfs/libtinymail-gnomevfs-$(API_VERSION).la
+libtinymailui_gtk_1_0_la_LIBADD += $(top_builddir)/libtinymail-gio/libtinymail-gio-$(API_VERSION).la
 endif
 
 libtinymailuigtkincludedir = $(includedir)/libtinymailui-gtk-$(API_VERSION)
diff --git a/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c b/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c
index 500cc7d..e2b1b01 100644
--- a/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c
+++ b/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c
@@ -40,17 +40,8 @@
 #include <gtk/gtk.h>
 #include <tny-list.h>
 
-#ifdef GNOME
-#include <tny-vfs-stream.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#else
-#include <tny-fs-stream.h>
-#endif
-
 #include <tny-gtk-attachment-mime-part-view.h>
 
-
 static GObjectClass *parent_class = NULL;
 
 typedef struct _TnyGtkAttachmentMimePartViewPriv TnyGtkAttachmentMimePartViewPriv;
diff --git a/libtinymailui-gtk/tny-gtk-image-mime-part-view.c b/libtinymailui-gtk/tny-gtk-image-mime-part-view.c
index b856fb0..3df6233 100644
--- a/libtinymailui-gtk/tny-gtk-image-mime-part-view.c
+++ b/libtinymailui-gtk/tny-gtk-image-mime-part-view.c
@@ -43,15 +43,6 @@
 #include <tny-gtk-image-mime-part-view.h>
 #include <tny-gtk-pixbuf-stream.h>
 
-#ifdef GNOME
-#include <tny-vfs-stream.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#else
-#include <tny-fs-stream.h>
-#endif
-
-
 static GObjectClass *parent_class = NULL;
 
 typedef struct _TnyGtkImageMimePartViewPriv TnyGtkImageMimePartViewPriv;
diff --git a/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c b/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c
index e82e8b5..6dd7361 100644
--- a/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c
+++ b/libtinymailui-gtk/tny-gtk-mime-part-save-strategy.c
@@ -21,7 +21,7 @@
  * TnyGtkMimePartSaveStrategy:
  *
  * a #TnyMimePartSaveStrategy that saves a #TnyMimePart using a file dialog
- * in Gtk+ and GnomeVFS if available.
+ * in Gtk+ and GIO if available.
  *
  * free-function: g_object_unref
  **/
@@ -46,9 +46,8 @@
 #include <tny-mime-part.h>
 
 #ifdef GNOME
-#include <tny-vfs-stream.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <tny-gio-output-stream.h>
+#include <gio/gio.h>
 #else
 #include <tny-fs-stream.h>
 #endif
@@ -73,17 +72,21 @@ static gboolean
 gtk_save_to_file (const gchar *uri, TnyMimePart *part, TnyMimePartSaveStrategy *self)
 {
 	TnyGtkMimePartSaveStrategyPriv *priv = TNY_GTK_MIME_PART_SAVE_STRATEGY_GET_PRIVATE (self);
-	GnomeVFSResult result;
-	GnomeVFSHandle *handle;
 	TnyStream *stream = NULL;
+	GFile *file;
+	GOutputStream *gio_stream;
 
-	result = gnome_vfs_create (&handle, uri, 
-		GNOME_VFS_OPEN_WRITE, FALSE, 0777);
+	file = g_file_new_for_uri (uri);
 
-	if (G_UNLIKELY (result != GNOME_VFS_OK))
+	gio_stream = (GOutputStream *) g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL);
+	g_object_unref (file);
+
+	if (gio_stream == NULL)
 		return FALSE;
 
-	stream = tny_vfs_stream_new (handle);
+	stream = tny_gio_output_stream_new (gio_stream);
+	g_object_unref (gio_stream);
+
 	tny_mime_part_decode_to_stream_async (part, stream, NULL, 
 		priv->status_callback, priv->status_user_data);
 
@@ -194,7 +197,7 @@ tny_gtk_mime_part_save_strategy_perform_save_default (TnyMimePartSaveStrategy *s
  * @status_user_data: (null-ok): user data for @status_callback
  *
  * Create a new #TnyMimePartSaveStrategy It will use the #GtkFileChooserDialog type and if
- * available consume its support for GnomeVFS.
+ * available consume its support for GIO.
  *
  * Whenever data must be retrieved or takes long to load, @status_callback will
  * be called to let the outside world know about what this compenent is doing.
diff --git a/libtinymailui-gtk/tny-gtk-msg-view.c b/libtinymailui-gtk/tny-gtk-msg-view.c
index 2b406da..2885fbf 100644
--- a/libtinymailui-gtk/tny-gtk-msg-view.c
+++ b/libtinymailui-gtk/tny-gtk-msg-view.c
@@ -56,14 +56,6 @@
 #include <tny-gtk-expander-mime-part-view.h>
 #include <tny-mime-part-saver.h>
 
-#ifdef GNOME
-#include <tny-vfs-stream.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#else
-#include <tny-fs-stream.h>
-#endif
-
 #include "tny-gtk-attach-list-model-priv.h"
 
 static GObjectClass *parent_class = NULL;
diff --git a/libtinymailui-gtk/tny-gtk-text-mime-part-view.c b/libtinymailui-gtk/tny-gtk-text-mime-part-view.c
index bfef606..6a711d7 100644
--- a/libtinymailui-gtk/tny-gtk-text-mime-part-view.c
+++ b/libtinymailui-gtk/tny-gtk-text-mime-part-view.c
@@ -42,14 +42,6 @@
 #include <tny-gtk-text-mime-part-view.h>
 #include <tny-gtk-text-buffer-stream.h>
 
-#ifdef GNOME
-#include <tny-vfs-stream.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#else
-#include <tny-fs-stream.h>
-#endif
-
 
 static GObjectClass *parent_class = NULL;
 
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index 7c26df4..d1c93ba 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -16,7 +16,7 @@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
 PACKAGE = @PACKAGE@
 VERSION = @VERSION@
 
-SHELL = /bin/sh
+SHELL = @SHELL@
 @SET_MAKE@
 
 srcdir = @srcdir@
@@ -56,7 +56,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
 SOURCES = 
 POFILES = @POFILES@
 GMOFILES = @GMOFILES@
-DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
+DISTFILES = LINGUAS ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
 $(POFILES) $(GMOFILES) $(SOURCES)
 
 POTFILES = \
@@ -95,6 +95,13 @@ all-no:
 $(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
 	$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
 	  --add-comments --keyword=_ --keyword=N_ \
+	  --keyword=C_:1c,2 \
+	  --keyword=NC_:1c,2 \
+	  --keyword=g_dngettext:2,3 \
+	  --flag=N_:1:pass-c-format \
+	  --flag=C_:2:pass-c-format \
+	  --flag=NC_:2:pass-c-format \
+	  --flag=g_dngettext:2:pass-c-format \
           --flag=g_strdup_printf:1:c-format \
           --flag=g_string_printf:2:c-format \
           --flag=g_string_append_printf:2:c-format \
@@ -263,8 +270,7 @@ POTFILES: POTFILES.in
 
 Makefile: Makefile.in.in ../config.status POTFILES
 	cd .. \
-	  && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
-	       $(SHELL) ./config.status
+	  && $(SHELL) ./config.status $(subdir)/$@.in
 
 # Tell versions [3.59,3.63) of GNU make not to export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
