Example #1
0
/**
 * AccessibleEvent_getSourceName:
 * @e: an #AccessibleEvent to be queried. 
 *
 * Get the 'accessible-name' of the object emitting the event.
 *
 * Returns: The name of the event source, or NULL if the event source cannot be identified
 *          or does not report a name.
 */
char*        AccessibleEvent_getSourceName (const AccessibleEvent *e)
{
  if (e && e->source)
    {
      return Accessible_getName (e->source);
    }
  return NULL;
}
static void
control_spi_listener_build_actions_list (ControlSpiListener *listener, Accessible *parent, int depth)
{
    Accessible* child;
    AccessibleRole role;

    int i, child_count;

    if (depth > SEARCH_DEPTH)
        return;

    child_count = Accessible_getChildCount (parent);

    child_count = MIN (child_count, SEARCH_BREADTH);

    for (i = 0; i < child_count; ++i) {
        char *name;
        char *normalized_name;

        child = Accessible_getChildAtIndex (parent, i);

        if (child == parent)
            continue;

        name = Accessible_getName (child);

#if DEBUG
        {
            gchar *role_name;

            role_name = Accessible_getRoleName (child);
            g_message ("Looking at %s %s", role_name, name);
        }
#endif

        if (name) {
            normalized_name = control_spi_listener_normalize (name);
            if (normalized_name && strlen(normalized_name) > 0 && is_actionable (child)) {
                AccessibleItem *item;

                item = g_new0(AccessibleItem, 1);
                Accessible_ref (child);
                item->accessible = child;
                item->name = g_strdup (normalized_name);

                listener->actions = g_slist_append (listener->actions, item);
            }
            SPI_freeString (name);
            g_free (normalized_name);
        }

        if (is_worth_searching (child))
            control_spi_listener_build_actions_list (listener, child, depth+1);

        Accessible_unref (child);
    }
}
Example #3
0
static void check_for_matching_frame( Driver* dp, Accessible* accessible ) {
    int role = Accessible_getRole( accessible );
    if ( role == SPI_ROLE_FRAME ) {
        char* frame_name = Accessible_getName( accessible );
        if ( strcmp(frame_name, dp->application_title) == 0 ) {
            dp->frame = accessible;
            dp->found_application = TRUE;
        }
        SPI_freeString( frame_name );
    }
}
Example #4
0
static gboolean
eval_func (Accessible *a, gpointer data)
{
    gboolean found;
    char *name;

    name = Accessible_getName (a);
    found = g_str_equal (name, "Window List");
    SPI_freeString (name);

    return found;
}
Example #5
0
static void
log_accessible (EventLog *log, Accessible *accessible)
{
	GtkTextTag *tag;
	GtkTextIter iter;
	char *text, *name, *descr, *short_descr;
	char *role_name, *ifaces;

	if (!accessible) {
		log_message (log, "<Null>");
		return;
	}

	tag = gtk_text_buffer_create_tag (log->log_text, NULL, 
					  "foreground", "blue", 
					  "underline", PANGO_UNDERLINE_SINGLE, 
					  NULL);
	Accessible_ref (accessible);
	g_object_set_data_full (G_OBJECT (tag), "accessible", accessible,
				(GDestroyNotify) Accessible_unref );

	ifaces = accessible_get_iface_string (accessible);
	role_name = Accessible_getRoleName (accessible);
	name = Accessible_getName (accessible);
	descr = Accessible_getDescription (accessible);
	short_descr = ellipsize (descr);

	/* FIXME: nice mangled printout of supported interfaces ? */
	text = g_strdup_printf ("%s:%s:%s:%s",
				ifaces,
				role_name ? role_name : "--",
				name ? name : "--",
				short_descr ? short_descr : "--");

	gtk_text_buffer_get_end_iter (log->log_text, &iter);
	gtk_text_buffer_insert_with_tags (log->log_text, &iter, text, -1, tag, NULL);

	g_free (text);
	g_free (short_descr);
	SPI_freeString (descr);
	SPI_freeString (name);
	SPI_freeString (role_name);
	g_free (ifaces);

	log_track_end (log);
}
Example #6
0
static void
report_leaked_ref (gpointer key, gpointer val, gpointer user_data)
{
  char *name, *role;
  Accessible *a = (Accessible *) val;
  
  name = Accessible_getName (a);
  if (cspi_exception ())
    {
      name = NULL;
    }

  role = Accessible_getRoleName (a);
  if (cspi_exception ())
    {
      role = NULL;
    }

  fprintf (stderr, "leaked %d references to object %s, role %s %p\n",
	   a->ref_count, name ? name : "<?>", role ? role : "<?>", a);

  SPI_freeString (name);
}
static void
validate_accessible (Accessible *accessible,
		     gboolean    has_parent,
		     gboolean    recurse_down)
{
	Accessible          *tmp;
	char                *name, *descr;
	AccessibleRole       role;
	AccessibleRelation **relations;
	char                *role_name;
	GString             *item_str = g_string_new ("");
	int                  i;

	name = Accessible_getName (accessible);
	g_assert (name != NULL);
	
	descr = Accessible_getDescription (accessible);
	g_assert (descr != NULL);

	role = Accessible_getRole (accessible);
	g_assert (role != SPI_ROLE_INVALID);
	role_name = Accessible_getRoleName (accessible);
	g_assert (role_name != NULL);

	relations = Accessible_getRelationSet (accessible);
	g_assert (relations != NULL);

	for (i = 0; relations [i]; i++) {
		AccessibleRelationType type;
		int                    targets;

		fprintf (stderr, "relation %d\n", i);

		type = AccessibleRelation_getRelationType (relations [i]);
		g_assert (type != SPI_RELATION_NULL);

		targets = AccessibleRelation_getNTargets (relations [i]);
		g_assert (targets != -1);

		AccessibleRelation_unref (relations [i]);
		relations [i] = NULL;
	}
	free (relations);

	if (print_tree) {
		int i;

		for (i = 0; i < print_tree_depth; i++)
			fputc (' ', stderr);
		fputs ("|-> [ ", stderr);
	}

	if (Accessible_isAction (accessible)) {
		tmp = Accessible_getAction (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "At");
		else
			test_action (tmp);
		AccessibleAction_unref (tmp);
	}

	if (Accessible_isApplication (accessible)) {
		tmp = Accessible_getApplication (accessible);
		if (print_tree)
			fprintf (stderr, "Ap");
		else
			test_application (tmp);
		AccessibleApplication_unref (tmp);
	}

	if (Accessible_isComponent (accessible)) {
		tmp = Accessible_getComponent (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Co");
		else
			test_component (tmp);
		AccessibleComponent_unref (tmp);
	}

	if (Accessible_isEditableText (accessible)) {
		tmp = Accessible_getEditableText (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Et");
		else
			test_editable_text (tmp);
		AccessibleEditableText_unref (tmp);
	}

	if (Accessible_isHypertext (accessible)) {
		tmp = Accessible_getHypertext (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Ht");
		AccessibleHypertext_unref (tmp);
	}

	if (Accessible_isImage (accessible)) {
		tmp = Accessible_getImage (accessible);
		g_assert (tmp != NULL);
		if (print_tree) {
			char *desc;

			fprintf (stderr, "Im");

			desc = AccessibleImage_getImageDescription (tmp);
			g_string_append_printf (
				item_str, " image descr: '%s'", desc);
			SPI_freeString (desc);
		} else
			test_image (tmp);

		AccessibleImage_unref (tmp);
	}

	if (Accessible_isSelection (accessible)) {
		tmp = Accessible_getSelection (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Se");
		AccessibleSelection_unref (tmp);
	}

	if (Accessible_isTable (accessible)) {
		tmp = Accessible_getTable (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Ta");
		else
			test_table (tmp);
		AccessibleTable_unref (tmp);
	}

	if (Accessible_isText (accessible)) {
		tmp = Accessible_getText (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Te");
		else {
			if (strcmp (name, TEST_STRING_A_OBJECT) == 0)	
				test_text (tmp);
		}
		AccessibleText_unref (tmp);
	}

	if (Accessible_isValue (accessible)) {
		tmp = Accessible_getValue (accessible);
		g_assert (tmp != NULL);
		if (print_tree)
			fprintf (stderr, "Va");
		else
			test_value (tmp); 
		AccessibleValue_unref (tmp);
	}

	if (print_tree)
		fprintf (stderr, " ] '%s' (%s) - %s: %s\n",
			 name, descr, role_name, item_str->str);

	SPI_freeString (name);
	SPI_freeString (descr);
	SPI_freeString (role_name);
	g_string_free (item_str, TRUE);

	validate_tree (accessible, has_parent, recurse_down);
}
char * windows_name ( SQByteArray * _pointer )
{
   Accessible * accessibleObject;
   accessibleObject = windows_to_accessible(_pointer);
   return windows_string ( Accessible_getName ( accessibleObject ) );
}