[monkey-bubble: 518/753] upd. to use it.
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 518/753] upd. to use it.
- Date: Wed, 14 Jul 2010 22:39:11 +0000 (UTC)
commit afc2ad489e019eca6467e6cbef4a4dc0e9fab6df
Author: Michael Meeks <michael ximian com>
Date: Tue Jul 10 12:04:04 2001 +0000
upd. to use it.
2001-07-10 Michael Meeks <michael ximian com>
* bonobo-moniker-file.c (bonobo_moniker_file_resolve):
upd. to use it.
* bonobo-storage-fs.c: port to BonoboObject / GObject.
monikers/ChangeLog | 7 ++
monikers/Makefile.am-50588 | 4 +-
monikers/bonobo-moniker-file.c | 10 ++-
monikers/bonobo-storage-fs.c | 199 +++++++++++++++++++++-------------------
monikers/bonobo-storage-fs.h | 16 ++--
monikers/bonobo-stream-fs.c | 5 +-
6 files changed, 135 insertions(+), 106 deletions(-)
---
diff --git a/monikers/ChangeLog b/monikers/ChangeLog
index c7eb47e..160ee5b 100644
--- a/monikers/ChangeLog
+++ b/monikers/ChangeLog
@@ -1,6 +1,13 @@
2001-07-10 Michael Meeks <michael ximian com>
* bonobo-moniker-file.c (bonobo_moniker_file_resolve):
+ upd. to use it.
+
+ * bonobo-storage-fs.c: port to BonoboObject / GObject.
+
+2001-07-10 Michael Meeks <michael ximian com>
+
+ * bonobo-moniker-file.c (bonobo_moniker_file_resolve):
use bonobo-stream-fs directly, not via the storage plugin
architecture.
diff --git a/monikers/Makefile.am-50588 b/monikers/Makefile.am-50588
index a1cc88c..774c947 100644
--- a/monikers/Makefile.am-50588
+++ b/monikers/Makefile.am-50588
@@ -39,9 +39,11 @@ CLEANFILES+=GNOME_Moniker_std.oaf GNOME_Moniker_std.oaf.in
libmoniker_gnome_std_la_SOURCES = \
gnome-moniker-std.c \
gnome-moniker-std.h \
- bonobo-moniker-extender-file.c \
bonobo-stream-fs.h \
bonobo-stream-fs.c \
+ bonobo-storage-fs.h \
+ bonobo-storage-fs.c \
+ bonobo-moniker-extender-file.c \
bonobo-moniker-file.c
libmoniker_gnome_std_la_LIBADD = \
diff --git a/monikers/bonobo-moniker-file.c b/monikers/bonobo-moniker-file.c
index 1a8e016..9910efa 100644
--- a/monikers/bonobo-moniker-file.c
+++ b/monikers/bonobo-moniker-file.c
@@ -16,6 +16,7 @@
#include "gnome-moniker-std.h"
#include "bonobo-stream-fs.h"
+#include "bonobo-storage-fs.h"
Bonobo_Unknown
bonobo_moniker_file_resolve (BonoboMoniker *moniker,
@@ -45,10 +46,13 @@ bonobo_moniker_file_resolve (BonoboMoniker *moniker,
return CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev);
} else if (!strcmp (requested_interface, "IDL:Bonobo/Storage:1.0")) {
- BonoboStorage *storage;
+ BonoboObject *storage;
- storage = bonobo_storage_open ("fs", fname,
- Bonobo_Storage_READ, 0664);
+ storage = BONOBO_OBJECT (bonobo_storage_fs_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);
diff --git a/monikers/bonobo-storage-fs.c b/monikers/bonobo-storage-fs.c
index 95b0cd2..d2f86f2 100644
--- a/monikers/bonobo-storage-fs.c
+++ b/monikers/bonobo-storage-fs.c
@@ -5,8 +5,11 @@
* This is just a sample file-system based Storage implementation.
* it is only used for debugging purposes
*
- * Author:
+ * Authors:
* Miguel de Icaza (miguel gnu org)
+ * Michael Meeks (michael ximian com)
+ *
+ * Copyright 2001, Ximian, Inc
*/
#include <config.h>
#include <stdio.h>
@@ -15,27 +18,32 @@
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
-#include <storage-modules/bonobo-storage-fs.h>
-#include <storage-modules/bonobo-stream-fs.h>
-#include <bonobo/bonobo-storage-plugin.h>
-static BonoboStorageClass *bonobo_storage_fs_parent_class;
+#include <libgnome/gnome-util.h>
+#include <bonobo/bonobo-storage.h>
+
+#include "bonobo-stream-fs.h"
+#include "bonobo-storage-fs.h"
+
+static BonoboObjectClass *bonobo_storage_fs_parent_class;
static void
-bonobo_storage_fs_destroy (GtkObject *object)
+bonobo_storage_fs_finalize (GObject *object)
{
BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (object);
g_free (storage_fs->path);
+ storage_fs->path = NULL;
}
static Bonobo_StorageInfo*
-fs_get_info (BonoboStorage *storage,
+fs_get_info (PortableServer_Servant storage,
const CORBA_char *path,
const Bonobo_StorageInfoFields mask,
CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
Bonobo_StorageInfo *si;
struct stat st;
char *full = NULL;
@@ -71,7 +79,8 @@ fs_get_info (BonoboStorage *storage,
CORBA_string_dup ("x-symlink/dangling");
else
si->content_type =
- CORBA_string_dup (gnome_mime_type_of_file (full));
+ CORBA_string_dup (
+ gnome_mime_type_of_file (full));
}
g_free (full);
@@ -99,55 +108,75 @@ fs_get_info (BonoboStorage *storage,
}
static void
-fs_set_info (BonoboStorage *storage,
- const CORBA_char *path,
- const Bonobo_StorageInfo *info,
+fs_set_info (PortableServer_Servant storage,
+ const CORBA_char *path,
+ const Bonobo_StorageInfo *info,
const Bonobo_StorageInfoFields mask,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Storage_NotSupported,
NULL);
}
-static BonoboStream *
-fs_open_stream (BonoboStorage *storage,
- const CORBA_char *path,
+static Bonobo_Stream
+fs_open_stream (PortableServer_Servant storage,
+ const CORBA_char *path,
Bonobo_Storage_OpenMode mode,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
- BonoboStream *stream;
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
+ BonoboObject *stream;
char *full;
full = g_concat_dir_and_file (storage_fs->path, path);
- stream = bonobo_stream_fs_open (full, mode, 0644, ev);
+ stream = BONOBO_OBJECT (
+ bonobo_stream_fs_open (full, mode, 0644, ev));
g_free (full);
- return stream;
+ return BONOBO_OBJREF (stream);
}
-static BonoboStorage *
-fs_open_storage (BonoboStorage *storage, const CORBA_char *path,
- Bonobo_Storage_OpenMode mode, CORBA_Environment *ev)
+static Bonobo_Storage
+fs_open_storage (PortableServer_Servant storage,
+ const CORBA_char *path,
+ Bonobo_Storage_OpenMode mode,
+ CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
- BonoboStorage *new_storage;
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
+ BonoboObject *new_storage;
char *full;
full = g_concat_dir_and_file (storage_fs->path, path);
- new_storage = bonobo_storage_fs_open (full, mode, 0644, ev);
+ new_storage = BONOBO_OBJECT (
+ bonobo_storage_fs_open (full, mode, 0644, ev));
g_free (full);
- return new_storage;
+ return BONOBO_OBJREF (new_storage);
}
+static void
+fs_copy_to (PortableServer_Servant storage,
+ Bonobo_Storage dest,
+ CORBA_Environment *ev)
+{
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
+
+ bonobo_storage_copy_to (
+ BONOBO_OBJREF (storage_fs), dest, ev);
+}
static void
-fs_rename (BonoboStorage *storage, const CORBA_char *path,
- const CORBA_char *new_path, CORBA_Environment *ev)
+fs_rename (PortableServer_Servant storage,
+ const CORBA_char *path,
+ const CORBA_char *new_path,
+ CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
char *full_old, *full_new;
full_old = g_concat_dir_and_file (storage_fs->path, path);
@@ -178,24 +207,29 @@ fs_rename (BonoboStorage *storage, const CORBA_char *path,
}
static void
-fs_commit (BonoboStorage *storage, CORBA_Environment *ev)
+fs_commit (PortableServer_Servant storage,
+ CORBA_Environment *ev)
{
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Stream_NotSupported, NULL);
}
static void
-fs_revert (BonoboStorage *storage, CORBA_Environment *ev)
+fs_revert (PortableServer_Servant storage,
+ CORBA_Environment *ev)
{
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Stream_NotSupported, NULL);
}
static Bonobo_Storage_DirectoryList *
-fs_list_contents (BonoboStorage *storage, const CORBA_char *path,
- Bonobo_StorageInfoFields mask, CORBA_Environment *ev)
+fs_list_contents (PortableServer_Servant storage,
+ const CORBA_char *path,
+ Bonobo_StorageInfoFields mask,
+ CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
Bonobo_Storage_DirectoryList *list = NULL;
Bonobo_StorageInfo *buf;
struct dirent *de;
@@ -280,7 +314,8 @@ fs_list_contents (BonoboStorage *storage, const CORBA_char *path,
} else {
buf [i].type = Bonobo_STORAGE_TYPE_REGULAR;
buf [i].content_type =
- CORBA_string_dup (gnome_mime_type_of_file (full));
+ CORBA_string_dup (
+ gnome_mime_type_of_file (full));
}
g_free (full);
@@ -321,11 +356,12 @@ fs_list_contents (BonoboStorage *storage, const CORBA_char *path,
}
static void
-fs_erase (BonoboStorage *storage,
- const CORBA_char *path,
- CORBA_Environment *ev)
+fs_erase (PortableServer_Servant storage,
+ const CORBA_char *path,
+ CORBA_Environment *ev)
{
- BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (storage);
+ BonoboStorageFS *storage_fs = BONOBO_STORAGE_FS (
+ bonobo_object (storage));
char *full;
full = g_concat_dir_and_file (storage_fs->path, path);
@@ -353,52 +389,39 @@ fs_erase (BonoboStorage *storage,
}
static void
-bonobo_storage_fs_class_init (BonoboStorageFSClass *class)
+bonobo_storage_fs_class_init (BonoboStorageFSClass *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_fs_parent_class =
- gtk_type_class (bonobo_storage_get_type ());
-
- sclass->get_info = fs_get_info;
- sclass->set_info = fs_set_info;
- sclass->open_stream = fs_open_stream;
- sclass->open_storage = fs_open_storage;
- sclass->copy_to = NULL; /* use the generic method */
- sclass->rename = fs_rename;
- sclass->commit = fs_commit;
- sclass->revert = fs_revert;
- sclass->list_contents = fs_list_contents;
- sclass->erase = fs_erase;
+ g_type_class_peek_parent (klass);
+
+ epv->getInfo = fs_get_info;
+ epv->setInfo = fs_set_info;
+ epv->openStream = fs_open_stream;
+ epv->openStorage = fs_open_storage;
+ epv->copyTo = fs_copy_to;
+ epv->rename = fs_rename;
+ epv->commit = fs_commit;
+ epv->revert = fs_revert;
+ epv->listContents = fs_list_contents;
+ epv->erase = fs_erase;
- object_class->destroy = bonobo_storage_fs_destroy;
+ object_class->finalize = bonobo_storage_fs_finalize;
}
static void
-bonobo_storage_fs_init (GtkObject *object)
+bonobo_storage_fs_init (GObject *object)
{
/* nothing to do */
}
-BONOBO_X_TYPE_FUNC (BonoboStorageFS,
- bonobo_storage_get_type (),
- bonobo_storage_fs);
-
-/*
- * Creates the Gtk object and the corba server bound to it
- */
-static BonoboStorage *
-do_bonobo_storage_fs_create (const char *path)
-{
- BonoboStorageFS *storage_fs;
-
- storage_fs = gtk_type_new (bonobo_storage_fs_get_type ());
- storage_fs->path = g_strdup (path);
-
- return BONOBO_STORAGE (storage_fs);
-}
+BONOBO_TYPE_FUNC (BonoboStorageFS,
+ bonobo_object_get_type (),
+ bonobo_storage_fs);
/**
* bonobo_storage_fs_open:
@@ -408,10 +431,11 @@ do_bonobo_storage_fs_create (const char *path)
*
* Returns a BonoboStorage object that represents the storage at @path
*/
-BonoboStorage *
-bonobo_storage_fs_open (const char *path, gint flags, gint mode,
- CORBA_Environment *ev)
+BonoboStorageFS *
+bonobo_storage_fs_open (const char *path, gint flags,
+ gint mode, CORBA_Environment *ev)
{
+ BonoboStorageFS *storage_fs;
struct stat st;
g_return_val_if_fail (path != NULL, NULL);
@@ -452,21 +476,8 @@ bonobo_storage_fs_open (const char *path, gint flags, gint mode,
return NULL;
}
- return do_bonobo_storage_fs_create (path);
-}
-
-gint
-init_storage_plugin (StoragePlugin *plugin)
-{
- g_return_val_if_fail (plugin != NULL, -1);
-
- plugin->name = "fs";
- plugin->description = "Native Filesystem Driver";
- plugin->version = BONOBO_STORAGE_VERSION;
-
- plugin->storage_open = bonobo_storage_fs_open;
- plugin->stream_open = bonobo_stream_fs_open;
+ storage_fs = g_object_new (bonobo_storage_fs_get_type (), NULL);
+ storage_fs->path = g_strdup (path);
- return 0;
+ return storage_fs;
}
-
diff --git a/monikers/bonobo-storage-fs.h b/monikers/bonobo-storage-fs.h
index e4dc1cd..d869204 100644
--- a/monikers/bonobo-storage-fs.h
+++ b/monikers/bonobo-storage-fs.h
@@ -2,15 +2,15 @@
#ifndef _BONOBO_STORAGE_FS_H_
#define _BONOBO_STORAGE_FS_H_
-#include <bonobo/bonobo-storage.h>
+#include <bonobo/bonobo-object.h>
-BEGIN_GNOME_DECLS
+G_BEGIN_DECLS
#define BONOBO_STORAGE_FS_TYPE (bonobo_storage_fs_get_type ())
-#define BONOBO_STORAGE_FS(o) (GTK_CHECK_CAST ((o), BONOBO_STORAGE_FS_TYPE, BonoboStorageFS))
-#define BONOBO_STORAGE_FS_CLASS(k) (GTK_CHECK_CLASS_CAST((k), BONOBO_STORAGE_FS_TYPE, BonoboStorageFSClass))
-#define BONOBO_IS_STORAGE_FS(o) (GTK_CHECK_TYPE ((o), BONOBO_STORAGE_FS_TYPE))
-#define BONOBO_IS_STORAGE_FS_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_STORAGE_FS_TYPE))
+#define BONOBO_STORAGE_FS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), BONOBO_STORAGE_FS_TYPE, BonoboStorageFS))
+#define BONOBO_STORAGE_FS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), BONOBO_STORAGE_FS_TYPE, BonoboStorageFSClass))
+#define BONOBO_IS_STORAGE_FS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), BONOBO_STORAGE_FS_TYPE))
+#define BONOBO_IS_STORAGE_FS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), BONOBO_STORAGE_FS_TYPE))
typedef struct {
BonoboObject parent;
@@ -19,6 +19,8 @@ typedef struct {
typedef struct {
BonoboObjectClass parent_class;
+
+ POA_Bonobo_Storage__epv epv;
} BonoboStorageFSClass;
GType bonobo_storage_fs_get_type (void);
@@ -27,6 +29,6 @@ BonoboStorageFS *bonobo_storage_fs_open (const char *path,
gint mode,
CORBA_Environment *ev);
-END_GNOME_DECLS
+G_END_DECLS
#endif /* _BONOBO_STORAGE_FS_H_ */
diff --git a/monikers/bonobo-stream-fs.c b/monikers/bonobo-stream-fs.c
index e576566..b25cf01 100644
--- a/monikers/bonobo-stream-fs.c
+++ b/monikers/bonobo-stream-fs.c
@@ -5,8 +5,11 @@
* This is just a sample file-system based Stream implementation.
* it is only used for debugging purposes
*
- * Author:
+ * Authors:
* Miguel de Icaza (miguel gnu org)
+ * Michael Meeks (michael ximian com)
+ *
+ * Copyright 2001, Ximian, Inc
*/
#include <config.h>
#include <stdio.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]