summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2015-06-29 09:14:48 +0200
committerLukasz Stanislawski <l.stanislaws@samsung.com>2015-06-29 09:15:54 +0200
commit493e87847e52785a67c70b7d0fd6413557a68d9e (patch)
tree2b01259f4de59a1c9c55348de0e3c5532a0abff3
parent6840832bf0dffb0278d597473b7110d8a31b5b18 (diff)
atspi: add cache_closure structure to avoid global reference
Change-Id: I9349ace9d152546d10bba242d55e2ffca1a4a418
-rw-r--r--src/lib/elm_atspi_bridge.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/lib/elm_atspi_bridge.c b/src/lib/elm_atspi_bridge.c
index 3d9b4d607..989a484a4 100644
--- a/src/lib/elm_atspi_bridge.c
+++ b/src/lib/elm_atspi_bridge.c
@@ -78,6 +78,11 @@ typedef struct _Elm_Atspi_Bridge_Data
78 Eina_Bool connected : 1; 78 Eina_Bool connected : 1;
79} Elm_Atspi_Bridge_Data; 79} Elm_Atspi_Bridge_Data;
80 80
81struct cache_closure {
82 Eo *bridge;
83 Eldbus_Message_Iter *iter;
84};
85
81static Eo *_instance; 86static Eo *_instance;
82static int _init_count = 0; 87static int _init_count = 0;
83 88
@@ -2327,11 +2332,12 @@ _cache_item_reference_append_cb(const Eina_Hash *hash EINA_UNUSED, const void *k
2327 if (!eo_ref_get(data) || eo_destructed_is(data)) 2332 if (!eo_ref_get(data) || eo_destructed_is(data))
2328 return EINA_TRUE; 2333 return EINA_TRUE;
2329 2334
2335 struct cache_closure *cl = fdata;
2330 Eldbus_Message_Iter *iter_struct, *iter_sub_array; 2336 Eldbus_Message_Iter *iter_struct, *iter_sub_array;
2331 Eldbus_Message_Iter *iter_array = fdata; 2337 Eldbus_Message_Iter *iter_array = cl->iter;
2332 Elm_Atspi_State_Set states; 2338 Elm_Atspi_State_Set states;
2333 Elm_Atspi_Role role; 2339 Elm_Atspi_Role role;
2334 Eo *root = elm_atspi_bridge_root_get(_instance); 2340 Eo *root = elm_atspi_bridge_root_get(cl->bridge);
2335 2341
2336 eo_do(data, role = elm_interface_atspi_accessible_role_get()); 2342 eo_do(data, role = elm_interface_atspi_accessible_role_get());
2337 2343
@@ -2339,10 +2345,10 @@ _cache_item_reference_append_cb(const Eina_Hash *hash EINA_UNUSED, const void *k
2339 EINA_SAFETY_ON_NULL_RETURN_VAL(iter_struct, EINA_TRUE); 2345 EINA_SAFETY_ON_NULL_RETURN_VAL(iter_struct, EINA_TRUE);
2340 2346
2341 /* Marshall object path */ 2347 /* Marshall object path */
2342 _bridge_iter_object_reference_append(_instance, iter_struct, data); 2348 _bridge_iter_object_reference_append(cl->bridge, iter_struct, data);
2343 2349
2344 /* Marshall application */ 2350 /* Marshall application */
2345 _bridge_iter_object_reference_append(_instance, iter_struct, root); 2351 _bridge_iter_object_reference_append(cl->bridge, iter_struct, root);
2346 2352
2347 Eo *parent = NULL; 2353 Eo *parent = NULL;
2348 eo_do(data, parent = elm_interface_atspi_accessible_parent_get()); 2354 eo_do(data, parent = elm_interface_atspi_accessible_parent_get());
@@ -2350,7 +2356,7 @@ _cache_item_reference_append_cb(const Eina_Hash *hash EINA_UNUSED, const void *k
2350 if ((!parent) && (ELM_ATSPI_ROLE_APPLICATION == role)) 2356 if ((!parent) && (ELM_ATSPI_ROLE_APPLICATION == role))
2351 _object_desktop_reference_append(iter_struct); 2357 _object_desktop_reference_append(iter_struct);
2352 else 2358 else
2353 _bridge_iter_object_reference_append(_instance, iter_struct, parent); 2359 _bridge_iter_object_reference_append(cl->bridge, iter_struct, parent);
2354 2360
2355 /* Marshall children */ 2361 /* Marshall children */
2356 Eina_List *children_list = NULL, *l; 2362 Eina_List *children_list = NULL, *l;
@@ -2361,7 +2367,7 @@ _cache_item_reference_append_cb(const Eina_Hash *hash EINA_UNUSED, const void *k
2361 EINA_SAFETY_ON_NULL_GOTO(iter_sub_array, fail); 2367 EINA_SAFETY_ON_NULL_GOTO(iter_sub_array, fail);
2362 2368
2363 EINA_LIST_FOREACH(children_list, l, child) 2369 EINA_LIST_FOREACH(children_list, l, child)
2364 _bridge_iter_object_reference_append(_instance, iter_sub_array, child); 2370 _bridge_iter_object_reference_append(cl->bridge, iter_sub_array, child);
2365 2371
2366 eldbus_message_iter_container_close(iter_struct, iter_sub_array); 2372 eldbus_message_iter_container_close(iter_struct, iter_sub_array);
2367 eina_list_free(children_list); 2373 eina_list_free(children_list);
@@ -2412,8 +2418,10 @@ fail:
2412static Eldbus_Message * 2418static Eldbus_Message *
2413_cache_get_items(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg) 2419_cache_get_items(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
2414{ 2420{
2415 Eldbus_Message_Iter *iter, *iter_array; 2421 Eldbus_Message_Iter *iter;
2416 Eldbus_Message *ret; 2422 Eldbus_Message *ret;
2423 struct cache_closure cl;
2424
2417 Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME); 2425 Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME);
2418 if (!bridge) return NULL; 2426 if (!bridge) return NULL;
2419 2427
@@ -2423,11 +2431,13 @@ _cache_get_items(const Eldbus_Service_Interface *iface, const Eldbus_Message *ms
2423 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); 2431 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
2424 2432
2425 iter = eldbus_message_iter_get(ret); 2433 iter = eldbus_message_iter_get(ret);
2426 iter_array = eldbus_message_iter_container_new(iter, 'a', CACHE_ITEM_SIGNATURE); 2434 cl.iter = eldbus_message_iter_container_new(iter, 'a', CACHE_ITEM_SIGNATURE);
2427 EINA_SAFETY_ON_NULL_GOTO(iter_array, fail); 2435 EINA_SAFETY_ON_NULL_GOTO(cl.iter, fail);
2428 2436
2429 eina_hash_foreach(pd->cache, _cache_item_reference_append_cb, iter_array); 2437 cl.bridge = bridge;
2430 eldbus_message_iter_container_close(iter, iter_array); 2438
2439 eina_hash_foreach(pd->cache, _cache_item_reference_append_cb, &cl);
2440 eldbus_message_iter_container_close(iter, cl.iter);
2431 2441
2432 return ret; 2442 return ret;
2433fail: 2443fail:
@@ -3495,6 +3505,7 @@ _screen_reader_enabled_get(void *data, const Eldbus_Message *msg, Eldbus_Pending
3495static void _bridge_object_register(Eo *bridge, Eo *obj) 3505static void _bridge_object_register(Eo *bridge, Eo *obj)
3496{ 3506{
3497 char *path; 3507 char *path;
3508 struct cache_closure cc;
3498 Eldbus_Message *sig; 3509 Eldbus_Message *sig;
3499 Eldbus_Service_Interface *ifc; 3510 Eldbus_Service_Interface *ifc;
3500 3511
@@ -3581,8 +3592,9 @@ static void _bridge_object_register(Eo *bridge, Eo *obj)
3581 } 3592 }
3582 3593
3583 sig = eldbus_service_signal_new(pd->cache_interface, ATSPI_OBJECT_CHILD_ADDED); 3594 sig = eldbus_service_signal_new(pd->cache_interface, ATSPI_OBJECT_CHILD_ADDED);
3584 Eldbus_Message_Iter *iter = eldbus_message_iter_get(sig); 3595 cc.iter = eldbus_message_iter_get(sig);
3585 _cache_item_reference_append_cb(NULL, NULL, obj, iter); 3596 cc.bridge = bridge;
3597 _cache_item_reference_append_cb(NULL, NULL, obj, &cc);
3586 3598
3587 eldbus_service_signal_send(pd->cache_interface, sig); 3599 eldbus_service_signal_send(pd->cache_interface, sig);
3588 3600