コード例 #1
0
ファイル: gnocam-camera.c プロジェクト: rajbot/gphoto
static gboolean
capture_image_idle (gpointer user_data)
{
	CameraFilePath path;
	IdleData *d = user_data;
	CORBA_Environment ev;
	CORBA_any any;
	gchar *p = NULL;

	CORBA_exception_init (&ev);
	memset (&path, 0, sizeof (CameraFilePath));
	CR (gp_camera_capture (d->gc->camera, GP_CAPTURE_IMAGE,
			       &path, NULL), &ev);
	if (BONOBO_EX (&ev)) {
		GNOME_Camera_ErrorCode e = GNOME_Camera_ERROR;
		any._type = TC_GNOME_Camera_ErrorCode;
		any._value = &e;
	} else {
		p = g_build_path ("/", path.folder, path.name);
		any._type = TC_CORBA_string;
		any._value = &p;
	}

	g_message ("Notifying...");
	Bonobo_Listener_event (d->listener, "result", &any, &ev);
	g_message ("Notified.");

	if (p)
		g_free (p);

	CORBA_exception_free (&ev);

	return (FALSE);
}
コード例 #2
0
ファイル: bonobo-event-source.c プロジェクト: GNOME/libbonobo
/**
 * bonobo_event_source_notify_listeners:
 * @event_source: the Event Source that will emit the event.
 * @event_name: Name of the event being emitted
 * @opt_value: A CORBA_any value that contains the data that is passed
 * to interested clients, or NULL for an empty value
 * @opt_ev: A CORBA_Environment where a failure code can be returned, can be NULL.
 *
 * This will notify all clients that have registered with this EventSource
 * (through the addListener or addListenerWithMask methods) of the availability
 * of the event named @event_name.  The @value CORBA::any value is passed to
 * all listeners.
 *
 * @event_name can not contain comma separators, as commas are used to
 * separate the various event names.
 */
void
bonobo_event_source_notify_listeners (BonoboEventSource *event_source,
                                      const char        *event_name,
                                      const CORBA_any   *opt_value,
                                      CORBA_Environment *opt_ev)
{
    GSList *l, *notify;
    CORBA_Environment  *ev, temp_ev;
    const BonoboArg *my_value;

    g_return_if_fail (BONOBO_IS_EVENT_SOURCE (event_source));

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

    if (!opt_value)
        my_value = bonobo_arg_new (BONOBO_ARG_NULL);
    else
        my_value = opt_value;

    notify = NULL;

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

        if (desc->event_masks == NULL ||
                event_match (event_name, desc->event_masks)) {
            notify = g_slist_prepend (
                         notify,
                         CORBA_Object_duplicate (desc->listener, ev));
        }
    }

    bonobo_object_ref (BONOBO_OBJECT (event_source));

    for (l = notify; l; l = l->next) {
        Bonobo_Listener_event (l->data, event_name, my_value, ev);
        CORBA_Object_release (l->data, ev);
    }

    bonobo_object_unref (BONOBO_OBJECT (event_source));

    g_slist_free (notify);

    if (!opt_ev)
        CORBA_exception_free (ev);

    if (!opt_value)
        bonobo_arg_release ((BonoboArg *) my_value);
}
コード例 #3
0
ファイル: gnocam-main.c プロジェクト: rajbot/gphoto
static gboolean
get_camera_idle (gpointer data)
{
	IdleData *d = data;
	GnoCamCamera *gc;
	CORBA_Environment ev;
	CORBA_any any;

	CORBA_exception_init (&ev);

	/* Get the camera */
	gc = gnocam_main_get_camera (d->gm, (const gchar *) d->model,
					    (const gchar *) d->port, &ev);
	if (BONOBO_EX (&ev)) {
		GNOME_GnoCam_ErrorCode e = GNOME_GnoCam_ERROR;
		any._type = TC_GNOME_GnoCam_ErrorCode;
		any._value = &e;
	} else {
		GNOME_Camera c = BONOBO_OBJREF (gc);
		any._type = TC_GNOME_Camera;
		any._value = &c;
	}

	/* Notify */
	g_message ("Notifying...");
	Bonobo_Listener_event (d->listener, "result", &any, &ev);
	g_message ("Notified.");

	/* Clean up */
	if (gc)
		bonobo_object_idle_unref (gc);
	bonobo_object_release_unref (d->listener, NULL);
	bonobo_object_unref (d->gm);
	if (d->model)
		CORBA_free (d->model);
	if (d->port)
		CORBA_free (d->port);
	g_free (d);
	CORBA_exception_free (&ev);
	
	return (FALSE);
};