Re: a proposal for 2 OAF features



Jaka Mocnik wrote:
> 
> Elliot Lee wrote:
> > Yup. I meant fixing the present functionality of IGNORE_EXISTING so it
> > performs like your EXCLUSIVE flag. As to whether the name itself is
> > changed is another matter for debate.
> how about the attached patch then? I favor the name change as EXCLUSIVE
> seem to describe the flag's behaviour better than IGNORE_EXISTING.
aaargh. stupid me... here comes the patch.

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/03 20:37:47
@@ -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_EXCLUSIVE = 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, 
@@ -87,6 +87,7 @@
                 REG_SUCCESS, 
                 REG_NOT_LISTED, 
                 REG_ALREADY_ACTIVE, 
+                REG_EXCLUSIVE,
                 REG_ERROR 
         };
 
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/03 20:37:47
@@ -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_exclusive;
 
 #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/03 20:37:48
@@ -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_exclusive = 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-exclusive", '\0', POPT_ARG_NONE, &oaf_exclusive, 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-exclusive", argv[i])) {
+                        oaf_exclusive = 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/03 20:37:48
@@ -47,6 +47,9 @@
 			close (iorfd);
 	}
 
+        if(oaf_exclusive)
+                return OAF_REG_EXCLUSIVE;
+
 	regcat.session_name = oaf_session_name_get ();
 	regcat.username = oaf_username_get ();
 	regcat.hostname = oaf_hostname_get ();
@@ -81,6 +84,9 @@
 	OAF_ObjectDirectory od;
 	OAFRegistrationCategory regcat = { "IDL:OAF/ObjectDirectory:1.0" };
 	CORBA_Environment ev;
+
+        if(oaf_exclusive)
+                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/03 20:37:49
@@ -43,16 +43,17 @@
 {
 	CORBA_Object retval = CORBA_OBJECT_NIL, factory = CORBA_OBJECT_NIL;
 	OAF_ActivationResult *res;
-	GNOME_stringlist dummy = { 0 };
+	GNOME_stringlist *params;
 
 	res =
 		OAF_ActivationContext_activate_from_id (actinfo->ac,
 							si->location_info,
 							((actinfo->flags |
 							  OAF_FLAG_NO_LOCAL) &
-							 (~OAF_FLAG_IGNORE_EXISTING)),
+							 (~OAF_FLAG_EXCLUSIVE)),
 							oaf_context_get (),
 							ev);
+
 	if (ev->_major != CORBA_NO_EXCEPTION)
 		goto out;
 
@@ -69,12 +70,25 @@
 		break;
 	}
 
+        params = GNOME_stringlist__alloc ();
+        if(actinfo->flags & OAF_FLAG_EXCLUSIVE) {
+                params->_length = 1;
+                params->_buffer = CORBA_sequence_CORBA_string_allocbuf (params->_length);
+                params->_buffer[0] = oaf_alloca (sizeof ("oaf-exclusive"));
+                g_snprintf (params->_buffer[0], sizeof ("oaf-exclusive"),
+                            "oaf-exclusive");
+        }
+        else
+                params->_length = 0;
+        CORBA_sequence_set_release (params, CORBA_TRUE);
+
 	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;
 
+        CORBA_free (params);
 	CORBA_free (res);
 
       out:
@@ -139,8 +153,15 @@
                 CORBA_free (iorstr);
         }
 
+        if(actinfo->flags & OAF_FLAG_EXCLUSIVE) {
+                extra_arg =
+                        oaf_alloca (sizeof ("--oaf-exclusive"));
+                args[i++] = extra_arg;
+                g_snprintf (extra_arg, sizeof ("--oaf-exclusive"),
+                            "--oaf-exclusive");
+        }
+
 	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/03 20:37:49
@@ -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_EXCLUSIVE))
 		return CORBA_Object_duplicate (retval, ev);
 
 	if (flags & OAF_FLAG_EXISTING_ONLY)
Index: test/empty-server.c
===================================================================
RCS file: /cvs/gnome/oaf/test/empty-server.c,v
retrieving revision 1.6
diff -u -r1.6 empty-server.c
--- test/empty-server.c	2000/05/27 14:47:10	1.6
+++ test/empty-server.c	2000/07/03 20:37:49
@@ -81,5 +81,5 @@
 static void
 do_Nothing (PortableServer_Servant servant, CORBA_Environment * ev)
 {
-	g_print ("doNothing called!");
+  g_print("I just did nothing\n");
 }


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