client-side Persist helpers



I am going to use these in the ClipboardStore, would it make sense to
include it in Bonobo proper?
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/Makefile.am,v
retrieving revision 1.33
diff -u -u -r1.33 Makefile.am
--- Makefile.am	2001/07/24 23:00:06	1.33
+++ Makefile.am	2001/07/25 19:05:35
@@ -84,6 +84,7 @@
 	bonobo-persist-file.h		\
 	bonobo-persist-stream.h		\
 	bonobo-persist.h		\
+	bonobo-persist-client.h		\
 	bonobo-property-bag.h		\
 	bonobo-property-bag-client.h	\
 	bonobo-shlib-factory.h		\
@@ -122,6 +123,7 @@
 	bonobo-persist-file.c		\
 	bonobo-persist-stream.c		\
 	bonobo-persist.c		\
+	bonobo-persist-client.c		\
 	bonobo-property-bag.c		\
 	bonobo-property-bag-client.c	\
 	bonobo-shlib-factory.c		\
Index: bonobo-persist-client.c
===================================================================
RCS file: bonobo-persist-client.c
diff -N bonobo-persist-client.c
--- /dev/null	Tue May  5 16:32:27 1998
+++ bonobo-persist-client.c	Wed Jul 25 15:05:35 2001
@@ -0,0 +1,92 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/**
+ * bonobo-persist-client.c: Client-side utility functions dealing with persistancy
+ *
+ * Author:
+ *   ÉRDI Gergő <cactus cactus rulez org>
+ *
+ * Copyright 2001 Gergő Érdi
+ */
+
+#include <bonobo/bonobo-persist-client.h>
+
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-stream-client.h>
+#include <bonobo/bonobo-moniker-util.h>
+
+void
+bonobo_object_save_to_stream (Bonobo_Unknown     object,
+			      Bonobo_Stream      stream,
+			      CORBA_Environment *opt_ev)
+{
+	char                           *iid = 0;
+	CORBA_Environment               my_ev;
+	Bonobo_PersistStream            pstream = CORBA_OBJECT_NIL;
+
+	CORBA_exception_init (&my_ev);
+	pstream = Bonobo_Unknown_queryInterface (object, "IDL:Bonobo/PersistStream:1.0", &my_ev);
+	CORBA_exception_free (&my_ev);
+
+	if (!pstream) {
+		bonobo_exception_set (opt_ev, ex_Bonobo_Moniker_InterfaceNotFound);
+		goto out;
+	}
+
+	CORBA_exception_init (&my_ev);
+	iid = Bonobo_Persist_getIId (pstream, &my_ev);
+	bonobo_stream_client_write_string (stream, iid, TRUE, &my_ev);
+	if (BONOBO_EX (&my_ev)) {
+		if (opt_ev)
+			bonobo_exception_set (opt_ev, BONOBO_EX_REPOID (&my_ev));
+		CORBA_exception_free (&my_ev);
+		goto out;
+	}
+
+	if (opt_ev) {
+		Bonobo_PersistStream_save (pstream, stream, "", opt_ev);
+	} else {
+		Bonobo_PersistStream_save (pstream, stream, "", opt_ev);
+		CORBA_exception_free (&my_ev);
+	}
+
+ out:
+	g_free (iid);
+	if (pstream != CORBA_OBJECT_NIL) {
+		CORBA_exception_init (&my_ev);
+		Bonobo_Unknown_unref (pstream, &my_ev);
+		CORBA_exception_free (&my_ev);
+	}
+}
+
+
+Bonobo_Unknown
+bonobo_object_from_stream (Bonobo_Stream stream)
+{
+	char                 *iid = 0;
+	CORBA_Environment     my_ev;
+	Bonobo_PersistStream  pstream = CORBA_OBJECT_NIL;
+
+	CORBA_exception_init (&my_ev);
+
+	bonobo_stream_client_read_string (stream, &iid, &my_ev);
+	if (BONOBO_EX (&my_ev)) {
+		goto out;
+	}
+	
+	
+	pstream = bonobo_get_object (iid,
+				     "IDL:Bonobo/PersistStream:1.0",
+				     &my_ev);
+	if (BONOBO_EX (&my_ev)) {
+		pstream = CORBA_OBJECT_NIL;
+		goto out;
+	}
+
+	Bonobo_PersistStream_load (pstream, stream, "", &my_ev);
+	
+ out:
+	CORBA_exception_free (&my_ev);
+	g_free (iid);
+	
+	return pstream;
+}
Index: bonobo-persist-client.h
===================================================================
RCS file: bonobo-persist-client.h
diff -N bonobo-persist-client.h
--- /dev/null	Tue May  5 16:32:27 1998
+++ bonobo-persist-client.h	Wed Jul 25 15:05:35 2001
@@ -0,0 +1,24 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/**
+ * bonobo-persist-client.h: Client-side utility functions dealing with persistancy
+ *
+ * Author:
+ *   ÉRDI Gergő <cactus cactus rulez org>
+ *
+ * Copyright 2001 Gergő Érdi
+ */
+#ifndef _BONOBO_PERSIST_CLIENT_H_
+#define _BONOBO_PERSIST_CLIENT_H_
+
+#include <bonobo/bonobo-object.h>
+
+G_BEGIN_DECLS
+
+void bonobo_object_save_to_stream (Bonobo_Unknown     object,
+				   Bonobo_Stream      stream,
+				   CORBA_Environment *opt_ev);
+Bonobo_Unknown bonobo_object_from_stream (Bonobo_Stream stream);
+
+G_END_DECLS
+
+#endif /* _BONOBO_PERSIST_CLIENT_H_ */
Index: bonobo-storage-memory.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-storage-memory.c,v
retrieving revision 1.1
diff -u -u -r1.1 bonobo-storage-memory.c
--- bonobo-storage-memory.c	2001/07/24 23:00:06	1.1
+++ bonobo-storage-memory.c	2001/07/25 19:05:45
@@ -86,7 +86,7 @@
 {
 	BonoboStorageMem      *ret;
 	BonoboStorageMemEntry *entry;
-	gchar *path_head, *path_tail;
+	gchar                 *path_head, *path_tail;
 
 	if (!strcmp (path, "/") || !strcmp (path, "")) {
 		if (filename)

-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
A világnak több szerény zsenire lenne szüksége. Olyan kevesen vagyunk...





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