evolution-data-server r8655 - in trunk: . addressbook addressbook/libebook calendar calendar/backends/file calendar/backends/google calendar/backends/groupwise calendar/libedata-cal camel src
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8655 - in trunk: . addressbook addressbook/libebook calendar calendar/backends/file calendar/backends/google calendar/backends/groupwise calendar/libedata-cal camel src
- Date: Thu, 17 Apr 2008 17:47:01 +0100 (BST)
Author: mcrha
Date: Thu Apr 17 17:47:00 2008
New Revision: 8655
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8655&view=rev
Log:
2008-04-17 Milan Crha <mcrha redhat com>
** Fix for bug #526741 (gnome-vfs to gio/gvfs port)
* configure.in: Do not require gnome-vfs, use gio/gvfs instead.
Bumped LIBCAMEL_CURRENT to 12.
* addressbook/libebook/e-contact.c: Do not include gnome-vfs anymore.
* calendar/libedata-cal/libedata-cal.pc.in: Do not require gnomve-vfs,
require gio-2.0 instead.
* calendar/backends/file/e-cal-backend-file.c: (struct _ECalBackendFilePrivate),
(save_file_when_idle), (uri_to_path), (open_cal), (reload_cal),
(create_cal), (get_uri_string), (e_cal_backend_file_open),
(e_cal_backend_file_compute_changes), (e_cal_backend_file_init):
* calendar/backends/groupwise/e-cal-backend-groupwise-utils.c:
(get_mime_type), (e_cal_backend_groupwise_set_attachments_from_comp):
* calendar/backends/groupwise/e-cal-backend-groupwise.c:
(e_cal_backend_groupwise_compute_changes):
Do not use gnome-vfs, use gio/gvfs instead.
* calendar/backends/google/e-cal-backend-google-utils.c:
* calendar/backends/google/e-cal-backend-google.c: Do not include gnome-vfs.
* camel/camel-stream-vfs.h:
* camel/camel-stream-vfs.c: Do not depend on gnomve-vfs, but use gio/gvfs
instead. Dropped camel_stream_vfs_new_with_handle, new function for
this is camel_stream_vfs_new_with_stream, also prototype for
camel_stream_vfs_new_with_uri has been changed.
CamelStreamVFS is not seekable anymore.
* src/server.c: (main):
Modified:
trunk/ChangeLog
trunk/addressbook/ChangeLog
trunk/addressbook/libebook/e-contact.c
trunk/calendar/ChangeLog
trunk/calendar/backends/file/e-cal-backend-file.c
trunk/calendar/backends/google/e-cal-backend-google-utils.c
trunk/calendar/backends/google/e-cal-backend-google.c
trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
trunk/calendar/libedata-cal/libedata-cal.pc.in
trunk/camel/ChangeLog
trunk/camel/camel-stream-vfs.c
trunk/camel/camel-stream-vfs.h
trunk/configure.in
trunk/src/server.c
Modified: trunk/addressbook/libebook/e-contact.c
==============================================================================
--- trunk/addressbook/libebook/e-contact.c (original)
+++ trunk/addressbook/libebook/e-contact.c Thu Apr 17 17:47:00 2008
@@ -29,7 +29,6 @@
#include <ctype.h>
#include <string.h>
#include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "e-contact.h"
#include "e-book.h"
#include "e-name-western.h"
Modified: trunk/calendar/backends/file/e-cal-backend-file.c
==============================================================================
--- trunk/calendar/backends/file/e-cal-backend-file.c (original)
+++ trunk/calendar/backends/file/e-cal-backend-file.c Thu Apr 17 17:47:00 2008
@@ -32,7 +32,7 @@
#include <bonobo/bonobo-moniker-util.h>
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
#include "libedataserver/e-data-server-util.h"
#include "libedataserver/e-xml-hash-utils.h"
#include <libecal/e-cal-recur.h>
@@ -55,8 +55,8 @@
/* Private part of the ECalBackendFile structure */
struct _ECalBackendFilePrivate {
- /* URI where the calendar data is stored */
- char *uri;
+ /* path where the calendar data is stored */
+ char *path;
/* Filename in the dir */
char *file_name;
@@ -122,16 +122,15 @@
save_file_when_idle (gpointer user_data)
{
ECalBackendFilePrivate *priv;
- GnomeVFSURI *uri, *backup_uri;
- GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result = GNOME_VFS_ERROR_BAD_FILE;
- GnomeVFSFileSize out;
+ GError *e = NULL;
+ GFile *file, *backup_file;
+ GFileOutputStream *stream;
gchar *tmp, *backup_uristr;
char *buf;
ECalBackendFile *cbfile = user_data;
priv = cbfile->priv;
- g_assert (priv->uri != NULL);
+ g_assert (priv->path != NULL);
g_assert (priv->icalcomp != NULL);
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -141,53 +140,64 @@
return FALSE;
}
- uri = gnome_vfs_uri_new (priv->uri);
- if (!uri)
+ file = g_file_new_for_path (priv->path);
+ if (!file)
goto error_malformed_uri;
/* save calendar to backup file */
- tmp = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ tmp = g_file_get_uri (file);
if (!tmp) {
- gnome_vfs_uri_unref (uri);
+ g_object_unref (file);
goto error_malformed_uri;
}
backup_uristr = g_strconcat (tmp, "~", NULL);
- backup_uri = gnome_vfs_uri_new (backup_uristr);
+ backup_file = g_file_new_for_uri (backup_uristr);
g_free (tmp);
g_free (backup_uristr);
- if (!backup_uri) {
- gnome_vfs_uri_unref (uri);
+ if (!backup_file) {
+ g_object_unref (file);
goto error_malformed_uri;
}
- result = gnome_vfs_create_uri (&handle, backup_uri,
- GNOME_VFS_OPEN_WRITE,
- FALSE, 0666);
- if (result != GNOME_VFS_OK) {
- gnome_vfs_uri_unref (uri);
- gnome_vfs_uri_unref (backup_uri);
+ stream = g_file_replace (backup_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &e);
+ if (!stream || e) {
+ if (stream)
+ g_object_unref (stream);
+
+ g_object_unref (file);
+ g_object_unref (backup_file);
goto error;
}
buf = icalcomponent_as_ical_string (priv->icalcomp);
- result = gnome_vfs_write (handle, buf, strlen (buf) * sizeof (char), &out);
+ g_output_stream_write (G_OUTPUT_STREAM (stream), buf, strlen (buf) * sizeof (char), NULL, &e);
g_free (buf);
- gnome_vfs_close (handle);
- if (result != GNOME_VFS_OK) {
- gnome_vfs_uri_unref (uri);
- gnome_vfs_uri_unref (backup_uri);
+
+ if (e) {
+ g_object_unref (stream);
+ g_object_unref (file);
+ g_object_unref (backup_file);
+ goto error;
+ }
+
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, &e);
+ g_object_unref (stream);
+
+ if (e) {
+ g_object_unref (file);
+ g_object_unref (backup_file);
goto error;
}
/* now copy the temporary file to the real file */
- result = gnome_vfs_move_uri (backup_uri, uri, TRUE);
+ g_file_move (backup_file, file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &e);
- gnome_vfs_uri_unref (uri);
- gnome_vfs_uri_unref (backup_uri);
- if (result != GNOME_VFS_OK)
+ g_object_unref (file);
+ g_object_unref (backup_file);
+ if (e)
goto error;
priv->is_dirty = FALSE;
@@ -205,9 +215,16 @@
error:
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
- /* TODO Add concat the message "Cannot save calendar data" to the error string later.Not
- doing it now as we have string freeze. */
- e_cal_backend_notify_error (E_CAL_BACKEND (cbfile), gnome_vfs_result_to_string (result));
+
+ if (e) {
+ char *msg = g_strdup_printf ("%s: %s", _("Cannot save calendar data"), e->message);
+
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbfile), msg);
+ g_free (msg);
+ g_error_free (e);
+ } else
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbfile), _("Cannot save calendar data"));
+
return FALSE;
}
@@ -294,9 +311,9 @@
g_static_rec_mutex_free (&priv->idle_save_rmutex);
- if (priv->uri) {
- g_free (priv->uri);
- priv->uri = NULL;
+ if (priv->path) {
+ g_free (priv->path);
+ priv->path = NULL;
}
if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ()) {
@@ -623,13 +640,13 @@
}
static char *
-get_uri_string_for_gnome_vfs (ECalBackend *backend)
+uri_to_path (ECalBackend *backend)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
const char *master_uri;
char *full_uri, *str_uri;
- GnomeVFSURI *uri;
+ GFile *file;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -644,21 +661,17 @@
}
full_uri = g_strdup_printf ("%s/%s", master_uri, priv->file_name);
- uri = gnome_vfs_uri_new (full_uri);
+ file = g_file_new_for_uri (full_uri);
g_free (full_uri);
- if (!uri)
+ if (!file)
return NULL;
- str_uri = gnome_vfs_uri_to_string (uri,
- (GNOME_VFS_URI_HIDE_USER_NAME
- | GNOME_VFS_URI_HIDE_PASSWORD
- | GNOME_VFS_URI_HIDE_HOST_NAME
- | GNOME_VFS_URI_HIDE_HOST_PORT
- | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD));
- gnome_vfs_uri_unref (uri);
+ str_uri = g_file_get_path (file);
+
+ g_object_unref (file);
- if (!str_uri || !strlen (str_uri)) {
+ if (!str_uri || !*str_uri) {
g_free (str_uri);
return NULL;
@@ -691,7 +704,7 @@
}
priv->icalcomp = icalcomp;
- priv->uri = get_uri_string_for_gnome_vfs (E_CAL_BACKEND (cbfile));
+ priv->path = uri_to_path (E_CAL_BACKEND (cbfile));
priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
scan_vcalendar (cbfile);
@@ -841,7 +854,7 @@
priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
scan_vcalendar (cbfile);
- priv->uri = get_uri_string_for_gnome_vfs (E_CAL_BACKEND (cbfile));
+ priv->path = uri_to_path (E_CAL_BACKEND (cbfile));
/* Compare old and new versions of calendar */
@@ -876,7 +889,7 @@
/* Create our internal data */
priv->comp_uid_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_object_data);
- priv->uri = get_uri_string_for_gnome_vfs (E_CAL_BACKEND (cbfile));
+ priv->path = uri_to_path (E_CAL_BACKEND (cbfile));
save (cbfile);
@@ -888,8 +901,8 @@
{
gchar *str_uri, *full_uri;
- str_uri = get_uri_string_for_gnome_vfs (backend);
- full_uri = gnome_vfs_unescape_string (str_uri, "");
+ str_uri = uri_to_path (backend);
+ full_uri = g_uri_unescape_string (str_uri, "");
g_free (str_uri);
return full_uri;
@@ -910,7 +923,7 @@
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
/* Claim a succesful open if we are already open */
- if (priv->uri && priv->comp_uid_hash) {
+ if (priv->path && priv->comp_uid_hash) {
status = GNOME_Evolution_Calendar_Success;
goto done;
}
@@ -1609,7 +1622,7 @@
/* FIXME Will this always work? */
- unescaped_uri = gnome_vfs_unescape_string (priv->uri, "");
+ unescaped_uri = g_uri_unescape_string (priv->path, "");
filename = g_strdup_printf ("%s-%s.db", unescaped_uri, change_id);
g_free (unescaped_uri);
if (!(ehash = e_xmlhash_new (filename))) {
@@ -2644,7 +2657,7 @@
priv = g_new0 (ECalBackendFilePrivate, 1);
cbfile->priv = priv;
- priv->uri = NULL;
+ priv->path = NULL;
priv->file_name = g_strdup ("calendar.ics");
priv->read_only = FALSE;
priv->is_dirty = FALSE;
Modified: trunk/calendar/backends/google/e-cal-backend-google-utils.c
==============================================================================
--- trunk/calendar/backends/google/e-cal-backend-google-utils.c (original)
+++ trunk/calendar/backends/google/e-cal-backend-google-utils.c Thu Apr 17 17:47:00 2008
@@ -39,8 +39,6 @@
#include <glib/gi18n-lib.h>
#include <glib/gprintf.h>
-#include <libgnomevfs/gnome-vfs.h>
-
#include <libedataserver/e-data-server-util.h>
#include <libedataserver/e-xml-hash-utils.h>
Modified: trunk/calendar/backends/google/e-cal-backend-google.c
==============================================================================
--- trunk/calendar/backends/google/e-cal-backend-google.c (original)
+++ trunk/calendar/backends/google/e-cal-backend-google.c Thu Apr 17 17:47:00 2008
@@ -37,7 +37,6 @@
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserver/e-xml-hash-utils.h>
Modified: trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
==============================================================================
--- trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c (original)
+++ trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c Thu Apr 17 17:47:00 2008
@@ -36,8 +36,8 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+#include <gio/gio.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <e-gw-connection.h>
#include <e-gw-message.h>
#include <libecal/e-cal-recur.h>
@@ -262,6 +262,33 @@
}
+static char *
+get_mime_type (const char *uri)
+{
+ GFile *file;
+ GFileInfo *fi;
+ char *mime_type;
+
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ file = g_file_new_for_uri (uri);
+ if (!file)
+ return NULL;
+
+ fi = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (!fi) {
+ g_object_unref (file);
+ return NULL;
+ }
+
+ mime_type = g_content_type_get_mime_type (g_file_info_get_content_type (fi));
+
+ g_object_unref (fi);
+ g_object_unref (file);
+
+ return mime_type;
+}
+
static void
e_cal_backend_groupwise_set_attachments_from_comp (ECalComponent *comp,
EGwItem *item)
@@ -299,11 +326,12 @@
continue;
}
+ g_free (attach_filename_full);
+
attach_item = g_new0 (EGwItemAttachment, 1);
/* FIXME the member does not follow the naming convention.
* Should be fixed in e-gw-item*/
- attach_item->contentType = g_strdup (gnome_vfs_get_mime_type (attach_filename_full));
- g_free (attach_filename_full);
+ attach_item->contentType = get_mime_type ((char *)l->data);
attach_item->name = g_strdup (filename + strlen(uid) + 1);
/* do a base64 encoding so it can be embedded in a soap
Modified: trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
==============================================================================
--- trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c (original)
+++ trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c Thu Apr 17 17:47:00 2008
@@ -33,8 +33,6 @@
#include <unistd.h>
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "libedataserver/e-xml-hash-utils.h"
#include "libedataserver/e-url.h"
#include <libedata-cal/e-cal-backend-cache.h>
@@ -1788,7 +1786,7 @@
cache = cbgw->priv->cache;
/* FIXME Will this always work? */
- unescaped_uri = gnome_vfs_unescape_string (cbgw->priv->uri, "");
+ unescaped_uri = g_uri_unescape_string (cbgw->priv->uri, "");
filename = g_strdup_printf ("%s-%s.db", unescaped_uri, change_id);
ehash = e_xmlhash_new (filename);
g_free (filename);
Modified: trunk/calendar/libedata-cal/libedata-cal.pc.in
==============================================================================
--- trunk/calendar/libedata-cal/libedata-cal.pc.in (original)
+++ trunk/calendar/libedata-cal/libedata-cal.pc.in Thu Apr 17 17:47:00 2008
@@ -13,6 +13,6 @@
Name: libedata-cal
Description: Backend library for evolution calendars
Version: @VERSION@
-Requires: libgnome-2.0 libbonobo-2.0 >= @LIBBONOBO_REQUIRED@ gnome-vfs-2.0 libedataserver-1.2 libecal-1.2
+Requires: libgnome-2.0 libbonobo-2.0 >= @LIBBONOBO_REQUIRED@ libedataserver-1.2 libecal-1.2 gio-2.0
Libs: -L${libdir} -ledata-cal-1.2 -lecal-1.2
Cflags: -I${privincludedir}
Modified: trunk/camel/camel-stream-vfs.c
==============================================================================
--- trunk/camel/camel-stream-vfs.c (original)
+++ trunk/camel/camel-stream-vfs.c Thu Apr 17 17:47:00 2008
@@ -27,47 +27,38 @@
#include <errno.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <glib.h>
-#include <glib/gstdio.h>
+#include <gio/gio.h>
#include "camel-file-utils.h"
#include "camel-operation.h"
#include "camel-private.h"
#include "camel-stream-vfs.h"
-static CamelSeekableStreamClass *parent_class = NULL;
+static CamelStreamClass *parent_class = NULL;
/* Returns the class for a CamelStreamVFS */
#define CSVFS_CLASS(so) CAMEL_STREAM_VFS_CLASS (CAMEL_OBJECT_GET_CLASS(so))
static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n);
static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n);
-/* static int stream_flush (CamelStream *stream); */
+static int stream_flush (CamelStream *stream);
static int stream_close (CamelStream *stream);
-static off_t stream_seek (CamelSeekableStream *stream, off_t offset,
- CamelStreamSeekPolicy policy);
static void
camel_stream_vfs_class_init (CamelStreamVFSClass *camel_stream_vfs_class)
{
- CamelSeekableStreamClass *camel_seekable_stream_class =
- CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_vfs_class);
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_stream_vfs_class);
- parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ()));
+ parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
/* virtual method overload */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
-/* camel_stream_class->flush = stream_flush; */
+ camel_stream_class->flush = stream_flush;
camel_stream_class->close = stream_close;
-
- camel_seekable_stream_class->seek = stream_seek;
}
static void
@@ -75,8 +66,7 @@
{
CamelStreamVFS *stream = CAMEL_STREAM_VFS (object);
- stream->handle = GINT_TO_POINTER (-1);
- ((CamelSeekableStream *)stream)->bound_end = CAMEL_STREAM_UNBOUND;
+ stream->stream = NULL;
}
static void
@@ -84,8 +74,8 @@
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (object);
- if (stream_vfs->handle != GINT_TO_POINTER (-1))
- gnome_vfs_close (stream_vfs->handle);
+ if (stream_vfs->stream)
+ g_object_unref (stream_vfs->stream);
}
@@ -95,7 +85,7 @@
static CamelType camel_stream_vfs_type = CAMEL_INVALID_TYPE;
if (camel_stream_vfs_type == CAMEL_INVALID_TYPE) {
- camel_stream_vfs_type = camel_type_register (camel_seekable_stream_get_type (), "CamelStreamVFS",
+ camel_stream_vfs_type = camel_type_register (camel_stream_get_type (), "CamelStreamVFS",
sizeof (CamelStreamVFS),
sizeof (CamelStreamVFSClass),
(CamelObjectClassInitFunc) camel_stream_vfs_class_init,
@@ -108,174 +98,179 @@
}
/**
- * camel_stream_vfs_new_with_handle:
- * @handle: a GnomeVFS handle
+ * camel_stream_vfs_new_with_stream:
+ * @stream: a GInputStream or GOutputStream instance
*
- * Creates a new fs stream using the given GnomeVFS handle @handle as the
+ * Creates a new fs stream using the given gio stream @stream as the
* backing store. When the stream is destroyed, the file descriptor
- * will be closed.
+ * will be closed. This will not increase reference counter on the stream.
*
* Returns a new #CamelStreamVFS
**/
CamelStream *
-camel_stream_vfs_new_with_handle (GnomeVFSHandle *handle)
+camel_stream_vfs_new_with_stream (GObject *stream)
{
CamelStreamVFS *stream_vfs;
- off_t offset;
- if (!handle)
+ errno = EINVAL;
+
+ if (!stream)
return NULL;
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream) || G_IS_INPUT_STREAM (stream), NULL);
+
+ errno = 0;
stream_vfs = CAMEL_STREAM_VFS (camel_object_new (camel_stream_vfs_get_type ()));
- stream_vfs->handle = handle;
- gnome_vfs_seek (handle, GNOME_VFS_SEEK_CURRENT, 0);
- offset = 0;
- CAMEL_SEEKABLE_STREAM (stream_vfs)->position = offset;
+ stream_vfs->stream = stream;
return CAMEL_STREAM (stream_vfs);
}
/**
* camel_stream_vfs_new_with_uri:
- * @name: a file uri
- * @flags: flags as in open(2)
- * @mode: a file mode
+ * @uri: a file uri
+ * @mode: opening mode for the uri file
*
- * Creates a new #CamelStreamVFS corresponding to the named file, flags,
- * and mode.
+ * Creates a new #CamelStreamVFS corresponding to the named file and mode.
*
* Returns the new stream, or %NULL on error.
**/
CamelStream *
-camel_stream_vfs_new_with_uri (const char *name, int flags, mode_t mode)
+camel_stream_vfs_new_with_uri (const char *uri, CamelStreamVFSOpenMethod mode)
{
- GnomeVFSResult result;
- GnomeVFSHandle *handle;
- int vfs_flag = 0;
-
- if (flags & O_WRONLY)
- vfs_flag = vfs_flag | GNOME_VFS_OPEN_WRITE;
- if (flags & O_RDONLY)
- vfs_flag = vfs_flag | GNOME_VFS_OPEN_READ;
- if (flags & O_RDWR)
- vfs_flag = vfs_flag | GNOME_VFS_OPEN_READ |GNOME_VFS_OPEN_WRITE;
+ GFile *file;
+ GObject *stream;
+ GError *error = NULL;
+
+ file = g_file_new_for_uri (uri);
+
+ switch (mode) {
+ case CAMEL_STREAM_VFS_CREATE:
+ stream = G_OBJECT (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error));
+ break;
+ case CAMEL_STREAM_VFS_APPEND:
+ stream = G_OBJECT (g_file_append_to (file, G_FILE_CREATE_NONE, NULL, &error));
+ break;
+ case CAMEL_STREAM_VFS_READ:
+ stream = G_OBJECT (g_file_read (file, NULL, &error));
+ break;
+ default:
+ errno = EINVAL;
+ g_return_val_if_reached (NULL);
+ }
- if (flags & O_CREAT)
- result = gnome_vfs_create (&handle, name, vfs_flag, FALSE, mode);
- else
- result = gnome_vfs_open (&handle, name, vfs_flag);
+ g_object_unref (file);
- if (result != GNOME_VFS_OK) {
+ if (error) {
+ errno = error->code;
+ g_warning ("%s", error->message);
+ g_error_free (error);
return NULL;
}
- return camel_stream_vfs_new_with_handle (handle);
+ return camel_stream_vfs_new_with_stream (stream);
+}
+
+/**
+ * camel_stream_vfs_is_writable:
+ * @stream_vfs: a #CamelStreamVFS instance
+ *
+ * Returns whether is the underlying stream writable or not.
+ **/
+gboolean
+camel_stream_vfs_is_writable (CamelStreamVFS *stream_vfs)
+{
+ g_return_val_if_fail (stream_vfs != NULL, FALSE);
+ g_return_val_if_fail (stream_vfs->stream != NULL, FALSE);
+
+ return G_IS_OUTPUT_STREAM (stream_vfs->stream);
}
static ssize_t
stream_read (CamelStream *stream, char *buffer, size_t n)
{
+ gssize nread;
+ GError *error = NULL;
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
- CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
- GnomeVFSFileSize nread = 0;
- GnomeVFSResult result;
-
- if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
- n = MIN (seekable->bound_end - seekable->position, n);
-
- result = gnome_vfs_read (stream_vfs->handle, buffer, n, &nread);
-
- if (nread > 0 && result == GNOME_VFS_OK)
- seekable->position += nread;
- else if (nread == 0)
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (stream_vfs->stream), 0);
+
+ nread = g_input_stream_read (G_INPUT_STREAM (stream_vfs->stream), buffer, n, NULL, &error);
+
+ if (nread == 0 || error)
stream->eos = TRUE;
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
return nread;
}
static ssize_t
stream_write (CamelStream *stream, const char *buffer, size_t n)
{
+ gssize nwritten;
+ GError *error = NULL;
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
- CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
- GnomeVFSFileSize nwritten = 0;
- GnomeVFSResult result;
- if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
- n = MIN (seekable->bound_end - seekable->position, n);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream), 0);
- result = gnome_vfs_write (stream_vfs->handle, buffer, n, &nwritten);
+ nwritten = g_output_stream_write (G_OUTPUT_STREAM (stream_vfs->stream), buffer, n, NULL, &error);
- if (nwritten > 0 && result == GNOME_VFS_OK)
- seekable->position += nwritten;
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
return nwritten;
}
-/* static int */
-/* stream_flush (CamelStream *stream) */
-/* { */
-/* return fsync(((CamelStreamVFS *)stream)->handle); */
-/* } */
-
static int
-stream_close (CamelStream *stream)
+stream_flush (CamelStream *stream)
{
- GnomeVFSResult result;
+ CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
+ GError *error = NULL;
+
+ g_return_val_if_fail (CAMEL_IS_STREAM_VFS (stream) && stream_vfs != NULL, -1);
+ g_return_val_if_fail (stream_vfs->stream != NULL, -1);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream), -1);
- result = gnome_vfs_close(((CamelStreamVFS *)stream)->handle);
+ g_output_stream_flush (G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
- if (result != GNOME_VFS_OK)
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
return -1;
+ }
- ((CamelStreamVFS *)stream)->handle = NULL;
return 0;
}
-static off_t
-stream_seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy)
+static int
+stream_close (CamelStream *stream)
{
CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
- GnomeVFSFileSize real = 0;
- GnomeVFSResult result;
- GnomeVFSHandle *handle = stream_vfs->handle;
-
- switch (policy) {
- case CAMEL_STREAM_SET:
- real = offset;
- break;
- case CAMEL_STREAM_CUR:
- real = stream->position + offset;
- break;
- case CAMEL_STREAM_END:
- if (stream->bound_end == CAMEL_STREAM_UNBOUND) {
- result = gnome_vfs_seek (handle, GNOME_VFS_SEEK_END, offset);
- if (result != GNOME_VFS_OK)
- return -1;
- gnome_vfs_tell (handle, &real);
- if (real != -1) {
- if (real<stream->bound_start)
- real = stream->bound_start;
- stream->position = real;
- }
- return real;
- }
- real = stream->bound_end + offset;
- break;
- }
-
- if (stream->bound_end != CAMEL_STREAM_UNBOUND)
- real = MIN (real, stream->bound_end);
- real = MAX (real, stream->bound_start);
+ GError *error = NULL;
- result = gnome_vfs_seek (handle, GNOME_VFS_SEEK_START, real);
- if (result != GNOME_VFS_OK)
- return -1;
+ g_return_val_if_fail (CAMEL_IS_STREAM_VFS (stream) && stream_vfs != NULL, -1);
+ g_return_val_if_fail (stream_vfs->stream != NULL, -1);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream) || G_IS_INPUT_STREAM (stream_vfs->stream), -1);
- if (real != stream->position && ((CamelStream *)stream)->eos)
- ((CamelStream *)stream)->eos = FALSE;
+ if (G_IS_OUTPUT_STREAM (stream_vfs->stream))
+ g_output_stream_close (G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
+ else
+ g_input_stream_close (G_INPUT_STREAM (stream_vfs->stream), NULL, &error);
- stream->position = real;
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return -1;
+ }
+
+ g_object_unref (stream_vfs->stream);
+ stream_vfs->stream = NULL;
- return real;
+ return 0;
}
Modified: trunk/camel/camel-stream-vfs.h
==============================================================================
--- trunk/camel/camel-stream-vfs.h (original)
+++ trunk/camel/camel-stream-vfs.h Thu Apr 17 17:47:00 2008
@@ -26,13 +26,10 @@
#ifndef CAMEL_STREAM_VFS_H
#define CAMEL_STREAM_VFS_H 1
-/* for open flags */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <glib.h>
+#include <glib-object.h>
-#include <camel/camel-seekable-stream.h>
+#include <camel/camel-stream.h>
#define CAMEL_STREAM_VFS_TYPE (camel_stream_vfs_get_type ())
#define CAMEL_STREAM_VFS(obj) (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_VFS_TYPE, CamelStreamVFS))
@@ -44,22 +41,30 @@
typedef struct _CamelStreamVFS CamelStreamVFS;
struct _CamelStreamVFS {
- CamelSeekableStream parent_object;
+ CamelStream parent_object;
- GnomeVFSHandle *handle;
+ GObject *stream;
};
typedef struct {
- CamelSeekableStreamClass parent_class;
+ CamelStreamClass parent_class;
} CamelStreamVFSClass;
/* Standard Camel function */
CamelType camel_stream_vfs_get_type (void);
+typedef enum {
+ CAMEL_STREAM_VFS_CREATE, /* writable, creates new file or replaces old file */
+ CAMEL_STREAM_VFS_APPEND, /* writable, creates new file or appends at the end of the old file */
+ CAMEL_STREAM_VFS_READ /* readable, opens existing file for reading */
+} CamelStreamVFSOpenMethod;
+
/* public methods */
-CamelStream * camel_stream_vfs_new_with_uri (const char *uri, int flags, mode_t mode);
-CamelStream * camel_stream_vfs_new_with_handle (GnomeVFSHandle *handle);
+CamelStream * camel_stream_vfs_new_with_uri (const char *uri, CamelStreamVFSOpenMethod method);
+CamelStream * camel_stream_vfs_new_with_stream (GObject *stream);
+
+gboolean camel_stream_vfs_is_writable (CamelStreamVFS *stream_vfs);
G_END_DECLS
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Apr 17 17:47:00 2008
@@ -16,7 +16,6 @@
m4_define([glib_minimum_version], [2.16.1])
m4_define([gtk_minimum_version], [2.10.0])
m4_define([ORBit_minimum_version], [2.9.8])
-m4_define([gnome_vfs_minimum_version], [2.4.0])
m4_define([libbonobo_minimum_version], [2.20.3])
m4_define([gconf_minimum_version], [2.0.0]) # XXX Just a Guess
m4_define([libglade_minimum_version], [2.0.0]) # XXX Just a Guess
@@ -67,7 +66,7 @@
LIBEGROUPWISE_REVISION=1
LIBEGROUPWISE_AGE=0
-LIBCAMEL_CURRENT=11
+LIBCAMEL_CURRENT=12
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
@@ -211,7 +210,6 @@
[glib-2.0 >= glib_minimum_version
gtk+-2.0 >= gtk_minimum_version
ORBit-2.0 >= ORBit_minimum_version
- gnome-vfs-2.0 >= gnome_vfs_minimum_version
libbonobo-2.0 >= libbonobo_minimum_version
gconf-2.0 >= gconf_minimum_version
libglade-2.0 >= libglade_minimum_version
@@ -1407,7 +1405,7 @@
AC_SUBST(E_DATA_SERVER_CFLAGS)
AC_SUBST(E_DATA_SERVER_LIBS)
-E_DATA_SERVER_UI_DEPS="gtk+-2.0 libglade-2.0 libgnome-2.0 gnome-vfs-2.0 $GNOME_KEYRING_REQUIREMENT"
+E_DATA_SERVER_UI_DEPS="gtk+-2.0 libglade-2.0 libgnome-2.0 gobject-2.0 gthread-2.0 gconf-2.0 $GNOME_KEYRING_REQUIREMENT"
EVO_SET_COMPILE_FLAGS(E_DATA_SERVER_UI, $E_DATA_SERVER_UI_DEPS, $THREADS_CFLAGS, $THREADS_LIBS)
AC_SUBST(E_DATA_SERVER_UI_CFLAGS)
@@ -1415,7 +1413,7 @@
dnl --- evolution-addressbook flags
-EVOLUTION_ADDRESSBOOK_DEPS="libxml-2.0 libgnome-2.0 gnome-vfs-2.0"
+EVOLUTION_ADDRESSBOOK_DEPS="libxml-2.0 libgnome-2.0 gobject-2.0 gthread-2.0 gconf-2.0"
EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS)
AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
@@ -1423,7 +1421,7 @@
dnl --- evolution-calendar flags
if test "x${enable_calendar}" = "xyes"; then
- EVOLUTION_CALENDAR_DEPS="libxml-2.0 libgnome-2.0 gnome-vfs-2.0"
+ EVOLUTION_CALENDAR_DEPS="libxml-2.0 libgnome-2.0 gio-2.0 gobject-2.0 gthread-2.0 gconf-2.0"
EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, $EVOLUTION_CALENDAR_DEPS)
AC_SUBST(EVOLUTION_CALENDAR_CFLAGS)
@@ -1432,7 +1430,7 @@
dnl --- factory flags
-E_FACTORY_DEPS="gnome-vfs-2.0 libgnome-2.0 $mozilla_nspr"
+E_FACTORY_DEPS="libgnome-2.0 $mozilla_nspr"
EVO_SET_COMPILE_FLAGS(E_FACTORY, $E_FACTORY_DEPS, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS)
AC_SUBST(E_FACTORY_CFLAGS)
@@ -1516,7 +1514,7 @@
AM_CONDITIONAL(ENABLE_LARGEFILE, test "x$enable_largefile" = "xyes")
-EVO_SET_COMPILE_FLAGS(CAMEL, $mozilla_nss gnome-vfs-2.0,
+EVO_SET_COMPILE_FLAGS(CAMEL, $mozilla_nss gio-2.0,
$THREADS_CFLAGS $KRB4_CFLAGS $KRB5_CFLAGS $MANUAL_NSS_CFLAGS $LARGEFILE_CFLAGS,
-lz $THREADS_LIBS $KRB4_LDFLAGS $KRB5_LDFLAGS $MANUAL_NSS_LIBS)
AC_SUBST(CAMEL_CFLAGS)
Modified: trunk/src/server.c
==============================================================================
--- trunk/src/server.c (original)
+++ trunk/src/server.c Thu Apr 17 17:47:00 2008
@@ -37,7 +37,6 @@
#include <glib/gi18n.h>
#include <libgnome/gnome-init.h>
#include <bonobo-activation/bonobo-activation.h>
-#include <libgnomevfs/gnome-vfs-init.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-generic-factory.h>
@@ -437,7 +436,5 @@
bonobo_object_unref (BONOBO_OBJECT (interface_check_iface));
interface_check_iface = NULL;
- gnome_vfs_shutdown ();
-
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]