summaryrefslogtreecommitdiff
path: root/src/examples/eldbus
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 16:53:54 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-03 17:22:18 -0300
commit865b69f6ff3f095e5d81648c391b2e9fb8519fdf (patch)
tree8255be1d494f5f79f0b4c1086e2c39922ba67d85 /src/examples/eldbus
parent8fec0d5139a3ff30037ba159bb62ff2f733d96a8 (diff)
eina: Fix examples using new Eina_Promise semantics
Diffstat (limited to 'src/examples/eldbus')
-rw-r--r--src/examples/eldbus/dbusmodel.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/examples/eldbus/dbusmodel.c b/src/examples/eldbus/dbusmodel.c
index a7c8ee7..4cc7178 100644
--- a/src/examples/eldbus/dbusmodel.c
+++ b/src/examples/eldbus/dbusmodel.c
@@ -15,21 +15,15 @@
15 15
16static int prop_count = 0; 16static int prop_count = 0;
17 17
18struct eina_iterator
19{
20 Eina_Iterator* success_iterator;
21 Eina_Iterator* failure_iterator;
22};
23
24static void 18static void
25promise_then_prop_c(Eo* obj, struct eina_iterator* it_struct) 19promise_then_prop_c(Eo* obj, void* data)
26{ 20{
27 Eina_Value * property_value; 21 Eina_Value * property_value;
28 const Eina_Array *properties_list; 22 const Eina_Array *properties_list;
29 Eina_Array_Iterator a_it; 23 Eina_Array_Iterator a_it;
30 char *property, *prop_str; 24 char *property, *prop_str;
31 const char *name; 25 const char *name;
32 Eina_Iterator* it = it_struct->success_iterator; 26 Eina_Iterator* it = data;
33 27
34 name = eldbus_model_proxy_name_get(obj); 28 name = eldbus_model_proxy_name_get(obj);
35 properties_list = efl_model_properties_get(obj); 29 properties_list = efl_model_properties_get(obj);
@@ -59,7 +53,7 @@ error_cb(void* data EINA_UNUSED, const Eina_Error *error EINA_UNUSED)
59} 53}
60 54
61static void 55static void
62promise_then_a(Eo* obj EINA_UNUSED, Eina_Accessor **accessor) 56promise_then_a(Eo* obj EINA_UNUSED, void* data)
63{ 57{
64 const Eina_Array *properties_list; 58 const Eina_Array *properties_list;
65 Eina_Array_Iterator a_it; 59 Eina_Array_Iterator a_it;
@@ -68,8 +62,9 @@ promise_then_a(Eo* obj EINA_UNUSED, Eina_Accessor **accessor)
68 char *property; 62 char *property;
69 Eo* child; 63 Eo* child;
70 int i = 0; 64 int i = 0;
65 Eina_Accessor* accessor = data;
71 66
72 EINA_ACCESSOR_FOREACH(*accessor, i, child) 67 EINA_ACCESSOR_FOREACH(accessor, i, child)
73 { 68 {
74 properties_list = efl_model_properties_get(child); 69 properties_list = efl_model_properties_get(child);
75 name = eldbus_model_proxy_name_get(child); 70 name = eldbus_model_proxy_name_get(child);
@@ -87,7 +82,7 @@ promise_then_a(Eo* obj EINA_UNUSED, Eina_Accessor **accessor)
87 efl_model_property_get(child, property, &promises[j]); 82 efl_model_property_get(child, property, &promises[j]);
88 } 83 }
89 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void **)promises)), 84 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void **)promises)),
90 (Eina_Promise_Cb)&promise_then_prop_c, &error_cb, child); 85 &promise_then_prop_c, &error_cb, child);
91 prop_count++; 86 prop_count++;
92 } 87 }
93 else 88 else
@@ -100,14 +95,14 @@ promise_then_a(Eo* obj EINA_UNUSED, Eina_Accessor **accessor)
100 ecore_main_loop_quit(); 95 ecore_main_loop_quit();
101} 96}
102static void 97static void
103promise_then(Eo* obj EINA_UNUSED, struct eina_iterator* it_struct) 98promise_then(Eo* obj EINA_UNUSED, void* data)
104{ 99{
105 Eina_Accessor **accessor; 100 Eina_Accessor *accessor;
106 unsigned int* count; 101 unsigned int* count;
107 102
108 Eina_Iterator* iterator = it_struct->success_iterator; 103 Eina_Iterator* iterator = data;
109 104
110 if (!eina_iterator_next(iterator, (void **)&accessor)) 105 if (!eina_iterator_next(iterator, (void**)&accessor))
111 { 106 {
112 printf("bye\n"); 107 printf("bye\n");
113 ecore_main_loop_quit(); 108 ecore_main_loop_quit();
@@ -144,7 +139,7 @@ main(int argc, char **argv EINA_UNUSED)
144 efl_model_children_count_get(root, &promises[1]); 139 efl_model_children_count_get(root, &promises[1]);
145 140
146 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void **)promises)), 141 eina_promise_then(eina_promise_all(eina_carray_iterator_new((void **)promises)),
147 (Eina_Promise_Cb)&promise_then, &error_cb, root); 142 &promise_then, &error_cb, root);
148 143
149 ecore_main_loop_begin(); 144 ecore_main_loop_begin();
150 145