1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
3
* Linux Desktop Testing Project http://ldtp.freedesktop.org
6
* Nagappan Alagappan <nagappan@gmail.com>
7
* S Thanikachalam <sthanikachalam@novell.com>
8
* Premkumar J <jpremkumar@novell.com>
10
* Copyright 2004 - 2006 Novell, Inc.
11
* Copyright 2007 - 2008 Nagappan Alagappan
13
* This program is free software; you can redistribute it and/or
14
* modify it under the terms of the GNU Lesser General Public
15
* License as published by the Free Software Foundation; either
16
* version 2 of the License, or (at your option) any later version.
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
* Lesser General Public License for more details.
23
* You should have received a copy of the GNU Lesser General Public
24
* License along with this program; if not, write to the
25
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26
* Boston, MA 02110, USA.
31
#include "ldtp-utils.h"
32
#include "ldtp-error.h"
33
#include "ldtp-logger.h"
34
#include "ldtp-appmap.h"
35
#include "ldtp-command.h"
36
#include "ldtp-gui-comp.h"
38
extern gboolean ldtp_debug;
39
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
42
read_delimiter (int fd, gchar delimit)
49
while (read (fd, &ch, 1) > 0) {
51
data = (gchar *) malloc (sizeof (gchar)*len);
53
data = (gchar *) realloc (data, sizeof (gchar)*len+size+1);
55
if (data[0] == '\n' || ch == delimit || (size && data[size - 1] == ']')) {
56
if (data[0] != '\n' && read (fd, &ch, 1) > 0) {
58
* Don't do any operation
62
data = (gchar *) realloc (data, sizeof (gchar)+size+1);
71
add_child_attributes (gchar *cur_entry, GHashTable *cur_context_table)
75
gchar *component = NULL;
77
token = strtok (strdup (cur_entry), "=");
79
component = strdup (token);
81
offset = strlen (component) + 1;
82
if (cur_entry[offset] == '{') {
83
gchar *end = strstr (cur_entry, "}");
86
gchar *all_attributes;
87
GHashTable *hash_attributes;
88
int len = (end - cur_entry) - (offset+1);
90
all_attributes = (gchar *) malloc (sizeof (gchar) * len + 1);
91
strncpy (all_attributes, (cur_entry + offset + 1), len);
92
all_attributes[len] = '\0';
95
Create new attribute hash table
97
hash_attributes = g_hash_table_new (&g_str_hash, &g_str_equal);
98
key = strtok (strdup (all_attributes), "=");
102
hash_key = g_strdup (key);
103
value = strtok (NULL, ",");
104
hash_value = g_strdup (value);
105
if (hash_key && hash_value)
106
g_print ("%s: %s\n", hash_key, hash_value);
107
if (hash_attributes && hash_key && hash_value)
108
g_hash_table_insert (hash_attributes, hash_key, hash_value);
109
key = strtok (NULL, "=");
111
if (component && cur_context_table && hash_attributes)
112
g_hash_table_insert (cur_context_table, component, hash_attributes);
118
print_attributes (gchar *key, gchar *value, gchar *userdata)
122
g_print ("\t|-------%s = %s\n", key, value);
126
print_component (gchar *key, GHashTable *component, gchar *userdata)
128
if (!key || !component)
130
g_print ("|-------%s\n", key);
131
g_hash_table_foreach (component, (GHFunc)&print_attributes, userdata);
135
print_context (gchar *key, GHashTable *context, gchar *userdata)
137
if (!key || !context || !ldtp_debug)
139
g_print (":%s:\n", key);
140
g_hash_table_foreach (context, (GHFunc)&print_component, userdata);
144
Initialize application map
147
appmap_init (gchar *gui_map_filename, FILE *log_fp)
152
gchar *cur_entry = NULL;
154
GHashTable *cur_context_table = NULL;
156
appmap = g_hash_table_new (&g_str_hash, &g_str_equal);
158
fp = fopen (gui_map_filename, "r");
160
g_print ("Unable to open appmap %s file\n", gui_map_filename);
161
log_msg (LDTP_LOG_CAUSE, "Unable to open appmap file", log_fp);
166
cur_entry = read_delimiter (fd, '}');
169
gchar *context = NULL;
172
cur_entry_len = strlen (cur_entry);
173
if (cur_entry [0] == '[' && cur_entry [cur_entry_len - 1] == ']') {
174
cur_context_table = g_hash_table_new (&g_str_hash, &g_str_equal);
175
context = (gchar *) g_new0 (gchar, sizeof (gchar) * (cur_entry_len - 1));
177
/* Copy everything except the leading '[' and trailing ']' */
178
memcpy (context, cur_entry+1, cur_entry_len-2);
179
if (appmap && context && cur_context_table)
180
g_hash_table_insert (appmap, context, cur_context_table);
182
else if (cur_entry[0] == '\n') {
183
cur_entry = read_delimiter (fd, '}');
187
add_child_attributes (cur_entry, cur_context_table);
188
cur_entry = read_delimiter (fd, '}');
191
g_hash_table_foreach (appmap, (GHFunc)&print_context, NULL);
196
destroy_hashtable (gpointer data)
199
g_hash_table_destroy (data);
205
destroy_string (gpointer data)
214
is_remaped (gpointer key, gpointer value, gpointer user_data)
216
if (key == NULL || value == NULL)
218
g_print ("%s - %s ******* DEBUG\n", (gchar *) key, (gchar *) value);
219
if (g_utf8_collate (key, "remap") == 0)
225
remove_remapped_entry (gpointer key, gpointer value, gpointer user_data)
227
if (key == NULL || value == NULL)
229
g_hash_table_foreach_remove (value, is_remaped, key);
234
Free application map resource
237
ldtp_appmap_free (GHashTable *appmap)
242
pthread_mutex_lock (&mutex);
243
g_hash_table_destroy (appmap);
244
pthread_mutex_unlock (&mutex);
249
search_key_based (gpointer key, gpointer value, gpointer user_data)
251
OBJInfo *obj = (OBJInfo *) user_data;
252
if (!key || !obj || !obj->key) {
255
if (g_pattern_match_simple (obj->key, key)) {
256
if (ldtp_debug && obj->key && key) {
257
g_print ("Key: %s %s\n",
261
if (obj->parent_name && value) {
262
gchar *parent = get_property (value, "parent", NULL);
263
if (parent == NULL) {
264
// Only the window's parent can be
265
// empty in current hash table, so let
266
// us consider that the requested key
268
g_print ("Parent NULL\n");
271
if (parent && g_pattern_match_simple (obj->parent_name, parent))
280
search_window_key_based (gpointer key, gpointer value, gpointer user_data)
283
obj = (OBJInfo *) user_data;
284
if (obj && obj->ht_data_list && search_key_based (key, value, user_data)) {
285
g_hash_table_insert (obj->ht_data_list, g_strdup ((gchar *) key), NULL);
290
search_obj_based_on_index (gpointer key, gpointer value, gpointer user_data)
292
gchar *obj_index = NULL;
293
OBJInfo *obj = (OBJInfo *) user_data;
294
if (!value || !obj || !obj->key) {
297
obj_index = get_property (value, "obj_index", NULL);
298
if (obj_index && g_pattern_match_simple (obj->key, obj_index)) {
299
if (obj->parent_name) {
300
gchar *parent = get_property (value, "parent", NULL);
301
if (parent == NULL) {
302
// Only the window's parent can be
303
// empty in current hash table, so let
304
// us consider that the requested key
306
g_print ("Parent NULL\n");
309
if (parent && g_pattern_match_simple (obj->parent_name, parent))
318
search_key_glob_based (gpointer key, gpointer value, gpointer user_data)
322
if (!key || !user_data) {
326
FIXME: Use get_object_info function to get the the type of object
327
if type and key matches then return true
329
obj = (OBJInfo *) user_data;
330
if (ldtp_debug && obj->key && key) {
331
g_print ("glob - key: %d - %d - %d - %s %s %ld %ld\n",
333
g_pattern_match_simple ("frm*", obj->key),
334
g_pattern_match_simple ("dlg*", obj->key),
335
obj->key, (gchar *) key, g_utf8_strlen (key, -1),
336
g_utf8_strlen (obj->key, -1));
338
if (obj->obj_is_window) {
340
if (g_pattern_match_string (obj->pattern, key)) {
341
if (obj->parent_name && value) {
342
gchar *parent = get_property (value, "parent", NULL);
343
if (parent == NULL) {
344
// Only the window's parent can be
345
// empty in current hash table, so let
346
// us consider that the requested key
348
g_print ("Parent NULL\n");
351
if (parent && g_pattern_match_simple (obj->parent_name, parent))
357
tmp = g_strdup_printf ("frm%s", (gchar *)key);
358
if (tmp && g_pattern_match_simple (tmp, key)) {
361
if (obj->parent_name && value) {
362
gchar *parent = get_property (value, "parent", NULL);
363
if (parent == NULL) {
364
// Only the window's parent can be
365
// empty in current hash table, so let
366
// us consider that the requested key
368
g_print ("Parent NULL\n");
371
if (parent && g_pattern_match_simple (obj->parent_name, parent))
378
tmp = g_strdup_printf ("dlg%s", obj->key);
379
if (tmp && g_pattern_match_simple (tmp, key)) {
382
if (obj->parent_name && value) {
383
gchar *parent = get_property (value, "parent", NULL);
384
if (parent == NULL) {
385
// Only the window's parent can be
386
// empty in current hash table, so let
387
// us consider that the requested key
389
g_print ("Parent NULL\n");
392
if (parent && g_pattern_match_simple (obj->parent_name, parent))
399
tmp = g_strdup_printf ("frm%s*", obj->key);
400
if (tmp && g_pattern_match_simple (tmp, key)) {
403
if (obj->parent_name && value) {
404
gchar *parent = get_property (value, "parent", NULL);
405
if (parent == NULL) {
406
// Only the window's parent can be
407
// empty in current hash table, so let
408
// us consider that the requested key
412
if (parent && g_pattern_match_simple (obj->parent_name, parent))
419
tmp = g_strdup_printf ("dlg%s*", obj->key);
420
if (tmp && g_pattern_match_simple (tmp, key)) {
423
if (obj->parent_name && value) {
424
gchar *parent = get_property (value, "parent", NULL);
425
if (parent == NULL) {
426
// Only the window's parent can be
427
// empty in current hash table, so let
428
// us consider that the requested key
430
g_print ("Parent NULL\n");
433
if (parent && g_pattern_match_simple (obj->parent_name, parent))
442
if (obj->pattern && !obj->obj_is_window) {
443
gboolean flag = g_pattern_match_string (obj->pattern, key);
444
if (flag && obj->parent_name && value) {
445
gchar *parent = get_property (value, "parent", NULL);
446
if (parent == NULL) {
447
// Only the window's parent can be
448
// empty in current hash table, so let
449
// us consider that the requested key
451
g_print ("Parent NULL\n");
454
if (parent && g_pattern_match_simple (obj->parent_name, parent))
463
search_window_key_glob_based (gpointer key, gpointer value, gpointer user_data)
466
obj = (OBJInfo *) user_data;
467
if (obj && obj->ht_data_list && search_key_glob_based (key, value, user_data)) {
468
g_hash_table_insert (obj->ht_data_list, g_strdup ((gchar *) key), value);
473
search_label_based (gpointer key, gpointer value, gpointer user_data)
479
gchar *label_by = NULL;
480
gchar *tmp_data = NULL;
481
gboolean flag = FALSE;
482
GPatternSpec *pattern = NULL;
484
if (!value || !user_data) {
488
g_print ("Key: %s\n", (gchar *) key);
489
obj = (OBJInfo *) user_data;
490
g_hash_table_lookup_extended (value, "class", NULL, (gpointer) &class);
491
g_hash_table_lookup_extended (value, "label", NULL, (gpointer) &label);
495
pattern = g_pattern_spec_new (class);
496
if (pattern && (g_pattern_match_string (pattern, "frame") ||
497
g_pattern_match_string (pattern, "dialog") ||
498
g_pattern_match_string (pattern, "alert") ||
499
g_pattern_match_string (pattern, "file_chooser") ||
500
g_pattern_match_string (pattern, "font_chooser"))) {
504
g_pattern_spec_free (pattern);
506
FIXME: Use get_object_info function to get the the type of object
507
if type and key matches then return true
509
if (label && tmp_data) {
510
if (ldtp_debug && (gchar *)key && label && tmp_data)
511
g_print ("Label: %s - %s - %s\n", (gchar *)key, (gchar *)tmp_data, label);
512
if (!obj->obj_is_window || flag)
513
if (g_utf8_collate (label, tmp_data) == 0) {
514
if (obj->parent_name && value) {
515
gchar *parent = get_property (value, "parent", NULL);
516
if (parent == NULL) {
517
// Only the window's parent can be
518
// empty in current hash table, so let
519
// us consider that the requested key
521
g_print ("Parent NULL\n");
524
if (parent && g_pattern_match_simple (obj->parent_name, parent))
529
// Search for mnemonics, if available then remove just _
530
if (g_utf8_strchr (label, -1, '_') == NULL)
532
tmp = escape_character (label, '_');
534
if (g_utf8_collate (tmp, tmp_data) == 0) {
537
if (obj->parent_name && value) {
538
gchar *parent = get_property (value, "parent", NULL);
540
g_print ("Parent: %s - %s\n", parent, obj->parent_name);
541
if (parent == NULL) {
542
// Only the window's parent can be
543
// empty in current hash table, so let
544
// us consider that the requested key
546
g_print ("Parent NULL\n");
549
if (parent && g_pattern_match_simple (obj->parent_name, parent))
558
g_hash_table_lookup_extended (value, "label_by", NULL, (gpointer) &label_by);
559
if (label_by && tmp_data) {
560
if ((gchar *)key && label_by && tmp_data)
561
g_print ("LabelBy: %s - %s - %s\n", (gchar *)key, (gchar *)tmp_data, label_by);
562
if (!obj->obj_is_window || flag)
563
if (g_utf8_collate (label_by, tmp_data) == 0) {
564
if (obj->parent_name && value) {
565
gchar *parent = get_property (value, "parent", NULL);
566
if (parent == NULL) {
567
// Only the window's parent can be
568
// empty in current hash table, so let
569
// us consider that the requested key
571
g_print ("Parent NULL\n");
574
if (parent && g_pattern_match_simple (obj->parent_name, parent))
579
// Search for mnemonics, if available then remove just _
580
if (g_utf8_strchr (label_by, -1, '_') == NULL)
582
tmp = escape_character (label, '_');
584
if (g_utf8_collate (tmp, tmp_data) == 0) {
587
if (obj->parent_name && value) {
588
gchar *parent = get_property (value, "parent", NULL);
589
if (parent == NULL) {
590
// Only the window's parent can be
591
// empty in current hash table, so let
592
// us consider that the requested key
594
g_print ("Parent NULL\n");
597
if (parent && g_pattern_match_simple (obj->parent_name, parent))
610
search_window_label_based (gpointer key, gpointer value, gpointer user_data)
613
obj = (OBJInfo *) user_data;
614
if (obj && obj->ht_data_list && search_label_based (key, value, user_data)) {
615
g_hash_table_insert (obj->ht_data_list, g_strdup ((gchar *) key), value);
620
search_label_glob_based (gpointer key, gpointer value, gpointer user_data)
624
gchar *tmp_label = NULL;
625
gchar *tmp_label_by = NULL;
626
GPatternSpec *pattern = NULL;
627
gboolean flag = FALSE;
629
if (!value || !user_data)
632
FIXME: Remove under score from label or label_by and do a pattern match too
635
obj = (OBJInfo *) user_data;
636
if (g_hash_table_lookup_extended (value, "class", NULL, (gpointer) &class))
637
pattern = g_pattern_spec_new (class);
638
if (pattern && (g_pattern_match_string (pattern, "frame") ||
639
g_pattern_match_string (pattern, "dialog") ||
640
g_pattern_match_string (pattern, "alert") ||
641
g_pattern_match_string (pattern, "file_chooser") ||
642
g_pattern_match_string (pattern, "font_chooser"))) {
646
g_pattern_spec_free (pattern);
647
if (g_hash_table_lookup_extended (value, "label", NULL, (gpointer) &tmp_label)) {
649
g_print ("Label glob: %s - %s\n", (gchar *)key, (gchar *)value);
650
if (obj->pattern && (!obj->obj_is_window || flag == TRUE)) {
651
gboolean tmp_flag = g_pattern_match_string (obj->pattern, tmp_label);
652
if (tmp_flag && obj->parent_name && value) {
653
gchar *parent = get_property (value, "parent", NULL);
654
if (parent == NULL) {
655
// Only the window's parent can be
656
// empty in current hash table, so let
657
// us consider that the requested key
659
g_print ("Parent NULL\n");
662
if (parent && g_pattern_match_simple (obj->parent_name, parent))
669
if (g_hash_table_lookup_extended (value, "label_by", NULL, (gpointer) &tmp_label_by)) {
670
g_print ("Label_By glob: %s\n", tmp_label_by);
671
if (obj->pattern && (!obj->obj_is_window || flag)) {
672
gboolean tmp_flag = g_pattern_match_string (obj->pattern, tmp_label_by);
673
if (tmp_flag && obj->parent_name && value) {
674
gchar *parent = get_property (value, "parent", NULL);
675
if (parent == NULL) {
676
// Only the window's parent can be
677
// empty in current hash table, so let
678
// us consider that the requested key
680
g_print ("Parent NULL\n");
683
if (parent && g_pattern_match_simple (obj->parent_name, parent))
693
search_window_label_glob_based (gpointer key, gpointer value, gpointer user_data)
696
obj = (OBJInfo *) user_data;
697
if (obj && obj->ht_data_list && search_label_glob_based (key, value, user_data)) {
698
g_hash_table_insert (obj->ht_data_list, g_strdup ((gchar *) key), value);
704
search_label_name (gpointer key, gpointer value, gpointer user_data)
706
gchar *child_index = NULL;
707
UnknLabelProperty *tmp_data = (UnknLabelProperty *) user_data;
708
if (!value && !tmp_data && !key) {
711
if (g_hash_table_lookup_extended (value, "child_index", NULL, (gpointer) &child_index)) {
712
if ((gchar *)key && tmp_data->str_child_index && tmp_data->parent_name)
713
g_print ("Key - Child index - Parent: %s - %s - %s\n",
714
(gchar *)key, tmp_data->str_child_index,
715
tmp_data->parent_name);
716
if (child_index && tmp_data->str_child_index &&
717
g_utf8_collate (child_index, tmp_data->str_child_index) == 0) {
718
gchar *parent_name = NULL;
719
g_hash_table_lookup_extended (value, "parent", NULL, (gpointer) &parent_name);
720
g_print ("Key - Parent: %s - %s\n",
723
if (parent_name && tmp_data->parent_name &&
724
g_utf8_collate (parent_name, tmp_data->parent_name) == 0) {
725
tmp_data->obj_name = (gchar *) key;
735
search_obj_after_stripping_space (gpointer key, gpointer value, gpointer user_data)
738
OBJInfo *obj = (OBJInfo *) user_data;
739
if (!key || !user_data || !obj->key)
741
if (g_utf8_strchr (obj->key, -1, ' ') == NULL)
743
tmp = escape_character (obj->key, ' ');
746
g_print ("DEBUG: %s - %s - %s\n", tmp, (gchar *)obj->key, (gchar *)key);
747
if (g_utf8_collate (key, tmp) == 0 || g_utf8_collate (key, obj->key) == 0) {
752
gchar *glob_str = NULL;
754
FIXME: Use get_object_info function to get the the type of object
755
and based on that use the convention, instead of directly using *
757
glob_str = g_strdup_printf ("*%s", tmp);
758
g_print ("Glob str: %s - %s - %s\n", glob_str, (gchar *)key, tmp);
759
if (g_pattern_match_simple (glob_str, key) ||
760
g_pattern_match_simple (key, tmp)) {
761
g_print ("search_obj_after_stripping_space - matched\n");
773
search_window_after_stripping_space (gpointer key, gpointer value, gpointer user_data)
776
if (!key || !user_data || !value)
778
obj = (OBJInfo *) user_data;
779
if (obj && obj->ht_data_list && search_obj_after_stripping_space (key, value, obj)) {
780
g_hash_table_insert (obj->ht_data_list, g_strdup ((gchar *) key), value);
785
get_all_matching_def (GHashTable *ht, gchar *context, gboolean obj_is_window, FILE *log_fp)
787
GHashTable *ht_data_list = NULL;
791
GPatternSpec *pattern = NULL;
793
err = LDTP_ERROR_APPMAP_NOT_INITIALIZED;
794
g_print ("%s - %d - %s\n", __FILE__, __LINE__, ldtp_error_get_message (err));
795
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
798
if (context == NULL) {
799
err = LDTP_ERROR_ARGUMENT_NULL;
800
g_print ("%s\n", ldtp_error_get_message (err));
801
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
804
ht_data_list = g_hash_table_new_full (&g_str_hash, &g_str_equal,
805
destroy_string, NULL);
807
obj.parent_name = NULL;
808
obj.obj_is_window = obj_is_window;
809
obj.ht_data_list = ht_data_list;
810
g_hash_table_foreach (ht, search_window_key_based, &obj);
812
if (!g_hash_table_size (ht_data_list)) {
814
Search key based on glob expression
816
g_print ("Search key based on glob expression: %s %s %d\n", context, __FILE__, __LINE__);
818
pattern = g_pattern_spec_new ((const gchar *)context);
820
obj.obj_is_window = obj_is_window;
821
obj.pattern = pattern;
823
obj.ht_data_list = ht_data_list;
824
g_hash_table_foreach (ht, search_window_key_glob_based, &obj);
826
g_pattern_spec_free (pattern);
828
if (!g_hash_table_size (ht_data_list)) {
832
g_print ("Search label based: %s\n", context);
836
obj.parent_name = NULL;
837
obj.obj_is_window = obj_is_window;
838
obj.ht_data_list = ht_data_list;
839
g_hash_table_foreach (ht, search_window_label_based, &obj);
841
if (!g_hash_table_size (ht_data_list)) {
843
Search label based on glob expression
846
GPatternSpec *pattern = NULL;
848
g_print ("Search label based on glob expression: %s\n", context);
850
pattern = g_pattern_spec_new (context);
852
obj.pattern = pattern;
854
obj.parent_name = NULL;
855
obj.obj_is_window = obj_is_window;
856
obj.ht_data_list = ht_data_list;
857
g_hash_table_foreach (ht, search_window_label_glob_based, &obj);
859
g_pattern_spec_free (pattern);
861
if (!g_hash_table_size (ht_data_list)) {
863
Search key after stripping space
865
g_print ("Search key after stripping space: %s\n", context);
867
obj.parent_name = NULL;
868
obj.obj_is_window = obj_is_window;
869
obj.ht_data_list = ht_data_list;
870
g_hash_table_foreach (ht, search_window_after_stripping_space, &obj);
876
match_object_def (gchar *key, gchar *value, gboolean obj_is_window)
880
GPatternSpec *pattern = NULL;
882
Search key based on glob expression
884
g_print ("Search key based on glob expression: %s %s %d\n", key, __FILE__, __LINE__);
886
pattern = g_pattern_spec_new (/*(const ggchar *)*/key);
888
obj.obj_is_window = obj_is_window;
889
obj.pattern = pattern;
891
if (search_key_glob_based (value, NULL, &obj)) {
893
g_pattern_spec_free (pattern);
897
g_pattern_spec_free (pattern);
899
g_print ("Search label based: %s - %d\n", value, obj_is_window);
901
obj.obj_is_window = obj_is_window;
904
if (search_label_based (NULL, value, &obj))
907
g_print ("Search label based on glob expression\n");
909
pattern = g_pattern_spec_new (key);
911
obj.obj_is_window = obj_is_window;
912
obj.pattern = pattern;
914
if (search_label_glob_based (NULL, value, &obj)) {
916
g_pattern_spec_free (pattern);
920
g_pattern_spec_free (pattern);
922
Search key after stripping space
924
g_print ("Search key after stripping space\n");
925
if (search_obj_after_stripping_space (key, NULL, value))
928
g_sprintf (msg, "Object definition %s not match", key);
929
g_print ("%s\n", msg);
934
Get window definition
937
get_object_def (GHashTable *ht, gchar *context, gchar *parent, FILE *log_fp, gboolean obj_is_window)
942
GPatternSpec *pattern = NULL;
943
GHashTable *ht_context = NULL;
946
err = LDTP_ERROR_APPMAP_NOT_INITIALIZED;
947
g_print ("%s - %d - %s\n", __FILE__, __LINE__, ldtp_error_get_message (err));
948
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
951
if (context == NULL) {
952
err = LDTP_ERROR_ARGUMENT_NULL;
953
g_print ("%s\n", ldtp_error_get_message (err));
954
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
958
Search given context in hash table
960
if (g_utf8_strchr (context, -1, '#')) {
962
Search key based on object index
965
g_print ("Search based on index: %s\n", context);
967
obj.parent_name = parent;
968
obj.obj_is_window = obj_is_window;
969
ht_context = g_hash_table_find (ht, search_obj_based_on_index, &obj);
972
g_print ("Search based on key: %s\n", context);
974
obj.parent_name = parent;
975
obj.obj_is_window = obj_is_window;
976
ht_context = g_hash_table_find (ht, search_key_based, &obj);
980
Search key based on glob expression
982
g_print ("Search key based on glob expression: %s - %d %s %d\n", context, obj_is_window, __FILE__, __LINE__);
984
pattern = g_pattern_spec_new ((const gchar *)context);
986
obj.pattern = pattern;
988
obj.parent_name = parent;
989
obj.obj_is_window = obj_is_window;
990
ht_context = g_hash_table_find (ht, search_key_glob_based, &obj);
992
g_pattern_spec_free (pattern);
1000
g_print ("Search label based: %s - %d\n", context, obj_is_window);
1004
obj.parent_name = parent;
1005
obj.obj_is_window = obj_is_window;
1006
ht_context = g_hash_table_find (ht, search_label_based, &obj);
1010
Search label based on glob expression
1013
GPatternSpec *pattern = NULL;
1015
g_print ("Search label based on glob expression: %s\n", context);
1017
pattern = g_pattern_spec_new (context);
1019
obj.pattern = pattern;
1021
obj.parent_name = parent;
1022
obj.obj_is_window = obj_is_window;
1023
ht_context = g_hash_table_find (ht, search_label_glob_based, &obj);
1025
g_pattern_spec_free (pattern);
1029
Search key after stripping space
1031
g_print ("Search key after stripping space: %s\n", context);
1033
obj.parent_name = parent;
1034
obj.obj_is_window = obj_is_window;
1035
ht_context = g_hash_table_find (ht, search_obj_after_stripping_space, &obj);
1038
g_sprintf (msg, "Object definition %s not found in appmap", context);
1039
g_print ("%s\n", msg);
1040
log_msg (LDTP_LOG_DEBUG, msg, log_fp);
1046
find_property (gpointer key, gpointer value, gpointer user_data)
1048
if (!key || !value || !user_data)
1051
g_print ("User data: %s\n", (gchar *) user_data);
1052
// g_print ("Value: %s\n", (gchar *) value);
1053
g_print ("Key: %s\n", (gchar *) key);
1056
if (g_utf8_collate (key, user_data) == 0)
1062
get_property (GHashTable *ht, gchar *property, FILE *log_fp)
1064
gchar *value = NULL;
1069
err = LDTP_ERROR_APPMAP_NOT_INITIALIZED;
1070
g_print ("%s - %d - %s\n", __FILE__, __LINE__, ldtp_error_get_message (err));
1071
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
1074
if (property == NULL) {
1075
err = LDTP_ERROR_ARGUMENT_NULL;
1076
g_print ("%s\n", ldtp_error_get_message (err));
1077
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (err), log_fp);
1080
value = (gchar *) g_hash_table_find (ht, find_property, (gpointer) property);
1082
g_sprintf (msg, "Property %s not found in appmap", property);
1083
g_print ("%s\n", msg);
1084
log_msg (LDTP_LOG_DEBUG, msg, log_fp);
1086
g_print ("Property: %s - Value: %s\n", property, value);
1091
search_title_based (gpointer key, gpointer value, gpointer user_data)
1093
gchar *tmp_key = NULL;
1094
if (!key && !user_data)
1096
if (g_utf8_collate (key, user_data) == 0)
1098
if (g_pattern_match_simple (key, user_data))
1100
tmp_key = g_strdup_printf ("*%s", (gchar *)key);
1101
if (tmp_key && g_pattern_match_simple (tmp_key, user_data)) {