//#define TEXT_GENERAL //#define TEXT_ATTRIBUTES //#define TEXT_BOUNDARY //#define TEXT_SELECTIONS //#define TEXT_COORD //#define TEXT_COORD_ALL #define TEXT //#define STATE //#define TYPE //#define TREE //#define APP_TREE //#define TOOLKIT //#define VALUE //#define SELECTION //#define COMPONENT //#define DESKTOP //#define RELATION //#define TABLE_LINE #define EVENT_DETAILS //#define PARENT_LINE //#define HYPERTEXT //#define ACTION #define GENERAL #define SKIP_EVENT #define REENTRANCY #define TREE_MAX_DIST 4 #include #include #include #include #include #include #include #include #include static void report_event (const AccessibleEvent *event, void *user_data); static AccessibleEventListener *mouse_listener; static AccessibleEventListener *focus_listener; static AccessibleEventListener *property_listener; static AccessibleEventListener *property_listener_name; static AccessibleEventListener *property_listener_description; static AccessibleEventListener *property_listener_parent; static AccessibleEventListener *property_listener_value; static AccessibleEventListener *property_listener_role; static AccessibleEventListener *property_listener_table_caption; static AccessibleEventListener *property_listener_table_column_description; static AccessibleEventListener *property_listener_table_cloumn_header; static AccessibleEventListener *property_listener_table_row_description; static AccessibleEventListener *property_listener_table_row_header; static AccessibleEventListener *property_listener_table_summary; static AccessibleEventListener *object_listener; static AccessibleEventListener *object_listener_state; static AccessibleEventListener *object_listener_children; static AccessibleEventListener *object_listener_data; static AccessibleEventListener *object_listener_selection; static AccessibleEventListener *object_listener_active_descendant; static AccessibleEventListener *object_listener_text_selection; static AccessibleEventListener *object_listener_text_changed_insert; static AccessibleEventListener *object_listener_text_changed_delete; static AccessibleEventListener *object_listener_caret; static AccessibleEventListener *object_listener_row_inserted; static AccessibleEventListener *object_listener_row_reordered; static AccessibleEventListener *object_listener_row_deleted; static AccessibleEventListener *object_listener_column_inserted; static AccessibleEventListener *object_listener_column_reordered; static AccessibleEventListener *object_listener_column_deleted; static AccessibleEventListener *object_listener_model; static AccessibleEventListener *window_listener; static AccessibleEventListener *window_listener_minimize; static AccessibleEventListener *window_listener_maximize; static AccessibleEventListener *window_listener_restore; static AccessibleEventListener *window_listener_close; static AccessibleEventListener *window_listener_create; static AccessibleEventListener *window_listener_reparent; static AccessibleEventListener *window_listener_desktop_create; static AccessibleEventListener *window_listener_desktop_destroy; static AccessibleEventListener *window_listener_focus_in; static AccessibleEventListener *window_listener_focus_out; static AccessibleEventListener *window_listener_raise; static AccessibleEventListener *window_listener_lower; static AccessibleEventListener *window_listener_move; static AccessibleEventListener *window_listener_resize; static AccessibleEventListener *window_listener_shade; static AccessibleEventListener *window_listener_unshade; static AccessibleEventListener *window_listener_restyle; int main(int argc, char **argv) { SPI_init(); mouse_listener = SPI_createAccessibleEventListener (report_event, NULL); focus_listener = SPI_createAccessibleEventListener (report_event, NULL); property_listener = SPI_createAccessibleEventListener (report_event, NULL); property_listener_name = SPI_createAccessibleEventListener (report_event, NULL); property_listener_description = SPI_createAccessibleEventListener (report_event, NULL); property_listener_parent = SPI_createAccessibleEventListener (report_event, NULL); property_listener_value = SPI_createAccessibleEventListener (report_event, NULL); property_listener_role = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_caption = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_column_description = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_cloumn_header = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_row_description = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_row_header = SPI_createAccessibleEventListener (report_event, NULL); property_listener_table_summary = SPI_createAccessibleEventListener (report_event, NULL); object_listener = SPI_createAccessibleEventListener (report_event, NULL); object_listener_state = SPI_createAccessibleEventListener (report_event, NULL); object_listener_children = SPI_createAccessibleEventListener (report_event, NULL); object_listener_data = SPI_createAccessibleEventListener (report_event, NULL); object_listener_selection = SPI_createAccessibleEventListener (report_event, NULL); object_listener_active_descendant = SPI_createAccessibleEventListener (report_event, NULL); object_listener_text_selection = SPI_createAccessibleEventListener (report_event, NULL); object_listener_text_changed_insert = SPI_createAccessibleEventListener (report_event, NULL); object_listener_text_changed_delete = SPI_createAccessibleEventListener (report_event, NULL); object_listener_caret = SPI_createAccessibleEventListener (report_event, NULL); object_listener_row_inserted = SPI_createAccessibleEventListener (report_event, NULL); object_listener_row_reordered = SPI_createAccessibleEventListener (report_event, NULL); object_listener_row_deleted = SPI_createAccessibleEventListener (report_event, NULL); object_listener_column_inserted = SPI_createAccessibleEventListener (report_event, NULL); object_listener_column_reordered = SPI_createAccessibleEventListener (report_event, NULL); object_listener_column_deleted = SPI_createAccessibleEventListener (report_event, NULL); object_listener_model = SPI_createAccessibleEventListener (report_event, NULL); window_listener = SPI_createAccessibleEventListener (report_event, NULL); window_listener_minimize = SPI_createAccessibleEventListener (report_event, NULL); window_listener_maximize = SPI_createAccessibleEventListener (report_event, NULL); window_listener_restore = SPI_createAccessibleEventListener (report_event, NULL); window_listener_close = SPI_createAccessibleEventListener (report_event, NULL); window_listener_create = SPI_createAccessibleEventListener (report_event, NULL); window_listener_reparent = SPI_createAccessibleEventListener (report_event, NULL); window_listener_desktop_create = SPI_createAccessibleEventListener (report_event, NULL); window_listener_desktop_destroy = SPI_createAccessibleEventListener (report_event, NULL); window_listener_focus_in = SPI_createAccessibleEventListener (report_event, NULL); window_listener_focus_out = SPI_createAccessibleEventListener (report_event, NULL); window_listener_raise = SPI_createAccessibleEventListener (report_event, NULL); window_listener_lower = SPI_createAccessibleEventListener (report_event, NULL); window_listener_move = SPI_createAccessibleEventListener (report_event, NULL); window_listener_resize = SPI_createAccessibleEventListener (report_event, NULL); window_listener_shade = SPI_createAccessibleEventListener (report_event, NULL); window_listener_unshade = SPI_createAccessibleEventListener (report_event, NULL); window_listener_restyle = SPI_createAccessibleEventListener (report_event, NULL); // SPI_registerGlobalEventListener (mouse_listener, // "mouse:rel"); SPI_registerGlobalEventListener (focus_listener, "focus:"); SPI_registerGlobalEventListener (property_listener, "object:property-change"); SPI_registerGlobalEventListener (property_listener_name, "object:property-change:accessible-name"); SPI_registerGlobalEventListener (property_listener_description, "object:property-change:accessible-description"); SPI_registerGlobalEventListener (property_listener_parent, "object:property-change:accessible-parent"); SPI_registerGlobalEventListener (property_listener_value, "object:property-change:accessible-value"); SPI_registerGlobalEventListener (property_listener_role, "object:property-change:accessible-role"); SPI_registerGlobalEventListener (property_listener_table_caption, "object:property-change:accessible-table-caption"); SPI_registerGlobalEventListener (property_listener_table_column_description, "object:property-change:accessible-table-column-description"); SPI_registerGlobalEventListener (property_listener_table_cloumn_header, "object:property-change:accessible-table-column-header"); SPI_registerGlobalEventListener (property_listener_table_row_description, "object:property-change:accessible-table-row-description"); SPI_registerGlobalEventListener (property_listener_table_row_header, "object:property-change:accessible-table-row-header"); SPI_registerGlobalEventListener (property_listener_table_summary, "object:property-change:accessible-table-summary"); SPI_registerGlobalEventListener (object_listener_state, "object:state-changed"); SPI_registerGlobalEventListener (object_listener_children, "object:children-changed"); SPI_registerGlobalEventListener (object_listener_data, "object:visible-data-changed"); SPI_registerGlobalEventListener (object_listener_selection, "object:selection-changed"); SPI_registerGlobalEventListener (object_listener_active_descendant, "object:active-descendant"); SPI_registerGlobalEventListener (object_listener_text_selection, "object:text-selection-changed"); SPI_registerGlobalEventListener (object_listener_text_changed_insert, "object:text-changed"); SPI_registerGlobalEventListener (object_listener_text_changed_insert, "object:text-changed:insert"); SPI_registerGlobalEventListener (object_listener_text_changed_delete, "object:text-changed:delete"); SPI_registerGlobalEventListener (object_listener_caret, "object:text-caret-moved"); SPI_registerGlobalEventListener (object_listener_caret, "object:link-selected"); SPI_registerGlobalEventListener (object_listener_row_inserted, "object:row-inserted"); SPI_registerGlobalEventListener (object_listener_row_reordered, "object:row-reordered"); SPI_registerGlobalEventListener (object_listener_row_deleted, "object:row-deleted"); SPI_registerGlobalEventListener (object_listener_column_inserted, "object:column-inserted"); SPI_registerGlobalEventListener (object_listener_column_reordered, "object:column-reordered"); SPI_registerGlobalEventListener (object_listener_column_deleted, "object:column-deleted"); SPI_registerGlobalEventListener (object_listener_model, "object:model-changed"); SPI_registerGlobalEventListener (window_listener_minimize, "window:minimize"); SPI_registerGlobalEventListener (window_listener_maximize, "window:maximize"); SPI_registerGlobalEventListener (window_listener_restore, "window:restore"); SPI_registerGlobalEventListener (window_listener_close, "window:close"); SPI_registerGlobalEventListener (window_listener_create, "window:create"); SPI_registerGlobalEventListener (window_listener_reparent, "window:reparent"); SPI_registerGlobalEventListener (window_listener_desktop_create, "window:desktop-create"); SPI_registerGlobalEventListener (window_listener_desktop_destroy, "window:desktop-destroy"); SPI_registerGlobalEventListener (window_listener_focus_in, // "window:focus-in"); // "window:activate"); "window:destroy"); SPI_registerGlobalEventListener (window_listener_focus_out, // "window:focus-out"); "window:deactivate"); SPI_registerGlobalEventListener (window_listener_raise, "window:raise"); SPI_registerGlobalEventListener (window_listener_lower, "window:lower"); SPI_registerGlobalEventListener (window_listener_move, "window:move"); SPI_registerGlobalEventListener (window_listener_resize, "window:resize"); SPI_registerGlobalEventListener (window_listener_shade, "window:shade"); SPI_registerGlobalEventListener (window_listener_unshade, "window:unshade"); SPI_registerGlobalEventListener (window_listener_restyle, "window:restyle"); SPI_event_main(); SPI_exit (); return 0; } #define STR(X) X ? X : "(none)" #ifdef TEXT_GENERAL static void text_general (AccessibleText *text) { if (!text) return; fprintf (stderr, "\n\tGENERAL:\n\t\tChar Count:%ld\n\t\tCaret Offset:%ld\n\t\tSelections count:%ld", AccessibleText_getCharacterCount (text), AccessibleText_getCaretOffset (text), AccessibleText_getNSelections (text)); } #endif #ifdef TEXT_ATTRIBUTES static void text_attributes (AccessibleText *text) { long int cp; long int sp, ep; char *str; if (!text) return; cp = AccessibleText_getCaretOffset (text); str = AccessibleText_getAttributes (text, cp, &sp, &ep); fprintf (stderr, "\n\tAttributes at %ld (%ld-%ld) :%s|", cp, sp, ep, STR (str)); SPI_freeString (str); } #endif #ifdef TEXT_BOUNDARY static void text_boundary (AccessibleText *text) { struct { AccessibleTextBoundaryType type; gchar *type_text; }boundary[] = { {SPI_TEXT_BOUNDARY_CHAR, "CHAR"}, {SPI_TEXT_BOUNDARY_CURSOR_POS, "CURSOR POS"}, {SPI_TEXT_BOUNDARY_WORD_START, "WORD START"}, {SPI_TEXT_BOUNDARY_WORD_END, "WORD END"}, {SPI_TEXT_BOUNDARY_SENTENCE_START, "SENTENCE START"}, {SPI_TEXT_BOUNDARY_SENTENCE_END, "SENTENCE END"}, {SPI_TEXT_BOUNDARY_LINE_START, "LINE START"}, {SPI_TEXT_BOUNDARY_LINE_END, "LINE END"}, {SPI_TEXT_BOUNDARY_ATTRIBUTE_RANGE, "ATT RANGE"}, }; int i; long int cp, sp, ep; char *str; if (!text) return; cp = AccessibleText_getCaretOffset (text); for (i = 0; i < sizeof (boundary) / sizeof (boundary[0]); i++) { str = AccessibleText_getTextAtOffset (text, cp, boundary[i].type, &sp, &ep); fprintf (stderr, "\n\tText from boundary %s (%ld-%ld) :%s:", boundary[i].type_text, sp, ep, str); SPI_freeString (str); } } #endif #ifdef TEXT_SELECTIONS static void text_selections (AccessibleText *text) { int i; if (!text) return; fprintf (stderr, "\n\tSELECTIONS :"); for (i = 0; i < AccessibleText_getNSelections (text); i++) { char *str = NULL; long int sp, ep; AccessibleText_getSelection (text, i, &sp, &ep); str = AccessibleText_getText (text, sp, ep); fprintf (stderr, "\n\t\tSelectia %d (%ld-%ld) :%s|", i, sp, ep, str?str:""); SPI_freeString (str); } } #endif #ifdef TEXT_COORD static void text_coord (AccessibleText *text) { long int cp; char *str = NULL; long int x, y, w, h; if (!text) return; cp = AccessibleText_getCaretOffset (text); str = AccessibleText_getText (text, cp, cp + 1); AccessibleText_getCharacterExtents (text, cp, &x, &y, &w, &h, SPI_COORD_TYPE_SCREEN); fprintf (stderr, "\n\tCOORD:\n\t\tChar:%s: (%ld-%ld)-(%ld-%ld)", str, x, y, x + w, y + h); SPI_freeString (str); } #endif #ifdef TEXT_COORD_ALL static void text_coord_all (AccessibleText *text) { long int cnt, i; if (!text) return; fprintf (stderr, "\n\tCOORD ALL:"); cnt = AccessibleText_getCharacterCount (text); for (i = 0; i < cnt; i++) { char *str = NULL; long int x, y, w, h; str = AccessibleText_getText (text, i, i + 1); AccessibleText_getCharacterExtents (text, i, &x, &y, &w, &h, SPI_COORD_TYPE_SCREEN); fprintf (stderr, "\n\t\tChar:%s: (%ld-%ld)-(%ld-%ld)", str, x, y, x + w, y + h); SPI_freeString (str); } } #endif #ifdef TEXT static void report_text (Accessible *acc) { AccessibleText *text; if (!acc) return; text = Accessible_getText (acc); if (!text) return; fprintf (stderr, "\nTEXT:"); #ifdef TEXT_GENERAL text_general (text); #endif #ifdef TEXT_ATTRIBUTES text_attributes (text); #endif #ifdef TEXT_BOUNDARY text_boundary (text); #endif #ifdef TEXT_SELECTIONS text_selections(text); #endif #ifdef TEXT_COORD text_coord (text); #endif #ifdef TEXT_COORD_ALL text_coord_all (text); #endif AccessibleText_unref (text); } #endif #ifdef STATE static void report_state (Accessible *acc) { AccessibleStateSet *state; struct { AccessibleState type; gchar *type_text; }states[] = { {SPI_STATE_INVALID, "INVALID"}, {SPI_STATE_ACTIVE, "ACTIVE"}, {SPI_STATE_ARMED, "ARMED"}, {SPI_STATE_BUSY, "BUSY"}, {SPI_STATE_CHECKED, "CHECKED"}, {SPI_STATE_COLLAPSED, "COLLAPSED"}, {SPI_STATE_DEFUNCT, "DEFUNCT"}, {SPI_STATE_EDITABLE, "EDITABLE"}, {SPI_STATE_ENABLED, "ENABLED"}, {SPI_STATE_EXPANDABLE, "EXPANDABLE"}, {SPI_STATE_EXPANDED, "EXPANDED"}, {SPI_STATE_FOCUSABLE, "FOCUSABLE"}, {SPI_STATE_FOCUSED, "FOCUSED"}, {SPI_STATE_HORIZONTAL, "HORIZONTAL"}, {SPI_STATE_ICONIFIED, "ICONIFIED"}, {SPI_STATE_MODAL, "MODAL"}, {SPI_STATE_MULTI_LINE, "MULTI_LINE"}, {SPI_STATE_MULTISELECTABLE, "MULTISELECTABLE"}, {SPI_STATE_OPAQUE, "OPAQUE"}, {SPI_STATE_PRESSED, "PRESSED"}, {SPI_STATE_RESIZABLE, "REZISEABLE"}, {SPI_STATE_SELECTABLE, "SELECTABLE"}, {SPI_STATE_SELECTED, "SELECTED"}, {SPI_STATE_SENSITIVE, "SENSITIVE"}, {SPI_STATE_SHOWING, "SHOWING"}, {SPI_STATE_SINGLE_LINE, "SINGLE_LINE"}, {SPI_STATE_STALE, "STALE"}, {SPI_STATE_TRANSIENT, "TRANSIENT"}, {SPI_STATE_VERTICAL, "VERTICAL"}, {SPI_STATE_VISIBLE, "VISIBLE"}, {SPI_STATE_MANAGES_DESCENDANTS, "MANGE_DESC"}, }; int i; if (!acc) return; state = Accessible_getStateSet (acc); if (!state) return; fprintf (stderr, "\nSTATE : "); for (i = 0; i < sizeof (states) / sizeof (states[0]); i++) { if (AccessibleStateSet_contains (state, states[i].type)) fprintf (stderr, " %s", states[i].type_text); } AccessibleStateSet_unref (state); } #endif #ifdef RELATION static void report_relation (Accessible *acc) { AccessibleRelation **rel; AccessibleRelation *crt; gint k; if (!acc) return; rel = Accessible_getRelationSet (acc); if (!rel) return; fprintf (stderr, "\nRELATIONS:"); for (k = 0; rel[k]; k++) { gint cnt, i; crt = rel[k]; cnt = AccessibleRelation_getNTargets (crt); fprintf (stderr, "\n\tRELATION: %d", AccessibleRelation_getRelationType (crt)); for (i = 0; i < cnt; i++) { Accessible *acc; acc = AccessibleRelation_getTarget (crt, i); fprintf (stderr, "\n\t\t%s---%s", Accessible_getName (acc), Accessible_getRoleName (acc)); } } } #endif #ifdef TYPE static void report_type (Accessible *acc) { struct { SPIBoolean (*is_function) (Accessible *acc); gchar *is_text; }types[] = { {Accessible_isAction, "ACT"}, {Accessible_isApplication, "APL"}, {Accessible_isComponent, "COMP"}, {Accessible_isEditableText, "EDTTXT"}, {Accessible_isHypertext, "HYP"}, {Accessible_isImage, "IMG"}, {Accessible_isSelection, "SEL"}, {Accessible_isTable, "TBL"}, {Accessible_isText, "TXT"}, {Accessible_isValue, "VAL"}, }; int i; if (!acc) return; fprintf (stderr, "\nTYPE : "); for (i = 0; i < sizeof (types) / sizeof (types[0]); i++) { if (types[i].is_function (acc)) fprintf (stderr, " %s", types[i].is_text); } } #endif #if defined(TREE) || defined (APP_TREE) static void report_tree (Accessible *acc, int dist) { int i; if (!acc) return; if (dist > TREE_MAX_DIST) return; fprintf (stderr, "\n"); for (i = 0; i < 2 * dist; i++) fprintf (stderr, " "); fprintf (stderr, "%s role %s", Accessible_getName (acc), Accessible_getRoleName (acc)); #ifdef TYPE report_type (acc); #endif #ifdef STATE report_state (acc); #endif #ifdef RELATION report_relation (acc); #endif for (i = 0; i < Accessible_getChildCount (acc); i++) { Accessible *child; child = Accessible_getChildAtIndex (acc, i); if (child) { report_tree (child, dist + 1); Accessible_unref (child); } } } #endif #ifdef APP_TREE static void report_app_tree (Accessible *acc) { Accessible *parent; if (!acc) return; fprintf (stderr, "\nAPP TREE :"); parent = acc; Accessible_ref (acc); while (parent) { acc = Accessible_getParent (parent); if (Accessible_isApplication (acc)) break; Accessible_unref (parent); parent = acc; } if (parent) report_tree (parent, 0); } #endif #ifdef TOOLKIT static void report_toolkit (Accessible *acc) { Accessible *parent; if (!acc) return; fprintf (stderr, "\nTOOLKIT :"); parent = acc; Accessible_ref (acc); while (parent) { if (Accessible_isApplication (parent)) break; acc = Accessible_getParent (parent); Accessible_unref (parent); parent = acc; } if (parent) { AccessibleApplication *app; app = Accessible_getApplication (acc); if (app) { fprintf (stderr, "%s", AccessibleApplication_getToolkitName (app)); AccessibleApplication_unref (app); } }; } #endif #ifdef VALUE static void report_value (Accessible *acc) { AccessibleValue *value; if (!acc) return; if (!Accessible_isValue (acc)) return; value = Accessible_getValue (acc); if (!value) return; fprintf (stderr, "\nVALUE:\n\tCURRENT:%f\n\tMINIMUM:%f\n\tMAXIMUM%f", AccessibleValue_getCurrentValue(value), AccessibleValue_getMaximumValue(value), AccessibleValue_getMinimumValue(value)); AccessibleValue_unref (value); } #endif #ifdef SELECTION static void report_selection (Accessible *acc) { AccessibleSelection *sel; int i; if (!acc) return; sel = Accessible_getSelection (acc); if (!sel) return; fprintf (stderr, "\nSELECTION"); for (i = 0; i < AccessibleSelection_getNSelectedChildren (sel); i++) { Accessible *acc; acc = AccessibleSelection_getSelectedChild (sel, i); if (acc) { fprintf (stderr, "\n\t%xp---%s", (unsigned int)acc, Accessible_getName (acc)); Accessible_unref (acc); } } AccessibleSelection_unref (sel); } #endif #ifdef COMPONENT static void report_component (Accessible *acc) { long int x, y, w, h; AccessibleComponent *comp; if (!acc) return; comp = Accessible_getComponent (acc); if (!comp) return; fprintf (stderr, "\nCOMPONENT:"); AccessibleComponent_getExtents (comp, &x, &y, &w, &h, SPI_COORD_TYPE_SCREEN); fprintf (stderr, "(%ld-%ld)-(%ld-%ld)", x, y, x + w, y + h); AccessibleComponent_unref (comp); } #endif #ifdef DESKTOP void report_desktop () { Accessible *desk; desk = SPI_getDesktop (0); if (desk) { if (Accessible_isComponent (desk)) fprintf (stderr, "\ndesktop IS component"); else fprintf (stderr, "\ndesktop IS NOT component"); } } #endif #ifdef TABLE_LINE static void report_table_line (Accessible *acc) { gint j; AccessibleTable *table; if (!acc) return; table = Accessible_getTable (Accessible_getParent (acc)); if (!table) return; fprintf (stderr, "\nTABLE LINE %d for index %d", (gint)AccessibleTable_getRowAtIndex (table, Accessible_getIndexInParent (acc)), (gint)Accessible_getIndexInParent (acc)); for (j = 0; j < AccessibleTable_getNColumns (table); j++) { Accessible *child; child = AccessibleTable_getAccessibleAt (table, AccessibleTable_getRowAtIndex (table, Accessible_getIndexInParent (acc)), j); fprintf (stderr, "\n\t%s", Accessible_getName (child)); } } #endif #ifdef EVENT_DETAILS static void report_event_details (const AccessibleEvent *event, void *user_data) { if (strncmp (event->type, "object:text-changed", strlen ("object:text-changed")) == 0) { gchar *tmp = AccessibleTextChangedEvent_getChangeString (event); fprintf (stderr, "\nTEXT CHANGED: %s", tmp); SPI_freeString (tmp); // g_free (tmp); } } #endif #ifdef PARENT_LINE static void report_parent_line (Accessible *acc) { if (!acc) return; fprintf (stderr, "\nPARENT LINE:"); while (acc) { fprintf (stderr, "\n\t%s---%s", Accessible_getName (acc), Accessible_getRoleName (acc)); acc = Accessible_getParent (acc); } } #endif #ifdef HYPERTEXT static void report_hypertext (Accessible *acc) { AccessibleHypertext *hyper; int i; if (!acc || !Accessible_isHypertext (acc)) return; hyper = Accessible_getHypertext (acc); if (!hyper) return; fprintf (stderr, "\nHYPERTEXT(%ld links):", AccessibleHypertext_getNLinks (hyper)); for (i = 0; i < AccessibleHypertext_getNLinks (hyper); i++) { AccessibleHyperlink *link; long int s, e; link = AccessibleHypertext_getLink (hyper, i); if (!link) continue; fprintf (stderr, "\n\tLINK:%d", i); fprintf (stderr, "---%ld anchors", AccessibleHyperlink_getNAnchors (link)); AccessibleHyperlink_getIndexRange (link, &s, &e); fprintf (stderr, "---s:%lde:%ld", s, e); fprintf (stderr, "---%s", Accessible_getName (AccessibleHyperlink_getObject (link, i))); // report_state (AccessibleHyperlink_getObject (link, i)); // report_type (AccessibleHyperlink_getObject (link, i)); AccessibleHyperlink_unref (link); } for (i = 0; i < AccessibleText_getCharacterCount (Accessible_getText (acc)); i++) { // fprintf (stderr, "\n\t%d---%s---%ld", i, // AccessibleText_getText (Accessible_getText (acc), i, i+1), // AccessibleHypertext_getLinkIndex (hyper, i)); } AccessibleHypertext_unref (hyper); } #endif #ifdef ACTION static void report_action (Accessible *acc) { gint i, n; AccessibleAction *action; if (!acc) return; action = Accessible_getAction (acc); if (!action) return; n = AccessibleAction_getNActions (action); fprintf (stderr, "\nACTION (%d):", n); for (i = 0; i < n; i++) { fprintf (stderr, "\n\taction %d:%s---%s---%s", i, AccessibleAction_getName (action, i), AccessibleAction_getDescription (action, i), AccessibleAction_getKeyBinding (action, i)); } AccessibleAction_unref (action); } #endif #ifdef GENERAL static void report_general (const AccessibleEvent *event, void *user_data) { fprintf (stderr, "\n\n%xp %s for %s(%s) role %s with details %ld %ld", (unsigned int)event->source, event->type, Accessible_getName (event->source), Accessible_getDescription (event->source), Accessible_getRoleName (event->source), event->detail1, event->detail2); } #endif #ifdef SKIP_EVENT static gboolean skip_event (const AccessibleEvent *event, void *user_data) { static Accessible *last_focus = NULL; Accessible_ref (event->source); if (strcmp (event->type, "focus:") == 0) last_focus = event->source; // if (strcmp (event->type, "focus:") != 0) // return TRUE; if (last_focus != event->source) return TRUE; /* if (Accessible_getRole (event->source) == SPI_ROLE_TERMINAL) { AccessibleStateSet *state; state = Accessible_getStateSet (event->source); if (!state) return TRUE; if (!AccessibleStateSet_contains (state, SPI_STATE_FOCUSED)) return TRUE; } */ // if (Accessible_getRole (event->source) == SPI_ROLE_LABEL) // return TRUE; // if (strcmp (event->type, "focus:") == 0 && // Accessible_getRole (event->source) == SPI_ROLE_LABEL) // return FALSE; // if (Accessible_getRole (event->source) == SPI_ROLE_TERMINAL) // return TRUE; // if (Accessible_getRole (event->source) == SPI_ROLE_LABEL && // strncmp (event->type, "object:text-changed", strlen ("object:text-changed")) == 0) // return TRUE; // if (Accessible_getRole (event->source) == SPI_ROLE_LABEL && // strcmp (event->type, "focus:") != 0) // return TRUE; // return TRUE; // if (strcmp (event->type, "object:link-selected") != 0 && // strcmp (event->type, "focus:") != 0) // return TRUE; // if (strcmp (event->type, "object:state-changed:selected") != 0) // return TRUE; // if (strcmp (event->type, "object:selection-changed") != 0 && // strcmp (event->type, "object:active-descendant") != 0) // return TRUE; // if (strcmp (event->type, "object:text-caret-moved") != 0 && // strcmp (event->type, "focus:") != 0) // return TRUE; // if (strcmp (event->type, "window:restore") != 0) // return TRUE; // if (Accessible_getRole (event->source) == SPI_ROLE_COMBO_BOX) // report_text (Accessible_getChildAtIndex (event->source, 1)); return FALSE; } #endif static void report_event (const AccessibleEvent *event, void *user_data) { #ifdef REENTRANCY static gboolean busy = FALSE; #endif Accessible_ref (event->source); #ifdef SKIP_EVENT if (skip_event (event, user_data)) return; #endif #ifdef REENTRANCY if (busy) { fprintf (stderr, "\nRRRR:%s", event->type); return; } busy = TRUE; #endif #ifdef GENERAL report_general (event, user_data); #endif #ifdef TEXT report_text (event->source); #endif #ifdef STATE report_state (event->source); #endif #ifdef TYPE report_type (event->source); #endif #ifdef TREE report_tree (event->source, 0); #endif #ifdef APP_TREE report_app_tree (event->source); #endif #ifdef TOOLKIT report_toolkit (event->source); #endif #ifdef VALUE report_value (event->source); #endif #ifdef SELECTION report_selection (event->source); #endif #ifdef COMPONENT report_component (event->source); #endif #ifdef DESKTOP report_desktop(); #endif #ifdef RELATION report_relation (event->source); #endif #ifdef EVENT_DETAILS report_event_details (event, user_data); #endif #ifdef PARENT_LINE report_parent_line (event->source); #endif #ifdef TABLE_LINE report_table_line (event->source); #endif #ifdef HYPERTEXT report_hypertext (event->source); #endif #ifdef ACTION report_action (event->source); #endif #ifdef REENTRANCY busy = FALSE; #endif } #if 0 #if 0 static void table_selected_rows (AccessibleTable *table) { int n; if (!table) return; fprintf (stderr, "\n\tSelected rows : "); n = AccessibleTable_getNSelectedRows (table); if (n > 0) { long int *rows; int i; n = AccessibleTable_getSelectedRows (table, &rows); for (i = 0; i < n; i++) fprintf (stderr, "%ld ", rows[i]); g_free (rows); } } static void table_selected_columns (AccessibleTable *table) { int n; if (!table) return; fprintf (stderr, "\n\tSelected columns : "); n = AccessibleTable_getNSelectedColumns (table); if (n > 0) { long int *columns; int i; n = AccessibleTable_getSelectedColumns (table, &columns); for (i = 0; i < n; i++) fprintf (stderr, "%ld ", columns[i]); g_free (columns); } } #else static void table_selected_rows (AccessibleTable *table) { int n; long int *rows; int i; if (!table) return; fprintf (stderr, "\n\tSelected rows : "); n = AccessibleTable_getSelectedRows (table, &rows); if (n > 0) for (i = 0; i < n; i++) fprintf (stderr, "%ld ", rows[i]); g_free (rows); } static void table_selected_columns (AccessibleTable *table) { int n; long int *columns; int i; if (!table) return; fprintf (stderr, "\n\tSelected columns : "); n = AccessibleTable_getSelectedColumns (table, &columns); if (n > 0) for (i = 0; i < n; i++) fprintf (stderr, "%ld ", columns[i]); g_free (columns); } #endif static void report_table (Accessible *acc) { Accessible *parent; AccessibleTable *table; if (!acc) return; if (Accessible_getRole (acc) != SPI_ROLE_TABLE_CELL) return; parent = Accessible_getParent (acc); if (!parent) return; table = Accessible_getTable (parent); if (!table) return; fprintf (stderr, "\nTABLE :"); table_selected_rows (table); table_selected_columns (table); AccessibleTable_unref (table); Accessible_unref (parent); } #endif #if 0 void report_obj (Accessible *obj, char * event) { static int cnt =0; static Accessible *ed = NULL; cnt++; if (cnt == 2000) SPI_event_quit (); if (NULL == obj) { printf ("\nNULLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL"); return; } Accessible_ref (obj); // if (strcmp (event, "focus:") != 0) // return; // if (strcmp (event, "object:state-changed:checked") != 0) // return; // if (strcmp (event, "focus:") != 0 && strcmp (event, "object:state-changed:checked") != 0) // return; if (strcmp (event, "focus:") != 0 && strcmp (event, "object:text-changed") != 0) return; #if 0 if (Accessible_isEditableText (obj)) { if (!ed) { ed = obj; Accessible_ref (obj); } } if (ed) { AccessibleStateSet *state = Accessible_getStateSet ( ed ); fprintf (stderr, "\nSTATE for text :"); if ( state ) { if (AccessibleStateSet_contains (state, SPI_STATE_INVALID)) fprintf (stderr, " INVALID"); if (AccessibleStateSet_contains (state, SPI_STATE_ACTIVE)) fprintf (stderr, " ACTIVE"); if (AccessibleStateSet_contains (state, SPI_STATE_ARMED)) fprintf (stderr, " ARMED"); if (AccessibleStateSet_contains (state, SPI_STATE_CHECKED)) fprintf (stderr, " CHECKED"); if (AccessibleStateSet_contains (state, SPI_STATE_COLLAPSED)) fprintf (stderr, " COLLAPSED"); if (AccessibleStateSet_contains (state, SPI_STATE_DEFUNCT)) fprintf (stderr, " DEFUNCT"); if (AccessibleStateSet_contains (state, SPI_STATE_EDITABLE)) fprintf (stderr, " EDITABLE"); if (AccessibleStateSet_contains (state, SPI_STATE_ENABLED)) fprintf (stderr, " ENABLED"); if (AccessibleStateSet_contains (state, SPI_STATE_EXPANDABLE)) fprintf (stderr, " EXPANDABLE"); if (AccessibleStateSet_contains (state, SPI_STATE_SENSITIVE)) fprintf (stderr, " SENSITIVE"); if (AccessibleStateSet_contains (state, SPI_STATE_TRANSIENT)) fprintf (stderr, " TRANSIENT"); if (AccessibleStateSet_contains (state, SPI_STATE_FOCUSED)) fprintf (stderr, " FOCUSED"); if (AccessibleStateSet_contains (state, SPI_STATE_ICONIFIED)) fprintf (stderr, " ICONIFIED"); if (AccessibleStateSet_contains (state, SPI_STATE_ACTIVE)) fprintf (stderr, " ACTIVE"); AccessibleStateSet_unref (state); } } #endif #if 0 { int i; Accessible *parent; parent = Accessible_getParent (obj); fprintf (stderr, "\nParent : %xp", parent); for (i = 0; i < Accessible_getChildCount (parent); i++) { Accessible *child; child = Accessible_getChildAtIndex (parent, i); fprintf (stderr, "\n\tChild : %xp", child); if (child == obj) fprintf (stderr, "========"); // Accessible_unref (child); } // Accessible_unref (parent); } #endif #if 1 //general info { gchar *name, *role_name; fprintf (stderr, "\n%xp %s event from %s role %s is", obj, event, name = Accessible_getName (obj), role_name = Accessible_getRoleName(obj)); if (Accessible_isAction (obj)) fprintf (stderr, " ACT"); if (Accessible_isApplication (obj)) fprintf (stderr, " APL"); if (Accessible_isComponent (obj)) fprintf (stderr, " COMP"); if (Accessible_isEditableText (obj)) fprintf (stderr, " EDTTXT"); if (Accessible_isHypertext (obj)) fprintf (stderr, " HYP"); if (Accessible_isImage (obj)) fprintf (stderr, " IMG"); if (Accessible_isSelection (obj)) fprintf (stderr, " SEL"); if (Accessible_isTable (obj)) fprintf (stderr, " TBL"); if (Accessible_isText (obj)) fprintf (stderr, " TXT"); if (Accessible_isValue (obj)) fprintf (stderr, " VAL"); SPI_freeString (name); SPI_freeString (role_name); } #endif #if 1 //for action { if (Accessible_isAction (obj)) { int i; AccessibleAction *act = Accessible_getAction (obj); for (i = 0; i < AccessibleAction_getNActions (act); i++) { fprintf (stderr, "\n%d action : %s : %s : %s", AccessibleAction_getName (act, i), AccessibleAction_getDescription (act, i), AccessibleAction_getKeyBinding (act, i)); } AccessibleAction_unref (act); } } #endif #if 0 //for menu { if (Accessible_getRole (obj) == SPI_ROLE_MENU) { int cc, i; cc = Accessible_getChildCount (obj); fprintf (stderr, "\nChildren Count for menu : %d", cc); for (i = 0; i < cc; i++) { Accessible *child; AccessibleStateSet *state; child = Accessible_getChildAtIndex (obj, i); g_assert (child); state = Accessible_getStateSet (child); g_assert (state); if (AccessibleStateSet_contains (state, SPI_STATE_FOCUSED)) fprintf (stderr, "\nFOCUS for %s", Accessible_getName (child)); else fprintf (stderr, "\n %s", Accessible_getName (child)); if (AccessibleStateSet_contains (state, SPI_STATE_VISIBLE)) fprintf (stderr, "\nVISIBLE for %s", Accessible_getName (child)); else fprintf (stderr, "\n INVISIBLE %s", Accessible_getName (child)); AccessibleStateSet_unref (state); Accessible_unref (child); } } } #endif #if 1 //for state { AccessibleStateSet *state = Accessible_getStateSet ( obj ); fprintf (stderr, "\nSTATE :"); if ( state ) { if (AccessibleStateSet_contains (state, SPI_STATE_FOCUSABLE)) fprintf (stderr, " FOCUSABLE"); if (AccessibleStateSet_contains (state, SPI_STATE_FOCUSED)) fprintf (stderr, " FOCUSED"); if (AccessibleStateSet_contains (state, SPI_STATE_SELECTED)) fprintf (stderr, " SELECTED"); if (AccessibleStateSet_contains (state, SPI_STATE_ICONIFIED)) fprintf (stderr, " ICONIFIED"); if (AccessibleStateSet_contains (state, SPI_STATE_ACTIVE)) fprintf (stderr, " ACTIVE"); if (AccessibleStateSet_contains (state, SPI_STATE_CHECKED)) fprintf (stderr, " CHECKED"); if (AccessibleStateSet_contains (state, SPI_STATE_EXPANDED)) fprintf (stderr, " EXPANDED"); if (AccessibleStateSet_contains (state, SPI_STATE_EXPANDABLE)) fprintf (stderr, " EXPANDABLE"); if (AccessibleStateSet_contains (state, SPI_STATE_SENSITIVE)) fprintf (stderr, " SENSITIVE"); AccessibleStateSet_unref (state); } } #endif //sleep(1); #if 0 //table caption { Accessible *parent; parent = Accessible_getParent (obj); g_assert (parent); if (Accessible_getRole (parent) == SPI_ROLE_TREE_TABLE || Accessible_getRole (parent) == SPI_ROLE_TABLE ) { AccessibleTable *table; Accessible *caption, *summary; table = Accessible_getTable (parent); g_assert (table); caption = AccessibleTable_getCaption (table); if (caption) fprintf (stderr, "\nCAPTION : %s for %s", Accessible_getName (caption), Accessible_getName (parent)); Accessible_unref (caption); summary = AccessibleTable_getSummary (table); if (summary) fprintf (stderr, "\nSUMMARY : %s for %s", Accessible_getName (summary), Accessible_getName (parent)); Accessible_unref (summary); Accessible_unref (parent); } } #endif #if 0 //for table { if (Accessible_getRole (obj) == SPI_ROLE_PUSH_BUTTON || Accessible_getRole (obj) == SPI_ROLE_TABLE_CELL ) { Accessible *parent; long int nc, i; fprintf (stderr, "\nAAAA"); parent = Accessible_getParent (obj); g_assert (parent); if (Accessible_getRole (parent) == SPI_ROLE_TREE_TABLE || Accessible_getRole (parent) == SPI_ROLE_TABLE ) { AccessibleTable *table; Accessible *caption; table = Accessible_getTable (parent); g_assert (table); caption = AccessibleTable_getCaption (table); // caption = AccessibleTable_getSummary (table); g_assert (caption); nc = Accessible_getChildCount (caption); for (i = 0; i < nc; i++) { Accessible *child; child = Accessible_getChildAtIndex (parent, i); g_assert (child); fprintf (stderr, "\nchild %ld %s", i, Accessible_getName (child)); if (Accessible_getRole (child) == SPI_ROLE_PUSH_BUTTON) { fprintf (stderr, "\nAAAAAAAAAAAAAAAAAA"); fprintf (stderr, "\n%s %s", Accessible_getRoleName (child), Accessible_getName (child)); } Accessible_unref (child); } } Accessible_unref (parent); } } #endif #if 0 //for table { if (Accessible_getRole (obj) == SPI_ROLE_PUSH_BUTTON) { Accessible *parent; long int nc, i; fprintf (stderr, "\nAAAA"); parent = Accessible_getParent (obj); g_assert (parent); if (Accessible_getRole (parent) == SPI_ROLE_TREE_TABLE) { nc = Accessible_getChildCount (parent); fprintf (stderr, "\nNC = %ld", nc); for (i = 0; i < nc; i++) { Accessible *child; // fprintf (stderr, "\nAAAAA"); child = Accessible_getChildAtIndex (parent, i); g_assert (child); fprintf (stderr, "\nchild %ld %s", i, Accessible_getName (child)); if (Accessible_getRole (child) == SPI_ROLE_PUSH_BUTTON) { fprintf (stderr, "\nAAAAAAAAAAAAAAAAAA"); fprintf (stderr, "\n%s %s", Accessible_getRoleName (child), Accessible_getName (child)); } Accessible_unref (child); } } Accessible_unref (parent); } } #endif #if 0 //for table { if (Accessible_getRole (obj) == SPI_ROLE_TABLE_CELL) { Accessible *parent; AccessibleTable *table; long int nc, i, nr, j; parent = Accessible_getParent (obj); g_assert (parent); // g_assert (Accessible_getRole (parent) == SPI_ROLE_TREE_TABLE); table = Accessible_getTable (parent); g_assert (table); nc = AccessibleTable_getNColumns (table); nr = AccessibleTable_getNRows (table); fprintf (stderr, "\nNR=%ld, NC=%ld", nr, nc); for (i = 0; i < nr; i++) { for (j = 0; j < nc; j++) { Accessible *child; long int index; fprintf (stderr, "\nchild %ld %ld %ld" , i, j, index); index = AccessibleTable_getIndexAt (table, i, j); fprintf (stderr, "\nchild %ld %ld %ld" , i, j, index); // child = Accessible_getChildAtIndex (parent, index); child = AccessibleTable_getAccessibleAt (table, i, j); g_assert (child); fprintf (stderr, "\nchild %ld %ld %ld %s", i, j, index, Accessible_getName (child)); if (Accessible_getRole (child) == SPI_ROLE_PUSH_BUTTON) { fprintf (stderr, "\nAAAAAAAAAAAAAAAAAA"); fprintf (stderr, "\n%s %s", Accessible_getRoleName (child), Accessible_getName (child)); } Accessible_unref (child); } } Accessible_unref (parent); AccessibleTable_unref (table); } } #endif #endif