Re: a proposal for 2 OAF features



Maciej Stachowiak wrote:
> Is is possible that OAF would later try to activate other objects
> (either private or non-private) from the same running executable? If
> so, the exclusive_iid variable may need to be a list, and perhaps
> should apply only to the first activation of a given IID?
no as the private flag applies only to the iid activated from the
command line (that's the one returned by oaf_activation_iid_get(), I
believe). the attached patch should implement this, eliminate extra
registration result and name the flag PRIVATE. if no one objects, I'll
commit it.

regards,
	jaKa

-- 

email: jaka.mocnik@kiss.uni-lj.si
w3:    http://pluton.ijs.si/~jaka
? oaf-patch.diff
Index: idl/oaf.idl
===================================================================
RCS file: /cvs/gnome/oaf/idl/oaf.idl,v
retrieving revision 1.16
diff -u -r1.16 oaf.idl
--- idl/oaf.idl	2000/06/26 00:28:01	1.16
+++ idl/oaf.idl	2000/07/05 22:01:30
@@ -12,9 +12,9 @@
 
         typedef long ActivationFlags;
         const ActivationFlags FLAG_NO_LOCAL = 1<<0; // No shared libraries
-        const ActivationFlags FLAG_IGNORE_EXISTING = 1<<1;
+        const ActivationFlags FLAG_PRIVATE = 1<<1; // start a new server and don't register it
         const ActivationFlags FLAG_EXISTING_ONLY = 1<<2; // don't start the server if not started
-  
+
         /* ActivationResult */
         enum ActivationResultType { 
                 RESULT_OBJECT, 
Index: liboaf/liboaf-private.h
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/liboaf-private.h,v
retrieving revision 1.7
diff -u -r1.7 liboaf-private.h
--- liboaf/liboaf-private.h	2000/05/30 16:37:10	1.7
+++ liboaf/liboaf-private.h	2000/07/05 22:01:30
@@ -15,11 +15,14 @@
 #endif
 #endif
 
+
 CORBA_Object oaf_server_by_forking (const char **cmd, int fd_Arg,
 				    CORBA_Environment * ev);
-extern void oaf_rloc_file_register (void);
+void oaf_rloc_file_register (void);
 int oaf_ior_fd_get (void);
 CORBA_Object oaf_activation_context_get (void);
+
+extern gboolean oaf_private;
 
 #endif
 
Index: liboaf/oaf-mainloop.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-mainloop.c,v
retrieving revision 1.18
diff -u -r1.18 oaf-mainloop.c
--- liboaf/oaf-mainloop.c	2000/05/31 12:15:10	1.18
+++ liboaf/oaf-mainloop.c	2000/07/05 22:01:31
@@ -74,6 +74,9 @@
 static CORBA_Context oaf_context;
 static gboolean is_initialized = FALSE;
 
+/* prevent registering with OAF when oaf_active_server_register() */
+gboolean oaf_private = FALSE;
+
 CORBA_ORB
 oaf_orb_get (void)
 {
@@ -153,6 +156,8 @@
 	 "File descriptor to print IOR on", "FD"},
 	{"oaf-activate-iid", '\0', POPT_ARG_STRING, &oaf_activate_iid, 0,
 	 "IID to activate", "IID"},
+        {"oaf-private", '\0', POPT_ARG_NONE, &oaf_private, 0,
+         "Prevent registering of server with OAF", NULL},
 	{NULL}
 };
 
@@ -324,21 +329,22 @@
 		if (!strncmp
 		    ("--oaf-od-ior=", argv[i], strlen ("--oaf-od-ior="))) {
 			oaf_od_ior = argv[i] + strlen ("--oaf-od-ior=");
-		} else
-			if (!strncmp
-			    ("--oaf-ior-fd=", argv[i],
-			     strlen ("--oaf-ior-fd="))) {
-			oaf_ior_fd =
-				atoi (argv[i] + strlen ("--oaf-ior-fd="));
-			if (!oaf_ior_fd)
-				oaf_ior_fd = 1;
-		} else
-			if (!strncmp
-			    ("--oaf-activate-iid=", argv[i],
-			     strlen ("--oaf-activate-iid="))) {
+		} else if (!strncmp
+                           ("--oaf-ior-fd=", argv[i],
+                            strlen ("--oaf-ior-fd="))) {
+                        oaf_ior_fd =
+                                atoi (argv[i] + strlen ("--oaf-ior-fd="));
+                        if (!oaf_ior_fd)
+                                oaf_ior_fd = 1;
+                } else if (!strncmp
+                           ("--oaf-activate-iid=", argv[i],
+                            strlen ("--oaf-activate-iid="))) {
 			oaf_activate_iid =
 				argv[i] + strlen ("--oaf-activate-iid=");
-		}
+                } else if (!strcmp
+                           ("--oaf-private", argv[i])) {
+                        oaf_private = TRUE;
+                }     
 	}
 
 	oaf_postinit (NULL, NULL);
Index: liboaf/oaf-servreg.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-servreg.c,v
retrieving revision 1.5
diff -u -r1.5 oaf-servreg.c
--- liboaf/oaf-servreg.c	2000/05/07 18:34:15	1.5
+++ liboaf/oaf-servreg.c	2000/07/05 22:01:31
@@ -47,6 +47,9 @@
 			close (iorfd);
 	}
 
+        if (actid && !strcmp(actid, iid) && oaf_private)
+                return OAF_REG_SUCCESS;
+
 	regcat.session_name = oaf_session_name_get ();
 	regcat.username = oaf_username_get ();
 	regcat.hostname = oaf_hostname_get ();
@@ -81,6 +84,11 @@
 	OAF_ObjectDirectory od;
 	OAFRegistrationCategory regcat = { "IDL:OAF/ObjectDirectory:1.0" };
 	CORBA_Environment ev;
+	const char *actid;
+
+	actid = oaf_activation_iid_get();
+	if(actid && !strcmp(actid, iid) && oaf_private)
+		return;
 
 	regcat.session_name = oaf_session_name_get ();
 	regcat.username = oaf_username_get ();
Index: oafd/od-activate.c
===================================================================
RCS file: /cvs/gnome/oaf/oafd/od-activate.c,v
retrieving revision 1.9
diff -u -r1.9 od-activate.c
--- oafd/od-activate.c	2000/05/07 19:42:25	1.9
+++ oafd/od-activate.c	2000/07/05 22:01:31
@@ -43,16 +43,17 @@
 {
 	CORBA_Object retval = CORBA_OBJECT_NIL, factory = CORBA_OBJECT_NIL;
 	OAF_ActivationResult *res;
-	GNOME_stringlist dummy = { 0 };
+	GNOME_stringlist params = { 0 };
 
 	res =
 		OAF_ActivationContext_activate_from_id (actinfo->ac,
 							si->location_info,
 							((actinfo->flags |
 							  OAF_FLAG_NO_LOCAL) &
-							 (~OAF_FLAG_IGNORE_EXISTING)),
+							 (~OAF_FLAG_PRIVATE)),
 							oaf_context_get (),
 							ev);
+
 	if (ev->_major != CORBA_NO_EXCEPTION)
 		goto out;
 
@@ -70,7 +71,7 @@
 	}
 
 	retval =
-		GNOME_GenericFactory_create_object (factory, si->iid, &dummy,
+		GNOME_GenericFactory_create_object (factory, si->iid, &params,
 						    ev);
 	if (ev->_major != CORBA_NO_EXCEPTION)
 		retval = CORBA_OBJECT_NIL;
@@ -139,8 +140,15 @@
                 CORBA_free (iorstr);
         }
 
+        if(actinfo->flags & OAF_FLAG_PRIVATE) {
+                extra_arg =
+                        oaf_alloca (sizeof ("--oaf-private"));
+                args[i++] = extra_arg;
+                g_snprintf (extra_arg, sizeof ("--oaf-private"),
+                            "--oaf-private");
+        }
+
 	args[i] = NULL;
 
 	return oaf_server_by_forking ((const char **) args, fd_arg, ev);
 }
-
Index: oafd/od-corba.c
===================================================================
RCS file: /cvs/gnome/oaf/oafd/od-corba.c,v
retrieving revision 1.19
diff -u -r1.19 od-corba.c
--- oafd/od-corba.c	2000/05/30 16:37:10	1.19
+++ oafd/od-corba.c	2000/07/05 22:01:32
@@ -380,7 +380,7 @@
 
 	if (!CORBA_Object_is_nil (retval, ev)
 	    && !CORBA_Object_non_existent (retval, ev)
-	    && !(flags & OAF_FLAG_IGNORE_EXISTING))
+	    && !(flags & OAF_FLAG_PRIVATE))
 		return CORBA_Object_duplicate (retval, ev);
 
 	if (flags & OAF_FLAG_EXISTING_ONLY)


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