Example #1
0
CORBA_char *
CORBA_ORB_object_to_string (CORBA_ORB          orb,
			    const CORBA_Object obj,
			    CORBA_Environment *ev)
{
	GIOPSendBuffer *buf;
	CORBA_octet     endianness = GIOP_FLAG_ENDIANNESS;
	CORBA_char     *out;
	int             i, j, k;

	g_return_val_if_fail (ev != NULL, NULL);

	if(!orb || !obj || MATECORBA_ROOT_OBJECT_TYPE (obj) != MATECORBA_ROT_OBJREF) {
		CORBA_exception_set_system (
				ev, ex_CORBA_BAD_PARAM, CORBA_COMPLETED_NO);

		return NULL;
	}

	if (matecorba_use_corbaloc) {
		out = MateCORBA_object_to_corbaloc (obj, ev);
		if (ev->_major == CORBA_NO_EXCEPTION)
			return out;

		CORBA_exception_free (ev);
		/* fall thru, common marshalling */
	}

	buf = giop_send_buffer_use (orb->default_giop_version);

	g_assert (buf->num_used == 1);

	buf->header_size             = 0;
	buf->lastptr                 = NULL;
	buf->num_used                = 0; /* we don't want the header in there */
	buf->msg.header.message_size = 0;

	giop_send_buffer_append (buf, &endianness, 1);

	MateCORBA_marshal_object (buf, obj);
	out = CORBA_string_alloc (4 + (buf->msg.header.message_size * 2) + 1);

	strcpy (out, "IOR:");

	for (i = 0, k = 4; i < buf->num_used; i++) {
		struct iovec *curvec;
		guchar       *ptr;

		curvec = &buf->iovecs [i];
		ptr    = curvec->iov_base;

		for (j = 0; j < curvec->iov_len; j++, ptr++) {
			int n1, n2;

			n1 = (*ptr & 0xF0) >> 4;
			n2 = (*ptr & 0xF);

			out [k++] = num2hexdigit (n1);
			out [k++] = num2hexdigit (n2);
		}
	}

	out [k++] = '\0';

	giop_send_buffer_unuse (buf);

	return out;
}
int
main (int argc, char *argv[])
{
	CORBA_Object obj;
	CORBA_Environment ev;
        MateComponent_ServerInfoList *info;
        CORBA_Object ac;
        char *sort_by[4];
        char *query;
        int   i;
        GTimer *timer = g_timer_new ();
	MateComponent_EventSource event_source;
	
        g_thread_init (NULL);

	CORBA_exception_init (&ev);

        matecomponent_activation_object_directory_get (
                matecomponent_activation_username_get (),
                matecomponent_activation_hostname_get ());

	matecomponent_init (&argc, argv);
/*      putenv("MateComponent_BARRIER_INIT=1"); */


	event_source = matecomponent_activation_activate_from_id
                ("OAFIID:MateComponent_Activation_EventSource", 0, NULL, &ev);
        if (event_source != CORBA_OBJECT_NIL) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: Activation event source okay\n",
                         passed + failed, TOTAL_TEST_SCORE);
   	        matecomponent_event_source_client_add_listener (event_source, listener_cb,
                                                         "MateComponent/ObjectDirectory", &ev, NULL);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Activation event source not found\n",
                         passed + failed, TOTAL_TEST_SCORE);
	}


        race_base_init ();

        sort_by[0] = "prefer_by_list_order(iid, ["
                "'OAFIID:nautilus_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058',"
                "'OAFIID:nautilus_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c',"
                "'OAFIID:nautilus_music_view:9456b5d2-60a8-407f-a56e-d561e1821391'])";
        sort_by[1] = "iid != 'OAFIID:nautilus_content_loser:95901458-c68b-43aa-aaca-870ced11062d'";
        sort_by[2] = "iid != 'OAFIID:nautilus_sample_content_view:45c746bc-7d64-4346-90d5-6410463b43ae'";
        sort_by[3] = NULL;

        query = "( (((repo_ids.has_all (['IDL:MateComponent/Control:1.0',"
                "'IDL:Nautilus/View:1.0']) OR (repo_ids.has_one "
                "(['IDL:MateComponent/Control:1.0','IDL:MateComponent/Embeddable:1.0']) AND "
                "repo_ids.has_one (['IDL:MateComponent/PersistStream:1.0', "
                "'IDL:MateComponent/ProgressiveDataSink:1.0', "
                "'IDL:MateComponent/PersistFile:1.0']))) AND (matecomponent:supported_mime_types.defined () OR "
                "matecomponent:supported_uri_schemes.defined () OR "
                "matecomponent:additional_uri_schemes.defined ()) AND "
                "(((NOT matecomponent:supported_mime_types.defined () OR "
                "matecomponent:supported_mime_types.has ('x-directory/normal') OR "
                "matecomponent:supported_mime_types.has ('x-directory/*') OR "
                "matecomponent:supported_mime_types.has ('*/*')) AND "
                "(NOT matecomponent:supported_uri_schemes.defined () OR "
                "matecomponent:supported_uri_schemes.has ('file') OR "
                "matecomponent:supported_uri_schemes.has ('*'))) OR "
                "(matecomponent:additional_uri_schemes.has ('file') OR "
                "matecomponent:additional_uri_schemes.has ('*'))) AND "
                "nautilus:view_as_name.defined ()) OR false) AND "
                "(has (['OAFIID:nautilus_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058', "
                "'OAFIID:nautilus_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c'], iid)) ) AND "
                "(NOT test_only.defined() OR NOT test_only)";

        ac = matecomponent_activation_activation_context_get ();

        g_timer_start (timer);

        info = matecomponent_activation_query (query, sort_by, &ev);

        for (i = 0; i < 1000; i++) {
                MateComponent_ServerInfoList *copy;
                copy = MateComponent_ServerInfoList_duplicate (info);
                CORBA_free (copy);
        }
        g_timer_stop (timer);

        fprintf (stderr, "Time to query '%g'\n", g_timer_elapsed (timer, NULL));
        if (ev._major == CORBA_NO_EXCEPTION) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: timed query\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: timed query\n", passed + failed, TOTAL_TEST_SCORE);
                CORBA_exception_free (&ev);
	}

        /*
         *    We wait to see if the server (sever)
         * timeout is mis-behaving [ at this stage we
         * have not registered anything with the server ]
         */
        fprintf (stderr, "Waiting to see if the server erroneously quits\n");
        g_usleep (SERVER_IDLE_QUIT_TIMEOUT * 2 * 1000);
        g_assert (MateCORBA_small_get_connection_status (ac) ==
                  MATECORBA_CONNECTION_CONNECTED);

        race_empty (&ev);
	
	
	
	

	obj = matecomponent_activation_activate_from_id ("OAFIID:Empty:19991025", 0, NULL, &ev);
        if (test_object (obj, &ev, "from id") && test_empty (obj, &ev, "from id")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: IID activation\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: IID activation\n", passed + failed, TOTAL_TEST_SCORE);
	}

	obj = matecomponent_activation_activate_from_id ("OAFAID:[OAFIID:Empty:19991025]", 0, NULL, &ev);
        if (test_object (obj, &ev, "from aid") && test_empty (obj, &ev, "from aid")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: AID activation\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: AID activation\n", passed + failed, TOTAL_TEST_SCORE);
	}

	obj = matecomponent_activation_activate_from_id ("OAFAID:[OAFIID:Plugin:20010713]",  0, NULL, &ev);
	if (test_object (obj, &ev, "from aid") && test_plugin (obj, &ev, "from aid")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: plugin activation\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: plugin activation\n", passed + failed, TOTAL_TEST_SCORE);
	}

        obj = matecomponent_activation_activate_from_id ("OAFIID:Bogus:20000526", 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: Broken link test : %s\n",
			 passed + failed, TOTAL_TEST_SCORE, matecomponent_activation_exception_id (&ev));
                CORBA_exception_free (&ev);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Broken link test\n", passed + failed, TOTAL_TEST_SCORE);
	}

        if (test_matecomponent_activation_server (&ev, "with broken factory link")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
	}

        fprintf (stderr, "Broken exe test ");
        obj = matecomponent_activation_activate_from_id ("OAFIID:Broken:20000530", 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: Broken exe test : %s\n",
			 passed + failed, TOTAL_TEST_SCORE, matecomponent_activation_exception_id (&ev));
                CORBA_exception_free (&ev);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Broken exe test\n", passed + failed, TOTAL_TEST_SCORE);
	}

        if (test_matecomponent_activation_server (&ev, "with broken factory link")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
	}

        obj = matecomponent_activation_activate_from_id ("OAFIID:Circular:20000530", 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: Circular link test : %s\n",
			 passed + failed, TOTAL_TEST_SCORE, matecomponent_activation_exception_id (&ev));
                CORBA_exception_free (&ev);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Circular link test\n", passed + failed, TOTAL_TEST_SCORE);
	}

        if (test_matecomponent_activation_server (&ev, "with broken factory link")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
	}

        obj = matecomponent_activation_activate_from_id ("OAFIID:NotInServer:20000717", 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: Server that doesn't register IID test : %s\n",
			 passed + failed, TOTAL_TEST_SCORE, matecomponent_activation_exception_id (&ev));
                CORBA_exception_free (&ev);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Server that doesn't register IID test\n",
			 passed + failed, TOTAL_TEST_SCORE);
	}

        if (test_matecomponent_activation_server (&ev, "with non-registering server")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
	}

        obj = matecomponent_activation_activate_from_id ("OAFIID:BrokenNoType:20000808", 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Server with IID but no type or location : %s\n",
			 passed + failed, TOTAL_TEST_SCORE, matecomponent_activation_exception_id (&ev));
                CORBA_exception_free (&ev);
        } else if (obj) {
		failed++;
		fprintf (stderr, "FAILED %d of %d: Server with IID but no type or location\n",
			 passed + failed, TOTAL_TEST_SCORE);
        } else {
                passed++;
		fprintf (stderr, "PASSED %d of %d: Server with IID but no type or location\n",
			 passed + failed, TOTAL_TEST_SCORE);
        }

        if (test_matecomponent_activation_server (&ev, "with no-type/loc server")) {
		passed++;
		fprintf (stderr, "PASSED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
        } else {
		failed++;
		fprintf (stderr, "FAILED %d of %d: activation server okay\n", passed + failed, TOTAL_TEST_SCORE);
	}

        fprintf (stderr, "\n%d of %d tests passed (%s)\n", passed,
                 TOTAL_TEST_SCORE,
                 passed == TOTAL_TEST_SCORE? "All": "some failures");

        if (passed < (TOTAL_TEST_SCORE * 2 / 3)) {
                fprintf (stderr, "It looks like you have not installed broken.server "
                         "into ${prefix}/share/matecomponent-activation/, this must be done "
                         "by hand to avoid problems with normal operation.\n");
		fprintf (stderr, "Another possibility is that you failed to kill "
			 "matecomponent_activation_server before running make check; try running matecomponent-slay.\n");
        }

        if (name_service != CORBA_OBJECT_NIL)
                CORBA_Object_release (name_service, &ev);
        
        if (event_source != CORBA_OBJECT_NIL)
		CORBA_Object_release (event_source, &ev);

	CORBA_exception_free (&ev);

        if (passed == TOTAL_TEST_SCORE) {
                if (matecomponent_debug_shutdown ()) {
                        return 0;
                } else {
                        return 1;
                }
        } else {
                return 1;
        }
}
Example #3
0
int main()
{
    double result=0;
    int i=0;
    erlang_pid pid;
    CORBA_Environment *env;
    ei_cnode ec;
  
    /* Create and init CORBA_Environment */
    env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ);
  
    /* Initiating the connection */
    ei_connect_init(&ec, "c47", COOKIE, 0);

    /* Initiating pid*/
    strcpy(pid.node, CLNODE);
    pid.num = 99;
    pid.serial = 0;
    pid.creation = 0;

    /* Fixing environment variable */
    env->_fd = ei_connect(&ec, SNODE);
    strcpy(env->_regname,SERVER);
    env->_to_pid = NULL;
    env->_from_pid = &pid;
  
    if (env->_fd < 0) {
	fprintf(stderr,"Error : Cannot connect to Server\n");

	/* Free env & buffers */
	CORBA_free(env->_inbuf);
	CORBA_free(env->_outbuf);
	CORBA_free(env);
	exit(1);
    }
  
    /* Calling the init function */
    rmod_random_init(NULL, 1, 2, 3, env);
 
    switch(env->_major) {
    case CORBA_NO_EXCEPTION:	/* Success */
	printf("Init complete !\n");
	break;
    case CORBA_SYSTEM_EXCEPTION: /* System exception */
	printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
	CORBA_exception_free(env);
	client_exit(env);
    default:			/* Should not come here */
	client_exit(env);
    }

    /* Calling the produce function */
    for(i=1; i<=10; i++) {
	result = rmod_random_produce(NULL, env);

	switch(env->_major) {
	case CORBA_NO_EXCEPTION: /* Success */
	    break;
	case CORBA_SYSTEM_EXCEPTION: /* System exception */
	    printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
	    CORBA_exception_free(env);
	    client_exit(env);
	default:		/* Should not come here */
	    client_exit(env);
	}

	printf("the random number nr%d is %f\n",i,result);
    }

    /* Closing the connection */
    close(env->_fd);
  
    /* Free env & buffers */
    CORBA_free(env->_inbuf);
    CORBA_free(env->_outbuf);
    CORBA_free(env);

    return 0;
}
Example #4
0
static gint
on_button_press_event (GtkWidget *widget, GdkEventButton *event,
		       GtkamList *list)
{
	GtkTreePath *path = NULL;
	GtkWidget *w;
	GtkamCamera *camera;
	CameraAbilities a;

	switch (event->button) {
	case 3:
		if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (list),
				event->x, event->y, &path, NULL, NULL, NULL))
			return (FALSE);
		gtk_tree_model_get_iter (GTK_TREE_MODEL (list->priv->store),
					 &list->priv->iter, path);
		gtk_tree_path_free (path);
		camera = gtkam_list_get_camera_from_iter (list,
							  &list->priv->iter);
		gp_camera_get_abilities (camera->camera, &a);

		/* What operations does the camera support? */
		w = gtk_item_factory_get_widget (list->priv->factory,
						 "/Delete");
		gtk_widget_set_sensitive (w,
			(a.file_operations & GP_FILE_OPERATION_DELETE));

#ifdef HAVE_BONOBO
{
    Bonobo_ServerInfoList *l;
    guint i;
    GtkWidget *item, *c;
    CORBA_Environment ev;
    CameraFileInfo finfo;
    gchar *fo, *fi, *query;
    ViewAsData *d;
    GList *cl;

    w = gtk_item_factory_get_widget (list->priv->factory, "/View with...");
    c = gtk_item_factory_get_widget (list->priv->factory,
		    		     "/View with.../Built-in viewer");
    cl = gtk_container_get_children (GTK_CONTAINER (w));
    for (i = 0; i < g_list_length (cl); i++) {
	    if (g_list_nth_data (cl, i) != c)
		    gtk_container_remove (GTK_CONTAINER (w),
				    GTK_WIDGET (g_list_nth_data (cl, i)));
    }

    fo = gtkam_list_get_folder_from_iter (list, &list->priv->iter);
    fi = gtkam_list_get_name_from_iter (list, &list->priv->iter);
    gp_camera_file_get_info (camera->camera, fo, fi, &finfo, NULL);
    g_free (fo);
    g_free (fi);

    if (finfo.file.fields & GP_FILE_INFO_TYPE) {
	CORBA_exception_init (&ev);
	query = g_strconcat ("repo_ids.has ('IDL:Bonobo/Control:1.0') AND "
			     "bonobo:supported_mime_types.has ('", 
			     finfo.file.type, "')", NULL);
	l = bonobo_activation_query (query, NULL, &ev);
	g_free (query);
	CORBA_exception_free (&ev);

	if (l && l->_length) {
		for (i = 0; i < l->_length; i++) {
			Bonobo_ServerInfo *si = &l->_buffer[i];
			const gchar *n;

			if (!si->iid)
				continue;

			n = bonobo_server_info_prop_lookup (si, "name", NULL);
			if (!n)
				n = si->iid;
			item = gtk_menu_item_new_with_label (n);
			gtk_widget_show (item);
			gtk_menu_shell_append (GTK_MENU_SHELL (w), item);

			d = g_new0 (ViewAsData, 1);
			d->list = list;
			d->camera = camera;
			g_object_ref (G_OBJECT (d->camera));
			d->folder = gtkam_list_get_folder_from_iter (list,
							&list->priv->iter);
			d->file = gtkam_list_get_name_from_iter (list, 
							&list->priv->iter);
			d->iid = g_strdup (si->iid);
			g_signal_connect (G_OBJECT (item), "activate",
				G_CALLBACK (on_view_as_activate), d);
			g_signal_connect (G_OBJECT (item), "destroy",
				G_CALLBACK (on_menu_item_destroy), d);
		}
	}
	if (l)
		CORBA_free (l);
    }
}
#endif

		gtk_item_factory_popup (list->priv->factory, event->x_root,
				event->y_root, event->button, event->time);

		return (TRUE);
	default:
		return (FALSE);
	}
}
Example #5
0
static void server_loop(int sd, int epmd_fd)
{
  ErlConnect conn;
  erlang_msg msg;
  int status=1;
  CORBA_Environment *env;
  
  /* Create and init CORBA_Environment */
  env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ);
  
  while (status >= 0) {
    
    status = 1;
    
    if ((env->_fd = erl_accept(sd,&conn)) < 0) {       
      /* error */
      fprintf(stderr,"Accept failed: %s\n",strerror(errno));
    }
    else {
      /* connection */
      fprintf(stderr,"Accepted connection from %s\n",conn.nodename);
      
      while (status >= 0) {

	/* write message to buffer */
	status = ei_receive_encoded(env->_fd, &env->_inbuf, &env->_inbufsz, &msg, &env->_iin); 
	switch(status) {
	case ERL_SEND:
	case ERL_REG_SEND :
	  /* do transaction with fd */
	  rmod_random__switch(NULL,env);
	  
	  switch(env->_major) {
	  case CORBA_NO_EXCEPTION: /* Success */
	    break;
	  case CORBA_SYSTEM_EXCEPTION: /* System exception */
	    printf("Request failure, reason : %s\n",(char *) CORBA_exception_value(env));
	  CORBA_exception_free(env);
	  break;
	  default: /* Should not come here */
	    CORBA_exception_free(env);
	    break;
	}
	  
	  /* send outdata */
	  if (env->_iout > 0) 
	    ei_send_encoded(env->_fd,&env->_caller,env->_outbuf,env->_iout);
	  break;
	  
      case ERL_TICK :
	break;
	default : /* < 0 */
	  printf("Connection terminated\n");
	  break;
	}  
      }
    }
    status=0; /* restart */
  }
  
  /* close file descriptors */
  terminate(&env->_fd, &sd, &epmd_fd);
  
  /* Free env & buffers */
  CORBA_free(env->_inbuf);
  CORBA_free(env->_outbuf);
  CORBA_free(env);
} 
Example #6
0
void
pymatecorba_generate_iinterface_stubs(MateCORBA_IInterface *iface)
{
    CORBA_TypeCode tc;
    PyObject *stub, *bases, *class_dict, *slots;
    PyObject **base_list;
    gint i, j, n_bases;

    init_hash_tables();

    tc = iface->tc;
    /* has wrapper already been generated? */
    if (g_hash_table_lookup(stubs, tc->repo_id))
        return;

    /* create bases tuple */
    base_list = g_new(PyObject *, iface->base_interfaces._length);
    for (i = 0; i < iface->base_interfaces._length; i++) {
        const gchar *base_repo_id = iface->base_interfaces._buffer[i];
        PyObject *base = pymatecorba_get_stub_from_repo_id(base_repo_id);

        /* if we haven't wrapped the base, try and look it up */
        if (!base) {
            MateCORBA_IInterface *base_iface;
            CORBA_Environment ev;

            CORBA_exception_init(&ev);
            base_iface = MateCORBA_small_get_iinterface(CORBA_OBJECT_NIL,
                         base_repo_id, &ev);
            if (ev._major != CORBA_NO_EXCEPTION) {
                g_warning("repo id for base %s has not been registered",
                          base_repo_id);
                CORBA_exception_free(&ev);
                for (j = 0; j < i; j++) Py_DECREF(base_list[j]);
                g_free(base_list);
                return;
            }
            CORBA_exception_free(&ev);

            /* generate interface, then get it */
            pymatecorba_generate_iinterface_stubs(base_iface);
            base = pymatecorba_get_stub_from_repo_id(base_repo_id);
            if (!base) {
                g_warning("could not generate stub for base %s", base_repo_id);
                for (j = 0; j < i; j++) Py_DECREF(base_list[j]);
                g_free(base_list);
                return;
            }
        }
        Py_INCREF(base);
        base_list[i] = base;
    }

    /* get rid of unneeded bases  */
    n_bases = iface->base_interfaces._length;
    for (i = 0; i < iface->base_interfaces._length; i++) {
        for (j = 0; j < iface->base_interfaces._length; j++) {
            if (i == j) continue;
            /* if base[j] is a subclass of base[i], we can ignore [i] */
            if (base_list[j] &&
                    PyType_IsSubtype((PyTypeObject *)base_list[j],
                                     (PyTypeObject *)base_list[i])) {
                Py_DECREF(base_list[i]);
                base_list[i] = NULL;
                n_bases--;
                break;
            }
        }
    }
    bases = PyTuple_New(n_bases);
    n_bases = 0;
    for (i = 0; i < iface->base_interfaces._length; i++) {
        if (base_list[i])
            PyTuple_SetItem(bases, n_bases++, base_list[i]);
    }
    g_free(base_list);

    class_dict = PyDict_New();
    slots = PyTuple_New(0);
    PyDict_SetItemString(class_dict, "__slots__", slots);
    Py_DECREF(slots);
    stub = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO",
                                 tc->name, bases, class_dict);
    Py_DECREF(bases);
    Py_DECREF(class_dict);
    if (!stub) {
        g_message("couldn't build stub %s:", tc->name);
        PyErr_Print();
        PyErr_Clear();
        return;
    }

    pymatecorba_add_imethods_to_stub(stub, &iface->methods);

    add_stub_to_container(tc, tc->name, stub);

    pymatecorba_register_stub(tc, stub);
}
Example #7
0
int
main (int argc, char **argv)
{
	BonoboWindow *win;
	BonoboUIComponent *componenta;
	BonoboUIComponent *componentb;
	BonoboUIComponent *componentc;
	BonoboUIContainer *container;
	Bonobo_UIContainer corba_container;
	CORBA_Environment  real_ev, *ev;
	GnomeProgram *program;
	char *txt, *fname;
	int i;

	char simplea [] =
		"<menu>\n"
		"	<submenu name=\"File\" _label=\"_Ga'\">\n"
		"		<menuitem name=\"open\" pos=\"bottom\" _label=\"_Open\" verb=\"FileOpen\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Wibble\"/>\n"
		"		<control name=\"MyControl\"/>\n"
		"		<control name=\"MyControl2\"/>\n"
		"		<control name=\"ThisIsEmpty\"/>\n"
		"		<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseA\" _tip=\"hi\""
		"		pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"	</submenu>\n"
		"</menu>";
	char keysa [] =
		"<keybindings>\n"
		"   <accel name=\"*Control*3\" id=\"MyFoo\"/>\n"
		"</keybindings>\n";
	char simpleb [] =
		"<submenu name=\"File\" _label=\"_File\">\n"
		"	<menuitem name=\"open\" _label=\"_OpenB\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Open you fool\"/>\n"
		"       <separator/>\n"
		"       <menuitem name=\"toggle\" type=\"toggle\" id=\"MyFoo\" _label=\"_ToggleMe\" _tip=\"a\" accel=\"*Control*t\"/>\n"
		"       <placeholder name=\"Nice\" delimit=\"top\"/>\n"
		"	<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseB\" _tip=\"hi\""
		"        pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"</submenu>\n";
	char simplec [] =
		"<submenu name=\"File\" _label=\"_FileC\" _tip=\"what!\">\n"
		"    <placeholder name=\"Nice\" delimit=\"top\" hidden=\"0\">\n"
		"	<menuitem name=\"fooa\" _label=\"_FooA\" type=\"radio\" group=\"foogroup\" _tip=\"Radio1\"/>\n"
		"	<menuitem name=\"foob\" _label=\"_FooB\" type=\"radio\" group=\"foogroup\" _tip=\"kippers\"/>\n"
		"	<menuitem name=\"wibble\" verb=\"ThisForcesAnError\" _label=\"_Baa\""
		"        pixtype=\"stock\" pixname=\"Open\" sensitive=\"0\" _tip=\"fish\"/>\n"
		"       <separator/>\n"
		"    </placeholder>\n"
		"</submenu>\n";
	char simpled [] =
		"<menuitem name=\"save\" _label=\"_SaveD\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip1\"/>\n";
	char simplee [] =
		"<menuitem name=\"fish\" _label=\"_Inplace\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip2\"/>\n";
	char toola [] =
		"<dockitem name=\"Toolbar\" homogeneous=\"0\" vlook=\"icon\">\n"
		"	<toolitem type=\"toggle\" name=\"foo2\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Save\""
		"        _label=\"TogSave\" _tip=\"My tooltip\" priority=\"1\"/>\n"
		"	<separator/>\n"
		"	<toolitem name=\"baa\" pixtype=\"stock\" pixname=\"Open\" _label=\"baa\" _tip=\"My 2nd tooltip\" verb=\"testme\"/>\n"
		"	<control name=\"AControl\" _tip=\"a tip on a control\" hidden=\"0\" vdisplay=\"button\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-italic\" _label=\"EntryControl\" verb=\"OpenEntry\"/>\n"
		"	<control name=\"BControl\" _tip=\"another tip on a control\" hidden=\"0\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-stop\"/>\n"
		"</dockitem>";
	char toolb [] =
		"<dockitem name=\"Toolbar\" look=\"icon\" relief=\"none\">\n"
		"	<toolitem name=\"foo1\" _label=\"Insensitive\" sensitive=\"0\" hidden=\"0\" priority=\"1\"/>\n"
		"	<toolitem type=\"toggle\" name=\"foo5\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Close\""
		"	 _label=\"TogSame\" _tip=\"My tooltip\"/>\n"
		"</dockitem>";
/*	char statusa [] =
		"<item name=\"main\">Kippers</item>\n";*/
	char statusb [] =
		"<status>\n"
		"	<item name=\"main\"/>\n"
		"	<control name=\"Progress\"/>\n"
		"</status>";

	ev = &real_ev;
	CORBA_exception_init (ev);

	free (malloc (8));

	program = gnome_program_init ("test-ui", VERSION,
			    LIBBONOBOUI_MODULE,
			    argc, argv, NULL);

	textdomain (GETTEXT_PACKAGE);

	bonobo_activate ();

	dump_prefs ();

	win = BONOBO_WINDOW (bonobo_window_new ("Win", "My Test Application"));
	container = bonobo_window_get_ui_container (win);
	
	bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win),
					  "/test-ui/UIConfig/kvps");

	corba_container = BONOBO_OBJREF (container);

	{
		GtkWidget *box = gtk_vbox_new (FALSE, 0);
		GtkWidget *button;
		GtkWidget *path_entry, *state_entry;

		button = gtk_button_new_with_label ("Press me to test!");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_quit, NULL);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Dump Xml tree");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_dump, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Popup");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_popup, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Hide toolbar");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_hide_toolbar, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		path_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (path_entry), "/commands/MyFoo");
		gtk_widget_show (GTK_WIDGET (path_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), path_entry);

		state_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (state_entry), "1");
		g_signal_connect (GTK_OBJECT (state_entry), "changed",
				    (GtkSignalFunc) cb_set_state, path_entry);
		gtk_widget_show (GTK_WIDGET (state_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), state_entry);

		gtk_widget_show (GTK_WIDGET (box));
		bonobo_window_set_contents (win, box);
	}

	g_signal_connect (GTK_OBJECT (win), "size_request", 
			    G_CALLBACK (slow_size_request), NULL);

	componenta = bonobo_ui_component_new ("A");
	bonobo_object_unref (BONOBO_OBJECT (componenta));

	componenta = bonobo_ui_component_new ("A");
	componentb = bonobo_ui_component_new ("B");
	componentc = bonobo_ui_component_new ("C");


	bonobo_ui_component_set_container (componenta, corba_container, NULL);
	bonobo_ui_component_set_container (componentb, corba_container, NULL);
	bonobo_ui_component_set_container (componentc, corba_container, NULL);

	global_component = componenta;

	fname = bonobo_ui_util_get_ui_fname (NULL, "../doc/std-ui.xml");
	if (fname && g_file_test (fname, G_FILE_TEST_EXISTS)) {
		fprintf (stderr, "\n\n--- Add std-ui.xml ---\n\n\n");
		bonobo_ui_util_set_ui (componenta, NULL, "../doc/std-ui.xml",
				       "gdm", NULL);

/*		bonobo_ui_component_set_prop (
			componenta, "/menu/Preferences",
			"pixname", "/demo/a.xpm", NULL);*/

		gtk_widget_show (GTK_WIDGET (win));

		bonobo_main ();
	} else {
		g_warning ("Can't find ../doc/std-ui.xml");
		gtk_widget_show (GTK_WIDGET (win));
	}
	g_free (fname);


	bonobo_ui_component_freeze (componenta, NULL);

	fprintf (stderr, "\n\n--- Remove A ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

/*	bonobo_ui_component_set_translate (componentb, "/status", statusa, ev);
	g_assert (!BONOBO_EX (ev));*/

	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",
				 "<popups> <popup name=\"MyStuff\"/> </popups>", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/popups/MyStuff", simpleb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/", keysa, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",   toola, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_button_new_with_label ("My Label");
		BonoboControl *control = bonobo_control_new (widget);
		BonoboUIComponent *componentp;

		g_signal_connect (GTK_OBJECT (widget), "button_press_event",
				    G_CALLBACK (do_sane_popup), control);
		componentp = bonobo_control_get_popup_ui_component (control);
#if 1
		bonobo_ui_component_set (componentp, "/", "<popups>"
					 "<popup name=\"button3\"/></popups>", ev);
		g_assert (!BONOBO_EX (ev));
		bonobo_ui_component_set_translate (
			componentp, "/popups/button3", simpleb, ev);
		g_assert (!BONOBO_EX (ev));
#endif

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta,
						"/menu/File/MyControl",
						BONOBO_OBJREF (control),
						ev);
		bonobo_object_unref (BONOBO_OBJECT (control));
		g_assert (!BONOBO_EX (ev));

		widget = gtk_menu_item_new_with_mnemonic ("_Foo item");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/menu/File/MyControl2",
						widget, ev);
	}

	{
		GtkWidget *widget = gtk_entry_new ();
		
		gtk_entry_set_text (GTK_ENTRY (widget), "Example text");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/AControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}
	{
		GtkWidget *widget;
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (tame_xpm);
		widget = bonobo_ui_toolbar_button_item_new (pixbuf, "Test Control");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/BControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}

	bonobo_ui_component_add_listener (componentb, "MyFoo", toggled_cb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",     statusb, ev);
	g_assert (!BONOBO_EX (ev));

	/* Duplicate set */
	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_add_verb_list_with_data (
		componenta, verbs, GUINT_TO_POINTER (15));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB2", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA3", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_rm (componenta, "/status", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB4", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA5", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA6>", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB7", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "", ev);
	g_assert (!BONOBO_EX (ev));

	g_assert (bonobo_ui_component_get_prop (
		componentb, "/status/main", "non-existant", ev) == NULL);
	g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_UIContainer_NonExistentAttr));
	CORBA_exception_free (ev);

  	{
 		const char *good = "<item name=\"main\">WhatA6&gt;</item>\n";

  		txt = bonobo_ui_component_get (componenta, "/status/main", TRUE, NULL);
 
 		if (!txt || strcmp (txt, good)) {
 			g_warning ("Broken merging code '%s' should be '%s'", txt, good);
 			bonobo_window_dump (win, "on fatal error");
  			g_assert_not_reached ();
  		}

		CORBA_free (txt);
  	}

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/menu", simpleb, ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_translate (componenta, "/",     toolb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_prop (componenta, "/menu/File", "label", "_Goo-wan>", ev);
	g_assert (!BONOBO_EX (ev));

	/* A 'transparent' node merge */
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("Before merge look '%s'\n", txt);
	bonobo_ui_component_set_translate (componenta, "/", "<dockitem name=\"Toolbar\"/>", ev);
	g_assert (!BONOBO_EX (ev));
	g_free (txt);
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("After merge look '%s'\n", txt);
	if (txt == NULL || strcmp (txt, "icon"))
		g_warning ("Serious transparency regression");
	g_free (txt);

	bonobo_ui_component_set_translate (componenta, "/menu/File/Nice", simplee, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_progress_bar_new ();
		BonoboControl *control = bonobo_control_new (widget);
		guint id;

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta, "/status/Progress",
						BONOBO_OBJREF (control),
						NULL);

		id = gtk_timeout_add (100, (GSourceFunc) update_progress, widget);
		g_signal_connect (GTK_OBJECT (widget), "destroy",
				    G_CALLBACK (disconnect_progress), GUINT_TO_POINTER (id));
		bonobo_object_unref (BONOBO_OBJECT (control));
	}

	bonobo_ui_component_set_status (componenta, "This is a very long status message "
					"that should cause the window to be resized if "
					"there is in fact a bug in it", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	g_warning ("Begginning stress test, this may take some time ...");
	for (i = 0; i < 100; i++) {
		bonobo_ui_component_freeze (componentc, ev);
		g_assert (!BONOBO_EX (ev));
		
		bonobo_ui_component_set_translate (componentc, "/commands",
						   "<cmd name=\"MyFoo\" sensitive=\"0\"/>", ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_set_translate (componentc, "/menu", simplec, ev);
		g_assert (!BONOBO_EX (ev));
	
		bonobo_ui_component_set_translate (componentc, "/menu/File", simpled, ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_thaw (componentc, ev);
		g_assert (!BONOBO_EX (ev));
	}
	g_warning ("Done stress test");
	bonobo_main ();
	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 2 ---\n\n\n");
	bonobo_ui_component_rm (componentb, "/", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_prop (componentc, "/menu/File/save",
				      "label", "SaveC", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 3 ---\n\n\n");
	bonobo_ui_component_rm (componentc, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 1 ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_object_unref (BONOBO_OBJECT (componenta));
	bonobo_object_unref (BONOBO_OBJECT (componentb));
	bonobo_object_unref (BONOBO_OBJECT (componentc));

	gtk_widget_destroy (GTK_WIDGET (win));

	CORBA_exception_free (ev);

	g_object_unref (program);

	return bonobo_ui_debug_shutdown ();
}
static void
xfapplet_applet_activated (MateComponent_Unknown object, CORBA_Environment *ev, gpointer data)
{
	GtkWidget		*bw, *child = NULL;
	CORBA_Object		 control;
	CORBA_Environment	 corba_ev;
	MateComponentControlFrame	*frame;
	MateComponentUIComponent	*uic;
	MateComponent_PropertyBag	 prop_bag;
	XfAppletPlugin		*xap = (XfAppletPlugin*) data;
	gchar			*error;

	if (MATECOMPONENT_EX (ev) || object == CORBA_OBJECT_NIL) {
		error = matecomponent_exception_get_text (ev);
		CORBA_exception_free (ev);
		g_warning ("Failed to load applet '%s' (can't get CORBA object): %s\n", xap->iid, error);
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	
	control = CORBA_Object_duplicate (object, NULL);
	bw = matecomponent_widget_new_control_from_objref (object, CORBA_OBJECT_NIL);
	matecomponent_object_release_unref (object, NULL);
	if (!bw) {
		g_warning ("Failed to load applet '%s' (can't get matecomponent widget)\n", xap->iid);
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		return;
	}
	
	frame = matecomponent_widget_get_control_frame (MATECOMPONENT_WIDGET (bw));
	if (!frame) {
		g_warning ("Failed to load applet '%s' (can't get control frame)\n", xap->iid);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		return;
	}
	
	CORBA_exception_init (&corba_ev);
	prop_bag = matecomponent_control_frame_get_control_property_bag (frame, &corba_ev);
	if (prop_bag == NULL || MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't get property bag): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	
        uic = matecomponent_control_frame_get_popup_component (frame, &corba_ev);
	if (uic == NULL || MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't get popup component): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
		
	matecomponent_ui_component_freeze (uic, CORBA_OBJECT_NIL);
	xfce_textdomain ("xfce4-panel", LIBXFCE4PANEL_LOCALE_DIR, "UTF-8");
	matecomponent_ui_util_set_ui (uic, PKGDATADIR "/ui", "XFCE_Panel_Popup.xml", "xfce4-xfapplet-plugin", &corba_ev);
	if (MATECOMPONENT_EX (&corba_ev)) {
		error = matecomponent_exception_get_text (&corba_ev);
		CORBA_exception_free (&corba_ev);
		g_warning ("Failed to load applet '%s' (can't set ui): %s\n", xap->iid, error);
		gtk_object_sink (GTK_OBJECT (bw));
		xfapplet_applet_load_failed (xap);
		xfapplet_cleanup_current (xap);
		g_free (error);
		return;
	}
	xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
	xfapplet_setup_menu_items (xap->plugin, uic);
	matecomponent_ui_component_thaw (uic, CORBA_OBJECT_NIL);

	gtk_widget_show (bw);

	if (xap->configured)
		xfapplet_unload_applet (xap);

	xap->object = control;
	xap->uic = uic;
	xap->prop_bag = prop_bag;
	MateCORBA_small_listen_for_broken (object, G_CALLBACK (xfapplet_connection_broken), xap);

	child = xfapplet_get_plugin_child (xap->plugin);
	if (child)
		gtk_widget_destroy (child);

	gtk_container_add (GTK_CONTAINER(xap->plugin), bw);
	xap->configured = TRUE;

	if (!xfapplet_save_configuration (xap))
		g_warning ("Failed to save XfApplet configuration.\n");
}
Example #9
0
int main(){
  
  double result=0;
  int i=0;
  int error = 0;
  erlang_pid pid;
  char host[HOSTNAMESZ];
  char server_node[HOSTNAMESZ];
  char client_node[HOSTNAMESZ];
  CORBA_Environment *env;
  
  /* Initiate names */
#ifdef __WIN32__
  WORD wVersionRequested;
  WSADATA wsaData;

  wVersionRequested = MAKEWORD(1, 1);
  if ((error = WSAStartup(wVersionRequested, &wsaData))) {
      fprintf(stderr,"Can't initialize windows sockets: %d",error);
      return 0;
  }
#endif
  error = gethostname(host,HOSTNAMESZ);
  if (error) {
#ifdef __WIN32__
      fprintf(stderr,"can't find own hostname (error = %ld) !\n",WSAGetLastError());
#else /* not __WIN32__ */
      fprintf(stderr,"can't find own hostname !\n");
#endif
  }
  sprintf(client_node,"%s@%s",CLNODENAME,host);
  sprintf(server_node,"%s@%s",SNODENAME,host);
    
  /* Create and init CORBA_Environment */
  env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ);
  
  /* Initiating the connection */
  erl_init(NULL,0);
  erl_connect_init(50,COOKIE,0);

  /* Initiating pid*/
  strcpy(pid.node,client_node);
  pid.num = 99;
  pid.serial = 0;
  pid.creation = 0;

  /* Fixing environment variable */
  env->_fd=erl_connect(server_node);
  strcpy(env->_regname,SREGNAME);
  env->_to_pid = NULL;
  env->_from_pid = &pid;
  
  if (env->_fd < 0) {
    fprintf(stderr,"Error : Cannot connect to Server\n");

    /* Free env & buffers */
    CORBA_free(env->_inbuf);
    CORBA_free(env->_outbuf);
    CORBA_free(env);
    exit(1);
  }
  
  /* Calling the init function */
  rmod_random_init(NULL, 1, 2, 3, env);
 
  switch(env->_major) {
  case CORBA_NO_EXCEPTION: /* Success */
    printf("Init complete !\n");
    break;
  case CORBA_SYSTEM_EXCEPTION: /* System exception */
    printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
    CORBA_exception_free(env);
    client_exit(env);
  default: /* Should not come here */
    client_exit(env);
  }

  /* Calling the produce function */
  for(i=1; i<=10; i++) {
    result = rmod_random_produce(NULL, env);

    switch(env->_major) {
    case CORBA_NO_EXCEPTION: /* Success */
      break;
    case CORBA_SYSTEM_EXCEPTION: /* System exception */
      printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
      CORBA_exception_free(env);
      client_exit(env);
    default: /* Should not come here */
      client_exit(env);
    }

    printf("the random number nr%d is %f\n",i,result);
  }

  /* Closing the connection */
  erl_close_connection(env->_fd);
  
  /* Free env & buffers */
  CORBA_free(env->_inbuf);
  CORBA_free(env->_outbuf);
  CORBA_free(env);

  return 0;
}
Example #10
0
File: at.c Project: GNOME/at-spi
int
main(int argc, char **argv)
{
        CORBA_Environment ev;
        CORBA_Object oclient;
        char *obj_id;
        CORBA_long i;
        CORBA_short n_desktops;
        CORBA_long j;
        CORBA_long n_apps;
	CORBA_string s;
        Accessibility_Desktop desktop;
        Accessibility_Application app;
        Accessibility_Registry registry;
        SpiListener *listener;

        CORBA_exception_init(&ev);

        if (!bonobo_init (&argc, argv))
          {
            g_error ("Could not initialize Bonobo");
          }

        obj_id = "OAFIID:Accessibility_Registry:1.0";

        oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
                fprintf(stderr,
                ("Accessibility app error: exception during registry activation from id: %s\n"),
                        CORBA_exception_id(&ev));
                CORBA_exception_free(&ev);
                exit(-1);
        }

        if (CORBA_Object_is_nil (oclient, &ev))
          {
            g_error ("Could not locate registry");
          }

        bonobo_activate ();

        listener = spi_listener_new ();

        registry = (Accessibility_Registry) oclient;

        Accessibility_Registry_registerGlobalEventListener
                                   (registry,
                                    (Accessibility_EventListener)
                                         bonobo_object_corba_objref (bonobo_object (listener)),
                                    "focus:",
                                    &ev);
        check_ev (&ev, "register:focus");
        Accessibility_Registry_registerGlobalEventListener
                                   (registry,
                                    (Accessibility_EventListener)
                                         bonobo_object_corba_objref (bonobo_object (listener)),
                                    "Gtk:GtkWidget:button-press-event",
                                    &ev);
        check_ev (&ev, "register:button_press");
        fprintf (stderr, "AT callback registered.\n");

            n_desktops = Accessibility_Registry_getDesktopCount (registry, &ev);

            for (i=0; i<n_desktops; ++i)
              {
                desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
		s = Accessibility_Desktop__get_name (desktop, &ev);
                fprintf (stderr, "desktop %d name: %s\n", i, s);
	        CORBA_free (s);	 
                check_ev (&ev, "desktop:name");
                n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
                check_ev (&ev, "desktop:childCount");
                fprintf (stderr, "desktop has %d apps:\n", n_apps);
                for (j=0; j<n_apps; ++j)
                  {
                    app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
                    check_ev (&ev, "desktop:getChildAtIndex");
                    s = Accessibility_Application__get_name (app, &ev);
		    fprintf (stderr, "app %d name: %s\n", j, s);
		    CORBA_free (s);
                    check_ev (&ev, "app:getName");
                  }
              }

            fprintf (stderr, "finished querying desktop(s).\n");
            bonobo_main ();
               /* needed by at because it is a server ? */
        exit(0);
}
static void
remove_folder (EvolutionShellComponent *shell_component,
         const char *physical_uri,
         const char *type,
         const GNOME_Evolution_ShellComponentListener listener,
         void *closure) {

  CORBA_Environment ev;
  const char *file_name;
  gchar *path;
  int rv;

  CORBA_exception_init(&ev);

	printf("type : %s\n", type);


  /* check URI */
  if (strncmp (physical_uri, "file://", 7)) {
    GNOME_Evolution_ShellComponentListener_notifyResult (
      listener,
      GNOME_Evolution_ShellComponentListener_INVALID_URI,
      &ev);
    CORBA_exception_free (&ev);
    return;
  }

  /* FIXME: check if there are subfolders? */

  file_name = YANK_FILENAME;
  if (file_name == NULL) {
    GNOME_Evolution_ShellComponentListener_notifyResult (listener,
                     GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE,
                     &ev);
    CORBA_exception_free (&ev);
    return;
  }

  /* remove the .ics file */
  path = g_concat_dir_and_file (physical_uri + 7, file_name);
  rv = unlink (path);
  g_free (path);
  if (rv == 0) {
    /* everything OK; notify the listener */
    GNOME_Evolution_ShellComponentListener_notifyResult (
      listener,
      GNOME_Evolution_ShellComponentListener_OK,
      &ev);
  }
  else {
    if (errno == EACCES || errno == EPERM)
      GNOME_Evolution_ShellComponentListener_notifyResult (
        listener,
        GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED,
        &ev);
    else
      GNOME_Evolution_ShellComponentListener_notifyResult (
        listener,
        GNOME_Evolution_ShellComponentListener_INVALID_URI, /*XXX*/
        &ev);
  }


  CORBA_exception_free(&ev);
}
 static void
xfer_folder (EvolutionShellComponent *shell_component,
       const char *source_physical_uri,
       const char *destination_physical_uri,
       const char *type,
       gboolean remove_source,
       const GNOME_Evolution_ShellComponentListener listener,
       void *closure)
{
 CORBA_Environment ev;
  gchar *source_path;
  gchar *dest_path;
  GnomeVFSHandle *handle;
  GnomeVFSURI *uri;
  GnomeVFSFileSize out;
  char *buf;
  const char *file_name;

  CORBA_exception_init (&ev);
	printf("type : %s\n", type);

  /* check URI */
  if (strncmp (source_physical_uri, "file://", 7)
      || strncmp (destination_physical_uri, "file://", 7)) {
    GNOME_Evolution_ShellComponentListener_notifyResult (
      listener,
      GNOME_Evolution_ShellComponentListener_INVALID_URI,
      &ev);   
    CORBA_exception_free (&ev);
    return; 
  }

  file_name = YANK_FILENAME; 
/*   if (file_name == NULL) {  */
/*     GNOME_Evolution_ShellComponentListener_notifyResult (listener, */
/*                      GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, */
/*                      &ev); */
/*     CORBA_exception_free (&ev); */
/*     return;  */
/*   } */

  /* open source and destination files */
  source_path = g_concat_dir_and_file (source_physical_uri + 7, YANK_FILENAME);
  dest_path = g_concat_dir_and_file (destination_physical_uri + 7, YANK_FILENAME);

	if (gnome_vfs_move (source_path, dest_path, TRUE)
      != GNOME_VFS_OK) {
    GNOME_Evolution_ShellComponentListener_notifyResult (
      listener,
      GNOME_Evolution_ShellComponentListener_INVALID_URI,
      &ev);
    g_free (source_path);
    g_free (dest_path);
		puts("move bad");

    CORBA_exception_free (&ev);
    return;
  }

 g_free (source_path);
    g_free (dest_path);

	puts("move ok");


 GNOME_Evolution_ShellComponentListener_notifyResult(listener, GNOME_Evolution_ShellComponentListener_OK, &ev);

  CORBA_exception_free (&ev);
}
int
main (int argc, char *argv[])
{
	MateComponent_ServerInfoList *result;
	CORBA_Environment ev;
	char *query;
	char **sort_criteria;
	int i;

	CORBA_exception_init (&ev);
	matecomponent_activation_init (argc, argv);

	sort_criteria = NULL;

	if (argc > 1) {
		query = argv[1];
		if (argc > 2) {
			int i;
			int num_conditions;

			num_conditions = argc - 2;

			printf ("Number of sort criteria: %d\n",
				num_conditions);

			sort_criteria =
				g_malloc (sizeof (char *) *
					  (num_conditions + 1));

			for (i = 0; i < num_conditions; i++) {
				sort_criteria[i] = g_strdup (argv[i + 2]);
				puts (sort_criteria[i]);
			}

			sort_criteria[num_conditions] = NULL;
		}
	} else {
		query = "repo_ids.has('IDL:Empty:1.0')";
	}

	/* putenv("MateComponent_BARRIER_INIT=1"); */
	result = matecomponent_activation_query (query, sort_criteria, &ev);

	/* result = matecomponent_activation_query ("iid == 'OAFIID:Empty:19991025'", NULL, &ev); */

        if (ev._major != CORBA_NO_EXCEPTION) {
                if (ev._major == CORBA_USER_EXCEPTION) {
                        if (!strcmp (ev._id, ex_MateComponent_GeneralError)) {
                                MateComponent_GeneralError *err = CORBA_exception_value (&ev);
                                printf ("An exception '%s' occurred\n", err->description);
                        } else {
                                printf ("An unknown user exception ('%s') "
                                        "occurred\n", ev._id);
                        }
                } else if (ev._major == CORBA_SYSTEM_EXCEPTION) {
                        printf ("A system exception ('%s') occurred\n", ev._id);
                } else {
                        g_assert_not_reached ();
                }
	} else if (result == NULL) {
		puts ("NULL result failed");
	} else {
		printf ("number of results: %d\n", result->_length);

		for (i = 0; i < result->_length; i++) {
			puts ((result->_buffer[i]).iid);
		}
                CORBA_free (result);
	}

	CORBA_exception_free (&ev);

        if (matecomponent_activation_debug_shutdown ()) {
                return 0;
        } else {
                return 1;
        }
}
Example #14
0
int
main (int argc, char *argv [])
{
	BonoboObject     *object;
	Bonobo_Unknown    ref;
	CORBA_Environment *ev, real_ev;

        g_thread_init (NULL);

	free (malloc (8));

	if (bonobo_init (&argc, argv) == FALSE)
		g_error ("Can not bonobo_init");
	bonobo_activate ();

	ev = &real_ev;
	CORBA_exception_init (ev);

	fprintf (stderr, "Local lifecycle\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		g_assert (bonobo_object_ref (object) == object);
		g_assert (bonobo_object_unref (BONOBO_OBJECT (object)) == NULL);

		bonobo_object_unref (BONOBO_OBJECT (object));
	}

	fprintf (stderr, "In-proc lifecycle\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		ref = CORBA_Object_duplicate (BONOBO_OBJREF (object), NULL);

		bonobo_object_release_unref (ref, NULL);
	}

	fprintf (stderr, "Query interface\n");
	{
		BonoboObject *a, *b;

		a = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));
		b = BONOBO_OBJECT (g_object_new (
			bonobo_stream_mem_get_type (), NULL));

		bonobo_object_add_interface (a, b);

		fprintf (stderr, "  invalid interface\n");
		object = bonobo_object_query_local_interface (
			a, "IDL:This/Is/Not/There:1.0");
		g_assert (object == CORBA_OBJECT_NIL);

		fprintf (stderr, "  symmetry\n");
		object = bonobo_object_query_local_interface (
			a, "IDL:Bonobo/Stream:1.0");
		g_assert (object == b);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			b, "IDL:Bonobo/Stream:1.0");
		g_assert (object == b);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			a, "IDL:Bonobo/Moniker:1.0");
		g_assert (object == a);
		bonobo_object_unref (object);

		object = bonobo_object_query_local_interface (
			b, "IDL:Bonobo/Moniker:1.0");
		g_assert (object == a);
		bonobo_object_unref (object);

		fprintf (stderr, "  remote\n");
		ref = Bonobo_Unknown_queryInterface (
			BONOBO_OBJREF (a), "IDL:Broken/1.0", ev);
		g_assert (!BONOBO_EX (ev));
		g_assert (ref == CORBA_OBJECT_NIL);

		ref = Bonobo_Unknown_queryInterface (
			BONOBO_OBJREF (a), "IDL:Bonobo/Stream:1.0", ev);
		g_assert (!BONOBO_EX (ev));
		g_assert (ref == BONOBO_OBJREF (b));
		bonobo_object_release_unref (ref, ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_object_unref (a);
	}

	fprintf (stderr, "Environment exception checks\n");
	{
		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		g_signal_connect (G_OBJECT (object),
				  "system_exception",
				  G_CALLBACK (system_exception_cb),
				  object);

		CORBA_exception_set_system (
			ev, ex_CORBA_COMM_FAILURE,
			CORBA_COMPLETED_MAYBE);
		g_assert (BONOBO_EX (ev));

		signal_emitted = 0;
		BONOBO_OBJECT_CHECK (
			object, BONOBO_OBJREF (object), ev);
		g_assert (signal_emitted);

		CORBA_exception_free (ev);

		bonobo_object_unref (object);
	}

	fprintf (stderr, "Servant mapping...\n");
	{
		PortableServer_Servant servant;

		object = BONOBO_OBJECT (g_object_new (
			bonobo_moniker_get_type (), NULL));

		servant = (PortableServer_Servant) &object->servant;

		g_assert (bonobo_object (object) == object);
		g_assert (bonobo_object (&object->servant) == object);
		g_assert (bonobo_object_get_servant (object) == servant);
		g_assert (bonobo_object_from_servant (servant) == object);
		g_assert (bonobo_object_fast (object) == object);
		g_assert (bonobo_object_fast (servant) == object);

		bonobo_object_unref (object);
	}

	fprintf (stderr, "Ret-ex tests...\n");
	{
		g_assert (!ret_ex_test (ev));
		ex_test (ev);

		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_Bonobo_PropertyBag_NotFound, NULL);
		g_assert (ret_ex_test (ev));
		
		CORBA_exception_free (ev);
	}

	fprintf (stderr, "General error tests...\n");
	{
		bonobo_exception_general_error_set (
			ev, NULL, "a%s exception occurred", "n exceptional");
		g_assert (BONOBO_EX (ev));
		g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_GeneralError));
		g_assert (!strcmp (bonobo_exception_get_text (ev),
				   "an exceptional exception occurred"));
	}

	fprintf (stderr, "All tests passed\n");

	return bonobo_debug_shutdown ();
}
Example #15
0
static gboolean
idle_cb (gchar **uris)
{
	GNOME_Evolution_Shell corba_shell;
	CORBA_Environment ev;
	EShellConstructResult result;
	EShellStartupLineMode startup_line_mode;

	g_return_val_if_fail (uris == NULL || g_strv_length (uris) > 0, FALSE);

#ifdef KILL_PROCESS_CMD
	kill_old_dataserver ();
#endif

	CORBA_exception_init (&ev);

	if (! start_online && ! start_offline)
		startup_line_mode = E_SHELL_STARTUP_LINE_MODE_CONFIG;
	else if (start_online)
		startup_line_mode = E_SHELL_STARTUP_LINE_MODE_ONLINE;
	else
		startup_line_mode = E_SHELL_STARTUP_LINE_MODE_OFFLINE;

	shell = e_shell_new (startup_line_mode, &result);

	switch (result) {
	case E_SHELL_CONSTRUCT_RESULT_OK:
		g_signal_connect (shell, "no_windows_left", G_CALLBACK (no_windows_left_cb), NULL);
		g_object_weak_ref (G_OBJECT (shell), shell_weak_notify, NULL);
		corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell));
		corba_shell = CORBA_Object_duplicate (corba_shell, &ev);
		break;

	case E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER:
		corba_shell = bonobo_activation_activate_from_id (E_SHELL_OAFIID, 0, NULL, &ev);
		if (ev._major != CORBA_NO_EXCEPTION || corba_shell == CORBA_OBJECT_NIL) {
			e_error_run(NULL, "shell:noshell", NULL);
			CORBA_exception_free (&ev);
			bonobo_main_quit ();
			return FALSE;
		}
		break;

	default:
		e_error_run(NULL, "shell:noshell-reason",
			    e_shell_construct_result_to_string(result), NULL);
		CORBA_exception_free (&ev);
		bonobo_main_quit ();
		return FALSE;

	}

	if (shell != NULL) {
		if (uris != NULL)
			open_uris (corba_shell, uris);
		else {
			GConfClient *client = gconf_client_get_default ();
			
			if (gconf_client_get_bool (client, RECOVERY_KEY, NULL) && e_file_lock_exists ()) {
				/* It should have crashed last time or a force-shutdown */
				gboolean skip = gconf_client_get_bool (client, SKIP_RECOVERY_DIALOG_KEY, NULL);
				gboolean recover = TRUE;
				if (!skip){
					int flags = show_recovery_warning ();

					gconf_client_set_bool (client, SKIP_RECOVERY_DIALOG_KEY, (flags & (1<<2)) ? TRUE : FALSE, NULL);
					recover = (flags & (1<<1)) ? TRUE: FALSE;
				}

				if (recover) {
					/* Disable the previews */
					gconf_client_set_bool (client, "/apps/evolution/mail/display/show_preview", FALSE, NULL);
					gconf_client_set_bool (client, "/apps/evolution/mail/display/safe_list", TRUE, NULL);
					gconf_client_set_bool (client, "/apps/evolution/addressbook/display/show_preview", FALSE, NULL);
					gconf_client_set_bool (client, "/apps/evolution/calendar/display/show_task_preview", FALSE, NULL);
				}
				/* Let us not delete and recreate a lock, instead reuse it. We don't use timestamps anyways */
			} else {
				/* What great can we do, if lock creation fails ?*/
				e_file_lock_create ();
			}
			g_object_unref (client);

			e_shell_create_window (shell, default_component_id, NULL);
		}
	} else {
		CORBA_Environment ev;

		CORBA_exception_init (&ev);
		if (uris != NULL)
			open_uris (corba_shell, uris);
		else
			if (default_component_id == NULL)
				GNOME_Evolution_Shell_createNewWindow (corba_shell, "", &ev);
			else
				GNOME_Evolution_Shell_createNewWindow (corba_shell, default_component_id, &ev);

		CORBA_exception_free (&ev);
	}

	CORBA_Object_release (corba_shell, &ev);

	CORBA_exception_free (&ev);

	if (shell == NULL) {
		/*there is another instance but because we don't open any windows
		we must notify the startup was complete manually*/
		gdk_notify_startup_complete ();
		bonobo_main_quit ();
	}

	return FALSE;
}
Example #16
0
int main(int argc, char **argv)
#endif
{
    struct hostent *hp;
    MyTimeval start, stop;
    int i, fd, ires, tries;
    CORBA_Environment *env;
    char *this_node_name = NULL;
    char *peer_node = NULL;
    char *cookie = NULL;
    char host[HOSTNAMESZ + 1];
    char this_node[NODENAMESZ + 1];
    erlang_msg msg;
    int status, loop; 
    
#ifdef __WIN32__
    WORD wVersionRequested;
    WSADATA wsaData;
    
    wVersionRequested = MAKEWORD(2, 0);
    
    if (WSAStartup(wVersionRequested, &wsaData) != 0) {
	fprintf(stderr, "Could not load winsock2 v2.0 compatible DLL");
	exit(1);
    }
#endif
    
    progname = argv[0];
    host[HOSTNAMESZ] = '\0';
    if (gethostname(host, HOSTNAMESZ) < 0) {
	fprintf(stderr, "Can't find own hostname\n");
	done(1);
    } 
    if ((hp = gethostbyname(host)) == 0) {
	fprintf(stderr, "Can't get ip address for host %s\n", host);
	done(1);
    }
    for (i = 1; i < argc; i++) {
	if (strcmp(argv[i], "-help") == 0) {
	    usage();
	    done(0);
	} else if (strcmp(argv[i], "-this-node-name") == 0) {
	    i++;
	    this_node_name = argv[i];
	} else if (strcmp(argv[i], "-peer-node") == 0) {
	    i++;
	    peer_node = argv[i];
	} else if (strcmp(argv[i], "-cookie") == 0) {
	    i++;
	    cookie = argv[i];
	} else {
	    fprintf(stderr, "Error : invalid argument \"%s\"\n", argv[i]);
	    usage();
	    done(1);
	}
    }

    if (this_node_name == NULL || peer_node == NULL || cookie == NULL) {
	fprintf(stderr, "Error: missing option\n");
	usage();
	done(1);
    }

    /* Behead hostname at first dot */
    for (i=0; host[i] != '\0'; i++) {
	if (host[i] == '.') { host[i] = '\0'; break; }
    }
    sprintf(this_node, "%s@%s", this_node_name, host);

    fprintf(stderr, "c_server: this node: \"%s\"\n", this_node);
    fprintf(stderr, "c_server: peer node: \"%s\"\n", peer_node);

    /* initialize erl_interface */
    erl_init(NULL, 0);

    for (tries = 0; tries < MAXTRIES; tries++) {
	/* connect to peer node */ 
    	ires = erl_connect_xinit(host, this_node_name, this_node, 
				 (struct in_addr *)*hp->h_addr_list, 
				 cookie, 0);
	fprintf(stderr, "c_server: erl_connect_xinit(): %d\n", ires);
    
	fd = erl_connect(peer_node);
	fprintf(stderr, "c_server: erl_connect(): %d\n", fd);
	if (fd >= 0) 
	    break;
	fprintf(stderr, "c_server: cannot connect, retrying\n");
    }
    if (fd < 0) {
	fprintf(stderr, "c_server: cannot connect, exiting\n");
	done(1);
    }
    env = CORBA_Environment_alloc(INBUFSZ, OUTBUFSZ);
    env->_fd = fd; 

    status = 1;
    loop = 1;
    my_gettimeofday(&start);
    while (status >= 0 && loop > 0) {
        status = ei_receive_encoded(env->_fd, &env->_inbuf, &env->_inbufsz, 
				    &msg, &env->_iin); 
	switch(status) {
	case ERL_SEND:
	case ERL_REG_SEND:
	    /* get result */
	    m_i__switch(NULL, env);
	    switch(env->_major) {
	    case CORBA_NO_EXCEPTION:
		break;
	    case CORBA_SYSTEM_EXCEPTION:
		fprintf(stderr, "Request failure, reason : %s\n", 
			(char *) CORBA_exception_value(env));
		CORBA_exception_free(env);
		break;
	    default: /* Should not happen */
		CORBA_exception_free(env);
		break;
	    }
	    /* send back result data */
	    if (env->_iout > 0) 
		ei_send_encoded(env->_fd, &env->_caller, env->_outbuf, 
				env->_iout);
	    loop = 0;
	    break;
	case ERL_TICK:
	    break;
	default: 
	    if (status < 0) {
		fprintf(stderr, "Status negative: %d\n", status);
		loop = 0;
	    }
	    break;
	}
    }	
    my_gettimeofday(&stop);
    showtime(&start, &stop);

    erl_close_connection(fd);

    CORBA_free(env->_inbuf);
    CORBA_free(env->_outbuf);
    CORBA_free(env);
    if (status < 0) 
	done(-status);
    else 
	done(0); 
}
/**
 * matecomponent_control_set_transient_for:
 * @control: a control with associated control frame
 * @window: a window upon which to set the transient window.
 * 
 *   Attempts to make the @window transient for the toplevel
 * of any associated controlframe the MateComponentControl may have.
 **/
void
matecomponent_control_set_transient_for (MateComponentControl     *control,
				  GtkWindow         *window,
				  CORBA_Environment *opt_ev)
{
	CORBA_char         *id;
	GdkDisplay         *display;
	GdkWindow          *win;
	GdkNativeWindow    window_id;
	CORBA_Environment  *ev = NULL, tmp_ev;
	MateComponent_ControlFrame frame;
	gpointer            local_win;

	g_return_if_fail (GTK_IS_WINDOW (window));
	g_return_if_fail (MATECOMPONENT_IS_CONTROL (control));

	/* FIXME: special case the local case !
	 * we can only do this if set_transient is virtualized
	 * and thus we can catch it in MateComponentSocket and chain up
	 * again if we are embedded inside an embedded thing. */

	frame = control->priv->frame;

	if (frame == CORBA_OBJECT_NIL)
		return;

	if (opt_ev)
		ev = opt_ev;
	else {
		CORBA_exception_init (&tmp_ev);
		ev = &tmp_ev;
	}

	id = MateComponent_ControlFrame_getToplevelId (frame, ev);
	g_return_if_fail (!MATECOMPONENT_EX (ev) && id != NULL);

	window_id = matecomponent_control_x11_from_window_id (id);

#ifdef TRANSIENT_DEBUG
	g_warning ("Got id '%s' -> %d", id, window_id);
#endif
	CORBA_free (id);

	display = gtk_widget_get_display (GTK_WIDGET (window));

#if defined (GDK_WINDOWING_X11)
	local_win = gdk_xid_table_lookup_for_display (display, window_id);
#elif defined (GDK_WINDOWING_WIN32)
	local_win = gdk_win32_handle_table_lookup (window_id);
#endif
	if (local_win == NULL)
		win = gdk_window_foreign_new_for_display (display, window_id);
	else {
		win = GDK_WINDOW (local_win);
		g_object_ref (win);
	}
	g_return_if_fail (win != NULL);

	window_set_transient_for_gdk (window, win);

	if (!opt_ev)
		CORBA_exception_free (&tmp_ev);
}