#include <stdbool.h>
#define ERROR_STATE -1
-#define SAFE_BUFFER_SIZE 255
+#define SAFE_BUFFER_SIZE 2048
#define CHECK_OUTPUT_WIDTH 42
#define MINIMAL_MODULE_WIDTH 3
#define ATTR_WIDTH 50
};
typedef struct _Box_Size {
+ char *x;
+ char *y;
char *height;
char *width;
} Box_Size;
static void _print_module_legend()
{
- printf("\n[[node role name],[attributes list],[width,height],[node name],[states list]]\n\n");
+ printf("\n[[node],[node role name],[attributes list],[x,y,width,height],[node name],[states list][flow to node, flow from node]\n\n");
}
static void _print_atspi_states_legend()
if (box_size == NULL)
return NULL;
+ char *x = NULL;
+ char *y = NULL;
char *width = NULL;
char *height = NULL;
- _combine_strings(&width, "_");
- _combine_strings(&height, "_");
-
- box_size->width = width;
- box_size->height = height;
-
AtspiComponent *component = atspi_accessible_get_component_iface(node);
+ AtspiRect *extent = component ? atspi_component_get_extents(component, ATSPI_COORD_TYPE_SCREEN, NULL) : NULL;
- if (component == NULL)
- return box_size;
-
- AtspiRect *extent = atspi_component_get_extents(component, ATSPI_COORD_TYPE_SCREEN, NULL);
- if (extent == NULL)
- return box_size;
+ if (extent == NULL) {
+ _combine_strings(&x, "_");
+ _combine_strings(&y, "_");
+ _combine_strings(&width, "_");
+ _combine_strings(&height, "_");
+ } else {
+ char temp_buff[NUMBER_WIDTH];
- *width = '\0';
- *height = '\0';
+ snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->x);
+ _combine_strings(&x, temp_buff);
- char temp_buff[NUMBER_WIDTH];
+ snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->y);
+ _combine_strings(&y, temp_buff);
- snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->width);
- _combine_strings(&width, temp_buff);
+ snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->width);
+ _combine_strings(&width, temp_buff);
- snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->height);
- _combine_strings(&height, temp_buff);
+ snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->height);
+ _combine_strings(&height, temp_buff);
- g_object_unref(component);
- g_free(extent);
+ g_object_unref(component);
+ g_free(extent);
+ }
+ box_size->x = x;
+ box_size->y = y;
box_size->width = width;
box_size->height = height;
return box_size;
}
-static char *_get_states(AtspiAccessible *node)
+static char *_get_states(AtspiAccessible *node, int length_limit)
{
AtspiStateSet *node_state_set = atspi_accessible_get_state_set(node);
GArray *states = atspi_state_set_get_states(node_state_set);
g_array_free(states, 0);
g_object_unref(node_state_set);
+ _truncate_string(state_string, length_limit);
+
return state_string;
}
-static char *_get_attributes(AtspiAccessible *node)
+static char *_get_attributes(AtspiAccessible *node, int length_limit)
{
- GHashTable *attributes = NULL;
- attributes = atspi_accessible_get_attributes(node, NULL);
+ GHashTable *attributes = atspi_accessible_get_attributes(node, NULL);
if (!attributes)
return NULL;
char *result = NULL;
while (g_hash_table_iter_next (&attributes_iter, &attr_key, &attr_value)) {
char attributes_string[ATTR_WIDTH];
- int ret = snprintf(attributes_string, ATTR_WIDTH, "(%s=%s)", (char*)attr_key, (char*)attr_value);
- if (ret >= ATTR_WIDTH) {
- fprintf(stderr, "_get_attributes: generated string is too long. Buffer overflow");
- abort();
- }
+ int ret = snprintf(attributes_string, ATTR_WIDTH, "(%s=%s)", (char *)attr_key, (char *)attr_value);
+ if (ret >= ATTR_WIDTH)
+ fprintf(stderr, "\n_get_attributes: generated string is too long. Buffer overflow\n");
+
_combine_strings(&result, attributes_string);
}
g_hash_table_unref(attributes);
+ _truncate_string(result, length_limit);
return result;
}
+static char *_get_object_in_relation(AtspiAccessible *source, AtspiRelationType search_type)
+{
+ if (source == NULL)
+ return "";
+
+ GArray *relations = atspi_accessible_get_relation_set(source, NULL);
+
+ if (relations == NULL)
+ return "";
+
+ AtspiAccessible *ret = NULL;
+ for (int i = 0; i < relations->len; ++i) {
+ AtspiRelation *relation = g_array_index(relations, AtspiRelation *, i);
+ AtspiRelationType type = atspi_relation_get_relation_type(relation);
+
+ if (type == search_type) {
+ ret = atspi_relation_get_target(relation, 0);
+ break;
+ }
+ }
+
+ g_array_free(relations, TRUE);
+
+ return ret ? atspi_accessible_get_path(ret, NULL) : g_strdup("");
+}
+
static char *_get_info(AtspiAccessible *node, int length_limit)
{
if (!node)
char *node_name = atspi_accessible_get_name(node, NULL);
char *node_role_name = atspi_accessible_get_role_name(node, NULL);
+ char *path = atspi_accessible_get_path(node, NULL);
- char *attributes = _get_attributes(node);
- _truncate_string(attributes, length_limit);
+ char *attributes = _get_attributes(node, length_limit);
Box_Size *box_size = _get_box_size(node);
- char *states = _get_states(node);
- _truncate_string(states, length_limit);
+ char *states = _get_states(node, length_limit);
char result[SAFE_BUFFER_SIZE];
- int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s,%s],[%s],[%s]]",
- node_role_name,
- attributes,
- box_size->width,
- box_size->height,
- node_name,
- states);
-
- if (ret >= SAFE_BUFFER_SIZE) {
- fprintf(stderr, "_get_info: generated string is too long. Buffer overflow");
- abort();
- }
+ int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%s,%s]]",
+ path,
+ node_role_name,
+ attributes,
+ box_size->x,
+ box_size->y,
+ box_size->width,
+ box_size->height,
+ node_name,
+ states,
+ _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO),
+ _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM));
+
+ if (ret >= SAFE_BUFFER_SIZE)
+ fprintf(stderr, "\n%s, %s %s: generated string is too long. Buffer overflow\n", __FILE__, __FUNCTION__, __LINE__);
free(node_name);
free(node_role_name);
else
snprintf(parent_status, NUMBER_WIDTH, "%d", parent_index);
- snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%p,%p>]", parent_candidate_index, parent_status, parent_candidate, parent);
+ snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%s,%s>]", parent_candidate_index, parent_status,
+ atspi_accessible_get_path(parent_candidate, NULL),
+ atspi_accessible_get_path(parent, NULL));
} else {
snprintf(output, CHECK_OUTPUT_WIDTH, "[OK]");
bool app_name_matched = false;
for (int i = 0; i < count; i++) {
AtspiAccessible *child = atspi_accessible_get_child_at_index(desktop, i, NULL);
- if (child) {
- char *name = atspi_accessible_get_name(child, NULL);
+ if (child == NULL) {
+ fprintf(stderr, "\n%s, %s %s: Null child occured. Results may be misleading.\n", __FILE__, __FUNCTION__, __LINE__);
+ continue;
+ }
+
+ char *name = atspi_accessible_get_name(child, NULL);
+
+ if (!dump && !check)
+ printf("%s\n", name);
- if (!dump && !check) {
- printf("%s\n", name);
- }
+ if ((check || dump) && name && !strcmp(name, app_name)) {
+ app_name_matched = true;
- if ((check || dump) && name && !strcmp(name, app_name)) {
- app_name_matched = true;
+ _print_module_legend();
- _print_module_legend();
+ if (check)
+ _test_atspi_parent_child_relation(child, desktop, i);
- if (check)
- _test_atspi_parent_child_relation(child, desktop, i);
+ _print_atspi_tree_verify_maybe_r(0, child, check, length_limit);
- _print_atspi_tree_verify_maybe_r(0, child, check, length_limit);
+ if (first_match) {
+ free(name);
+ break;
+ } else
+ printf("\n");
- if (first_match) {
- free(name);
- break;
- } else
- printf("\n");
- }
free(name);
}
}