Re: Bonobo::Persist::getIID ()



OK so here it is. It is super-incompatible since it modifies a public,
released interface. C'est la vie.

If you are wandering what this is all about, to recreate an object from
scratch using data you formerly aquired through Bonobo::Persist*, you will
also need the object's type since this is not necesserily obvious from the
MIME type.

This will be needed by c&p, d&d, and other acronyms hopefully also in the
a&b form :)

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonobo/ChangeLog,v
retrieving revision 1.49
diff -u -u -r1.49 ChangeLog
--- ChangeLog	2001/06/20 15:04:31	1.49
+++ ChangeLog	2001/06/20 22:21:10
@@ -1,3 +1,16 @@
+2001-06-21  ERDI Gergo  <cactus cactus rulez org>
+
+	* idl/Bonobo_Persist.idl: Added new getIID method to
+	Bonobo::Persist
+
+	* bonobo/bonobo-persist.[ch]:
+	* bonobo/bonobo-persist-file.[ch]:
+	* bonobo/bonobo-persist-stream.[ch]: Added code to support
+	Bonobo::Persist::getIID
+
+	* bonobo/bonobo-persist-stream.[ch]: Since new arguments are added
+	to _new and _construct, I removed the legacy dummy argument
+
 2001-06-19  Peter Williams  <peterw ximian com>
 
 	* bonobo/bonobo-property-bag.c (bonobo_property_bag_add_gtk_args): 
Index: bonobo/bonobo-persist-file.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist-file.c,v
retrieving revision 1.33
diff -u -u -r1.33 bonobo-persist-file.c
--- bonobo/bonobo-persist-file.c	2001/04/18 22:09:07	1.33
+++ bonobo/bonobo-persist-file.c	2001/06/20 22:21:11
@@ -160,6 +160,7 @@
  * @pf: A BonoboPersistFile
  * @load_fn: Loading routine
  * @save_fn: Saving routine
+ * @iid: OAF IID of the object this interface is aggregated to
  * @closure: Data passed to IO routines.
  *
  * Initializes the BonoboPersistFile object.  The @load_fn and @save_fn
@@ -170,6 +171,7 @@
 bonobo_persist_file_construct (BonoboPersistFile    *pf,
 			       BonoboPersistFileIOFn load_fn,
 			       BonoboPersistFileIOFn save_fn,
+			       const gchar          *iid,
 			       void                 *closure)
 {
 	g_return_val_if_fail (pf != NULL, NULL);
@@ -178,6 +180,8 @@
 	pf->load_fn = load_fn;
 	pf->save_fn = save_fn;
 	pf->closure = closure;
+
+	bonobo_persist_construct (BONOBO_PERSIST (pf), iid);
 		
 	return pf;
 }
@@ -186,6 +190,7 @@
  * bonobo_persist_file_new:
  * @load_fn: Loading routine
  * @save_fn: Saving routine
+ * @iid: OAF IID of the object this interface is aggregated to
  * @closure: Data passed to IO routines.
  *
  * Creates a BonoboPersistFile object.  The @load_fn and @save_fn
@@ -193,9 +198,10 @@
  * operations are performed by the class load and save methods
  */
 BonoboPersistFile *
-bonobo_persist_file_new (BonoboPersistFileIOFn load_fn,
-			 BonoboPersistFileIOFn save_fn,
-			 void                 *closure)
+bonobo_persist_file_new (BonoboPersistFileIOFn  load_fn,
+			 BonoboPersistFileIOFn  save_fn,
+			 const gchar           *iid,
+			 void                  *closure)
 {
 	BonoboPersistFile *pf;
 
@@ -203,7 +209,7 @@
 
 	pf->filename = NULL;
 
-	bonobo_persist_file_construct (pf, load_fn, save_fn, closure);
+	bonobo_persist_file_construct (pf, load_fn, save_fn, iid, closure);
 
 	return pf;
 }
Index: bonobo/bonobo-persist-file.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist-file.h,v
retrieving revision 1.19
diff -u -u -r1.19 bonobo-persist-file.h
--- bonobo/bonobo-persist-file.h	2001/04/18 22:09:07	1.19
+++ bonobo/bonobo-persist-file.h	2001/06/20 22:21:11
@@ -71,11 +71,13 @@
 
 BonoboPersistFile *bonobo_persist_file_new       (BonoboPersistFileIOFn load_fn,
 						  BonoboPersistFileIOFn save_fn,
+						  const gchar          *iid,
 						  void                 *closure);
 
 BonoboPersistFile *bonobo_persist_file_construct (BonoboPersistFile    *ps,
 						  BonoboPersistFileIOFn load_fn,
 						  BonoboPersistFileIOFn save_fn,
+						  const gchar          *iid,
 						  void                 *closure);
 
 G_END_DECLS
Index: bonobo/bonobo-persist-stream.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist-stream.c,v
retrieving revision 1.41
diff -u -u -r1.41 bonobo-persist-stream.c
--- bonobo/bonobo-persist-stream.c	2001/05/02 22:19:26	1.41
+++ bonobo/bonobo-persist-stream.c	2001/06/20 22:21:11
@@ -124,8 +124,8 @@
  * @ps: A BonoboPersistStream object
  * @load_fn: Loading routine
  * @save_fn: Saving routine
- * @compat_dummy: unused, NULL
  * @types_fn: returns the supported types
+ * @iid: OAF IID of the object this interface is aggregated to
  * @closure: Data passed to IO routines.
  *
  * Initializes the BonoboPersistStream object.  The load and save
@@ -141,8 +141,8 @@
 bonobo_persist_stream_construct (BonoboPersistStream       *ps,
 				 BonoboPersistStreamIOFn    load_fn,
 				 BonoboPersistStreamIOFn    save_fn,
-				 gpointer                   compat_dummy,
 				 BonoboPersistStreamTypesFn types_fn,
+				 const gchar               *iid,
 				 void                      *closure)
 {
 	g_return_val_if_fail (ps != NULL, NULL);
@@ -152,6 +152,8 @@
 	ps->save_fn = save_fn;
 	ps->types_fn = types_fn;
 	ps->closure = closure;
+
+	bonobo_persist_construct (BONOBO_PERSIST (ps), iid);
 	
 	return ps;
 }
@@ -160,8 +162,8 @@
  * bonobo_persist_stream_new:
  * @load_fn: Loading routine
  * @save_fn: Saving routine
- * @compat_dummy: unused, NULL
  * @types_fn: get_content_types routine
+ * @iid: OAF IID of the object this interface is aggregated to
  * @closure: Data passed to IO routines.
  *
  * Creates a new BonoboPersistStream object. The various operations
@@ -175,8 +177,8 @@
 BonoboPersistStream *
 bonobo_persist_stream_new (BonoboPersistStreamIOFn    load_fn,
 			   BonoboPersistStreamIOFn    save_fn,
-			   gpointer                   compat_dummy,
 			   BonoboPersistStreamTypesFn types_fn,
+			   const gchar               *iid,
 			   void                      *closure)
 {
 	BonoboPersistStream *ps;
@@ -184,7 +186,7 @@
 	ps = g_object_new (bonobo_persist_stream_get_type (), NULL);
 
 	bonobo_persist_stream_construct (ps, load_fn, save_fn,
-					 compat_dummy, types_fn, closure);
+					 types_fn, iid, closure);
 
 	return ps;
 }
Index: bonobo/bonobo-persist-stream.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist-stream.h,v
retrieving revision 1.23
diff -u -u -r1.23 bonobo-persist-stream.h
--- bonobo/bonobo-persist-stream.h	2001/05/02 22:19:26	1.23
+++ bonobo/bonobo-persist-stream.h	2001/06/20 22:21:11
@@ -78,15 +78,15 @@
 
 BonoboPersistStream *bonobo_persist_stream_new       (BonoboPersistStreamIOFn    load_fn,
 						      BonoboPersistStreamIOFn    save_fn,
-						      gpointer                   compat_dummy,
 						      BonoboPersistStreamTypesFn types_fn,
+						      const gchar               *iid,
 						      void                      *closure);
 
 BonoboPersistStream *bonobo_persist_stream_construct (BonoboPersistStream       *ps,
 						      BonoboPersistStreamIOFn    load_fn,
 						      BonoboPersistStreamIOFn    save_fn,
-						      gpointer                   compat_dummy,
 						      BonoboPersistStreamTypesFn types_fn,
+						      const gchar               *iid,
 						      void                      *closure);
 
 G_END_DECLS
Index: bonobo/bonobo-persist.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist.c,v
retrieving revision 1.27
diff -u -u -r1.27 bonobo-persist.c
--- bonobo/bonobo-persist.c	2001/04/18 22:09:07	1.27
+++ bonobo/bonobo-persist.c	2001/06/20 22:21:11
@@ -19,6 +19,11 @@
 
 #define CLASS(o) BONOBO_PERSIST_CLASS(G_OBJECT_GET_CLASS (o))
 
+struct _BonoboPersistPrivate
+{
+	gchar *iid;
+};
+
 static inline BonoboPersist *
 bonobo_persist_from_servant (PortableServer_Servant servant)
 {
@@ -34,9 +39,23 @@
 	return CLASS (persist)->get_content_types (persist, ev);
 }
 
+static CORBA_char*
+impl_Bonobo_Persist_getIID (PortableServer_Servant   servant,
+			    CORBA_Environment       *ev)
+{
+	BonoboPersist *persist = bonobo_persist_from_servant (servant);
+
+	return CORBA_string_dup (persist->priv->iid);
+}
+
 static void
 bonobo_persist_finalize (GObject *object)
 {
+	BonoboPersist *persist = BONOBO_PERSIST (object);
+	
+	g_free (persist->priv->iid);
+	g_free (persist->priv);
+	
 	bonobo_persist_parent_class->finalize (object);
 }
 
@@ -52,12 +71,14 @@
 	object_class->finalize = bonobo_persist_finalize;
 
 	epv->getContentTypes = impl_Bonobo_Persist_getContentTypes;
+	epv->getIID = impl_Bonobo_Persist_getIID;
 }
 
 static void
 bonobo_persist_init (GObject *object)
 {
-	/* nothing to do */
+	BonoboPersist *persist = BONOBO_PERSIST (object);
+	persist->priv = g_new0 (BonoboPersistPrivate, 1);
 }
 
 BONOBO_TYPE_FUNC_FULL (BonoboPersist, 
@@ -94,4 +115,28 @@
 	va_end (ap);
 
 	return types;
+}
+
+/**
+ * bonobo_persist_construct:
+ * @persist: A BonoboPersist
+ * @iid: OAF IID of the object this interface is aggregated to
+ *
+ * Initializes the BonoboPersist object. You should only use this
+ * method in derived implementations, because a BonoboPersist instance
+ * doesn't make a lot of sense, but the iid private field has to be
+ * set at construction time.
+ */
+BonoboPersist *
+bonobo_persist_construct (BonoboPersist *persist,
+			  const gchar   *iid)
+{
+	g_return_val_if_fail (persist != NULL, NULL);
+	g_return_val_if_fail (BONOBO_IS_PERSIST (persist), NULL);
+
+	g_return_val_if_fail (iid != NULL, NULL);
+
+	persist->priv->iid = g_strdup (iid);
+
+	return persist;
 }
Index: bonobo/bonobo-persist.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-persist.h,v
retrieving revision 1.22
diff -u -u -r1.22 bonobo-persist.h
--- bonobo/bonobo-persist.h	2001/04/18 22:09:07	1.22
+++ bonobo/bonobo-persist.h	2001/06/20 22:21:11
@@ -38,11 +38,13 @@
 						    CORBA_Environment *ev);
 } BonoboPersistClass;
 
-GType                         bonobo_persist_get_type               (void);
+GType                           bonobo_persist_get_type (void);
 
 Bonobo_Persist_ContentTypeList *bonobo_persist_generate_content_types (int num,
 								       ...);
 
+BonoboPersist                  *bonobo_persist_construct (BonoboPersist *persist,
+							  const gchar   *iid);
 G_END_DECLS
 
 #endif /* _BONOBO_PERSIST_H_ */
Index: idl/Bonobo_Persist.idl
===================================================================
RCS file: /cvs/gnome/libbonobo/idl/Bonobo_Persist.idl,v
retrieving revision 1.28
diff -u -u -r1.28 Bonobo_Persist.idl
--- idl/Bonobo_Persist.idl	2001/05/02 22:19:27	1.28
+++ idl/Bonobo_Persist.idl	2001/06/20 22:21:11
@@ -26,7 +26,6 @@
 
 		exception WrongDataType {};
 		exception FileNotFound {};
-	
 
 		typedef string                ContentType;
 		typedef sequence<ContentType> ContentTypeList;
@@ -39,6 +38,16 @@
 		 * preferred type being the first element.
 		 */
 		ContentTypeList getContentTypes ();
+
+		typedef string                IID;
+		
+		/**
+		 * getIID:
+		 *
+		 * Get the IID necessary to recreate the object whose
+		 * internal state this interface represents
+		 */
+		IID getIID ();
 	};
 	
 	/*

-- 
   .--= ULLA! =---------------------.   `We are not here to give users what
   \     http://cactus.rulez.org     \   they want'  -- RMS, at GUADEC 2001
    `---= cactus cactus rulez org =---'
Her hair glistened in the rain like nose hair after a sneeze.





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