Пример #1
0
static void
print_element_signals (GstElement * element, gint pfx)
{
  guint *signals;
  guint nsignals;
  gint i, k;
  GSignalQuery *query;

  signals = g_signal_list_ids (G_OBJECT_TYPE (element), &nsignals);
  for (k = 0; k < 2; k++) {
    gint counted = 0;

    if (k == 0)
      PUT_START_TAG (pfx, "element-signals");
    else
      PUT_START_TAG (pfx, "element-actions");

    for (i = 0; i < nsignals; i++) {
      gint n_params;
      GType return_type;
      const GType *param_types;
      gint j;

      query = g_new0 (GSignalQuery, 1);
      g_signal_query (signals[i], query);

      if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
          (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
        n_params = query->n_params;
        return_type = query->return_type;
        param_types = query->param_types;

        PUT_START_TAG (pfx + 1, "signal");
        PUT_ESCAPED (pfx + 2, "name", query->signal_name);
        PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type));
        PUT_ESCAPED (pfx + 2, "object-type",
            g_type_name (G_OBJECT_TYPE (element)));

        PUT_START_TAG (pfx + 2, "params");
        for (j = 0; j < n_params; j++) {
          PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j]));
        }

        PUT_END_TAG (pfx + 2, "params");

        PUT_END_TAG (pfx + 1, "signal");

        counted++;
      }

      g_free (query);
    }
    if (k == 0)
      PUT_END_TAG (pfx, "element-signals");
    else
      PUT_END_TAG (pfx, "element-actions");
  }
}
Пример #2
0
void connect_signals (gpointer obj)
{
    guint i, n_ids = 0;
    guint *ids = NULL;
    GType type = G_OBJECT_TYPE (obj);

    ids = g_signal_list_ids (type, &n_ids);
    for (i = 0; i < n_ids; i++) {
        const gchar *name = g_signal_name (ids[i]);
        g_signal_connect (obj, name, G_CALLBACK (signaled), (gpointer)name);
    }
}
Пример #3
0
static void
do_msg_reuse_test (void)
{
	SoupSession *session;
	SoupMessage *msg;
	SoupURI *uri;
	guint *signal_ids, n_signal_ids;

	debug_printf (1, "\nSoupMessage reuse\n");

	signal_ids = g_signal_list_ids (SOUP_TYPE_MESSAGE, &n_signal_ids);

	session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL);
	g_signal_connect (session, "authenticate",
			  G_CALLBACK (reuse_test_authenticate), NULL);

	debug_printf (1, "  First message\n");
	msg = soup_message_new_from_uri ("GET", base_uri);
	soup_session_send_message (session, msg);
	ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);

	debug_printf (1, "  Redirect message\n");
	uri = soup_uri_new_with_base (base_uri, "/redirect");
	soup_message_set_uri (msg, uri);
	soup_uri_free (uri);
	soup_session_send_message (session, msg);
	if (!soup_uri_equal (soup_message_get_uri (msg), base_uri)) {
		debug_printf (1, "    Message did not get redirected!\n");
		errors++;
	}
	ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);

	debug_printf (1, "  Auth message\n");
	uri = soup_uri_new_with_base (base_uri, "/auth");
	soup_message_set_uri (msg, uri);
	soup_uri_free (uri);
	soup_session_send_message (session, msg);
	if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
		debug_printf (1, "    Message did not get authenticated!\n");
		errors++;
	}
	ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);

	/* One last try to make sure the auth stuff got cleaned up */
	debug_printf (1, "  Last message\n");
	soup_message_set_uri (msg, base_uri);
	soup_session_send_message (session, msg);
	ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);

	soup_test_session_abort_unref (session);
	g_object_unref (msg);
	g_free (signal_ids);
}
Пример #4
0
static void
plugin_connect_action (GigglePlugin *plugin,
		       GtkAction    *action)
{
	guint        *signals, n_signals, i;
	GSignalQuery  query;

	signals = g_signal_list_ids (G_OBJECT_TYPE (action), &n_signals);

	for (i = 0; i < n_signals; ++i) {
		g_signal_query (signals[i], &query);

		if (G_TYPE_NONE != query.return_type || query.n_params > 0)
			continue;

		g_signal_connect (action, query.signal_name,
				  G_CALLBACK (plugin_action_cb), plugin);
	}

	g_free (signals);
}
Пример #5
0
static void
process_signals (GType type)
{
    guint i, n_signals, *signal_ids;
    char *camel;

    comma = TRUE;
    if (type == GTK_TYPE_WIDGET) {
        g_print ("%sSignals = ", g_type_name (type));
        comma = FALSE;
    } else {
        g_print ("%sSignals = %sSignals", g_type_name (type), g_type_name (g_type_parent (type)));
    }
    signal_ids = g_signal_list_ids (type, &n_signals);
    for (i = 0; i < n_signals; i++) {
        camel = camel_case (g_signal_name (signal_ids[i]));
        g_print ("%sattribute on%s { text }?", COMMA, camel);
        g_free (camel);
        comma = TRUE;
    }
    g_free (signal_ids);
}
static PHP_METHOD(php_midgard_reflection_class, listSignals)
{
	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	_GET_RC_CE;

	if (ce == NULL)
		return;

	array_init(return_value);

	GType classtype = g_type_from_name(php_class_name_to_g_class_name(ce->name));

	if (!classtype) {
		return;
	}


	guint n_ids = 0;
	guint *ids = g_signal_list_ids(classtype, &n_ids);

	if (ids == NULL) {
		return;
	}

	size_t i;
	for (i = 0; i < n_ids; i++) {

		zval *signalname;
		MAKE_STD_ZVAL(signalname);
		ZVAL_STRING(signalname, (char *) g_signal_name(ids[i]), 1);
		zend_hash_next_index_insert(HASH_OF(return_value), &signalname, sizeof(zval *), NULL);
	}

	g_free(ids);
}
Пример #7
0
static void
print_signal_info (GstElement * element)
{
  /* Signals/Actions Block */
  guint *signals;
  guint nsignals;
  gint i = 0, j, k;
  GSignalQuery *query = NULL;
  GType type;
  GSList *found_signals, *l;

  for (k = 0; k < 2; k++) {
    found_signals = NULL;

    /* For elements that have sometimes pads, also list a few useful GstElement
     * signals. Put these first, so element-specific ones come later. */
    if (k == 0 && has_sometimes_template (element)) {
      query = g_new0 (GSignalQuery, 1);
      g_signal_query (g_signal_lookup ("pad-added", GST_TYPE_ELEMENT), query);
      found_signals = g_slist_append (found_signals, query);
      query = g_new0 (GSignalQuery, 1);
      g_signal_query (g_signal_lookup ("pad-removed", GST_TYPE_ELEMENT), query);
      found_signals = g_slist_append (found_signals, query);
      query = g_new0 (GSignalQuery, 1);
      g_signal_query (g_signal_lookup ("no-more-pads", GST_TYPE_ELEMENT),
          query);
      found_signals = g_slist_append (found_signals, query);
    }

    for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
      if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
        break;

      if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
        continue;

      signals = g_signal_list_ids (type, &nsignals);
      for (i = 0; i < nsignals; i++) {
        query = g_new0 (GSignalQuery, 1);
        g_signal_query (signals[i], query);

        if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
            (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
          found_signals = g_slist_append (found_signals, query);
        else
          g_free (query);
      }
      g_free (signals);
      signals = NULL;
    }

    if (found_signals) {
      n_print ("\n");
      if (k == 0)
        n_print ("Element Signals:\n");
      else
        n_print ("Element Actions:\n");
    } else {
      continue;
    }

    for (l = found_signals; l; l = l->next) {
      gchar *indent;
      const gchar *pmark;
      int indent_len;

      query = (GSignalQuery *) l->data;
      indent_len = strlen (query->signal_name) +
          strlen (g_type_name (query->return_type)) + 24;


      if (query->return_type == G_TYPE_POINTER) {
        pmark = "";
      } else if (G_TYPE_FUNDAMENTAL (query->return_type) == G_TYPE_POINTER
          || G_TYPE_IS_BOXED (query->return_type)
          || G_TYPE_IS_OBJECT (query->return_type)) {
        pmark = "* ";
        indent_len += 2;
      } else {
        pmark = "";
      }

      indent = g_new0 (gchar, indent_len + 1);
      memset (indent, ' ', indent_len);

      n_print ("  \"%s\" :  %s %suser_function (%s* object",
          query->signal_name, g_type_name (query->return_type), pmark,
          g_type_name (type));

      for (j = 0; j < query->n_params; j++) {
        g_print (",\n");
        if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
          n_print ("%s%s arg%d", indent,
              g_type_name (query->param_types[j]), j);
        } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
          n_print ("%s%s arg%d", indent,
              g_type_name (query->param_types[j]), j);
        } else {
          n_print ("%s%s* arg%d", indent,
              g_type_name (query->param_types[j]), j);
        }
      }

      if (k == 0) {
        g_print (",\n");
        n_print ("%sgpointer user_data);\n", indent);
      } else
        g_print (");\n");

      g_free (indent);
    }

    if (found_signals) {
      g_slist_foreach (found_signals, (GFunc) g_free, NULL);
      g_slist_free (found_signals);
    }
  }
}
Пример #8
0
std::string
get_signals(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
{
  std::string strResult;
  std::string strObjectName = g_type_name(gtype);

  gpointer gclass_ref = nullptr;
  gpointer ginterface_ref = nullptr;

  if (G_TYPE_IS_OBJECT(gtype))
    gclass_ref = g_type_class_ref(gtype); // Ensures that class_init() is called.
  else if (G_TYPE_IS_INTERFACE(gtype))
    ginterface_ref = g_type_default_interface_ref(gtype); // install signals.

  // Get the list of signals:
  guint iCount = 0;
  guint* pIDs = g_signal_list_ids(gtype, &iCount);

  // Loop through the list of signals:
  if (pIDs)
  {
    for (guint i = 0; i < iCount; i++)
    {
      guint signal_id = pIDs[i];

      // Name:
      std::string strName = g_signal_name(signal_id);
      strResult += "(define-signal " + strName + "\n";
      strResult += "  (of-object \"" + strObjectName + "\")\n";

      // Other information about the signal:
      GSignalQuery signalQuery = {
        0, nullptr, 0, GSignalFlags(0), 0, 0, nullptr,
      };
      g_signal_query(signal_id, &signalQuery);

      // Return type:
      std::string strReturnTypeName =
        get_type_name_signal(signalQuery.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE,
          is_a_pointer_func); // The type is mangled with a flag. Hacky.
      // bool bReturnTypeHasStaticScope = (signalQuery.return_type & G_SIGNAL_TYPE_STATIC_SCOPE) ==
      // G_SIGNAL_TYPE_STATIC_SCOPE;
      strResult += "  (return-type \"" + strReturnTypeName + "\")\n";

      // Flags:
      std::string strFlags;
      add_signal_flag_if(strFlags, "Run First", signalQuery, G_SIGNAL_RUN_FIRST);
      add_signal_flag_if(strFlags, "Run Last", signalQuery, G_SIGNAL_RUN_LAST);
      add_signal_flag_if(strFlags, "Run Cleanup", signalQuery, G_SIGNAL_RUN_CLEANUP);
      add_signal_flag_if(strFlags, "No Recurse", signalQuery, G_SIGNAL_NO_RECURSE);
      add_signal_flag_if(strFlags, "Action", signalQuery, G_SIGNAL_ACTION);
      add_signal_flag_if(strFlags, "No Hooks", signalQuery, G_SIGNAL_NO_HOOKS);
      add_signal_flag_if(strFlags, "Must Collect", signalQuery, G_SIGNAL_MUST_COLLECT);
      strResult += "  (flags \"" + strFlags + "\")\n";

      if (signalQuery.signal_flags & G_SIGNAL_DETAILED)
        strResult += "  (detailed #t)\n"; // Default: not detailed

      if (signalQuery.signal_flags & G_SIGNAL_DEPRECATED)
        strResult += "  (deprecated #t)\n"; // Default: not deprecated

      // Loop through the list of parameters:
      const GType* pParameters = signalQuery.param_types;
      if (pParameters)
      {
        strResult += "  (parameters\n";

        for (unsigned j = 0; j < signalQuery.n_params; j++)
        {
          GType typeParamMangled = pParameters[j];

          // Parameter name:
          // We can't get the real parameter name from the GObject system. It's not registered with
          // g_signal_new().
          gchar* pchNum = g_strdup_printf("%d", j);
          std::string strParamName = "p" + std::string(pchNum);
          g_free(pchNum);
          pchNum = nullptr;

          // Just like above, for the return type:
          std::string strTypeName =
            get_type_name_signal(typeParamMangled & ~G_SIGNAL_TYPE_STATIC_SCOPE,
              is_a_pointer_func); // The type is mangled with a flag. Hacky.
          // bool bTypeHasStaticScope = (typeParamMangled & G_SIGNAL_TYPE_STATIC_SCOPE) ==
          // G_SIGNAL_TYPE_STATIC_SCOPE;

          strResult += "    '(\"" + strTypeName + "\" \"" + strParamName + "\")\n";
        }

        strResult += "  )\n"; // close (parameters
      }

      strResult += ")\n\n"; // close (define-signal
    }
  }

  g_free(pIDs);

  if (gclass_ref)
    g_type_class_unref(gclass_ref); // to match the g_type_class_ref() above.
  else if (ginterface_ref)
    g_type_default_interface_unref(ginterface_ref); // for interface ref above.

  return strResult;
}
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;
}
Пример #10
0
static void
print_signal_info (GstElement * element)
{
  /* Signals/Actions Block */
  guint *signals;
  guint nsignals;
  gint i = 0, j, k;
  GSignalQuery *query = NULL;
  GType type;
  GSList *found_signals, *l;

  for (k = 0; k < 2; k++) {
    found_signals = NULL;
    for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
      if (type == GST_TYPE_ELEMENT || type == GST_TYPE_OBJECT)
        break;

      if (type == GST_TYPE_BIN && G_OBJECT_TYPE (element) != GST_TYPE_BIN)
        continue;

      signals = g_signal_list_ids (type, &nsignals);
      for (i = 0; i < nsignals; i++) {
        query = g_new0 (GSignalQuery, 1);
        g_signal_query (signals[i], query);

        if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
            (k == 1 && (query->signal_flags & G_SIGNAL_ACTION)))
          found_signals = g_slist_append (found_signals, query);
        else
          g_free (query);
      }
      g_free (signals);
      signals = NULL;
    }

    if (found_signals) {
      n_print ("\n");
      if (k == 0)
        n_print ("Element Signals:\n");
      else
        n_print ("Element Actions:\n");
    } else {
      continue;
    }

    for (l = found_signals; l; l = l->next) {
      gchar *indent;
      int indent_len;

      query = (GSignalQuery *) l->data;
      indent_len = strlen (query->signal_name) +
          strlen (g_type_name (query->return_type)) + 24;

      indent = g_new0 (gchar, indent_len + 1);
      memset (indent, ' ', indent_len);

      n_print ("  \"%s\" :  %s user_function (%s* object",
          query->signal_name,
          g_type_name (query->return_type), g_type_name (type));

      for (j = 0; j < query->n_params; j++) {
        if (_name)
          g_print ("%s", _name);
        if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) {
          g_print (",\n%s%s arg%d", indent,
              g_type_name (query->param_types[j]), j);
        } else if (G_TYPE_IS_ENUM (query->param_types[j])) {
          g_print (",\n%s%s arg%d", indent,
              g_type_name (query->param_types[j]), j);
        } else {
          g_print (",\n%s%s* arg%d", indent,
              g_type_name (query->param_types[j]), j);
        }
      }

      if (k == 0) {
        if (_name)
          g_print ("%s", _name);
        g_print (",\n%sgpointer user_data);\n", indent);
      } else
        g_print (");\n");

      g_free (indent);
    }

    if (found_signals) {
      g_slist_foreach (found_signals, (GFunc) g_free, NULL);
      g_slist_free (found_signals);
    }
  }
}