Re: GEP 12 part 2: configurable server environment



	OK.  Now I tested in a real desktop environment and gnome-session
failed, because I forgot to update the bonobo activation async method
invocation args.  Just another example where the lack of compile-time
verification leads to human error...
	Here's an updated patch.

A Qua, 2003-12-03 às 21:49, Gustavo J. A. M. Carneiro escreveu:
> 	Ok, so here's the patch that provides the missing piece in the GEP 12
> puzzle.  With this code, you can put something like this in your .server
> files (diff-like format):
> 
> <oaf_server iid="OAFIID:Bonobo_Sample_Echo_Factory" type="exe" 
> 	location="/opt/gnome-2.5//lib/bonobo-2.0/samples/bonobo-echo-2">
> 	<oaf_attribute name="repo_ids" type="stringv">
> 		<item value="IDL:GNOME/ObjectFactory:1.0"/>
> 	</oaf_attribute>
> +	<oaf_attribute name="bonobo:environment" type="stringv">
> +		<item value="FOOBAR"/>
> +	</oaf_attribute>
> 	<oaf_attribute name="name" type="string" value="Echo component
> factory"/>
> 
> 	This means that, when you try to activate this object,
> bonobo-activation tries to obtain running factory with a matching value
> for the env. var. $FOOBAR.  If the environment doesn't match, a new
> factory is spawned with modified environment to match client's.
> 
> 	OK, this is preliminary code.  I haven't tested yet in a real desktop
> environment.  I'll test that first thing tomorrow.  I already know about
> the following problems:
> 	1. Per-client environment needs to be released when client disconnects;
> 	2. The BonoboApplication code needs to make use of this new feature,
> somehow;
> 	3. As Michael suggested, we need "meta-variables" and intelligent
> handling of special variables.
> 
> 	So, it really needs more fine-tuning.  However, I am confident that the
> hard part is already done.
> 
> 	Awaiting comments.
> 
> PS: the patch also contains a bug fix for my previous patch as bonus! ;)
-- 
Gustavo João Alves Marques Carneiro
<gjc inescporto pt> <gustavo users sourceforge net>

? stamp-h1
? activation-server/test-performance
? tests/test-uniqapp
Index: activation-server/activation-context-corba.c
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/activation-context-corba.c,v
retrieving revision 1.62
diff -u -p -r1.62 activation-context-corba.c
--- activation-server/activation-context-corba.c	1 Dec 2003 12:56:14 -0000	1.62
+++ activation-server/activation-context-corba.c	4 Dec 2003 16:14:22 -0000
@@ -455,6 +455,7 @@ ac_do_activation (ActivationContext     
 		  Bonobo_ActivationResult            *out,
 		  Bonobo_ActivationFlags              flags,
 		  const char                         *hostname,
+                  Bonobo_ActivationClient             client,
 		  CORBA_Context                       ctx,
                   CORBA_Environment                  *ev)
 {
@@ -543,7 +544,8 @@ ac_do_activation (ActivationContext     
 		CORBA_Object retval;
 
 		retval = Bonobo_ObjectDirectory_activate (
-                        actx->obj, server->iid, BONOBO_OBJREF (actx), environment, flags, ctx, ev);
+                        actx->obj, server->iid, BONOBO_OBJREF (actx),
+                        environment, flags, client, ctx, ev);
 
 		if (ev->_major == CORBA_NO_EXCEPTION) {
 			char tbuf[512];
@@ -571,6 +573,7 @@ impl_Bonobo_ActivationContext_activateMa
         const Bonobo_StringList            *selection_order,
 	const Bonobo_ActivationEnvironment *environment,
         const Bonobo_ActivationFlags        flags,
+        Bonobo_ActivationClient             client,
         CORBA_Context                       ctx,
         CORBA_Environment                  *ev)
 {
@@ -601,7 +604,7 @@ impl_Bonobo_ActivationContext_activateMa
 		curitem = items[i];
 
 		ac_do_activation (actx, curitem, environment,
-				  retval, flags, hostname, ctx, ev);
+				  retval, flags, hostname, client, ctx, ev);
 	}
 
 	if (retval->res._d == Bonobo_ACTIVATION_RESULT_NONE)
@@ -766,6 +769,7 @@ static Bonobo_ActivationResult *
 impl_Bonobo_ActivationContext_activateFromAid (PortableServer_Servant  servant,
 					       const CORBA_char       *aid,
 					       Bonobo_ActivationFlags  flags,
+                                               Bonobo_ActivationClient client,
 					       CORBA_Context           ctx,
 					       CORBA_Environment      *ev)
 {
@@ -814,7 +818,7 @@ impl_Bonobo_ActivationContext_activateFr
 	memset (&environment, 0, sizeof (Bonobo_ActivationEnvironment));
 
         retval = impl_Bonobo_ActivationContext_activateMatching (
-                actx, requirements, &selection_order, &environment, flags, ctx, ev);
+                actx, requirements, &selection_order, &environment, flags, client, ctx, ev);
 
         g_free (sort_criteria[0]);
         g_free (sort_criteria[1]);
Index: activation-server/activation-server-main.c
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/activation-server-main.c,v
retrieving revision 1.52
diff -u -p -r1.52 activation-server-main.c
--- activation-server/activation-server-main.c	3 Nov 2003 15:21:32 -0000	1.52
+++ activation-server/activation-server-main.c	4 Dec 2003 16:14:22 -0000
@@ -286,7 +286,8 @@ main (int argc, char *argv[])
         CORBA_exception_init (ev);
 
         Bonobo_ObjectDirectory_register_new 
-                (od, NAMING_CONTEXT_IID, &environment, naming_service, 0, "", &existing, ev);
+                (od, NAMING_CONTEXT_IID, &environment, naming_service, 0, "",
+                 &existing, CORBA_OBJECT_NIL, ev);
         g_assert (ev->_major == CORBA_NO_EXCEPTION);
         
 	if (existing != CORBA_OBJECT_NIL)
Index: activation-server/client.c
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/client.c,v
retrieving revision 1.20
diff -u -p -r1.20 client.c
--- activation-server/client.c	9 Jul 2003 07:09:09 -0000	1.20
+++ activation-server/client.c	4 Dec 2003 16:14:22 -0000
@@ -237,6 +237,7 @@ do_activating()
                                                                                                                              
 	a_res = Bonobo_ActivationContext_activateMatching (
  				ac, specs, &reqs, &environment, 0,
+                                bonobo_activation_client_get (),
 				bonobo_activation_context_get (), &ev);
 	switch (ev._major) {
 	case CORBA_NO_EXCEPTION:
Index: activation-server/object-directory-activate.c
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/object-directory-activate.c,v
retrieving revision 1.29
diff -u -p -r1.29 object-directory-activate.c
--- activation-server/object-directory-activate.c	30 May 2003 15:56:01 -0000	1.29
+++ activation-server/object-directory-activate.c	4 Dec 2003 16:14:22 -0000
@@ -42,6 +42,7 @@ static CORBA_Object
 od_server_activate_factory (Bonobo_ServerInfo                  *si,
 			    ODActivationInfo                   *actinfo,
 			    const Bonobo_ActivationEnvironment *environment,
+                            Bonobo_ActivationClient             client,
 			    CORBA_Environment                  *ev)
 {
 	Bonobo_ActivationResult *res;
@@ -60,7 +61,7 @@ od_server_activate_factory (Bonobo_Serve
 
 	res = Bonobo_ActivationContext_activateMatching (
 			actinfo->ac, requirements, &selorder,
-			environment, flags, actinfo->ctx, ev);
+			environment, flags, client, actinfo->ctx, ev);
 
 	if (ev->_major != CORBA_NO_EXCEPTION)
 		goto out;
@@ -170,6 +171,7 @@ od_server_activate (Bonobo_ServerInfo   
 		    ODActivationInfo                   *actinfo,
 		    CORBA_Object                        od_obj,
 		    const Bonobo_ActivationEnvironment *environment,
+                    Bonobo_ActivationClient             client,
 		    CORBA_Environment                  *ev)
 {
         g_return_val_if_fail (ev->_major == CORBA_NO_EXCEPTION,
@@ -179,7 +181,7 @@ od_server_activate (Bonobo_ServerInfo   
 		return od_server_activate_exe (si, actinfo, od_obj, environment, ev);
 
 	else if (!strcmp (si->server_type, "factory"))
-		return od_server_activate_factory (si, actinfo, environment, ev);
+		return od_server_activate_factory (si, actinfo, environment, client, ev);
 
 	else if (!strcmp (si->server_type, "shlib"))
 		g_warning (_("We don't handle activating shlib objects in a remote process yet"));
Index: activation-server/object-directory-corba.c
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/object-directory-corba.c,v
retrieving revision 1.62
diff -u -p -r1.62 object-directory-corba.c
--- activation-server/object-directory-corba.c	24 Nov 2003 01:04:03 -0000	1.62
+++ activation-server/object-directory-corba.c	4 Dec 2003 16:14:23 -0000
@@ -325,13 +325,13 @@ od_get_active_server (ObjectDirectory   
 
 	retval = CORBA_OBJECT_NIL;
 
-	for (i = 0; i < servers->n_servers; i++)
+	for (i = 0; i < servers->n_servers; i++) {
 		if (Bonobo_ActivationEnvironment_match (
 				&servers->servers [i].environment,
 				environment)) {
 			retval = servers->servers [i].server;
 		}
-
+        }
 	if (retval != CORBA_OBJECT_NIL &&
 	    !CORBA_Object_non_existent (retval, NULL))
 		return CORBA_Object_duplicate (retval, NULL);
@@ -339,6 +339,80 @@ od_get_active_server (ObjectDirectory   
 	return CORBA_OBJECT_NIL;
 }
 
+
+  /* returns (@merged_environment) new environment as result of
+   * merging activation request environment and client registered
+   * environment; the activation supplied environment takes precedence
+   * over the client one */
+static void
+od_merge_client_environment (ObjectDirectory                    *od,
+                             Bonobo_ServerInfo                  *server,
+                             const Bonobo_ActivationEnvironment *environment,
+                             Bonobo_ActivationEnvironment       *merged_environment,
+                             Bonobo_ActivationClient             client)
+{
+        GArray *array;
+        int i, serverinfo_env_idx;
+        const Bonobo_ActivationEnvironment *client_env;
+        const Bonobo_StringList *serverinfo_env = NULL;
+
+        array = g_array_new (FALSE, FALSE, sizeof (Bonobo_ActivationEnvValue));
+
+          /* copy all values from @environment */
+        for (i = 0; i < environment->_length; ++i)
+                g_array_append_val (array, environment->_buffer[i]);
+
+        if (client == CORBA_OBJECT_NIL) goto exit;
+
+          /* scan through server properties*/
+        for (i = 0; i < server->props._length; ++i) {
+                if (strcmp (server->props._buffer[i].name, "bonobo:environment") == 0)
+                {
+                        Bonobo_ActivationPropertyValue const *prop =
+                                &server->props._buffer[i].v;
+                        if (prop->_d == Bonobo_ACTIVATION_P_STRINGV)
+                                serverinfo_env = &prop->_u.value_stringv;
+                        else
+                                g_warning ("bonobo:environment should have type stringv");
+                        break;
+                }
+        }
+        if (!serverinfo_env) goto exit;
+
+          /* do the actual merging */
+        client_env = (const Bonobo_ActivationEnvironment *)
+                g_hash_table_lookup (od->client_envs, client);
+
+        for (serverinfo_env_idx = 0;
+             serverinfo_env_idx < serverinfo_env->_length; ++serverinfo_env_idx)
+        {
+                CORBA_char *env = serverinfo_env->_buffer[serverinfo_env_idx];
+                gboolean duplicated_env = FALSE;
+
+                  /* check if array already has this environment */
+                for (i = 0; i < environment->_length; ++i)
+                        if (strcmp (environment->_buffer[i].name, env) == 0) {
+                                duplicated_env = TRUE;
+                                break;
+                        }
+                if (duplicated_env) continue;
+                  /* look for environment in client_env */
+                for (i = 0; i < client_env->_length; ++i) {
+                        if (strcmp (client_env->_buffer[i].name, env) == 0) {
+                                  /* found it! */
+                                g_array_append_val (array, client_env->_buffer[i]);
+                                break;
+                        }
+                }
+        }
+exit:
+          /* return the resulting environment */
+        merged_environment->_buffer = (Bonobo_ActivationEnvValue *) array->data;
+        merged_environment->_length = merged_environment->_maximum = array->len;
+        g_array_free (array, FALSE);
+}
+
+
 static CORBA_Object
 impl_Bonobo_ObjectDirectory_activate (
 	PortableServer_Servant              servant,
@@ -346,6 +420,7 @@ impl_Bonobo_ObjectDirectory_activate (
 	const Bonobo_ActivationContext      ac,
 	const Bonobo_ActivationEnvironment *environment,
 	const Bonobo_ActivationFlags        flags,
+	Bonobo_ActivationClient             client,
 	CORBA_Context                       ctx,
 	CORBA_Environment                  *ev)
 {
@@ -356,16 +431,23 @@ impl_Bonobo_ObjectDirectory_activate (
 #ifdef BONOBO_ACTIVATION_DEBUG
 	static int                       depth = 0;
 #endif
+        Bonobo_ActivationEnvironment merged_environment;
+
+        od_merge_client_environment (od, (Bonobo_ServerInfo *)
+                                     g_hash_table_lookup (od->by_iid, iid),
+                                     environment, &merged_environment, client);
 
 	retval = CORBA_OBJECT_NIL;
 
         update_registry (od, FALSE);
 
         if (!(flags & Bonobo_ACTIVATION_FLAG_PRIVATE)) {
-                retval = od_get_active_server (od, iid, environment);
+                retval = od_get_active_server (od, iid, &merged_environment);
 
-                if (retval != CORBA_OBJECT_NIL)
+                if (retval != CORBA_OBJECT_NIL) {
+                        g_free (merged_environment._buffer);
                         return retval;
+                }
         }
 
 	if (flags & Bonobo_ACTIVATION_FLAG_EXISTING_ONLY) {
@@ -390,7 +472,7 @@ impl_Bonobo_ObjectDirectory_activate (
 
 	if (si) {
 		retval = od_server_activate (
-				si, &ai, BONOBO_OBJREF (od), environment, ev);
+				si, &ai, BONOBO_OBJREF (od), &merged_environment, client, ev);
 
                 /* If we failed to activate - it may be because our
                  * request re-entered _during_ the activation
@@ -408,7 +490,7 @@ impl_Bonobo_ObjectDirectory_activate (
                 /* FIXME: this path is theoretically redundant now */
                 if (ev->_major != CORBA_NO_EXCEPTION ||
                     retval == CORBA_OBJECT_NIL) {
-                        retval = od_get_active_server (od, iid, environment);
+                        retval = od_get_active_server (od, iid, &merged_environment);
 
                         if (retval != CORBA_OBJECT_NIL)
                                 CORBA_exception_free (ev);
@@ -424,6 +506,7 @@ impl_Bonobo_ObjectDirectory_activate (
                 depth--;
         }
 #endif
+        g_free (merged_environment._buffer);
 
 	return retval;
 }
@@ -722,8 +805,10 @@ od_register_runtime_server_info (ObjectD
                  g_ptr_array_add (od->attr_runtime_servers, new_serverinfo);
            /* FIXME: this kills performance, need an alternative */
          update_registry (od, TRUE);
+         return new_serverinfo;
 }
 
+
 static Bonobo_RegistrationResult
 impl_Bonobo_ObjectDirectory_register_new (
 	PortableServer_Servant              servant,
@@ -733,29 +818,39 @@ impl_Bonobo_ObjectDirectory_register_new
         Bonobo_RegistrationFlags            flags,
         const CORBA_char                   *description,
         CORBA_Object                       *existing,
+	Bonobo_ActivationClient             client,
 	CORBA_Environment                  *ev)
 {
 	ObjectDirectory *od = OBJECT_DIRECTORY (servant);
 	CORBA_Object     oldobj;
+        Bonobo_ActivationEnvironment merged_environment;
 
-	oldobj = od_get_active_server (od, iid, environment);
+        od_merge_client_environment (od, (Bonobo_ServerInfo *)
+                                     g_hash_table_lookup (od->by_iid, iid),
+                                     environment, &merged_environment, client);
+	oldobj = od_get_active_server (od, iid, &merged_environment);
         *existing = oldobj;
 
 	if (oldobj != CORBA_OBJECT_NIL) {
-		if (!CORBA_Object_non_existent (oldobj, ev))
+		if (!CORBA_Object_non_existent (oldobj, ev)) {
+                        g_free (merged_environment._buffer);
 			return Bonobo_ACTIVATION_REG_ALREADY_ACTIVE;
+                }
 	}
 
         if (!od_register_runtime_server_info (od, iid, description)) {
-                if (!(flags&Bonobo_REGISTRATION_FLAG_NO_SERVERINFO))
+                if (!(flags&Bonobo_REGISTRATION_FLAG_NO_SERVERINFO)) {
+                        g_free (merged_environment._buffer);
                         return Bonobo_ACTIVATION_REG_NOT_LISTED;
+                }
         }
 
 #ifdef BONOBO_ACTIVATION_DEBUG
         g_warning ("Server register. '%s' : %p", iid, obj);
 #endif
 
-        add_active_server (od, iid, environment, obj);
+        add_active_server (od, iid, &merged_environment, obj);
+        g_free (merged_environment._buffer);
 
 	return Bonobo_ACTIVATION_REG_SUCCESS;
 }
@@ -888,6 +983,40 @@ impl_Bonobo_ObjectDirectory_remove_path(
 	return Bonobo_DYNAMIC_LOAD_SUCCESS;
 }
 
+
+static void
+impl_Bonobo_ObjectDirectory_addClientEnv (
+        PortableServer_Servant         servant,
+        const Bonobo_ActivationClient  client,
+        const Bonobo_StringList       *client_env,
+        CORBA_Environment             *ev)
+{
+        Bonobo_ActivationEnvironment *env;
+	ObjectDirectory *od = OBJECT_DIRECTORY (servant);
+        int i;
+        
+        env = Bonobo_ActivationEnvironment__alloc ();
+        env->_length  = env->_maximum = client_env->_length;
+        env->_buffer  = Bonobo_ActivationEnvironment_allocbuf (env->_length);
+        env->_release = CORBA_TRUE;
+
+        for (i = 0; i < client_env->_length; ++i)
+        {
+                const char *keyval = client_env->_buffer[i];
+                const char *equals = strchr (keyval, '=');
+                guint       keylen = (guint) (equals - keyval);
+
+                env->_buffer[i].name = CORBA_string_alloc (keylen + 1);
+                strncpy (env->_buffer[i].name, keyval, keylen);
+                env->_buffer[i].name[keylen] = 0;
+                env->_buffer[i].value = CORBA_string_dup (equals + 1);
+                env->_buffer[i].flags = 0;
+        }
+
+        g_hash_table_insert (od->client_envs, client, env);
+}
+
+
 Bonobo_ObjectDirectory
 bonobo_object_directory_get (void)
 {
@@ -976,6 +1105,11 @@ object_directory_finalize (GObject *obje
 
         g_strfreev (od->registry_source_directories);
 
+        if (od->client_envs) {
+                g_hash_table_destroy (od->client_envs);
+                od->client_envs = NULL;
+        }
+
         parent_class->finalize (object);
 }
 
@@ -995,6 +1129,7 @@ object_directory_class_init (ObjectDirec
 	epv->unregister          = impl_Bonobo_ObjectDirectory_unregister;
 	epv->dynamic_add_path    = impl_Bonobo_ObjectDirectory_add_path;
 	epv->dynamic_remove_path = impl_Bonobo_ObjectDirectory_remove_path;
+        epv->addClientEnv        = impl_Bonobo_ObjectDirectory_addClientEnv;
 }
 
 static void
@@ -1012,6 +1147,8 @@ object_directory_init (ObjectDirectory *
         od->no_servers_timeout = 0;
 
         od->attr_runtime_servers = g_ptr_array_new ();
+        od->client_envs = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+                                                 NULL, (GDestroyNotify) CORBA_free);
 }
 
 BONOBO_TYPE_FUNC_FULL (ObjectDirectory,
Index: activation-server/object-directory.h
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/object-directory.h,v
retrieving revision 1.3
diff -u -p -r1.3 object-directory.h
--- activation-server/object-directory.h	24 Nov 2003 01:04:03 -0000	1.3
+++ activation-server/object-directory.h	4 Dec 2003 16:14:23 -0000
@@ -48,6 +48,10 @@ struct _ObjectDirectory {
         char           **registry_source_directories;
         time_t           time_did_stat;
         GHashTable      *registry_directory_mtimes;
+
+	  /* Maps client objrefs to
+	     CORBA-allocated Bonobo_ActivationEnvironment */
+	GHashTable *client_envs;
 };
 
 typedef struct {
Index: activation-server/server.h
===================================================================
RCS file: /cvs/gnome/libbonobo/activation-server/server.h,v
retrieving revision 1.22
diff -u -p -r1.22 server.h
--- activation-server/server.h	24 Nov 2003 01:04:03 -0000	1.22
+++ activation-server/server.h	4 Dec 2003 16:14:23 -0000
@@ -43,6 +43,7 @@ CORBA_Object             od_server_activ
                                                           ODActivationInfo                   *actinfo,
                                                           CORBA_Object                        od_obj,
                                                           const Bonobo_ActivationEnvironment *environment,
+                                                          Bonobo_ActivationClient             client,
                                                           CORBA_Environment                  *ev);
 
 /* activation-context-corba.c */
Index: bonobo-activation/bonobo-activation-activate.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo-activation/bonobo-activation-activate.c,v
retrieving revision 1.42
diff -u -p -r1.42 bonobo-activation-activate.c
--- bonobo-activation/bonobo-activation-activate.c	31 Oct 2003 16:09:49 -0000	1.42
+++ bonobo-activation/bonobo-activation-activate.c	4 Dec 2003 16:14:23 -0000
@@ -369,7 +369,8 @@ bonobo_activation_activate (const char  
 
 	result = Bonobo_ActivationContext_activateMatching (
 			ac, requirements, &selorder, &activation_environment,
-			flags, bonobo_activation_context_get (), ev);
+			flags, bonobo_activation_client_get (),
+                        bonobo_activation_context_get (), ev);
 
 	if (ev->_major == CORBA_NO_EXCEPTION)
 		retval = handle_activation_result (result, ret_aid, ev);
@@ -434,7 +435,8 @@ bonobo_activation_activate_from_id (cons
 	}
 
 	result = Bonobo_ActivationContext_activateFromAid (
-			ac, aid, flags, bonobo_activation_context_get (), ev);
+			ac, aid, flags, bonobo_activation_client_get (),
+                        bonobo_activation_context_get (), ev);
 
 	if (ev->_major == CORBA_NO_EXCEPTION)
 		retval = handle_activation_result (result, ret_aid, ev);
@@ -563,7 +565,8 @@ bonobo_activation_activate_async (const 
 	AsyncActivationData      *async_data;
 	CORBA_Environment        *ev, tempenv;
 	Bonobo_StringList         selorder;
-	gpointer                  args [4];
+        Bonobo_ActivationClient   client;
+	gpointer                  args [5];
 
 	if (!requirements) {
 		async_cb (CORBA_OBJECT_NIL, ASYNC_ERROR_NO_REQUIREMENTS, user_data);
@@ -588,10 +591,13 @@ bonobo_activation_activate_async (const 
 
 	copy_strv_to_sequence (selection_order, &selorder);
 
-	args [0] = &requirements;
+        client = bonobo_activation_client_get ();
+
+        args [0] = &requirements;
 	args [1] = &selorder;
 	args [2] = &activation_environment;
 	args [3] = &flags;
+	args [4] = &client;
 
 	if (!activate_matching_method)
 		setup_methods ();
@@ -641,7 +647,8 @@ bonobo_activation_activate_from_id_async
 	Bonobo_ActivationContext  ac;
 	AsyncActivationData      *async_data;
 	CORBA_Environment        *ev, tempenv;
-	gpointer                  args [2];
+        Bonobo_ActivationClient   client;
+	gpointer                  args [3];
 
 	if (!aid) {
 		async_cb (CORBA_OBJECT_NIL, ASYNC_ERROR_NO_AID, user_data);
@@ -682,8 +689,11 @@ bonobo_activation_activate_from_id_async
 	if (!activate_from_aid_method)
 		setup_methods ();
 
+        client = bonobo_activation_client_get ();
+
 	args [0] = (gpointer) &aid;
 	args [1] = &flags;
+	args [2] = &client;
 
 	ORBit_small_invoke_async (ac, activate_from_aid_method,
 				  activation_async_callback, async_data,
Index: bonobo-activation/bonobo-activation-client.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo-activation/bonobo-activation-client.c,v
retrieving revision 1.9
diff -u -p -r1.9 bonobo-activation-client.c
--- bonobo-activation/bonobo-activation-client.c	1 Dec 2003 12:56:15 -0000	1.9
+++ bonobo-activation/bonobo-activation-client.c	4 Dec 2003 16:14:23 -0000
@@ -27,6 +27,8 @@
 #include <bonobo-activation/bonobo-activation-client.h>
 #include <bonobo-activation/Bonobo_ActivationContext.h>
 
+extern char **environ;
+
 static GSList *reset_notify_callbacks = NULL;
 
 static void
@@ -200,9 +202,45 @@ void
 bonobo_activation_register_client (Bonobo_ActivationContext context,
                                    CORBA_Environment       *ev)
 {
+        Bonobo_StringList      client_env;
+        int                    i;
+        Bonobo_ObjectDirectory od;
+
         if (client == CORBA_OBJECT_NIL) {
                 client = bonobo_activation_corba_client_new ();
         }
 
         Bonobo_ActivationContext_addClient (context, client, get_lang_list (), ev);
+
+        od = bonobo_activation_object_directory_get (
+                bonobo_activation_username_get (),
+                bonobo_activation_hostname_get ());
+
+          /* send environment to activation server */
+        client_env._release = CORBA_FALSE;
+        for (i = 0; environ[i]; ++i);
+        client_env._length = client_env._maximum = i;
+        client_env._buffer = g_new (CORBA_string, client_env._length);
+        for (i = 0; i < client_env._length; ++i)
+                client_env._buffer[i] = environ[i];
+        Bonobo_ObjectDirectory_addClientEnv (od, client, &client_env, ev);
+        g_free (client_env._buffer);
 }
+
+Bonobo_ActivationClient
+bonobo_activation_client_get (void)
+{
+        CORBA_Environment ev;
+
+        if (client == CORBA_OBJECT_NIL) {
+                CORBA_exception_init (&ev);
+                bonobo_activation_register_client
+                        ((Bonobo_ActivationContext)
+                         bonobo_activation_activation_context_get (), &ev);
+                if (ev._major != CORBA_NO_EXCEPTION)
+                        g_warning ("Failed to register Bonobo::ActivationClient");
+                CORBA_exception_free (&ev);
+        }
+        return client;
+}
+
Index: bonobo-activation/bonobo-activation-private.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo-activation/bonobo-activation-private.h,v
retrieving revision 1.27
diff -u -p -r1.27 bonobo-activation-private.h
--- bonobo-activation/bonobo-activation-private.h	9 Jun 2003 13:17:55 -0000	1.27
+++ bonobo-activation/bonobo-activation-private.h	4 Dec 2003 16:14:23 -0000
@@ -82,5 +82,7 @@ void Bonobo_ActivationEnvValue_copy (Bon
 
 const GList *bonobo_activation_i18n_get_language_list (const gchar *category_name);
 
+Bonobo_ActivationClient bonobo_activation_client_get (void);
+
 #endif /* BONOBO_ACTIVATION_PRIVATE_H */
 
Index: bonobo-activation/bonobo-activation-register.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo-activation/bonobo-activation-register.c,v
retrieving revision 1.39
diff -u -p -r1.39 bonobo-activation-register.c
--- bonobo-activation/bonobo-activation-register.c	9 Jun 2003 13:17:55 -0000	1.39
+++ bonobo-activation/bonobo-activation-register.c	4 Dec 2003 16:14:23 -0000
@@ -147,7 +147,8 @@ copy_env_list_to_sequence (Bonobo_Activa
 		g_warning ("Registration environment for '%s' = '%s'%s",
 			   environment->_buffer [i].name,
 			   environment->_buffer [i].value,
-			   environment->_buffer [i].unset ? "(unset)" : "");
+			   (environment->_buffer [i].flags &
+                            Bonobo_ACTIVATION_ENV_FLAG_UNSET) ? "(unset)" : "");
 #endif
 	}
 }
@@ -300,7 +301,8 @@ bonobo_activation_register_active_server
 					reg_env ? &environment : &global_reg_env,
 				        obj, flags,
                                         description ? description : "",
-                                        existing, &ev);
+                                        existing, bonobo_activation_client_get (),
+                                        &ev);
 
 		if (reg_env)
 			CORBA_free (environment._buffer);
Index: idl/Bonobo_ActivationContext.idl
===================================================================
RCS file: /cvs/gnome/libbonobo/idl/Bonobo_ActivationContext.idl,v
retrieving revision 1.39
diff -u -p -r1.39 Bonobo_ActivationContext.idl
--- idl/Bonobo_ActivationContext.idl	1 Dec 2003 12:56:15 -0000	1.39
+++ idl/Bonobo_ActivationContext.idl	4 Dec 2003 16:14:23 -0000
@@ -39,9 +39,11 @@
 #include <Bonobo_Unknown.idl>
 #include <Bonobo_Activation_types.idl>
 
-/* ObjectDirectory needs a forward declaration of ActivationContext */
+/* ObjectDirectory needs a forward declaration of ActivationContext
+ * and ActivationClient */
 module Bonobo {
         interface ActivationContext;
+        interface ActivationClient;
 };
 
 #include <Bonobo_ObjectDirectory.idl>
@@ -73,14 +75,16 @@ module Bonobo {
                 ActivationResult activateMatching (in string                        requirements,
                                                    in Bonobo::StringList            selection_order,
                                                    in Bonobo::ActivationEnvironment environment,
-                                                   in ActivationFlags               flags)
+                                                   in ActivationFlags               flags,
+                                                   in ActivationClient              client)
                         raises (Bonobo::Activation::ParseFailed,
                                 Bonobo::Activation::IncompleteContext,
                                 Bonobo::GeneralError)
                         context ("username", "hostname");
 
-                ActivationResult activateFromAid (in ActivationID    aid,
-                                                  in ActivationFlags flags)
+                ActivationResult activateFromAid (in ActivationID     aid,
+                                                  in ActivationFlags  flags,
+                                                  in ActivationClient client)
                         raises (Bonobo::Activation::ParseFailed,
                                 Bonobo::Activation::IncompleteContext,
                                 Bonobo::GeneralError)
Index: idl/Bonobo_ObjectDirectory.idl
===================================================================
RCS file: /cvs/gnome/libbonobo/idl/Bonobo_ObjectDirectory.idl,v
retrieving revision 1.10
diff -u -p -r1.10 Bonobo_ObjectDirectory.idl
--- idl/Bonobo_ObjectDirectory.idl	19 May 2003 15:19:42 -0000	1.10
+++ idl/Bonobo_ObjectDirectory.idl	4 Dec 2003 16:14:23 -0000
@@ -70,7 +70,8 @@ module Bonobo {
                 Object activate (in ImplementationID              iid,
                                  in ActivationContext             ac,
                                  in Bonobo::ActivationEnvironment environment,
-                                 in ActivationFlags               flags)
+                                 in ActivationFlags               flags,
+                                 in ActivationClient              client)
                         context ("username", "hostname");
 
                 RegistrationResult register_new (in  ImplementationID              iid,
@@ -78,13 +79,17 @@ module Bonobo {
                                                  in  Object                        obj,
 						 in  RegistrationFlags             flags,
                                                  in  string                        description,
-                                                 out Object                        existing);
+                                                 out Object                        existing,
+                                                 in  ActivationClient              client);
                 void               unregister   (in ImplementationID              iid,
                                                  in Object                        obj)
                         raises (NotRegistered);
 
                 DynamicPathLoadResult dynamic_add_path (in string add_path);
                 DynamicPathLoadResult dynamic_remove_path (in string remove_path);
+
+                void addClientEnv (in ActivationClient client,
+                                   in StringList       env);
         };
 
 };


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