Пример #1
0
void
PortableServer_POAManager_activate (PortableServer_POAManager  manager,
				    CORBA_Environment         *ev)
{
	GSList *l;

	if (!manager) {
		CORBA_exception_set_system (ev, ex_CORBA_BAD_PARAM,
					    CORBA_COMPLETED_NO);
		return;
	}

	POA_MGR_LOCK (poa_mgr);

	if (manager->state == PortableServer_POAManager_INACTIVE)
		CORBA_exception_set
			(ev, CORBA_USER_EXCEPTION,
			 ex_PortableServer_POAManager_AdapterInactive,
			 NULL);
	else {
		manager->state = PortableServer_POAManager_ACTIVE;

		for (l = manager->poa_collection; l; l = l->next) {
			PortableServer_POA poa = (PortableServer_POA)l->data;

			/* FIXME: need better locking here */
			ORBit_POA_handle_held_requests (poa);
		}
	}

	POA_MGR_UNLOCK (poa_mgr);
}
Пример #2
0
/** The InvalidName exception is raised at @ev when
 *  ORB.resolve_initial_references is passed an @identifier for which
 *  there is no initial reference.
 */
CORBA_Object
CORBA_ORB_resolve_initial_references (CORBA_ORB          orb,
				      const CORBA_char  *identifier,
				      CORBA_Environment *ev)
{
	CORBA_Object objref;

	/* FIXME, verify identifier and raise exception for invalid
	 * service names, valid names might be: NameService, RootPOA,
	 * SecurityCurrent, PolicyCurrent, etc. */

	if (!orb->initial_refs ||
	    !(objref = g_hash_table_lookup (orb->initial_refs, identifier)))
		return CORBA_OBJECT_NIL;

	return MateCORBA_RootObject_duplicate (objref);
#if 0
 raise_invalid_name:
	CORBA_exception_set (ev,
			     CORBA_USER_EXCEPTION,
			     ex_CORBA_ORB_InvalidName,
			     NULL);
	return CORBA_OBJECT_NIL;
#endif
}
Пример #3
0
static void
mem_truncate (PortableServer_Servant servant,
	      const CORBA_long new_size, 
	      CORBA_Environment *ev)
{
	BonoboStreamMem *smem = BONOBO_STREAM_MEM (
		bonobo_object (servant));
	void *newp;
	
	if (smem->read_only)
		return;

	newp = g_realloc (smem->buffer, new_size);
	if (!newp) {
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_Bonobo_Stream_NoPermission, NULL);
		return;
	}

	smem->buffer = newp;
	smem->size = new_size;

	if (smem->pos > new_size)
		smem->pos = new_size;
}
Пример #4
0
void
PortableServer_POAManager_hold_requests (PortableServer_POAManager  manager,
					 const CORBA_boolean        wait_for_completion,
					 CORBA_Environment         *ev)
{
	if (!manager) {
		CORBA_exception_set_system (ev, ex_CORBA_BAD_PARAM,
					    CORBA_COMPLETED_NO);
		return;
	}

	POA_MGR_LOCK (poa_mgr);
	if (manager->state == PortableServer_POAManager_INACTIVE)
		CORBA_exception_set
			(ev, CORBA_USER_EXCEPTION,
			 ex_PortableServer_POAManager_AdapterInactive,
			 NULL);
	else {
		manager->state = PortableServer_POAManager_HOLDING;

		if (!wait_for_completion)
			g_warning ("hold_requests not finished - don't "
				   "know how to kill outstanding request fulfillments");
	}
	POA_MGR_UNLOCK (poa_mgr);
}
Пример #5
0
static void
mem_revert (PortableServer_Servant servant,
	    CORBA_Environment *ev)
{
	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
			     ex_Bonobo_Stream_NotSupported, NULL);
}
Пример #6
0
static GNOME_C_Camera
impl_connect (PortableServer_Servant servant, const CORBA_char *manufacturer,
	      const CORBA_char *model, const CORBA_char *port, 
	      CORBA_Environment *ev)
{
	KncCMngr *m = KNC_C_MNGR (bonobo_object (servant));
	KncCCamera *c;
	GPPort *p = NULL;
	GPPortInfo info;
	unsigned int i;

	gp_port_new (&p);
	for (i = 0; i < MAX (gp_port_info_list_count (m->priv->il), 0); i++) {
		gp_port_info_list_get_info (m->priv->il, i, &info);
		if (!strcmp (info.name, port)) {
			gp_port_set_info (p, info);
			c = knc_c_camera_new (manufacturer, model, p, ev);
			if (BONOBO_EX (ev)) return CORBA_OBJECT_NIL;
			return CORBA_Object_duplicate (BONOBO_OBJREF (c), ev);
		}
	}
	gp_port_free (p);
	
	CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_C_Error, NULL);
	return CORBA_OBJECT_NIL;
}
static void
impl_MateComponent_EventSource_removeListener (PortableServer_Servant servant,
					const MateComponent_Listener  listener,
					CORBA_Environment     *ev)
{
	GSList                   *l, *next;
	MateComponentEventSourcePrivate *priv;

	priv = matecomponent_event_source_from_servant (servant)->priv;

	for (l = priv->listeners; l; l = next) {
		ListenerDesc *desc = l->data;

		next = l->next;

		if (CORBA_Object_is_equivalent (listener, desc->listener, ev)) {
			priv->listeners = g_slist_remove_link (
				priv->listeners, l);
			g_slist_free_1 (l);
			desc_free (desc, ev);
			return;
		}
	}

	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
			     ex_MateComponent_EventSource_UnknownListener, 
			     NULL);
}
static MateComponent_Control
impl_MateComponent_PropertyControl_getControl (PortableServer_Servant servant,
					CORBA_long pagenumber,
					CORBA_Environment *ev)
{
	MateComponentObject *matecomponent_object;
	MateComponentPropertyControl *property_control;
	MateComponentPropertyControlPrivate *priv;
	MateComponentControl *control;

	matecomponent_object = matecomponent_object_from_servant (servant);
	property_control = MATECOMPONENT_PROPERTY_CONTROL (matecomponent_object);
	priv = property_control->priv;

	if (pagenumber < 0 || pagenumber >= priv->page_count) {
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_MateComponent_PropertyControl_NoPage, NULL);
		return CORBA_OBJECT_NIL;
	}

	control = priv->get_fn (property_control, 
			        pagenumber,
		                priv->closure);

	if (control == NULL)
		return CORBA_OBJECT_NIL;

	return (MateComponent_Control) CORBA_Object_duplicate 
		(MATECOMPONENT_OBJREF (control), ev);
}
Пример #9
0
/*
 * This function implements the Bonobo::PersistStream:load method.
 */
static void
pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
              Bonobo_Persist_ContentType type, void *data,
              CORBA_Environment *ev)
{
    GList *list;
    char *vcard;
    EABVCardControl *vcard_control = data;

    if (type && g_ascii_strcasecmp (type, "text/vCard") != 0 &&
            g_ascii_strcasecmp (type, "text/x-vCard") != 0) {
        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                             ex_Bonobo_Persist_WrongDataType, NULL);
        return;
    }

    if ((vcard = stream_read (stream)) == NULL) {
        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                             ex_Bonobo_Persist_FileNotFound, NULL);
        return;
    }

    g_list_foreach (
        vcard_control->card_list,
        (GFunc) g_object_unref, NULL);
    g_list_free (vcard_control->card_list);

    list = eab_contact_list_from_string (vcard);
    g_free(vcard);
    vcard_control->card_list = list;
    if (list) {
        eab_contact_display_render (vcard_control->display, E_CONTACT (list->data),
                                    vcard_control->render_mode);
    }
    if (list && list->next) {
        char *message;
        int length = g_list_length (list) - 1;
        message = g_strdup_printf (ngettext("There is one other contact.",
                                            "There are %d other contacts.", length),
                                   length);
        gtk_label_set_text (GTK_LABEL (vcard_control->label), message);
        g_free (message);
        gtk_widget_show (vcard_control->label);
    } else {
        gtk_widget_hide (vcard_control->label);
    }
} /* pstream_load */
Пример #10
0
void CORBA_exception_set_system(
	CORBA_Environment *ev,
	CORBA_unsigned_long minor,
	CORBA_completion_status completed
)
{
	const char * const exception_table[] = {
		NULL,
		"IDL:CORBA/UNKNOWN:1.0",						/* 1 */
		"IDL:CORBA/BAD_PARAM:1.0",						/* 2 */
		"IDL:CORBA/NO_MEMORY:1.0",						/* 3 */
		"IDL:CORBA/IMP_LIMIT:1.0",						/* 4 */
		"IDL:CORBA/COMM_FAILURE:1.0",					/* 5 */
		"IDL:CORBA/INV_OBJREF:1.0",					/* 6 */
		"IDL:CORBA/NO_PERMISSION:1.0",				/* 7 */
		"IDL:CORBA/INTERNAL:1.0",						/* 8 */
		"IDL:CORBA/MARSHAL:1.0",						/* 9 */
		"IDL:CORBA/INITIALIZE:1.0",					/* 10 */
		"IDL:CORBA/NO_IMPLEMENT:1.0",					/* 11 */
		"IDL:CORBA/BAD_TYPECODE:1.0",					/* 12 */
		"IDL:CORBA/BAD_OPERATION:1.0",				/* 13 */
		"IDL:CORBA/NO_RESOURCES:1.0",					/* 14 */
		"IDL:CORBA/NO_RESPONSE:1.0",					/* 15 */
		"IDL:CORBA/PERSIST_STORE:1.0",				/* 16 */
		"IDL:CORBA/BAD_INV_ORDER:1.0",				/* 17 */
		"IDL:CORBA/TRANSIENT:1.0",						/* 18 */
		"IDL:CORBA/FREE_MEM:1.0",						/* 19 */
		"IDL:CORBA/INV_IDENT:1.0",						/* 20 */
		"IDL:CORBA/INV_FLAG:1.0",						/* 21 */
		"IDL:CORBA/INTF_REPOS:1.0",					/* 22 */
		"IDL:CORBA/BAD_CONTEXT:1.0",					/* 23 */
		"IDL:CORBA/OBJ_ADAPTER:1.0",					/* 24 */
		"IDL:CORBA/DATA_CONVERSION:1.0",				/* 25 */
		"IDL:CORBA/OBJECT_NOT_EXIST:1.0",			/* 26 */
		"IDL:CORBA/TRANSACTION_REQUIRED:1.0",		/* 27 */
		"IDL:CORBA/TRANSACTION_ROLLEDBACK:1.0",	/* 28 */
		"IDL:CORBA/INVALID_TRANSACTION:1.0",		/* 29 */
		"IDL:CORBA/INV_POLICY:1.0",					/* 30 */
		"IDL:CORBA/CODESET_INCOMPATIBLE:1.0",		/* 31 */
		"IDL:CORBA/REBIND:1.0",							/* 32 */
		"IDL:CORBA/TIMEOUT:1.0",						/* 33 */
		"IDL:CORBA/TRANSACTION_UNAVAILABLE:1.0",	/* 34 */
		"IDL:CORBA/TRANSACTION_MODE:1.0",			/* 35 */
		"IDL:CORBA/BAD_QOS:1.0",						/* 36 */
	};
	static CORBA_SystemException _CORBA_SystemException;
	char * repo_id = NULL;

	if (minor > 0 && minor <= 36) {
		repo_id = (char *)exception_table[minor];
	}
	_CORBA_SystemException.minor = minor;
	_CORBA_SystemException.completed = completed;

	CORBA_exception_set(ev, CORBA_SYSTEM_EXCEPTION, repo_id,
								&_CORBA_SystemException);
}
Пример #11
0
Bonobo_Unknown
bonobo_moniker_ior_resolve (BonoboMoniker               *moniker,
			    const Bonobo_ResolveOptions *options,
			    const CORBA_char            *requested_interface,
			    CORBA_Environment           *ev)
{
	const char    *ior;
	CORBA_Object   object;
	Bonobo_Unknown retval;
	gboolean       is_unknown, is_correct;

	ior = bonobo_moniker_get_name (moniker);
	
	object = CORBA_ORB_string_to_object (bonobo_orb (), ior, ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

	is_unknown = CORBA_Object_is_a (object, "IDL:Bonobo/Unknown:1.0", ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

	if (!is_unknown) {
		is_correct = CORBA_Object_is_a (object, requested_interface, ev);
		BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

		if (is_correct)
			return object;
		else {
			CORBA_exception_set (
				ev, CORBA_USER_EXCEPTION,
				ex_Bonobo_Moniker_InterfaceNotFound, NULL);
			return CORBA_OBJECT_NIL;
		}
	}

	retval = Bonobo_Unknown_queryInterface (
		object, requested_interface, ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);
	
	if (retval == CORBA_OBJECT_NIL)
		CORBA_exception_set (
			ev, CORBA_USER_EXCEPTION,
			ex_Bonobo_Moniker_InterfaceNotFound, NULL);

	return retval;
}
Пример #12
0
static void
mem_set_info (PortableServer_Servant servant,
	      const Bonobo_StorageInfo *info,
	      const Bonobo_StorageInfoFields mask,
	      CORBA_Environment *ev)
{
	BonoboStreamMem *smem = BONOBO_STREAM_MEM (
		bonobo_object (servant));

	if (smem->read_only) {
		CORBA_exception_set (
			ev, CORBA_USER_EXCEPTION,
			ex_Bonobo_Stream_NoPermission, NULL);
		return;
	}

	if (mask & Bonobo_FIELD_SIZE) {
		CORBA_exception_set (
			ev, CORBA_USER_EXCEPTION,
			ex_Bonobo_Stream_NotSupported, NULL);
		return;
	}

	if ((mask & Bonobo_FIELD_TYPE) &&
	    (info->type != Bonobo_STORAGE_TYPE_REGULAR)) {
		CORBA_exception_set (
			ev, CORBA_USER_EXCEPTION,
			ex_Bonobo_Stream_NotSupported, NULL);
		return;
	}

	if (mask & Bonobo_FIELD_CONTENT_TYPE) {
		bonobo_return_if_fail (info->content_type != NULL, ev);
		g_free (smem->content_type);
		smem->content_type = g_strdup (info->content_type);
	}

	if (strcmp (info->name, smem->name)) {
		bonobo_return_if_fail (info->name != NULL, ev);
		g_free (smem->name);
		smem->name = g_strdup (info->name);
	}
}
Пример #13
0
static void
impl_requestCreateItem (PortableServer_Servant servant,
			const CORBA_char *item_type_name,
			CORBA_Environment *ev)
{
	MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant));

	if (create_item(item_type_name, mc->priv->model, NULL, NULL) == -1) {
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_GNOME_Evolution_Component_UnknownType, NULL);
	}
}
MateComponent_Unknown
matecomponent_moniker_oaf_resolve (MateComponentMoniker               *moniker,
			    const MateComponent_ResolveOptions *options,
			    const CORBA_char            *requested_interface,
			    CORBA_Environment           *ev)
{
	MateComponent_Moniker       parent;
	MateComponent_Unknown       object;
	
	parent = matecomponent_moniker_get_parent (moniker, ev);

	if (ev->_major != CORBA_NO_EXCEPTION)
		return CORBA_OBJECT_NIL;
	
	if (parent != CORBA_OBJECT_NIL) {
		matecomponent_object_release_unref (parent, ev);

#ifdef G_ENABLE_DEBUG
		g_warning ("wierd; oafid moniker with a parent; strange");
#endif
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_MateComponent_Moniker_InterfaceNotFound, NULL);
		return CORBA_OBJECT_NIL;
	}

	object = matecomponent_activation_activate_from_id (
		(char *) matecomponent_moniker_get_name_full (moniker), 0, NULL, ev);

	if (MATECOMPONENT_EX (ev)) {
		if (ev->_major == CORBA_USER_EXCEPTION) {
			if (strcmp (ev->_id, ex_MateComponent_GeneralError)) {
				CORBA_exception_free (ev);

				matecomponent_exception_general_error_set (
					ev, NULL, _("Exception activating '%s'"),
					matecomponent_moniker_get_name_full (moniker));
			}
		}
		return CORBA_OBJECT_NIL;

	} else if (object == CORBA_OBJECT_NIL) {

		matecomponent_exception_general_error_set (
			ev, NULL, _("Failed to activate '%s'"),
			matecomponent_moniker_get_name_full (moniker));

		return CORBA_OBJECT_NIL;
	}

	return matecomponent_moniker_util_qi_return (object, requested_interface, ev);
}
Пример #15
0
void
CORBA_exception_set_system (CORBA_Environment *ev,
			    const CORBA_char *except_repos_id,
			    CORBA_completion_status completed)
{
	CORBA_SystemException *se;

	g_return_if_fail (ev != NULL);

	se = CORBA_SystemException__alloc ();
	/* I have never seen a case where 'minor' is actually necessary */
	se->minor = 0 /* minor */;
	se->completed = completed;
	CORBA_exception_set (
		ev, CORBA_SYSTEM_EXCEPTION, except_repos_id, se);
}
CORBA_Object
impl_GNOME_FileManagerFactory_create_object(impl_POA_GNOME_FileManagerFactory * servant,
					    CORBA_char * goad_id,
					    GNOME_stringlist * params,
					    CORBA_Environment * ev)
{
	if(!strcmp(goad_id, "gmc_filemanager_window"))
		return impl_GNOME_FileManagerFactory_create_window(
			servant,
			params->_length ? params->_buffer [0] : home_dir, ev);
	
	CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
			     ex_GNOME_GenericFactory_CannotActivate,
			     NULL);
	
	return CORBA_OBJECT_NIL;
}
Пример #17
0
Bonobo_Unknown
bonobo_moniker_new_resolve (BonoboMoniker               *moniker,
			    const Bonobo_ResolveOptions *options,
			    const CORBA_char            *requested_interface,
			    CORBA_Environment           *ev)
{
	Bonobo_Moniker        parent;
	Bonobo_GenericFactory factory;
	Bonobo_Unknown        containee;
	Bonobo_Unknown        retval = CORBA_OBJECT_NIL;
	
	parent = bonobo_moniker_get_parent (moniker, ev);

	if (ev->_major != CORBA_NO_EXCEPTION)
		return CORBA_OBJECT_NIL;

	g_assert (parent != CORBA_OBJECT_NIL);

	factory = Bonobo_Moniker_resolve (parent, options,
					  "IDL:Bonobo/GenericFactory:1.0", ev);

	if (ev->_major != CORBA_NO_EXCEPTION)
		goto return_unref_parent;

	if (factory == CORBA_OBJECT_NIL) {
#ifdef G_ENABLE_DEBUG
		g_warning ("Failed to extract a factory from our parent");
#endif
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_Bonobo_Moniker_InterfaceNotFound, NULL);
		goto return_unref_parent;
	}

	containee = Bonobo_GenericFactory_createObject (
		factory, requested_interface, ev);

	bonobo_object_release_unref (factory, ev);

	return bonobo_moniker_util_qi_return (containee, requested_interface, ev);

 return_unref_parent:
	bonobo_object_release_unref (parent, ev);

	return retval;
}
Пример #18
0
static void
BasicServer_opException (PortableServer_Servant  servant,
			 CORBA_Environment      *ev)
{
	test_TestException *ex = test_TestException__alloc ();

	ex->reason           = CORBA_string_dup (constants_STRING_IN);
	ex->number           = constants_LONG_IN;
	ex->aseq._buffer     = CORBA_sequence_CORBA_long_allocbuf (1);
	ex->aseq._length     = 1;
	ex->aseq._buffer [0] = constants_LONG_IN;
	ex->factory          = getFactoryInstance(ev);

	CORBA_sequence_set_release (&ex->aseq, CORBA_TRUE);

	CORBA_exception_set (
		ev, CORBA_USER_EXCEPTION, ex_test_TestException,ex);
}
Пример #19
0
static void
impl_upgradeFromVersion (PortableServer_Servant servant, const short major, const short minor, const short revision, CORBA_Environment *ev)
{
	MailComponent *component;
	CamelException ex;

	component = mail_component_peek ();

	camel_exception_init (&ex);
	if (em_migrate (e_get_user_data_dir (), major, minor, revision, &ex) == -1) {
		GNOME_Evolution_Component_UpgradeFailed *failedex;

		failedex = GNOME_Evolution_Component_UpgradeFailed__alloc();
		failedex->what = CORBA_string_dup(_("Failed upgrading Mail settings or folders."));
		failedex->why = CORBA_string_dup(ex.desc);
		CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex);
	}

	camel_exception_clear (&ex);
}
Пример #20
0
/*
 * This function implements the Bonobo::PersistStream:save method.
 */
static void
pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream,
              Bonobo_Persist_ContentType type, void *data,
              CORBA_Environment *ev)
{
    EABVCardControl *vcard_control = data;
    char             *vcard;
    int               length;

    if (type && g_ascii_strcasecmp (type, "text/vCard") != 0 &&
            g_ascii_strcasecmp (type, "text/x-vCard") != 0) {
        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                             ex_Bonobo_Persist_WrongDataType, NULL);
        return;
    }

    vcard = eab_contact_list_to_string (vcard_control->card_list);
    length = strlen (vcard);
    bonobo_stream_client_write (stream, vcard, length, ev);
    g_free (vcard);
} /* pstream_save */
Пример #21
0
/* ARGSUSED */
CORBA_long
Calc_Div(
	Calc _o,
	CORBA_long val1, // in (fixed length)
	CORBA_long val2, // in (fixed length)
	CORBA_Environment * _ev
)
{
/* START_EDIT (Calc_Div) */
	static Calc_DivisionByZero _Calc_DivisionByZero;
	if (0 == val2)
	{
		CORBA_exception_set(_ev, CORBA_USER_EXCEPTION, ex_Calc_DivisionByZero, &_Calc_DivisionByZero);
		return 0;
	}
	else
	{
		return val1 / val2;
	}
/* STOP_EDIT (Calc_Div) */
}
static void
impl_MateComponent_PropertyControl_notifyAction (PortableServer_Servant servant,
					  CORBA_long pagenumber,
					  MateComponent_PropertyControl_Action action,
					  CORBA_Environment *ev)
{
	MateComponentObject *matecomponent_object;
	MateComponentPropertyControl *property_control;
	MateComponentPropertyControlPrivate *priv;

	matecomponent_object = matecomponent_object_from_servant (servant);
	property_control = MATECOMPONENT_PROPERTY_CONTROL (matecomponent_object);
	priv = property_control->priv;

	if (pagenumber < 0 || pagenumber >= priv->page_count) {
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_MateComponent_PropertyControl_NoPage, NULL);
		return;
	}
	
	g_signal_emit (matecomponent_object, signals [ACTION], 0, pagenumber, action);
}
Пример #23
0
void
PortableServer_POAManager_deactivate (PortableServer_POAManager  manager,
				      const CORBA_boolean        etherealize_objects,
				      const CORBA_boolean        wait_for_completion,
				      CORBA_Environment         *ev)
{
	GSList *l;

	if (!manager) {
		CORBA_exception_set_system (ev, ex_CORBA_BAD_PARAM,
					    CORBA_COMPLETED_NO);
		return;
	}

	POA_MGR_LOCK (poa_mgr);
	if (manager->state == PortableServer_POAManager_INACTIVE)
		CORBA_exception_set
			(ev, CORBA_USER_EXCEPTION,
			 ex_PortableServer_POAManager_AdapterInactive,
			 NULL);
	else {
		if (wait_for_completion)
			for (l = manager->poa_collection; l; l = l->next)
				if (!ORBit_POA_is_inuse (l->data, FALSE, ev)) {
					CORBA_exception_set_system
						(ev, ex_CORBA_BAD_INV_ORDER,
						 CORBA_COMPLETED_NO);
					POA_MGR_UNLOCK (poa_mgr);
					return;
				}

		manager->state = PortableServer_POAManager_INACTIVE;

		for (l = manager->poa_collection; l; l = l->next)
			ORBit_POA_deactivate (l->data, etherealize_objects, ev);
	}
	POA_MGR_UNLOCK (poa_mgr);
}
Пример #24
0
IDL4_INLINE void ILanAddress_generate_lan_address_implementation(
	CORBA_Object _caller,
	lanaddress_t *lanaddress,
	idl4_server_environment *_env)
{
    if( !lanaddress_valid )
    {
	CORBA_exception_set( _env, ex_ILanAddress_insufficient_resources, NULL);
	return;
    }

    // Create a new address, combined from the base, and the handle.
    lanaddress_set_handle( &lanaddress_base, lanaddress_handle );
    lanaddress->align4.lsb = lanaddress_base.align4.lsb;
    lanaddress->align4.msb = lanaddress_base.align4.msb;

    // Move to the next handle.
    lanaddress_handle++;
    if( lanaddress_handle == 0 )
    {
	// wrap around
	lanaddress_valid = 0;
    }
}
Пример #25
0
static Examples_BadCall_Foo
impl_Examples_BadCall_trigger(impl_POA_Examples_BadCall * servant,
			      const CORBA_long val,
			      Examples_BadCall_Foo * bar,
			      CORBA_Environment * ev)
{
   Examples_BadCall_Foo ret_val = {0.0};


   /* ------   insert method code here   ------ */
   switch ((servant->counter++) % 2)
   {
   case 0:
   {
	   /* this piece of code demonstrates how to raise exception
	    * without any further parameter */

	   Examples_BadCall_Foo dummy_foo = {0.0};

	   /* after user has assinged exception attributes, user may
	    * not touch the data anymore, ownership is handed over to
	    * CORBA environment  */
           CORBA_exception_set (ev, 
				CORBA_USER_EXCEPTION,
                                ex_Examples_BadCall_NoParam,
                                NULL); /* exception has no members */

 	   /* on exception you need not to care about out-argument
	    * @bar, but due to programming language C it is necessary
	    * to return valid value */ 
           return dummy_foo;
           break;
   }
   case 1:
   {
	   /* this piece of code demonstrates how to raise exception
	    * that has a string as parameter */

	   Examples_BadCall_Foo dummy_foo = {0.0};

	   Examples_BadCall_SingleParam* ex_parameters
		   = Examples_BadCall_SingleParam__alloc();

	   ex_parameters->mesg 
		   = CORBA_string_dup ("raised in \"" __FILE__ "\"");

	   /* after user has assinged exception attributes, user may
	    * not touch the data anymore, ownership is handed over to
	    * CORBA environment  */
           CORBA_exception_set (ev, 
				CORBA_USER_EXCEPTION,
                                ex_Examples_BadCall_SingleParam,
                                ex_parameters); /* exception has members */

 	   /* on exception you need not to care about out-argument
	    * @bar, but due to programming language C it is necessary
	    * to return valid value */ 
           return dummy_foo;
           break;
   }
   /* this code will never raise exception DoubleParam */

   default:
           g_assert_not_reached ();
   }
   /* ------ ---------- end ------------ ------ */

   return ret_val;
}
/**
 * matecomponent_activation_activate_shlib_server:
 * @sh:
 * @ev:
 *
 * Private function.
 *
 * Return value: 
 */
CORBA_Object
matecomponent_activation_activate_shlib_server (MateComponent_ActivationResult *sh, 
                                         CORBA_Environment *ev)
{
	CORBA_Object retval;
	const MateComponentActivationPlugin *plugin;
	ActivePluginInfo *local_plugin_info = NULL;
	const MateComponentActivationPluginObject *pobj;
	int i;
	PortableServer_POA poa;
	CORBA_ORB orb;
	char *filename;
	const char *iid;

	g_return_val_if_fail (sh->res._d == MateComponent_ACTIVATION_RESULT_SHLIB,
			      CORBA_OBJECT_NIL);
	g_return_val_if_fail (sh->res._u.res_shlib._length > 0,
			      CORBA_OBJECT_NIL);

        MATECOMPONENT_ACTIVATION_LOCK ();

	/* The location info is at the end to of the string list */
	filename = sh->res._u.res_shlib._buffer[sh->res._u.res_shlib._length - 1];
	if (living_by_filename)
		local_plugin_info =
			g_hash_table_lookup (living_by_filename, filename);

	if (!local_plugin_info) {
		/* We have to load the thing from scratch */
		GModule *gmod;
		gboolean success;

		gmod = g_module_open (filename, G_MODULE_BIND_LAZY);
		if (!gmod) {
                        char *error_string;
                        MateComponent_GeneralError *error = MateComponent_GeneralError__alloc ();

                        error_string = g_strdup_printf (
                                _("g_module_open of `%s' failed with `%s'"),
                                filename, g_module_error ());
                        error->description = CORBA_string_dup (error_string);
                        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                                             ex_MateComponent_GeneralError, error);
                        g_free (error_string);
                        MATECOMPONENT_ACTIVATION_UNLOCK ();
			return CORBA_OBJECT_NIL; /* Couldn't load it */
		}
		
		success = g_module_symbol (gmod, "MateComponent_Plugin_info",
					   (gpointer *) &plugin);
		if (!success) {
                        char *error_string;
                        MateComponent_GeneralError *error = MateComponent_GeneralError__alloc ();

			g_module_close (gmod);

                        error_string = g_strdup_printf (
                                _("Can't find symbol MateComponent_Plugin_info in `%s'"),
                                filename);
                        error->description = CORBA_string_dup (error_string);
                        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                                             ex_MateComponent_GeneralError, error);
                        g_free (error_string);
                        MATECOMPONENT_ACTIVATION_UNLOCK ();
			return CORBA_OBJECT_NIL;
		}

		local_plugin_info =
			g_malloc (sizeof (ActivePluginInfo) +
				  strlen (filename) + 1);

		local_plugin_info->refcount = 0;
		local_plugin_info->loaded = gmod;
		strcpy (local_plugin_info->filename, filename);

		if (!living_by_filename)
			living_by_filename =
				g_hash_table_new (g_str_hash, g_str_equal);

		g_hash_table_insert (living_by_filename,
				     local_plugin_info->filename,
				     local_plugin_info);
	} else {
		int success;

		success =
			g_module_symbol (local_plugin_info->loaded,
					 "MateComponent_Plugin_info",
					 (gpointer *) & plugin);
		if (!success) {
                        char *error_string;
                        MateComponent_GeneralError *error = MateComponent_GeneralError__alloc ();

                        error_string = g_strdup_printf (
                                _("Can't find symbol MateComponent_Plugin_info in `%s'"),
                                filename);
                        error->description = CORBA_string_dup (error_string);
                        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                                             ex_MateComponent_GeneralError, error);
                        g_free (error_string);
                        MATECOMPONENT_ACTIVATION_UNLOCK ();
			return CORBA_OBJECT_NIL;
		}
	}

	retval = CORBA_OBJECT_NIL;

	orb = matecomponent_activation_orb_get ();
	poa = (PortableServer_POA)
		CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev);

	/* Index into the string list one element from the end to get the iid of the shlib */
	iid = sh->res._u.res_shlib._buffer[sh->res._u.res_shlib._length - 2];
	for (pobj = plugin->plugin_object_list; pobj->iid; pobj++) {
		if (strcmp (iid, pobj->iid) == 0) {
			/* Found a match */
			break;
		}
	}

	if (pobj->iid) {
		/* Activate the shlib */
		retval = pobj->activate (poa, pobj->iid, local_plugin_info, ev);

		if (ev->_major != CORBA_NO_EXCEPTION)
			retval = CORBA_OBJECT_NIL;

		/* Activate the factiories contained in the shlib */
		i =  sh->res._u.res_shlib._length - 2;
		for (i--; i >= 0 && !CORBA_Object_is_nil (retval, ev); i--) {
			CORBA_Object new_retval;

			iid = sh->res._u.res_shlib._buffer[i];

			new_retval =
				MateComponent_GenericFactory_createObject (
                                        retval, (char *) iid, ev);

			if (ev->_major != CORBA_NO_EXCEPTION
			    || CORBA_Object_is_nil (new_retval, ev)) {
                                if (ev->_major == CORBA_NO_EXCEPTION) {
                                        MateComponent_GeneralError *error = MateComponent_GeneralError__alloc ();
                                        char *error_string = g_strdup_printf (
                                                _("Factory `%s' returned NIL for `%s'"),
                                                pobj->iid, iid);
                                        error->description = CORBA_string_dup (error_string);
                                        CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                                                             ex_MateComponent_GeneralError, error);
                                        g_free (error_string);
                                        
                                }
				new_retval = CORBA_OBJECT_NIL;
                        }

			CORBA_Object_release (retval, ev);
			retval = new_retval;
		}
	} else {
                MateComponent_GeneralError *error = MateComponent_GeneralError__alloc ();
                char *error_string = g_strdup_printf (
                        _("Shlib `%s' didn't contain `%s'"),
                        filename, iid);
                error->description = CORBA_string_dup (error_string);
                CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                                     ex_MateComponent_GeneralError, error);
                g_free (error_string);
        }

        CORBA_Object_release ((CORBA_Object) poa, ev);
        MATECOMPONENT_ACTIVATION_UNLOCK ();

	return retval;
}
static GNOME_Evolution_Addressbook_Book
impl_GNOME_Evolution_Addressbook_BookFactory_getBook (PortableServer_Servant        servant,
						      const CORBA_char             *source_xml,
						      const GNOME_Evolution_Addressbook_BookListener listener,
						      CORBA_Environment            *ev)
{
	EDataBookFactory      *factory = E_DATA_BOOK_FACTORY (bonobo_object (servant));
	GNOME_Evolution_Addressbook_Book corba_book;
	EBookBackend *backend;
	EDataBook *book = NULL;
	ESource *source;
	gchar *uri;

	printf ("impl_GNOME_Evolution_Addressbook_BookFactory_getBook\n");

	source = e_source_new_from_standalone_xml (source_xml);
	if (!source) {
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
				     NULL);
		return CORBA_OBJECT_NIL;
	}

	uri = e_source_get_uri (source);
	if (!uri) {
		g_object_unref (source);
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
				     NULL);
		return CORBA_OBJECT_NIL;
	}
	printf (" + %s\n", uri);

	/* Look up the backend and create one if needed */
	g_mutex_lock (factory->priv->map_mutex);

	backend = g_hash_table_lookup (factory->priv->active_server_map, uri);

	if (!backend) {
		EBookBackendFactory*  backend_factory;

		backend_factory = e_data_book_factory_lookup_backend_factory (factory, uri);

		if (backend_factory == NULL) {
			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
					     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
					     NULL);

			g_mutex_unlock (factory->priv->map_mutex);

			g_free (uri);
			return CORBA_OBJECT_NIL;
		}

		backend = e_data_book_factory_launch_backend (factory, backend_factory, listener, uri);
	}

	g_free (uri);

	if (backend) {
		g_mutex_unlock (factory->priv->map_mutex);

		book = e_data_book_new (backend, source, listener);

		e_book_backend_add_client (backend, book);
		e_book_backend_set_mode (backend, factory->priv->mode);
		corba_book = bonobo_object_corba_objref (BONOBO_OBJECT (book));
	}
	else {
		/* probably need a more descriptive exception here */
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
				     NULL);
		g_mutex_unlock (factory->priv->map_mutex);

		corba_book = CORBA_OBJECT_NIL;
	}

	g_object_unref (source);
	if (book)
		printf (" => %p\n", book);
	return corba_book;
}
Bonobo_Unknown
bonobo_stream_extender_resolve (BonoboMonikerExtender       *extender,
				const Bonobo_Moniker         m,
				const Bonobo_ResolveOptions *options,
				const CORBA_char            *display_name,
				const CORBA_char            *requested_interface,
				CORBA_Environment           *ev)
{
	char          *mime_type;
	char          *requirements;
	Bonobo_Unknown object;
	Bonobo_Unknown stream;
	Bonobo_Persist persist;

#ifdef G_ENABLE_DEBUG
	g_message ("Stream extender: '%s'", display_name);
#endif
	if (!m)
		return CORBA_OBJECT_NIL;

	stream = Bonobo_Moniker_resolve (m, options, "IDL:Bonobo/Stream:1.0", ev);

	if (!stream)
		return CORBA_OBJECT_NIL;

	mime_type = get_stream_type (stream, ev);
	if (!mime_type)
		goto unref_stream_exception;

	requirements = g_strdup_printf (
		"bonobo:supported_mime_types.has ('%s') AND repo_ids.has ('%s') AND "
		"repo_ids.has ('IDL:Bonobo/PersistStream:1.0')",
		mime_type, requested_interface);
		
	object = bonobo_activation_activate (requirements, NULL, 0, NULL, ev);
#ifdef G_ENABLE_DEBUG
	g_message ("Attempt activate object satisfying '%s': %p",
		   requirements, object);
#endif
	g_free (requirements);

	if (ev->_major != CORBA_NO_EXCEPTION)
		goto unref_stream_exception;
		
	if (object == CORBA_OBJECT_NIL) {
#ifdef G_ENABLE_DEBUG
		g_warning ("Can't find object satisfying requirements");
#endif
		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
				     ex_Bonobo_Moniker_InterfaceNotFound, NULL);
		goto unref_stream_exception;
	}

	persist = Bonobo_Unknown_queryInterface (
		object, "IDL:Bonobo/PersistStream:1.0", ev);

	if (ev->_major != CORBA_NO_EXCEPTION)
		goto unref_object_exception;

	if (persist != CORBA_OBJECT_NIL) {
		Bonobo_PersistStream_load (
			persist, stream, (const Bonobo_Persist_ContentType) mime_type, ev);

		bonobo_object_release_unref (persist, ev);
		bonobo_object_release_unref (stream, ev);

		return bonobo_moniker_util_qi_return (
			object, requested_interface, ev);
	}

	g_free (mime_type);

 unref_object_exception:
	bonobo_object_release_unref (object, ev);

 unref_stream_exception:
	bonobo_object_release_unref (stream, ev);

	return CORBA_OBJECT_NIL;
}
Пример #29
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 ();
}