[monkey-bubble: 520/753] add.



commit 1bbe4604d86658d201a05103f0060cca56a95865
Author: Michael Meeks <michael ximian com>
Date:   Tue Jul 10 16:16:59 2001 +0000

    add.
    
    2001-07-10  Michael Meeks  <michael ximian com>
    
    	* bonobo-moniker-vfs.c: add.
    
    	* bonobo-stream-vfs.c: port to GObject / BonoboObject.
    
    	* bonobo-storage-vfs.c: ditto.
    
    	* GNOME_Moniker_std.oaf.in.in: register the vfs moniker.

 monikers/ChangeLog                   |   10 ++
 monikers/GNOME_Moniker_std.oaf.in.in |   12 ++
 monikers/Makefile.am-50588           |    7 +-
 monikers/bonobo-moniker-vfs.c        |   69 +++++++++++
 monikers/bonobo-storage-vfs.c        |  206 +++++++++++++++-----------------
 monikers/bonobo-storage-vfs.h        |   27 +++--
 monikers/bonobo-stream-vfs.c         |  217 ++++++++++++----------------------
 monikers/bonobo-stream-vfs.h         |   31 +++--
 monikers/gnome-moniker-std.c         |    5 +
 monikers/gnome-moniker-std.h         |    5 +
 10 files changed, 315 insertions(+), 274 deletions(-)
---
diff --git a/monikers/ChangeLog b/monikers/ChangeLog
index 223783a..0e5b418 100644
--- a/monikers/ChangeLog
+++ b/monikers/ChangeLog
@@ -1,5 +1,15 @@
 2001-07-10  Michael Meeks  <michael ximian com>
 
+	* bonobo-moniker-vfs.c: add.
+
+	* bonobo-stream-vfs.c: port to GObject / BonoboObject.
+
+	* bonobo-storage-vfs.c: ditto.
+
+	* GNOME_Moniker_std.oaf.in.in: register the vfs moniker.
+
+2001-07-10  Michael Meeks  <michael ximian com>
+
 	* bonobo-storage-fs.c (fs_open_storage),
 	(fs_open_stream): CORBA_Object_duplicate the return
 	values.
diff --git a/monikers/GNOME_Moniker_std.oaf.in.in b/monikers/GNOME_Moniker_std.oaf.in.in
index 33eb256..caa8f43 100644
--- a/monikers/GNOME_Moniker_std.oaf.in.in
+++ b/monikers/GNOME_Moniker_std.oaf.in.in
@@ -33,4 +33,16 @@
 	</oaf_attribute>
 </oaf_server>
 
+<oaf_server iid="OAFIID:GNOME_Moniker_VFS" type="factory"
+	location="OAFIID:GNOME_Moniker_std_Factory">
+	<oaf_attribute name="repo_ids" type="stringv">
+		<item value="IDL:Bonobo/Moniker:1.0"/>
+		<item value="IDL:Bonobo/Unknown:1.0"/>
+	</oaf_attribute>
+	<oaf_attribute name="name" type="string" _value="generic Gnome VFS moniker"/>
+	<oaf_attribute name="bonobo:moniker" type="stringv">
+		<item value="vfs:"/>
+	</oaf_attribute>
+</oaf_server>
+
 </oaf_info>
diff --git a/monikers/Makefile.am-50588 b/monikers/Makefile.am-50588
index 774c947..b5c07cf 100644
--- a/monikers/Makefile.am-50588
+++ b/monikers/Makefile.am-50588
@@ -44,7 +44,12 @@ libmoniker_gnome_std_la_SOURCES = \
 	bonobo-storage-fs.h		\
 	bonobo-storage-fs.c		\
 	bonobo-moniker-extender-file.c	\
-	bonobo-moniker-file.c
+	bonobo-moniker-file.c		\
+	bonobo-stream-vfs.h		\
+	bonobo-stream-vfs.c		\
+	bonobo-storage-vfs.h		\
+	bonobo-storage-vfs.c		\
+	bonobo-moniker-vfs.c
 
 libmoniker_gnome_std_la_LIBADD = \
 	../libgnome/libgnome-2.la \
diff --git a/monikers/bonobo-moniker-vfs.c b/monikers/bonobo-moniker-vfs.c
new file mode 100644
index 0000000..b4b4598
--- /dev/null
+++ b/monikers/bonobo-moniker-vfs.c
@@ -0,0 +1,69 @@
+/*
+ * bonobo-moniker-file.c: Sample file-system based Moniker implementation
+ *
+ * This is the file-system based Moniker implementation.
+ *
+ * Author:
+ *	Michael Meeks (michael helixcode com)
+ *
+ * Copyright 2000, Helix Code, Inc.
+ */
+#include <config.h>
+#include <string.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-storage.h>
+#include <bonobo/bonobo-moniker-util.h>
+
+#include "gnome-moniker-std.h"
+#include "bonobo-stream-vfs.h"
+
+Bonobo_Unknown
+bonobo_moniker_vfs_resolve (BonoboMoniker               *moniker,
+			    const Bonobo_ResolveOptions *options,
+			    const CORBA_char            *requested_interface,
+			    CORBA_Environment           *ev)
+{
+	const char    *fname = bonobo_moniker_get_name (moniker);
+
+	if (!strcmp (requested_interface, "IDL:Bonobo/Stream:1.0")) {
+		BonoboObject *stream;
+		
+		stream = BONOBO_OBJECT (bonobo_stream_vfs_open (
+			fname, Bonobo_Storage_READ, 0664, ev));
+
+		if (BONOBO_EX (ev))
+			return CORBA_OBJECT_NIL;
+
+		if (!stream) {
+			g_warning ("Failed to open stream '%s'", fname);
+			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+					     ex_Bonobo_Moniker_InterfaceNotFound, NULL);
+			return CORBA_OBJECT_NIL;
+		}
+
+		return CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev);
+
+	}
+	else if (!strcmp (requested_interface, "IDL:Bonobo/Storage:1.0")) {
+		BonoboObject *storage;
+		
+		storage = BONOBO_OBJECT (bonobo_storage_vfs_open (
+			fname, Bonobo_Storage_READ, 0664, ev));
+
+		if (BONOBO_EX (ev))
+			return CORBA_OBJECT_NIL;
+
+		if (!storage) {
+			g_warning ("Failed to open storage '%s'", fname);
+			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+					     ex_Bonobo_Moniker_InterfaceNotFound, NULL);
+			return CORBA_OBJECT_NIL;
+		}
+
+		return CORBA_Object_duplicate (BONOBO_OBJREF (storage), ev);
+	}
+	else
+		return bonobo_moniker_use_extender (
+			"OAFIID:Bonobo_MonikerExtender_stream",
+			moniker, options, requested_interface, ev);
+}
diff --git a/monikers/bonobo-storage-vfs.c b/monikers/bonobo-storage-vfs.c
index a7cdbe7..cc52ce5 100644
--- a/monikers/bonobo-storage-vfs.c
+++ b/monikers/bonobo-storage-vfs.c
@@ -10,31 +10,32 @@
 #include <unistd.h>
 #include <libgnome/gnome-defs.h>
 #include <libgnome/gnome-util.h>
-#include <storage-modules/bonobo-storage-vfs.h>
-#include <storage-modules/bonobo-stream-vfs.h>
-#include <bonobo/bonobo-storage-plugin.h>
+#include <bonobo/bonobo-storage.h>
+#include "bonobo-storage-vfs.h"
+#include "bonobo-stream-vfs.h"
 
-static BonoboStorageClass *bonobo_storage_vfs_parent_class;
+static BonoboObjectClass *bonobo_storage_vfs_parent_class;
 
 static Bonobo_StorageInfo*
-vfs_get_info (BonoboStorage *storage,
-	      const CORBA_char *path,
+vfs_get_info (PortableServer_Servant         storage,
+	      const CORBA_char              *path,
 	      const Bonobo_StorageInfoFields mask,
-	      CORBA_Environment *ev)
+	      CORBA_Environment             *ev)
 {
 	g_warning ("FIXME: get_info not yet implemented");
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION, 
 			     ex_Bonobo_Storage_NotSupported, 
 			     NULL);
+
 	return CORBA_OBJECT_NIL;
 }
 
 static void
-vfs_set_info (BonoboStorage *storage,
-	      const CORBA_char *path,
-	      const Bonobo_StorageInfo *info,
+vfs_set_info (PortableServer_Servant         storage,
+	      const CORBA_char              *path,
+	      const Bonobo_StorageInfo      *info,
 	      const Bonobo_StorageInfoFields mask,
-	      CORBA_Environment *ev)
+	      CORBA_Environment             *ev)
 {
 	g_warning ("FIXME: set_info not yet implemented");
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION, 
@@ -42,47 +43,43 @@ vfs_set_info (BonoboStorage *storage,
 			     NULL);
 }
 
-static BonoboStream *
-vfs_open_stream (BonoboStorage *storage, const CORBA_char *path,
-		Bonobo_Storage_OpenMode mode, CORBA_Environment *ev)
+static Bonobo_Stream
+vfs_open_stream (PortableServer_Servant  storage,
+		 const CORBA_char       *path,
+		 Bonobo_Storage_OpenMode mode,
+		 CORBA_Environment      *ev)
 {
-	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (storage);
-	BonoboStream *stream;
+	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (
+		bonobo_object (storage));
+	BonoboStreamVfs *stream;
 	char *full;
 
 	full = g_concat_dir_and_file (storage_vfs->path, path);
 	stream = bonobo_stream_vfs_open (full, 0664, mode, ev);
 	g_free (full);
 
-	return stream;
+	return BONOBO_OBJREF (stream);
 }
 
 /*
  * Creates the Gtk object and the corba server bound to it
  */
-static BonoboStorage *
+static BonoboStorageVfs *
 do_bonobo_storage_vfs_create (const char *path)
 {
 	BonoboStorageVfs *storage_vfs;
-	Bonobo_Storage corba_storage;
 
-	storage_vfs = gtk_type_new (bonobo_storage_vfs_get_type ());
+	storage_vfs = g_object_new (bonobo_storage_vfs_get_type (), NULL);
 	storage_vfs->path = g_strdup (path);
-	
-	corba_storage = bonobo_storage_corba_object_create (
-		BONOBO_OBJECT (storage_vfs));
-	if (corba_storage == CORBA_OBJECT_NIL) {
-		bonobo_object_unref (BONOBO_OBJECT (storage_vfs));
-		return NULL;
-	}
 
-	return bonobo_storage_construct (
-		BONOBO_STORAGE (storage_vfs), corba_storage);
+	return storage_vfs;
 }
 
 static void
-vfs_rename (BonoboStorage *storage, const CORBA_char *path,
-	   const CORBA_char *new_path, CORBA_Environment *ev)
+vfs_rename (PortableServer_Servant storage,
+	    const CORBA_char      *path,
+	   const CORBA_char       *new_path,
+	    CORBA_Environment     *ev)
 {
 	g_warning ("Not yet implemented");
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
@@ -90,28 +87,31 @@ vfs_rename (BonoboStorage *storage, const CORBA_char *path,
 }
 
 static void
-vfs_commit (BonoboStorage *storage, CORBA_Environment *ev)
+vfs_commit (PortableServer_Servant storage,
+	    CORBA_Environment     *ev)
 {
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 			     ex_Bonobo_Stream_NotSupported, NULL);
 }
 
 static void
-vfs_revert (BonoboStorage *storage, CORBA_Environment *ev)
+vfs_revert (PortableServer_Servant storage,
+	    CORBA_Environment     *ev)
 {
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 			     ex_Bonobo_Stream_NotSupported, NULL);
 }
 
 static Bonobo_Storage_DirectoryList *
-vfs_list_contents (BonoboStorage *storage, const CORBA_char *path, 
-		   Bonobo_StorageInfoFields mask, CORBA_Environment *ev)
+vfs_list_contents (PortableServer_Servant   storage,
+		   const CORBA_char        *path, 
+		   Bonobo_StorageInfoFields mask,
+		   CORBA_Environment       *ev)
 {
 	BonoboStorageVfs              *storage_vfs;
 	Bonobo_Storage_DirectoryList  *list = NULL;
 	GnomeVFSResult                 result;
-	GnomeVFSDirectoryList         *dir_list;
-	GnomeVFSFileInfo              *info;
+	GList                         *dir_list, *info;
 	char                          *uri;
 	int                            len, i;
 
@@ -132,21 +132,20 @@ vfs_list_contents (BonoboStorage *storage, const CORBA_char *path,
 		return NULL;
 	}
 
-	len  = gnome_vfs_directory_list_get_num_entries (dir_list);
+	len  = g_list_length (dir_list);
 	list = Bonobo_Storage_DirectoryList__alloc      ();
 	list->_buffer = CORBA_sequence_Bonobo_StorageInfo_allocbuf (len);
 	list->_length = len;
 	CORBA_sequence_set_release (list, TRUE); 
 
 	i = 0;
-	for (info = gnome_vfs_directory_list_first (dir_list);
-	     info; info = gnome_vfs_directory_list_next (dir_list))
-
+	for (info = dir_list; info; info = info->next) {
 		bonobo_stream_vfs_storageinfo_from_file_info (
-			&list->_buffer [i++], info);
-
-	gnome_vfs_directory_list_destroy (dir_list);
+			&list->_buffer [i++], info->data);
+		gnome_vfs_file_info_unref (info->data);
+	}
 
+	g_list_free (dir_list);
 	g_free (uri);
 
 	return list;
@@ -160,8 +159,9 @@ vfs_list_contents (BonoboStorage *storage, const CORBA_char *path,
  *
  * Returns a BonoboStorage object that represents the storage at @path
  */
-static BonoboStorage *
-bonobo_storage_vfs_open (const char *path, gint flags, gint mode,
+BonoboStorageVfs *
+bonobo_storage_vfs_open (const char *path,
+			 gint flags, gint mode,
 			 CORBA_Environment *ev)
 {
 	GnomeVFSResult    result;
@@ -220,14 +220,15 @@ bonobo_storage_vfs_open (const char *path, gint flags, gint mode,
 	return do_bonobo_storage_vfs_create (path);
 }
 
-static BonoboStorage *
-vfs_open_storage (BonoboStorage *storage,
-		  const CORBA_char *path,
+static Bonobo_Storage
+vfs_open_storage (PortableServer_Servant  storage,
+		  const CORBA_char       *path,
 		  Bonobo_Storage_OpenMode mode,
-		  CORBA_Environment *ev)
+		  CORBA_Environment      *ev)
 {
-	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (storage);
-	BonoboStorage    *new_storage;
+	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (
+		bonobo_object (storage));
+	BonoboStorageVfs *new_storage;
 	GnomeVFSResult    result;
 	char *full;
 
@@ -242,15 +243,16 @@ vfs_open_storage (BonoboStorage *storage,
 
 	g_free (full);
 
-	return new_storage;
+	return BONOBO_OBJREF (new_storage);
 }
 
 static void
-vfs_erase (BonoboStorage *storage,
-	   const CORBA_char *path,
-	   CORBA_Environment *ev)
+vfs_erase (PortableServer_Servant storage,
+	   const CORBA_char      *path,
+	   CORBA_Environment     *ev)
 {
-	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (storage);
+	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (
+		bonobo_object (storage));
 	GnomeVFSResult    result;
 	char *full;
 
@@ -267,69 +269,55 @@ vfs_erase (BonoboStorage *storage,
 }
 
 static void
-bonobo_storage_vfs_destroy (GtkObject *object)
+vfs_copy_to (PortableServer_Servant storage,
+	     Bonobo_Storage         dest,
+	     CORBA_Environment     *ev)
+{
+	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (
+		bonobo_object (storage));
+
+	bonobo_storage_copy_to (
+		BONOBO_OBJREF (storage_vfs), dest, ev);
+}
+
+static void
+bonobo_storage_vfs_finalize (GObject *object)
 {
 	BonoboStorageVfs *storage_vfs = BONOBO_STORAGE_VFS (object);
 
 	g_free (storage_vfs->path);
+	storage_vfs->path = NULL;
 }
 
 static void
-bonobo_storage_vfs_class_init (BonoboStorageVfsClass *class)
+bonobo_storage_vfs_class_init (BonoboStorageVfsClass *klass)
 {
-	GtkObjectClass *object_class = (GtkObjectClass *) class;
-	BonoboStorageClass *sclass = BONOBO_STORAGE_CLASS (class);
+	GObjectClass *object_class = (GObjectClass *) klass;
+	POA_Bonobo_Storage__epv *epv = &klass->epv;
 	
-	bonobo_storage_vfs_parent_class = gtk_type_class (bonobo_storage_get_type ());
-
-	sclass->get_info       = vfs_get_info;
-	sclass->set_info       = vfs_set_info;
-	sclass->open_stream    = vfs_open_stream;
-	sclass->open_storage   = vfs_open_storage;
-	sclass->copy_to        = NULL; /* use the generic method */
-	sclass->rename         = vfs_rename;
-	sclass->commit         = vfs_commit;
-	sclass->revert         = vfs_revert;
-	sclass->list_contents  = vfs_list_contents;
-	sclass->erase          = vfs_erase;
-
-	object_class->destroy = bonobo_storage_vfs_destroy;
+	bonobo_storage_vfs_parent_class = 
+		g_type_class_peek_parent (klass);
+
+	epv->getInfo       = vfs_get_info;
+	epv->setInfo       = vfs_set_info;
+	epv->openStream    = vfs_open_stream;
+	epv->openStorage   = vfs_open_storage;
+	epv->copyTo        = vfs_copy_to;
+	epv->rename        = vfs_rename;
+	epv->commit        = vfs_commit;
+	epv->revert        = vfs_revert;
+	epv->listContents  = vfs_list_contents;
+	epv->erase         = vfs_erase;
+
+	object_class->finalize = bonobo_storage_vfs_finalize;
 }
 
-GtkType
-bonobo_storage_vfs_get_type (void)
+static void 
+bonobo_storage_vfs_init (GObject *object)
 {
-	static GtkType type = 0;
-
-	if (!type){
-		GtkTypeInfo info = {
-			"IDL:GNOME/StorageVfs:1.0",
-			sizeof (BonoboStorageVfs),
-			sizeof (BonoboStorageVfsClass),
-			(GtkClassInitFunc) bonobo_storage_vfs_class_init,
-			(GtkObjectInitFunc) NULL,
-			NULL, /* reserved 1 */
-			NULL, /* reserved 2 */
-			(GtkClassInitFunc) NULL
-		};
-
-		type = gtk_type_unique (bonobo_storage_get_type (), &info);
-	}
-
-	return type;
+	/* nothing to do */
 }
 
-gint 
-init_storage_plugin (StoragePlugin *plugin)
-{
-	g_return_val_if_fail (plugin != NULL, -1);
-
-	plugin->name = "vfs";
-	plugin->description = "Gnome Virtual Filesystem Driver";
-	plugin->version = BONOBO_STORAGE_VERSION;
-	
-	plugin->storage_open = bonobo_storage_vfs_open; 
-	plugin->stream_open  = bonobo_stream_vfs_open; 
-
-	return 0;
-}
+BONOBO_TYPE_FUNC (BonoboStorageVfs,
+		  bonobo_object_get_type (),
+		  bonobo_storage_vfs);
diff --git a/monikers/bonobo-storage-vfs.h b/monikers/bonobo-storage-vfs.h
index 6d1613f..ea16fe3 100644
--- a/monikers/bonobo-storage-vfs.h
+++ b/monikers/bonobo-storage-vfs.h
@@ -2,27 +2,32 @@
 #ifndef _BONOBO_STORAGE_VFS_H_
 #define _BONOBO_STORAGE_VFS_H_
 
-#include <bonobo/bonobo-storage.h>
+#include <bonobo/bonobo-object.h>
 
-BEGIN_GNOME_DECLS
+G_BEGIN_DECLS
 
 #define BONOBO_STORAGE_VFS_TYPE        (bonobo_storage_vfs_get_type ())
-#define BONOBO_STORAGE_VFS(o)          (GTK_CHECK_CAST ((o), BONOBO_STORAGE_VFS_TYPE, BonoboStorageVfs))
-#define BONOBO_STORAGE_VFS_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), BONOBO_STORAGE_VFS_TYPE, BonoboStorageVfsClass))
-#define BONOBO_IS_STORAGE_VFS(o)       (GTK_CHECK_TYPE ((o), BONOBO_STORAGE_VFS_TYPE))
-#define BONOBO_IS_STORAGE_VFS_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_STORAGE_VFS_TYPE))
+#define BONOBO_STORAGE_VFS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), BONOBO_STORAGE_VFS_TYPE, BonoboStorageVfs))
+#define BONOBO_STORAGE_VFS_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), BONOBO_STORAGE_VFS_TYPE, BonoboStorageVfsClass))
+#define BONOBO_IS_STORAGE_VFS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), BONOBO_STORAGE_VFS_TYPE))
+#define BONOBO_IS_STORAGE_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), BONOBO_STORAGE_VFS_TYPE))
 
 typedef struct {
-	BonoboStorage storage;
-	char *path;
+	BonoboObject parent;
+	char        *path;
 } BonoboStorageVfs;
 
 typedef struct {
-	BonoboStorageClass parent_class;
+	BonoboObjectClass       parent_class;
+
+	POA_Bonobo_Storage__epv epv;
 } BonoboStorageVfsClass;
 
-GtkType         bonobo_storage_vfs_get_type     (void);
+GType             bonobo_storage_vfs_get_type (void);
+BonoboStorageVfs *bonobo_storage_vfs_open     (const char *path,
+					       gint flags, gint mode,
+					       CORBA_Environment *ev);
 
-END_GNOME_DECLS
+G_END_DECLS
 
 #endif /* _BONOBO_STORAGE_VFS_H_ */
diff --git a/monikers/bonobo-stream-vfs.c b/monikers/bonobo-stream-vfs.c
index ca7dc5e..aebd204 100644
--- a/monikers/bonobo-stream-vfs.c
+++ b/monikers/bonobo-stream-vfs.c
@@ -5,7 +5,7 @@
  * Author:
  *   Michael Meeks <michael helixcode com>
  *
- * Copyright 2000, Helix Code Inc.
+ * Copyright 2001, Ximian, Inc.
  */
 #include <config.h>
 #include <stdio.h>
@@ -16,7 +16,7 @@
 #include "bonobo-stream-vfs.h"
 #include <errno.h>
 
-static BonoboStreamClass *bonobo_stream_vfs_parent_class;
+static BonoboObjectClass *bonobo_stream_vfs_parent_class;
 
 void
 bonobo_stream_vfs_storageinfo_from_file_info (Bonobo_StorageInfo *si,
@@ -46,13 +46,14 @@ bonobo_stream_vfs_storageinfo_from_file_info (Bonobo_StorageInfo *si,
 }
 
 static Bonobo_StorageInfo *
-vfs_get_info (BonoboStream                   *stream,
+vfs_get_info (PortableServer_Servant          stream,
 	      const Bonobo_StorageInfoFields  mask,
 	      CORBA_Environment              *ev)
 {
-	BonoboStreamVfs    *sfs = BONOBO_STREAM_VFS (stream);
+	BonoboStreamVfs    *sfs = BONOBO_STREAM_VFS (
+		bonobo_object (stream));
 	Bonobo_StorageInfo *si;
-	GnomeVFSFileInfo    fi;
+	GnomeVFSFileInfo   *fi;
 	GnomeVFSResult      result;
 
 	if (mask & ~(Bonobo_FIELD_CONTENT_TYPE | Bonobo_FIELD_SIZE |
@@ -62,9 +63,9 @@ vfs_get_info (BonoboStream                   *stream,
 		return CORBA_OBJECT_NIL;
 	}
 
-	gnome_vfs_file_info_init (&fi);
+	fi = gnome_vfs_file_info_new ();
 	result = gnome_vfs_get_file_info_from_handle (
-		sfs->handle, &fi,
+		sfs->handle, fi,
 		(mask & Bonobo_FIELD_CONTENT_TYPE) ?
 		GNOME_VFS_FILE_INFO_GET_MIME_TYPE :
 		GNOME_VFS_FILE_INFO_DEFAULT);
@@ -81,15 +82,15 @@ vfs_get_info (BonoboStream                   *stream,
 
 	si = Bonobo_StorageInfo__alloc ();
 
-	bonobo_stream_vfs_storageinfo_from_file_info (si, &fi);
+	bonobo_stream_vfs_storageinfo_from_file_info (si, fi);
 
-	gnome_vfs_file_info_clear (&fi);
+	gnome_vfs_file_info_unref (fi);
 
 	return si;
 }
 
 static void
-vfs_set_info (BonoboStream                   *stream,
+vfs_set_info (PortableServer_Servant          stream,
 	      const Bonobo_StorageInfo       *info,
 	      const Bonobo_StorageInfoFields  mask,
 	      CORBA_Environment              *ev)
@@ -100,11 +101,12 @@ vfs_set_info (BonoboStream                   *stream,
 }
 
 static void
-vfs_write (BonoboStream *stream,
+vfs_write (PortableServer_Servant     stream,
 	   const Bonobo_Stream_iobuf *buffer,
-	   CORBA_Environment *ev)
+	   CORBA_Environment         *ev)
 {
-	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (stream);
+	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (
+		bonobo_object (stream));
 	GnomeVFSResult   result;
 	GnomeVFSFileSize bytes_written;
 
@@ -119,11 +121,13 @@ vfs_write (BonoboStream *stream,
 }
 
 static void
-vfs_read (BonoboStream *stream, CORBA_long count,
-	  Bonobo_Stream_iobuf **buffer,
-	  CORBA_Environment    *ev)
+vfs_read (PortableServer_Servant stream,
+	  CORBA_long             count,
+	  Bonobo_Stream_iobuf  **buffer,
+	  CORBA_Environment     *ev)
 {
-	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (stream);
+	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (
+		bonobo_object (stream));
 	GnomeVFSResult   result;
 	GnomeVFSFileSize bytes_read;
 	CORBA_octet     *data;
@@ -155,11 +159,13 @@ vfs_read (BonoboStream *stream, CORBA_long count,
 }
 
 static CORBA_long
-vfs_seek (BonoboStream *stream,
-	  CORBA_long offset, Bonobo_Stream_SeekType whence,
-	  CORBA_Environment *ev)
+vfs_seek (PortableServer_Servant stream,
+	  CORBA_long             offset,
+	  Bonobo_Stream_SeekType whence,
+	  CORBA_Environment     *ev)
 {
-	BonoboStreamVfs     *sfs = BONOBO_STREAM_VFS (stream);
+	BonoboStreamVfs     *sfs = BONOBO_STREAM_VFS (
+		bonobo_object (stream));
 	GnomeVFSSeekPosition pos;
 	GnomeVFSResult       result;
 	GnomeVFSFileOffset   where;
@@ -201,11 +207,12 @@ vfs_seek (BonoboStream *stream,
 }
 
 static void
-vfs_truncate (BonoboStream *stream,
-	      const CORBA_long new_size, 
-	      CORBA_Environment *ev)
+vfs_truncate (PortableServer_Servant stream,
+	      const CORBA_long       new_size, 
+	      CORBA_Environment     *ev)
 {
-	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (stream);
+	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (
+		bonobo_object (stream));
 	GnomeVFSResult result;
 
 	result = gnome_vfs_truncate_handle (sfs->handle, new_size);
@@ -217,76 +224,23 @@ vfs_truncate (BonoboStream *stream,
 }
 
 static void
-vfs_copy_to  (BonoboStream      *stream,
-	      const CORBA_char  *dest,
-	      const CORBA_long  bytes,
-	      CORBA_long       *read_bytes,
-	      CORBA_long       *written_bytes,
-	      CORBA_Environment *ev)
-{
-	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (stream);
-#define READ_CHUNK_SIZE 65536
-	CORBA_octet      data [READ_CHUNK_SIZE];
-	CORBA_unsigned_long more = bytes;
-	GnomeVFSHandle  *fd_out;
-	GnomeVFSResult   res;
-	GnomeVFSFileSize rsize, wsize;
-
-	*read_bytes = 0;
-	*written_bytes = 0;
-
-	res = gnome_vfs_create (&fd_out, dest, GNOME_VFS_OPEN_WRITE, FALSE, 0666);
-	if (res != GNOME_VFS_OK) {
-		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
-				     ex_Bonobo_Stream_NoPermission, NULL);
-		return;
-	}
-
-	do {
-		if (bytes == -1) 
-			more = READ_CHUNK_SIZE;
-
-		res = gnome_vfs_read (sfs->handle, data,
-				      MIN (READ_CHUNK_SIZE, more), &rsize);
-
-		if (res == GNOME_VFS_OK) {
-			*read_bytes += rsize;
-			more -= rsize;
-			res = gnome_vfs_write (fd_out, data, rsize, &wsize);
-			if (res == GNOME_VFS_OK)
-				*written_bytes += wsize;
-			else
-				break;
-		} else
-			rsize = 0;
-
-	} while ((more > 0 || bytes == -1) && rsize > 0);
-
-	if (res != GNOME_VFS_OK)
-		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
-				     ex_Bonobo_Stream_IOError, NULL);
-
-	gnome_vfs_close (fd_out);
-}
-
-static void
-vfs_commit (BonoboStream *stream,
-	    CORBA_Environment *ev)
+vfs_commit (PortableServer_Servant stream,
+	    CORBA_Environment     *ev)
 {
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 			     ex_Bonobo_Stream_NotSupported, NULL);
 }
 
 static void
-vfs_revert (BonoboStream *stream,
-	    CORBA_Environment *ev)
+vfs_revert (PortableServer_Servant stream,
+	    CORBA_Environment     *ev)
 {
 	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 			     ex_Bonobo_Stream_NotSupported, NULL);
 }
 	
 static void
-bonobo_stream_vfs_destroy (GtkObject *object)
+vfs_destroy (BonoboObject *object)
 {
 	BonoboStreamVfs *sfs = BONOBO_STREAM_VFS (object);
 
@@ -296,28 +250,27 @@ bonobo_stream_vfs_destroy (GtkObject *object)
 
 	sfs->handle = NULL;
 
-	GTK_OBJECT_CLASS (bonobo_stream_vfs_parent_class)->destroy (object);	
+	bonobo_stream_vfs_parent_class->destroy (object);
 }
 
 static void
 bonobo_stream_vfs_class_init (BonoboStreamVfsClass *klass)
 {
-	BonoboStreamClass *sclass = BONOBO_STREAM_CLASS (klass);
-	GtkObjectClass    *object_class = GTK_OBJECT_CLASS (klass);
+	POA_Bonobo_Stream__epv *epv = &klass->epv;
 	
-	bonobo_stream_vfs_parent_class = gtk_type_class (bonobo_stream_get_type ());
-
-	sclass->get_info = vfs_get_info;
-	sclass->set_info = vfs_set_info;
-	sclass->write    = vfs_write;
-	sclass->read     = vfs_read;
-	sclass->seek     = vfs_seek;
-	sclass->truncate = vfs_truncate;
-	sclass->copy_to  = vfs_copy_to;
-	sclass->commit   = vfs_commit;
-	sclass->commit   = vfs_revert;
-
-	object_class->destroy = bonobo_stream_vfs_destroy;
+	bonobo_stream_vfs_parent_class = 
+		g_type_class_peek_parent (klass);
+
+	epv->getInfo  = vfs_get_info;
+	epv->setInfo  = vfs_set_info;
+	epv->write    = vfs_write;
+	epv->read     = vfs_read;
+	epv->seek     = vfs_seek;
+	epv->truncate = vfs_truncate;
+        epv->commit   = vfs_commit;
+        epv->revert   = vfs_revert;
+
+	((BonoboObjectClass *)klass)->destroy = vfs_destroy;
 }
 
 /**
@@ -325,55 +278,34 @@ bonobo_stream_vfs_class_init (BonoboStreamVfsClass *klass)
  *
  * Returns the GtkType for the BonoboStreamVfs class.
  */
-GtkType
+GType
 bonobo_stream_vfs_get_type (void)
 {
-	static GtkType type = 0;
+	static GType type = 0;
 
-	if (!type){
-		GtkTypeInfo info = {
-			"BonoboStreamVfs",
-			sizeof (BonoboStreamVfs),
+	if (!type) {
+		GTypeInfo info = {
 			sizeof (BonoboStreamVfsClass),
-			(GtkClassInitFunc) bonobo_stream_vfs_class_init,
-			(GtkObjectInitFunc) NULL,
-			NULL, /* reserved 1 */
-			NULL, /* reserved 2 */
-			(GtkClassInitFunc) NULL
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) bonobo_stream_vfs_class_init,
+			NULL, /* class_finalize */
+			NULL, /* class_data */
+			sizeof (BonoboStreamVfs),
+			0, /* n_preallocs */
+			(GInstanceInitFunc) NULL
 		};
 
-		type = gtk_type_unique (bonobo_stream_get_type (), &info);
+		type = bonobo_type_unique (
+			BONOBO_OBJECT_TYPE,
+			POA_Bonobo_Stream__init, NULL,
+			G_STRUCT_OFFSET (BonoboStreamVfsClass, epv),
+			&info, "BonoboStreamVFS");
 	}
 
 	return type;
 }
 
-static BonoboStream *
-bonobo_stream_create (GnomeVFSHandle *handle)
-{
-	BonoboStreamVfs *stream_vfs;
-	Bonobo_Stream corba_stream;
-
-	stream_vfs = gtk_type_new (bonobo_stream_vfs_get_type ());
-	if (stream_vfs == NULL)
-		return NULL;
-	
-	stream_vfs->handle = handle;
-	
-	corba_stream = bonobo_stream_corba_object_create (
-		BONOBO_OBJECT (stream_vfs));
-
-	if (corba_stream == CORBA_OBJECT_NIL){
-		bonobo_object_unref (BONOBO_OBJECT (stream_vfs));
-		return NULL;
-	}
-
-	return BONOBO_STREAM (
-		bonobo_object_construct (
-			BONOBO_OBJECT (stream_vfs), corba_stream));
-}
-
-
 /**
  * bonobo_stream_vfs_open:
  * @path: The path to the file to be opened.
@@ -382,13 +314,14 @@ bonobo_stream_create (GnomeVFSHandle *handle)
  * Creates a new BonoboStream object for the filename specified by
  * @path.  
  */
-BonoboStream *
+BonoboStreamVfs *
 bonobo_stream_vfs_open (const char *path, gint flags, gint mode,
 			CORBA_Environment *ev)
 {
 	GnomeVFSResult   result;
 	GnomeVFSHandle  *handle;
 	GnomeVFSOpenMode vfs_mode = GNOME_VFS_OPEN_NONE;
+	BonoboStreamVfs *stream_vfs;
 
 	g_return_val_if_fail (path != NULL, NULL);
 
@@ -412,5 +345,11 @@ bonobo_stream_vfs_open (const char *path, gint flags, gint mode,
 	if (result != GNOME_VFS_OK)
 		return NULL;
 
-	return bonobo_stream_create (handle);
+	stream_vfs = g_object_new (bonobo_stream_vfs_get_type (), NULL);
+	if (!stream_vfs)
+		return NULL;
+	
+	stream_vfs->handle = handle;
+
+	return stream_vfs;
 }
diff --git a/monikers/bonobo-stream-vfs.h b/monikers/bonobo-stream-vfs.h
index 0470432..fcf8c10 100644
--- a/monikers/bonobo-stream-vfs.h
+++ b/monikers/bonobo-stream-vfs.h
@@ -2,39 +2,42 @@
 #ifndef _BONOBO_STREAM_VFS_H_
 #define _BONOBO_STREAM_VFS_H_
 
-#include <bonobo/bonobo-stream.h>
+#include <bonobo/bonobo-object.h>
 #include <libgnomevfs/gnome-vfs.h>
 
-BEGIN_GNOME_DECLS
+G_BEGIN_DECLS
 
 typedef struct _BonoboStreamVfs BonoboStreamVfs;
 
+
 #define BONOBO_STREAM_VFS_TYPE        (bonobo_stream_vfs_get_type ())
-#define BONOBO_STREAM_VFS(o)          (GTK_CHECK_CAST ((o), BONOBO_STREAM_VFS_TYPE, BonoboStreamVfs))
-#define BONOBO_STREAM_VFS_CLASS(k)    (GTK_CHECK_CLASS_CAST((k), BONOBO_STREAM_VFS_TYPE, BonoboStreamVfsClass))
-#define BONOBO_IS_STREAM_VFS(o)       (GTK_CHECK_TYPE ((o), BONOBO_STREAM_VFS_TYPE))
-#define BONOBO_IS_STREAM_VFS_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_STREAM_VFS_TYPE))
+#define BONOBO_STREAM_VFS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), BONOBO_STREAM_VFS_TYPE, BonoboStreamVfs))
+#define BONOBO_STREAM_VFS_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), BONOBO_STREAM_VFS_TYPE, BonoboStreamVfsClass))
+#define BONOBO_IS_STREAM_VFS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), BONOBO_STREAM_VFS_TYPE))
+#define BONOBO_IS_STREAM_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), BONOBO_STREAM_VFS_TYPE))
 
 typedef struct _BonoboStreamVfsPrivate BonoboStreamVfsPrivate;
 
 struct _BonoboStreamVfs {
-	BonoboStream    stream;
-	GnomeVFSHandle *handle;
+	BonoboObject            parent;
+	GnomeVFSHandle         *handle;
 
 	BonoboStreamVfsPrivate *priv;
 };
 
 typedef struct {
-	BonoboStreamClass parent_class;
+	BonoboObjectClass       parent_class;
+
+	POA_Bonobo_Stream__epv  epv;
 } BonoboStreamVfsClass;
 
-GtkType       bonobo_stream_vfs_get_type (void);
-BonoboStream *bonobo_stream_vfs_open     (const char *path,
-					  gint flags, gint mode,
-					  CORBA_Environment *ev);
+GType            bonobo_stream_vfs_get_type (void);
+BonoboStreamVfs *bonobo_stream_vfs_open     (const char *path,
+					     gint flags, gint mode,
+					     CORBA_Environment *ev);
 void bonobo_stream_vfs_storageinfo_from_file_info (Bonobo_StorageInfo *si,
 						   GnomeVFSFileInfo   *fi);
 	
-END_GNOME_DECLS
+G_END_DECLS
 
 #endif /* _BONOBO_STREAM_VFS_H_ */
diff --git a/monikers/gnome-moniker-std.c b/monikers/gnome-moniker-std.c
index 0503b24..72b5d17 100644
--- a/monikers/gnome-moniker-std.c
+++ b/monikers/gnome-moniker-std.c
@@ -16,6 +16,11 @@ bonobo_std_moniker_factory (BonoboGenericFactory *this,
 		return BONOBO_OBJECT (bonobo_moniker_simple_new (
 			"file:", bonobo_moniker_file_resolve));
 
+	else if (!strcmp (object_id, "OAFIID:GNOME_Moniker_VFS"))
+
+		return BONOBO_OBJECT (bonobo_moniker_simple_new (
+			"vfs:", bonobo_moniker_vfs_resolve));
+
 	else if (!strcmp (object_id, "OAFIID:GNOME_MonikerExtender_file"))
 		
 		return BONOBO_OBJECT (bonobo_moniker_extender_new (
diff --git a/monikers/gnome-moniker-std.h b/monikers/gnome-moniker-std.h
index 9f6eab8..23fd66f 100644
--- a/monikers/gnome-moniker-std.h
+++ b/monikers/gnome-moniker-std.h
@@ -9,6 +9,11 @@ Bonobo_Unknown bonobo_moniker_file_resolve    (BonoboMoniker               *moni
 					       const CORBA_char            *requested_interface,
 					       CORBA_Environment           *ev);
 
+Bonobo_Unknown bonobo_moniker_vfs_resolve     (BonoboMoniker               *moniker,
+					       const Bonobo_ResolveOptions *options,
+					       const CORBA_char            *requested_interface,
+					       CORBA_Environment           *ev);
+
 Bonobo_Unknown bonobo_file_extender_resolve   (BonoboMonikerExtender *extender,
 					       const Bonobo_Moniker   m,
 					       const Bonobo_ResolveOptions *options,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]