gboolean
_tf_content_start_receiving (TfContent *self, guint *handles,
    guint handle_count)
{
  GValue instance_and_params[3] = {{0} , {0}, {0}};
  GValue receiving_success_val = {0,};
  gboolean receiving_success;

  g_value_init (&receiving_success_val, G_TYPE_BOOLEAN);
  g_value_set_boolean (&receiving_success_val, TRUE);

  g_value_init (&instance_and_params[0], TF_TYPE_CONTENT);
  g_value_set_object (&instance_and_params[0], self);

  g_value_init (&instance_and_params[1], G_TYPE_POINTER);
  g_value_set_pointer (&instance_and_params[1], handles);

  g_value_init (&instance_and_params[2], G_TYPE_UINT);
  g_value_set_uint (&instance_and_params[2], handle_count);

  g_debug ("Requesting that the application start receiving");

  g_signal_emitv (instance_and_params, signals[SIGNAL_START_RECEIVING], 0,
      &receiving_success_val);
  receiving_success = g_value_get_boolean (&receiving_success_val);

  g_value_unset (&instance_and_params[0]);

  g_debug ("Request to start receiving %s",
      receiving_success ? "succeeded" : "failed");

  return receiving_success;
}
Ejemplo n.º 2
0
static GstCaps *
gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt)
{
  GstCaps *caps;
  GValue ret = { 0 };
  GValue args[2] = { {0}, {0} };

  /* figure out the caps */
  g_value_init (&args[0], GST_TYPE_ELEMENT);
  g_value_set_object (&args[0], rtpdemux);
  g_value_init (&args[1], G_TYPE_UINT);
  g_value_set_uint (&args[1], pt);

  g_value_init (&ret, GST_TYPE_CAPS);
  g_value_set_boxed (&ret, NULL);

  g_signal_emitv (args, gst_rtp_pt_demux_signals[SIGNAL_REQUEST_PT_MAP], 0,
      &ret);

  g_value_unset (&args[0]);
  g_value_unset (&args[1]);
  caps = g_value_dup_boxed (&ret);
  g_value_unset (&ret);
  if (caps == NULL) {
    caps = GST_PAD_CAPS (rtpdemux->sink);
    if (caps)
      gst_caps_ref (caps);
  }

  GST_DEBUG ("pt %d, got caps %" GST_PTR_FORMAT, pt, caps);

  return caps;
}
gboolean
_tf_content_start_sending (TfContent *self)
{
  GValue instance = {0};
  GValue sending_success_val = {0,};
  gboolean sending_success;


  if (self->sending_count)
    {
      self->sending_count ++;
      return TRUE;
    }

  g_value_init (&sending_success_val, G_TYPE_BOOLEAN);
  g_value_set_boolean (&sending_success_val, TRUE);

  g_value_init (&instance, TF_TYPE_CONTENT);
  g_value_set_object (&instance, self);

  g_debug ("Requesting that the application start sending");

  g_signal_emitv (&instance, signals[SIGNAL_START_SENDING], 0,
      &sending_success_val);
  sending_success = g_value_get_boolean (&sending_success_val);

  g_value_unset (&instance);

  g_debug ("Request to start sending %s",
      sending_success ? "succeeded" : "failed");

  self->sending_count = 1;

  return sending_success;
}
Ejemplo n.º 4
0
static JSValueRef
seed_gobject_signal_emit (JSContextRef ctx,
			  JSObjectRef function,
			  JSObjectRef thisObject,
			  size_t argumentCount,
			  const JSValueRef arguments[],
			  JSValueRef * exception)
{
  JSValueRef ret;
  GValue *params;
  GValue ret_value = { 0 };
  GSignalQuery query;

  signal_privates *privates;
  guint i, signal_id;

  privates = JSObjectGetPrivate (thisObject);

  signal_id = g_signal_lookup (privates->signal_name,
			       G_OBJECT_TYPE (privates->object));

  g_signal_query (signal_id, &query);

  if (argumentCount != query.n_params)
    {
      seed_make_exception (ctx, exception, "ArgumentError",
			   "Signal: %s for type %s expected %u "
			   "arguments, got %zd",
			   query.signal_name,
			   g_type_name (query.itype),
			   query.n_params, argumentCount);

      return JSValueMakeNull (ctx);
    }

  params = g_new0 (GValue, argumentCount + 1);

  g_value_init (&params[0], G_TYPE_OBJECT);
  g_value_set_object (&params[0], privates->object);
  for (i = 0; i < argumentCount; i++)
    seed_value_to_gvalue (ctx, arguments[i],
			  query.param_types[i],
			  &params[i + 1], exception);


  if (query.return_type != G_TYPE_NONE)
    g_value_init (&ret_value, query.return_type);
  g_signal_emitv (params, signal_id, 0, &ret_value);

  for (i = 0; i < argumentCount; i++)
    g_value_unset (&params[i]);
  g_free (params);

  ret = seed_value_from_gvalue (ctx, &ret_value, exception);

  if (query.return_type != G_TYPE_NONE)
    g_value_unset (&ret_value);

  return ret;
}
Ejemplo n.º 5
0
static gboolean gst_vlc_video_sink_setcaps( GstBaseSink *p_basesink,
        GstCaps *p_caps )
{
    GstVlcVideoSink *p_vsink = GST_VLC_VIDEO_SINK( p_basesink );
    GstVideoInfo info;
    gboolean b_ret = FALSE;

   //FIXME caps_signal
#if 0
    GValue ret = { 0 };
    GValue args[2] = { {0}, {0} };
#endif

    if( !gst_video_info_from_caps( &info, p_caps ))
        return FALSE;

    p_vsink->vinfo = info;

    //FIXME caps_signal
#if 0
    g_value_init( &args[0], GST_TYPE_ELEMENT );
    g_value_set_object( &args[0], p_vsink );
    g_value_init( &args[1], GST_TYPE_CAPS );
    g_value_set_boxed( &args[1], p_caps );

    g_signal_emitv( args, gst_vlc_video_sink_signals[ SIGNAL_NEW_CAPS ],
            0, &b_ret );
#else
    b_ret = p_vsink->new_caps( GST_ELEMENT_CAST( p_vsink ), p_caps,
            (gpointer) p_vsink->p_dec );
#endif

    return b_ret;
}
Ejemplo n.º 6
0
static gboolean _signal_raise(gpointer user_data)
{
  _signal_param_t *params = (_signal_param_t *)user_data;
  g_signal_emitv(params->instance_and_params, params->signal_id, 0, NULL);
  for(int i = 0; i <= params->n_params; i++) g_value_unset(&params->instance_and_params[i]);
  free(params->instance_and_params);
  free(params);
  return FALSE;
}
Ejemplo n.º 7
0
static gboolean
autoar_common_g_signal_emit_main_context (void *data)
{
  AutoarCommonSignalData *signal_data = data;
  g_signal_emitv (signal_data->instance_and_params,
                  signal_data->signal_id,
                  signal_data->detail,
                  NULL);
  autoar_common_signal_data_free (signal_data);
  return FALSE;
}
Ejemplo n.º 8
0
void
gtk_signal_emitv (GtkObject *object,
		  guint      signal_id,
		  GtkArg    *args)
{
  GSignalQuery query;
  GValue params[SIGNAL_MAX_PARAMS + 1] = { { 0, }, };
  GValue rvalue = { 0, };
  guint i;
  
  g_return_if_fail (GTK_IS_OBJECT (object));
  
  g_signal_query (signal_id, &query);
  g_return_if_fail (query.signal_id != 0);
  g_return_if_fail (g_type_is_a (GTK_OBJECT_TYPE (object), query.itype));
  g_return_if_fail (query.n_params < SIGNAL_MAX_PARAMS);
  if (query.n_params > 0)
    g_return_if_fail (args != NULL);
  
  g_value_init (params + 0, GTK_OBJECT_TYPE (object));
  g_value_set_object (params + 0, G_OBJECT (object));
  for (i = 0; i < query.n_params; i++)
    {
      GValue *value = params + 1 + i;
      GtkArg *arg = args + i;
      
      g_value_init (value, arg->type & ~G_SIGNAL_TYPE_STATIC_SCOPE);
      if (!gtk_arg_static_to_value (arg, value))
	{
	  g_warning ("%s: failed to convert arg type `%s' to value type `%s'",
		     G_STRLOC, g_type_name (arg->type & ~G_SIGNAL_TYPE_STATIC_SCOPE),
		     g_type_name (G_VALUE_TYPE (value)));
	  return;
	}
    }
  if (query.return_type != G_TYPE_NONE)
    g_value_init (&rvalue, query.return_type);
  
  g_signal_emitv (params, signal_id, 0, &rvalue);
  
  if (query.return_type != G_TYPE_NONE)
    {
      gtk_argloc_set_from_value (args + query.n_params, &rvalue, TRUE);
      g_value_unset (&rvalue);
    }
  for (i = 0; i < query.n_params; i++)
    g_value_unset (params + 1 + i);
  g_value_unset (params + 0);
}
Ejemplo n.º 9
0
static void
ol_config_emit_change (OlConfig *config,
                       const char *group,
                       const char *name)
{
  int i;
  GValue params[3] = {0};
  g_value_init (&params[0], G_OBJECT_TYPE (config));
  g_value_set_object (&params[0], G_OBJECT (config));
  g_value_init (&params[1], G_TYPE_STRING);
  g_value_set_string (&params[1], group);
  g_value_init (&params[2], G_TYPE_STRING);
  g_value_set_string (&params[2], name);
  g_signal_emitv (params, OL_CONFIG_GET_CLASS (config)->signals[CHANGED],
                  0, NULL);
  for (i = 0; i < 3; i++)
    g_value_reset (&params[i]);
}
static void on_edited(GtkCellRendererText *cell, gchar *path_string,
		      gchar *new_text, GebrGuiSequenceEdit *self)
{
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreeIter iter;
	gchar *old_text;
	GValue *params;
	GValue retval = {0,};

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->tree_view));
	if (!gtk_tree_selection_get_selected(selection, &model, &iter))
		return;
	gtk_tree_model_get(GTK_TREE_MODEL(self->list_store), &iter, 0, &old_text, -1);
	
	/*false rename */
	if (!strcmp(old_text, new_text)) {
		g_free(old_text);
		return;
	}

	params = g_new0 (GValue, 3);
	g_value_init (params, G_TYPE_OBJECT);
	g_value_set_object (params, self);

	g_value_init (params+1, G_TYPE_STRING);
	g_value_set_string (params+1, old_text);

	g_value_init (params+2, G_TYPE_STRING);
	g_value_set_string (params+2, new_text);

	g_value_init (&retval, G_TYPE_BOOLEAN);
	g_value_set_boolean (&retval, TRUE);

	g_signal_emitv (params, object_signals[RENAMED], 0, &retval);

	g_free (params);

	if (g_value_get_boolean (&retval))
		GEBR_GUI_SEQUENCE_EDIT_GET_CLASS(self)->rename(self, &iter, new_text);

	g_free(old_text);
}
Ejemplo n.º 11
0
static gboolean
gst_rtp_jitter_buffer_get_clock_rate (GstRtpJitterBuffer * jitterbuffer,
    guint8 pt)
{
  GValue ret = { 0 };
  GValue args[2] = { {0}, {0} };
  GstCaps *caps;
  gboolean res;

  g_value_init (&args[0], GST_TYPE_ELEMENT);
  g_value_set_object (&args[0], jitterbuffer);
  g_value_init (&args[1], G_TYPE_UINT);
  g_value_set_uint (&args[1], pt);

  g_value_init (&ret, GST_TYPE_CAPS);
  g_value_set_boxed (&ret, NULL);

  g_signal_emitv (args, gst_rtp_jitter_buffer_signals[SIGNAL_REQUEST_PT_MAP], 0,
      &ret);

  g_value_unset (&args[0]);
  g_value_unset (&args[1]);
  caps = (GstCaps *) g_value_dup_boxed (&ret);
  g_value_unset (&ret);
  if (!caps)
    goto no_caps;

  res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps);

  gst_caps_unref (caps);

  return res;

  /* ERRORS */
no_caps:
  {
    GST_DEBUG_OBJECT (jitterbuffer, "could not get caps");
    return FALSE;
  }
}
Ejemplo n.º 12
0
static void
pfn_notify (const char *errinfo,
            const void *private_info,
            size_t cb,
            void *user_data)
{
    GValue instance_and_params[4] = { 0 };
    GopenclContext *self = GOPENCL_CONTEXT(user_data);
    GopenclContextPrivate *priv = GOPENCL_CONTEXT_GET_PRIVATE(self);

    g_value_init(&instance_and_params[0], GOPENCL_TYPE_CONTEXT);
    g_value_set_object(&instance_and_params[0], self);

    g_value_init(&instance_and_params[1], G_TYPE_STRING);
    g_value_set_string(&instance_and_params[1], errinfo);

    g_value_init(&instance_and_params[2], G_TYPE_POINTER);
    g_value_set_pointer(&instance_and_params[2], (void *) private_info);

    g_value_init(&instance_and_params[3], G_TYPE_UINT);
    g_value_set_uint(&instance_and_params[3], cb);

    g_signal_emitv(instance_and_params, signals[ERROR_OCURRED], 0, NULL);
}
Ejemplo n.º 13
0
static gboolean
activate_session (GstRDTManager * rdtmanager, GstRDTManagerSession * session,
    guint32 ssrc, guint8 pt)
{
  GstPadTemplate *templ;
  GstElementClass *klass;
  gchar *name;
  GstCaps *caps;
  GValue ret = { 0 };
  GValue args[3] = { {0}
  , {0}
  , {0}
  };

  GST_DEBUG_OBJECT (rdtmanager, "creating stream");

  session->ssrc = ssrc;
  session->pt = pt;

  /* get pt map */
  g_value_init (&args[0], GST_TYPE_ELEMENT);
  g_value_set_object (&args[0], rdtmanager);
  g_value_init (&args[1], G_TYPE_UINT);
  g_value_set_uint (&args[1], session->id);
  g_value_init (&args[2], G_TYPE_UINT);
  g_value_set_uint (&args[2], pt);

  g_value_init (&ret, GST_TYPE_CAPS);
  g_value_set_boxed (&ret, NULL);

  g_signal_emitv (args, gst_rdt_manager_signals[SIGNAL_REQUEST_PT_MAP], 0,
      &ret);

  g_value_unset (&args[0]);
  g_value_unset (&args[1]);
  g_value_unset (&args[2]);
  caps = (GstCaps *) g_value_dup_boxed (&ret);
  g_value_unset (&ret);

  if (caps)
    gst_rdt_manager_parse_caps (rdtmanager, session, caps);

  name = g_strdup_printf ("recv_rtp_src_%u_%u_%u", session->id, ssrc, pt);
  klass = GST_ELEMENT_GET_CLASS (rdtmanager);
  templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u");
  session->recv_rtp_src = gst_pad_new_from_template (templ, name);
  g_free (name);

  gst_pad_set_element_private (session->recv_rtp_src, session);
  gst_pad_set_query_function (session->recv_rtp_src, gst_rdt_manager_query_src);
  gst_pad_set_activatemode_function (session->recv_rtp_src,
      gst_rdt_manager_src_activate_mode);

  gst_pad_set_active (session->recv_rtp_src, TRUE);

  gst_pad_set_caps (session->recv_rtp_src, caps);
  gst_caps_unref (caps);

  gst_element_add_pad (GST_ELEMENT_CAST (rdtmanager), session->recv_rtp_src);

  return TRUE;
}
static GstFlowReturn
gst_rtp_dec_chain_rtp (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
    GstFlowReturn res;
    GstRTPDec *rtpdec;
    GstRTPDecSession *session;
    guint32 ssrc;
    guint8 pt;
    GstRTPBuffer rtp = { NULL, };

    rtpdec = GST_RTP_DEC (parent);

    GST_DEBUG_OBJECT (rtpdec, "got rtp packet");

    if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))
        goto bad_packet;

    ssrc = gst_rtp_buffer_get_ssrc (&rtp);
    pt = gst_rtp_buffer_get_payload_type (&rtp);
    gst_rtp_buffer_unmap (&rtp);

    GST_DEBUG_OBJECT (rtpdec, "SSRC %08x, PT %d", ssrc, pt);

    /* find session */
    session = gst_pad_get_element_private (pad);

    /* see if we have the pad */
    if (!session->active) {
        GstPadTemplate *templ;
        GstElementClass *klass;
        gchar *name;
        GstCaps *caps;
        GValue ret = { 0 };
        GValue args[3] = { {0}
            , {0}
            , {0}
        };

        GST_DEBUG_OBJECT (rtpdec, "creating stream");

        session->ssrc = ssrc;
        session->pt = pt;

        /* get pt map */
        g_value_init (&args[0], GST_TYPE_ELEMENT);
        g_value_set_object (&args[0], rtpdec);
        g_value_init (&args[1], G_TYPE_UINT);
        g_value_set_uint (&args[1], session->id);
        g_value_init (&args[2], G_TYPE_UINT);
        g_value_set_uint (&args[2], pt);

        g_value_init (&ret, GST_TYPE_CAPS);
        g_value_set_boxed (&ret, NULL);

        g_signal_emitv (args, gst_rtp_dec_signals[SIGNAL_REQUEST_PT_MAP], 0, &ret);

        caps = (GstCaps *) g_value_get_boxed (&ret);

        name = g_strdup_printf ("recv_rtp_src_%u_%u_%u", session->id, ssrc, pt);
        klass = GST_ELEMENT_GET_CLASS (rtpdec);
        templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u");
        session->recv_rtp_src = gst_pad_new_from_template (templ, name);
        g_free (name);

        gst_pad_set_caps (session->recv_rtp_src, caps);

        gst_pad_set_element_private (session->recv_rtp_src, session);
        gst_pad_set_query_function (session->recv_rtp_src, gst_rtp_dec_query_src);
        gst_pad_set_active (session->recv_rtp_src, TRUE);
        gst_element_add_pad (GST_ELEMENT_CAST (rtpdec), session->recv_rtp_src);

        session->active = TRUE;
    }

    res = gst_pad_push (session->recv_rtp_src, buffer);

    return res;

bad_packet:
    {
        GST_ELEMENT_WARNING (rtpdec, STREAM, DECODE, (NULL),
                             ("RTP packet did not validate, dropping"));
        gst_buffer_unref (buffer);
        return GST_FLOW_OK;
    }
}
Ejemplo n.º 15
0
int
main (int argc, char **argv)
{
    gint i;
    GTest *test1, *test2;
    GArray *test_threads;
    const gint n_threads = 1;

#ifdef SYMBIAN
    g_log_set_handler (NULL,  G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
    g_set_print_handler(mrtPrintHandler);
#endif /*SYMBIAN*/

    g_thread_init (NULL);

#ifndef SYMBIAN
    g_print ("START: %s\n", argv[0]);
#else

#ifdef VERBOSE
    g_print ("START: %s\n", argv[0]);
#endif

#endif /*SYMBIAN*/
    g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK));
    g_type_init ();

    test1 = g_object_new (G_TYPE_TEST, NULL);
    test2 = g_object_new (G_TYPE_TEST, NULL);

    g_signal_connect (test1, "notify::test-prop", G_CALLBACK (notify), NULL);
    g_signal_connect (test1, "test-signal1", G_CALLBACK (notify), NULL);
    g_signal_connect (test1, "test-signal2", G_CALLBACK (notify), NULL);




#ifndef SYMBIAN
    test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));

    stopping = FALSE;

    for (i = 0; i < n_threads; i++) {
        GThread *thread;

        thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL);
        g_array_append_val (test_threads, thread);

        thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL);
        g_array_append_val (test_threads, thread);
    }
    g_usleep (500000);

    stopping = TRUE;

    g_print ("\nstopping\n");

    /* join all threads */
    for (i = 0; i < 2 * n_threads; i++) {
        GThread *thread;

        thread = g_array_index (test_threads, GThread *, i);
        g_thread_join (thread);
    }

    g_print ("stopped:%d\n",TESTNUM);
#else

#ifdef MULTITHREAD

    test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
    stopping = FALSE;
    TESTNUM=1;
    notifynum=0;
    handlernum=0;
    for (i = 0; i < n_threads; i++)
    {
        GThread *thread;

        thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL);
        g_array_append_val (test_threads, thread);

        thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL);
        g_array_append_val (test_threads, thread);
    }
    g_usleep (500000);

    stopping = TRUE;

#ifdef VERBOSE
    g_print ("\nstopping\n");
#endif
    /* join all threads */
    for (i = 0; i < 2 * n_threads; i++)
    {
        GThread *thread;

        thread = g_array_index (test_threads, GThread *, i);
        g_thread_join (thread);
    }

    g_assert(notifynum != 0);
    g_assert(handlernum == 0);

    g_array_free (test_threads, TRUE);

#ifdef VERBOSE
    g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM);
#endif



    test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
    stopping = FALSE;
    TESTNUM=2;
    notifynum=0;
    handlernum=0;

    for (i = 0; i < n_threads; i++)
    {
        GThread *thread;

        thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL);
        g_array_append_val (test_threads, thread);

        thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL);
        g_array_append_val (test_threads, thread);
    }
    g_usleep (500000);

    stopping = TRUE;

#ifdef VERBOSE
    g_print ("\nstopping\n");
#endif
    /* join all threads */
    for (i = 0; i < 2 * n_threads; i++)
    {
        GThread *thread;

        thread = g_array_index (test_threads, GThread *, i);
        g_thread_join (thread);
    }

    g_assert(notifynum != 0);
    g_assert(handlernum != 0);

    g_array_free (test_threads, TRUE);

#ifdef VERBOSE
    g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM);
#endif


    test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
    stopping = FALSE;
    TESTNUM=3;
    notifynum=0;
    handlernum=0;

    for (i = 0; i < n_threads; i++)
    {
        GThread *thread;

        thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL);
        g_array_append_val (test_threads, thread);

        thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL);
        g_array_append_val (test_threads, thread);
    }
    g_usleep (5000000);

    stopping = TRUE;

#ifdef VERBOSE
    g_print ("\nstopping\n");
#endif
    /* join all threads */
    for (i = 0; i < 2 * n_threads; i++)
    {
        GThread *thread;

        thread = g_array_index (test_threads, GThread *, i);
        g_thread_join (thread);
    }

    g_assert(notifynum != 0);
    g_assert(handlernum == 0);

    g_array_free (test_threads, TRUE);

#ifdef VERBOSE
    g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM);
#endif

#else	/* ! MULTITHREAD*/


    TESTNUM=1;
#ifdef VERBOSE
    g_print ("\nStarting with TESTNUM=%d\n",TESTNUM);
#endif

    notifynum=0;
    handlernum=0;
    run_thread(test1);
    g_assert(notifynum == LOOP +1);
    g_assert(handlernum ==0);

    notifynum=0;
    handlernum=0;
    run_thread(test2);
    g_assert(notifynum == 0);
    g_assert(handlernum == 0);

    TESTNUM=2;
#ifdef VERBOSE
    g_print ("\nStarting with TESTNUM=%d\n",TESTNUM);
#endif

    notifynum=0;
    handlernum=0;
    run_thread(test1);
    g_assert(notifynum == LOOP+1);
    g_assert(handlernum == LOOP+1);

    notifynum=0;
    handlernum=0;
    run_thread(test2);
    g_assert(notifynum == 0);
    g_assert(handlernum == LOOP+1);

    TESTNUM=3;
#ifdef VERBOSE
    g_print ("\nStarting with TESTNUM=%d\n",TESTNUM);
#endif

    notifynum=0;
    handlernum=0;
    run_thread(test1);
    g_assert(notifynum == LOOP +1);
    g_assert(handlernum ==0);

    notifynum=0;
    handlernum=0;
    run_thread(test2);
    g_assert(notifynum == 0);
    g_assert(handlernum == 0);

    g_assert(g_signal_has_handler_pending(G_OBJECT(test1),g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,TRUE)==TRUE);
    g_assert(g_signal_has_handler_pending(G_OBJECT(test2),g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,TRUE)==FALSE);

    g_assert(g_signal_handler_is_connected(G_OBJECT(test1),g_signal_lookup("test-signal1",G_TYPE_TEST))==TRUE);
    g_assert(g_signal_handler_is_connected(G_OBJECT(test2),g_signal_lookup("test-signal2",G_TYPE_TEST))==FALSE);

    handlernum=g_signal_lookup("test-signal1",G_TYPE_TEST);
#ifdef VERBOSE
    g_print("Signal id: %d\n",handlernum);
#endif

    g_signal_connect (test2, "test-signal1", G_CALLBACK (notify), NULL);

    hookid=g_signal_add_emission_hook(handlernum,NULL,(GSignalEmissionHook) hook_function,NULL,NULL);

#ifdef VERBOSE
    g_print("Hookid: %d\n",hookid);
#endif
    /********************/

#ifdef TEST_STOP_EMISSION
    /*
    notifynum=0;
    handlernum=0;
    g_print("The following call stops signal emission\n");
    g_signal_stop_emission(G_OBJECT(test1),g_signal_lookup("test-signal1",G_TYPE_TEST),0);

    g_print("The following call should abort and it is normal\n");
    run_thread(test1);
    printf("Notifynum: %d and Handlernum: %d\n",notifynum,handlernum);

    */
    notifynum=0;
    handlernum=0;
    g_signal_stop_emission_by_name(G_OBJECT(test1),"test-signal1");
//run_thread(test1);
    g_print("Notifynum: %d and Handlernum: %d\n",notifynum,handlernum);


#endif /*TEST_STOP_EMISSION*/

    /*******************/


    handlernum=0;
    g_signal_emit(G_OBJECT (test1), g_test_signals[TEST_SIGNAL1], 0, 0);
    g_signal_emit(G_OBJECT (test2), g_test_signals[TEST_SIGNAL1], 0, 0);
    g_assert(handlernum==2);


    g_signal_remove_emission_hook(g_signal_lookup("test-signal1",G_TYPE_TEST),hookid);

#ifdef VERBOSE
    g_print("Emitting signal again after removing emission hook\n");
#endif

    handlernum=0;
    g_signal_emit (G_OBJECT (test1), g_test_signals[TEST_SIGNAL1], 0, 0);
    g_signal_emit (G_OBJECT (test2), g_test_signals[TEST_SIGNAL1], 0, 0);
    g_assert(handlernum==0);

    g_assert (strcmp ("test-signal1", g_signal_name (g_signal_lookup("test-signal1",G_TYPE_TEST))) == 0);
    g_assert (strcmp ("test-signal2", g_signal_name (g_signal_lookup("test-signal2",G_TYPE_TEST))) == 0);


    memset(&gv,0,sizeof(gv));
    g_value_init(&gv,G_TYPE_OBJECT);
    g_value_set_object(&gv,test1);

    gi=0;
    g_signal_list_ids(G_OBJECT_TYPE(test1),&gi);
    g_assert(g_signal_lookup("test-signal1",G_TYPE_TEST)==gi);

    notifynum=0;
    g_signal_emitv (&gv, g_test_signals[TEST_SIGNAL1], 0, &gv);
    g_assert(notifynum==1);

    g_signal_query(g_signal_lookup("test-signal1",G_TYPE_TEST),&gq);
    g_assert(strcmp("test-signal1",gq.signal_name)==0);
    g_assert(g_signal_lookup("test-signal1",G_TYPE_TEST)==gq.signal_id);


    g_assert(g_signal_handler_find(G_OBJECT(test1), G_SIGNAL_RUN_LAST,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,NULL,NULL)==2);


    notifynum=g_signal_handlers_block_matched(G_OBJECT(test1),G_SIGNAL_MATCH_FUNC,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,(gpointer)G_CALLBACK(notify),NULL);
    handlernum=g_signal_handlers_unblock_matched(G_OBJECT(test1),G_SIGNAL_MATCH_FUNC,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,(gpointer)G_CALLBACK(notify),NULL);
    g_assert(notifynum==handlernum);

#endif /*MULTITHREAD*/


#ifdef VERBOSE
    g_printf ("\nsignals-multithread.c: Completed all tests\n");
#endif

#endif /*SYMBIAN*/



#if SYMBIAN
    testResultXml("signals-singlethread");
#endif /* EMULATOR */

    return 0;
}
Ejemplo n.º 16
0
/*
 * "Adds" app window to the set of managed windows.
 * Actually, no data structures involved. The only thing we do is save app state
 * and register ourselves us listeners.
 * Note: User's callback is called
 */
void
xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
			       Window parent,
			       gboolean ignore_existing_state,
			       XklState * init_state)
{
	XklState state = *init_state;
	gint default_group_to_use = -1;
	GValue params[3];
	GValue rv;
	guint signal_id;

	if (toplevel_win == xkl_engine_priv(engine, root_window))
		xkl_debug(150, "??? root app win ???\n");

	xkl_debug(150,
		  "Trying to add window " WINID_FORMAT
		  "/%s with group %d\n", toplevel_win,
		  xkl_get_debug_window_title(engine, toplevel_win),
		  init_state->group);

	if (!ignore_existing_state) {
		gboolean have_state =
		    xkl_engine_get_toplevel_window_state(engine,
							 toplevel_win,
							 &state);

		if (have_state) {
			xkl_debug(150,
				  "The window " WINID_FORMAT
				  " does not require to be added, it already has the xklavier state \n",
				  toplevel_win);
			return;
		}
	}
	memset(params, 0, sizeof(params));
	g_value_init(params, XKL_TYPE_ENGINE);
	g_value_set_object(params, engine);
	g_value_init(params + 1, G_TYPE_LONG);
	g_value_set_long(params + 1, toplevel_win);
	g_value_init(params + 2, G_TYPE_LONG);
	g_value_set_long(params + 2, parent);

	memset(&rv, 0, sizeof(rv));
	g_value_init(&rv, G_TYPE_INT);
	g_value_set_int(&rv, default_group_to_use);

	signal_id =
	    g_signal_lookup("new-toplevel-window", xkl_engine_get_type());
	g_signal_emitv(params, signal_id, 0, &rv);
	default_group_to_use = g_value_get_int(&rv);
        
	if (default_group_to_use == -1) {
		Window transient_for = 0;
		if (XGetTransientForHint(xkl_engine_get_display(engine), toplevel_win, &transient_for)) {
			if (transient_for) {
				XklState trans_state;
				gboolean have_state =
					xkl_engine_get_toplevel_window_state(engine,
							 transient_for,
							 &trans_state);
				if (have_state) {
					default_group_to_use = trans_state.group;
				}
			}
		}
	}

	if (default_group_to_use == -1)
		default_group_to_use =
		    xkl_engine_priv(engine, default_group);

	if (default_group_to_use != -1)
		state.group = default_group_to_use;

	xkl_engine_save_toplevel_window_state(engine, toplevel_win,
					      &state);
	xkl_engine_select_input_merging(engine, toplevel_win,
					FocusChangeMask |
					PropertyChangeMask);

	if (default_group_to_use != -1) {
		if (xkl_engine_priv(engine, curr_toplvl_win) ==
		    toplevel_win) {
			if ((xkl_engine_priv(engine, secondary_groups_mask)
			     & (1 << default_group_to_use)) != 0)
				xkl_engine_allow_one_switch_to_secondary_group
				    (engine);
			xkl_engine_lock_group(engine,
					      default_group_to_use);
		}
	}

	if (parent == (Window) NULL)
		parent =
		    xkl_engine_get_registered_parent(engine, toplevel_win);

	xkl_debug(150, "done\n");
}