diff options
author | nagappan <nagappan> | 2005-10-11 11:36:48 +0000 |
---|---|---|
committer | nagappan <nagappan> | 2005-10-11 11:36:48 +0000 |
commit | 25d6970b21b6a3a8c18454a28d5c4917f563b8b7 (patch) | |
tree | 12dd2437acc30933a0101c34c691b15864ca2f77 | |
parent | eb3ac4a4081b0858193ac385acb35471e6072177 (diff) |
2005-10-11 Nagappan A <anagappan@novell.com>
* Fixed SPI leaks in get_relation_name
2005-10-11 Premkumar J <jpremkumar@novell.com>
* Updated with code to strip '.' from context headers generated
2005-10-06 Premkumar J <jpremkumar@novell.com>
* Changed appmap code to generate name for toggle buttons with prefix 'tbtn' instead of 'btn'
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | appmap-gen.c | 130 |
2 files changed, 81 insertions, 55 deletions
@@ -1,3 +1,9 @@ +2005-10-11 Nagappan A <anagappan@novell.com> + * Fixed SPI leaks in get_relation_name +2005-10-11 Premkumar J <jpremkumar@novell.com> + * Updated with code to strip '.' from context headers generated +2005-10-06 Premkumar J <jpremkumar@novell.com> + * Changed appmap code to generate name for toggle buttons with prefix 'tbtn' instead of 'btn' 2005-10-04 Nagappan A <anagappan@novell.com> * Commented a line in configure.in to work with Debian / Ubuntu distro 2005-10-04 Premkumar J <jpremkumar@novell.com> diff --git a/appmap-gen.c b/appmap-gen.c index 6b41ccd..ba583a0 100644 --- a/appmap-gen.c +++ b/appmap-gen.c @@ -38,6 +38,7 @@ int table = 0, page_tab = 0, spin_button = 0, button = 0, + tbutton = 0, radio_button = 0, check_box = 0, tree_table = 0, @@ -71,6 +72,7 @@ void reset_count() page_tab = 0; spin_button = 0; button = 0; + tbutton = 0; radio_button = 0; tree_table = 0; layered_pane = 0; @@ -141,6 +143,8 @@ Accessible *accessible_app_handle (char *app_name) */ name = Accessible_getName (child); + g_print ("Application name: %s\n", name); + /* Incase of OO.o due to spaces, string compare gives different result. Found because of extra spaces. Now stripped it ;) @@ -199,24 +203,19 @@ int filter_appmap_data (Accessible *accessible, OBJECT_INFO *obj_info, char *lab return 0; if (g_ascii_strcasecmp (obj_info->object_type, "menu_item" ) == 0) { + int parent_type; Accessible *parent; Accessible *grand_parent; - int parent_type; + parent = Accessible_getParent (accessible); grand_parent = Accessible_getParent (parent); parent_type = Accessible_getRole (grand_parent); + Accessible_unref (grand_parent); + Accessible_unref (parent); if (parent_type == SPI_ROLE_COMBO_BOX) - { - Accessible_unref (parent); - Accessible_unref (grand_parent); - return 0; - } + return 0; else - { - Accessible_unref (parent); - Accessible_unref (grand_parent); - return 1; - } + return 1; } if (g_ascii_strcasecmp (obj_info->object_type, "list_item") == 0) @@ -228,28 +227,22 @@ int filter_appmap_data (Accessible *accessible, OBJECT_INFO *obj_info, char *lab int parent_type; parent = Accessible_getParent (accessible); parent_type = Accessible_getRole (parent); + Accessible_unref (parent); if (parent_type == SPI_ROLE_TABLE || parent_type == SPI_ROLE_TREE_TABLE ) - { - Accessible_unref (parent); - return 0; - } + return 0; else - { - Accessible_unref (parent); - return 1; - } + return 1; } - return 1; } char *get_relation_name (Accessible *object) { - int i; + int i = 0, j = 0; int max_accessible = 0; char *label_by = NULL; - AccessibleRelation **relation; + AccessibleRelation **relation = NULL; relation = Accessible_getRelationSet (object); if (relation) @@ -257,39 +250,52 @@ char *get_relation_name (Accessible *object) max_accessible = AccessibleRelation_getNTargets (*relation); if (max_accessible > 0) { - int relation_targets = 0; - for (i = 0; i < (relation_targets = AccessibleRelation_getNTargets (relation[i])); i++) + for (i = 0; relation[i] != NULL; i++) { - AccessibleRelationType relation_type; - relation_type = AccessibleRelation_getRelationType (relation[i]); - if (relation_type == SPI_RELATION_LABELED_BY || - relation_type == SPI_RELATION_CONTROLLED_BY || - relation_type == SPI_RELATION_LABEL_FOR) + for (j = 0; j < AccessibleRelation_getNTargets (relation[i]); j++) { - int j = 0; - char *name = NULL; - Accessible *tmp_obj; - tmp_obj = AccessibleRelation_getTarget (relation[i], i); - name = Accessible_getName (tmp_obj); - if (g_ascii_strcasecmp (name, "") == 0) + AccessibleRelationType relation_type; + relation_type = AccessibleRelation_getRelationType (relation[i]); + if (relation_type == SPI_RELATION_LABELED_BY || + relation_type == SPI_RELATION_CONTROLLED_BY || + relation_type == SPI_RELATION_LABEL_FOR) { + int k = 0; + char *name = NULL; + Accessible *tmp_obj; + tmp_obj = AccessibleRelation_getTarget (relation[i], i); + name = Accessible_getName (tmp_obj); + if (name == NULL) + { + Accessible_unref (tmp_obj); + for (k = j; relation[k] != NULL; k++) + Accessible_unref (relation[k]); + Accessible_unref (*relation); + return NULL; + } + if (g_ascii_strcasecmp (name, "") == 0) + { + SPI_freeString (name); + Accessible_unref (tmp_obj); + for (k = j; relation[k] != NULL; k++) + Accessible_unref (relation[k]); + Accessible_unref (*relation); + return NULL; + } + g_print ("Relation name: %s\n", name); + label_by = g_strdup (name); SPI_freeString (name); Accessible_unref (tmp_obj); - for (j = i; relation[j] != NULL; j++) - Accessible_unref (relation[j]); - return NULL; + for (k = j; relation[k] != NULL; k++) + Accessible_unref (relation[k]); + Accessible_unref (*relation); + return label_by; } - label_by = g_strdup (name); - SPI_freeString (name); - Accessible_unref (tmp_obj); - for (j = i; relation[j] != NULL; j++) - Accessible_unref (relation[j]); - return label_by; } - Accessible_unref (relation[i]); } } } + Accessible_unref (*relation); return NULL; } @@ -593,9 +599,9 @@ OBJECT_INFO *get_object_info (Accessible *accessible) } else if (role == SPI_ROLE_TOGGLE_BUTTON) { - obj_info->prefix = g_strdup ("btn"); - obj_info->instance_index = button; - button++; + obj_info->prefix = g_strdup ("tbtn"); + obj_info->instance_index = tbutton; + tbutton++; obj_info->object_type = g_strdup ("toggle_button"); } else if (role == SPI_ROLE_SCROLL_BAR) @@ -735,11 +741,17 @@ void insert_context_header (FILE *fp, Accessible *accessible) if (strcmp (label, "") != 0) { char *stripped_data = NULL; + char *tmp_data = NULL; if (strchr (label, ' ')) stripped_data = strip_white_space (label); else stripped_data = g_strdup (label); - name = g_strdup_printf ("%s%s", cur_obj_info->prefix, stripped_data); + if (strchr (stripped_data, '.')) + tmp_data = strip_delim (stripped_data, '.'); + else + tmp_data = g_strdup (stripped_data); + name = g_strdup_printf ("%s%s", cur_obj_info->prefix, tmp_data); + g_free (tmp_data); g_free (stripped_data); } else @@ -840,6 +852,12 @@ void accessible_object_handle (FILE *fp, Accessible *accessible, char* parent_na Accessible_unref (accessible); } +void ldtp_print (const char *string) +{ + if (getenv ("LDTP_DEBUG") != NULL) + printf ("%s", string); +} + int appmap_main (char *app_name) { FILE *fp = NULL; @@ -858,9 +876,7 @@ int appmap_main (char *app_name) close_appmap (fp); } else - { - g_print ("Unable to open file for writing application map!!\n"); - } + g_print ("Unable to open file for writing application map!!\n"); return 0; } @@ -874,7 +890,7 @@ int main (int argc, char *argv[]) if (argc < 2) { - printf("Syntax: appmap <application name>\n"); + g_print ("Syntax: appmap <application name>\n"); exit(0); } @@ -884,20 +900,24 @@ int main (int argc, char *argv[]) init_error = SPI_init (); if (init_error) { - g_warning ("Error: SPI Init\n"); + g_print ("Error: SPI Init\n"); return init_error; } putenv ("GTK_MODULES=gail:atk-bridge"); putenv ("GNOME_ACCESSIBILITY=1"); + // Register local print function + g_set_print_handler (ldtp_print); + appmap_main (application_name); g_free (application_name); g_free (map_filename); leaked = SPI_exit (); - g_print ("Leaked %d SPI handles\n", leaked); + if (leaked) + g_print ("Leaked %d SPI handles\n", leaked); putenv ("AT_BRIDGE_SHUTDOWN=1"); return 0; |