summaryrefslogtreecommitdiff
path: root/src/lib/eldbus
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2016-04-20 17:07:53 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-04-29 13:21:24 -0300
commit0c76f82a31b1ad06a4da4c12f1a02139e0d0c6fa (patch)
tree254f0542b8fc5ea1af14936da8e6806262f3f8a6 /src/lib/eldbus
parent42346e22f4c06634e180c44cf63924dbc50a5184 (diff)
Efl, Eio, Eldbus, Elementary: new model API use eina_promise
Efl - efl_model_base changed to use eina_promise Eio - eio_model use efl_model_base with promise Eldbus - elddbus models use promise now Elementary - elm_view_list and elm_view_form use new models with promise updated all related examples and tests
Diffstat (limited to 'src/lib/eldbus')
-rw-r--r--src/lib/eldbus/eldbus_model_arguments.c144
-rw-r--r--src/lib/eldbus/eldbus_model_arguments.eo13
-rw-r--r--src/lib/eldbus/eldbus_model_arguments_private.h1
-rw-r--r--src/lib/eldbus/eldbus_model_connection.c194
-rw-r--r--src/lib/eldbus/eldbus_model_connection.eo13
-rw-r--r--src/lib/eldbus/eldbus_model_connection_private.h6
-rw-r--r--src/lib/eldbus/eldbus_model_method.c5
-rw-r--r--src/lib/eldbus/eldbus_model_method.eo2
-rw-r--r--src/lib/eldbus/eldbus_model_object.c195
-rw-r--r--src/lib/eldbus/eldbus_model_object.eo13
-rw-r--r--src/lib/eldbus/eldbus_model_object_private.h9
-rw-r--r--src/lib/eldbus/eldbus_model_private.h30
-rw-r--r--src/lib/eldbus/eldbus_model_proxy.c304
-rw-r--r--src/lib/eldbus/eldbus_model_proxy.eo13
-rw-r--r--src/lib/eldbus/eldbus_model_proxy_private.h5
-rw-r--r--src/lib/eldbus/eldbus_model_signal.c22
-rw-r--r--src/lib/eldbus/eldbus_model_signal.eo2
17 files changed, 436 insertions, 535 deletions
diff --git a/src/lib/eldbus/eldbus_model_arguments.c b/src/lib/eldbus/eldbus_model_arguments.c
index 50bbc80e8d..d3271f0217 100644
--- a/src/lib/eldbus/eldbus_model_arguments.c
+++ b/src/lib/eldbus/eldbus_model_arguments.c
@@ -5,6 +5,7 @@
5#include "eldbus_model_arguments_private.h" 5#include "eldbus_model_arguments_private.h"
6#include "eldbus_model_private.h" 6#include "eldbus_model_private.h"
7 7
8#include <Ecore.h>
8#include <Eina.h> 9#include <Eina.h>
9#include <Eldbus.h> 10#include <Eldbus.h>
10 11
@@ -13,8 +14,7 @@
13 14
14#define ARGUMENT_FORMAT "arg%u" 15#define ARGUMENT_FORMAT "arg%u"
15 16
16static void _eldbus_model_arguments_efl_model_base_properties_load(Eo *, Eldbus_Model_Arguments_Data *); 17static void _eldbus_model_arguments_properties_load(Eldbus_Model_Arguments_Data *);
17static void _eldbus_model_arguments_efl_model_base_children_load(Eo *, Eldbus_Model_Arguments_Data *);
18static void _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *); 18static void _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *);
19static Eina_Bool _eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *, const char *); 19static Eina_Bool _eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *, const char *);
20static Eina_Bool _eldbus_model_arguments_is_output_argument(Eldbus_Model_Arguments_Data *, const char *); 20static Eina_Bool _eldbus_model_arguments_is_output_argument(Eldbus_Model_Arguments_Data *, const char *);
@@ -33,7 +33,6 @@ _eldbus_model_arguments_eo_base_constructor(Eo *obj, Eldbus_Model_Arguments_Data
33 obj = eo_constructor(eo_super(obj, MY_CLASS)); 33 obj = eo_constructor(eo_super(obj, MY_CLASS));
34 34
35 pd->obj = obj; 35 pd->obj = obj;
36 pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
37 pd->properties_array = NULL; 36 pd->properties_array = NULL;
38 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_arguments_hash_free)); 37 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_arguments_hash_free));
39 pd->pending_list = NULL; 38 pd->pending_list = NULL;
@@ -71,31 +70,23 @@ _eldbus_model_arguments_eo_base_destructor(Eo *obj, Eldbus_Model_Arguments_Data
71 eo_destructor(eo_super(obj, MY_CLASS)); 70 eo_destructor(eo_super(obj, MY_CLASS));
72} 71}
73 72
74static Efl_Model_Load_Status 73static Eina_Array const *
75_eldbus_model_arguments_efl_model_base_properties_get(Eo *obj EINA_UNUSED, 74_eldbus_model_arguments_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
76 Eldbus_Model_Arguments_Data *pd, 75 Eldbus_Model_Arguments_Data *pd)
77 Eina_Array * const* properties_array)
78{ 76{
79 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR); 77 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
80 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
81 78
82 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)) 79 _eldbus_model_arguments_properties_load(pd);
83 { 80 return pd->properties_array;
84 ERR("%s", "o not loaded.");
85 return EFL_MODEL_LOAD_STATUS_ERROR;
86 }
87
88 *(Eina_Array**)properties_array = pd->properties_array;
89 return pd->load.status;
90} 81}
91 82
92static void 83static void
93_eldbus_model_arguments_efl_model_base_properties_load(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd) 84_eldbus_model_arguments_properties_load(Eldbus_Model_Arguments_Data *pd)
94{ 85{
95 unsigned int arguments_count; 86 unsigned int arguments_count;
96 unsigned int i; 87 unsigned int i;
97 88
98 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES) 89 if (pd->properties_array)
99 return; 90 return;
100 91
101 arguments_count = eina_list_count(pd->arguments); 92 arguments_count = eina_list_count(pd->arguments);
@@ -120,86 +111,55 @@ _eldbus_model_arguments_efl_model_base_properties_load(Eo *obj EINA_UNUSED, Eldb
120 value = eina_value_new(type); 111 value = eina_value_new(type);
121 eina_hash_add(pd->properties_hash, name, value); 112 eina_hash_add(pd->properties_hash, name, value);
122 } 113 }
123
124 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
125} 114}
126 115
127static Efl_Model_Load_Status 116static void
128_eldbus_model_arguments_efl_model_base_property_set(Eo *obj EINA_UNUSED, 117_eldbus_model_arguments_efl_model_base_property_set(Eo *obj EINA_UNUSED,
129 Eldbus_Model_Arguments_Data *pd, 118 Eldbus_Model_Arguments_Data *pd,
130 const char *property, 119 const char *property,
131 Eina_Value const* value) 120 Eina_Value const* value,
121 Eina_Promise_Owner *promise)
132{ 122{
133 Eina_Value *prop_value; 123 Eina_Value *prop_value;
134 Eina_Bool ret;
135 124
136 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 125 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(property, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
137 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR); 126 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(value, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
138 DBG("(%p): property=%s", obj, property); 127 DBG("(%p): property=%s", obj, property);
139 128
140 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)) 129 _eldbus_model_arguments_properties_load(pd);
141 return EFL_MODEL_LOAD_STATUS_ERROR;
142 130
143 if (!_eldbus_model_arguments_is_input_argument(pd, property)) 131 Eina_Bool ret = _eldbus_model_arguments_is_input_argument(pd, property);
144 { 132 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_READ_ONLY);
145 WRN("Property (argument) not found or it is for output only: %s", property);
146 return EFL_MODEL_LOAD_STATUS_ERROR;
147 }
148 133
149 prop_value = eina_hash_find(pd->properties_hash, property); 134 prop_value = eina_hash_find(pd->properties_hash, property);
150 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EFL_MODEL_LOAD_STATUS_ERROR); 135 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(prop_value, promise, EFL_MODEL_ERROR_NOT_FOUND);
151 136
152 eina_value_flush(prop_value); 137 eina_value_flush(prop_value);
153 ret = eina_value_copy(value, prop_value); 138 eina_value_copy(value, prop_value);
154 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR); 139 eina_promise_owner_value_set(promise, prop_value, NULL);
155
156 return pd->load.status;
157} 140}
158 141
159static Efl_Model_Load_Status 142static void
160_eldbus_model_arguments_efl_model_base_property_get(Eo *obj EINA_UNUSED, 143_eldbus_model_arguments_efl_model_base_property_get(Eo *obj EINA_UNUSED,
161 Eldbus_Model_Arguments_Data *pd, 144 Eldbus_Model_Arguments_Data *pd,
162 const char *property, 145 const char *property,
163 Eina_Value const ** value) 146 Eina_Promise_Owner *promise)
164{ 147{
165 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 148 EINA_SAFETY_ON_NULL_RETURN(promise);
166 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
167 DBG("(%p): property=%s", obj, property);
168 149
169 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)) 150 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(property, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
170 return EFL_MODEL_LOAD_STATUS_ERROR; 151 DBG("(%p): property=%s", obj, property);
171 152
172 if (!_eldbus_model_arguments_is_output_argument(pd, property)) 153 _eldbus_model_arguments_properties_load(pd);
173 {
174 WRN("Property (argument) not found or it is for input only: %s", property);
175 return EFL_MODEL_LOAD_STATUS_ERROR;
176 }
177 154
178 *value = eina_hash_find(pd->properties_hash, property); 155 Eina_Bool ret = _eldbus_model_arguments_is_output_argument(pd, property);
179 EINA_SAFETY_ON_NULL_RETURN_VAL(*value, EFL_MODEL_LOAD_STATUS_ERROR); 156 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_PERMISSION_DENIED);
180 157
181 return pd->load.status; 158 Eina_Value* value = eina_hash_find(pd->properties_hash, property);
182} 159 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(value, promise, EFL_MODEL_ERROR_NOT_FOUND);
183 160
184static void 161 eina_value_copy(value, eina_promise_owner_buffer_get(promise));
185_eldbus_model_arguments_efl_model_base_load(Eo *obj, Eldbus_Model_Arguments_Data *pd EINA_UNUSED) 162 eina_promise_owner_value_set(promise, NULL, (Eina_Promise_Free_Cb)&eina_value_flush);
186{
187 efl_model_properties_load(obj);
188 efl_model_children_load(obj);
189}
190
191static Efl_Model_Load_Status
192_eldbus_model_arguments_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd)
193{
194 return pd->load.status;
195}
196
197static void
198_eldbus_model_arguments_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd)
199{
200 _eldbus_model_arguments_unload(pd);
201
202 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
203} 163}
204 164
205static Eo * 165static Eo *
@@ -208,41 +168,30 @@ _eldbus_model_arguments_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Mod
208 return NULL; 168 return NULL;
209} 169}
210 170
211static Efl_Model_Load_Status 171static void
212_eldbus_model_arguments_efl_model_base_child_del(Eo *obj EINA_UNUSED, 172_eldbus_model_arguments_efl_model_base_child_del(Eo *obj EINA_UNUSED,
213 Eldbus_Model_Arguments_Data *pd EINA_UNUSED, 173 Eldbus_Model_Arguments_Data *pd EINA_UNUSED,
214 Eo *child EINA_UNUSED) 174 Eo *child EINA_UNUSED)
215{ 175{
216 return EFL_MODEL_LOAD_STATUS_ERROR;
217} 176}
218 177
219static Efl_Model_Load_Status 178static void
220_eldbus_model_arguments_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED, 179_eldbus_model_arguments_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
221 Eldbus_Model_Arguments_Data *pd, 180 Eldbus_Model_Arguments_Data *pd EINA_UNUSED,
222 unsigned start EINA_UNUSED, 181 unsigned start EINA_UNUSED,
223 unsigned count EINA_UNUSED, 182 unsigned count EINA_UNUSED,
224 Eina_Accessor **children_accessor) 183 Eina_Promise_Owner *promise)
225{ 184{
226 *children_accessor = NULL; 185 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_SUPPORTED);
227 return pd->load.status;
228}
229
230static Efl_Model_Load_Status
231_eldbus_model_arguments_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
232 Eldbus_Model_Arguments_Data *pd,
233 unsigned *children_count)
234{
235 *children_count = 0;
236 return pd->load.status;
237} 186}
238 187
239static void 188static void
240_eldbus_model_arguments_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd) 189_eldbus_model_arguments_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
190 Eldbus_Model_Arguments_Data *pd EINA_UNUSED,
191 Eina_Promise_Owner *promise)
241{ 192{
242 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN) 193 unsigned count = 0;
243 return; 194 eina_promise_owner_value_set(promise, &count, NULL);
244
245 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
246} 195}
247 196
248static const char * 197static const char *
@@ -289,11 +238,13 @@ eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *pd,
289 unsigned int i = 0; 238 unsigned int i = 0;
290 Eina_Bool result = EINA_FALSE; 239 Eina_Bool result = EINA_FALSE;
291 240
241 _eldbus_model_arguments_properties_load(pd);
242
292 pd->pending_list = eina_list_remove(pd->pending_list, pending); 243 pd->pending_list = eina_list_remove(pd->pending_list, pending);
293 if (eldbus_message_error_get(msg, &error_name, &error_text)) 244 if (eldbus_message_error_get(msg, &error_name, &error_text))
294 { 245 {
295 ERR("%s: %s", error_name, error_text); 246 ERR("%s: %s", error_name, error_text);
296 efl_model_error_notify(pd->obj); 247 //efl_model_error_notify(pd->obj);
297 return EINA_FALSE; 248 return EINA_FALSE;
298 } 249 }
299 250
@@ -350,6 +301,8 @@ _eldbus_model_arguments_property_set(Eldbus_Model_Arguments_Data *pd,
350 Eina_Value value; 301 Eina_Value value;
351 Eina_Bool ret; 302 Eina_Bool ret;
352 303
304 _eldbus_model_arguments_properties_load(pd);
305
353 prop_value = eina_hash_find(pd->properties_hash, property); 306 prop_value = eina_hash_find(pd->properties_hash, property);
354 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EINA_FALSE); 307 EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EINA_FALSE);
355 308
@@ -372,6 +325,8 @@ _eldbus_model_arguments_is(Eldbus_Model_Arguments_Data *pd,
372 Eldbus_Introspection_Argument *argument_introspection; 325 Eldbus_Introspection_Argument *argument_introspection;
373 unsigned int i; 326 unsigned int i;
374 327
328 _eldbus_model_arguments_properties_load(pd);
329
375 i = _eldbus_model_arguments_argument_index_get(pd, argument); 330 i = _eldbus_model_arguments_argument_index_get(pd, argument);
376 if (i >= eina_array_count(pd->properties_array)) 331 if (i >= eina_array_count(pd->properties_array))
377 { 332 {
@@ -404,6 +359,7 @@ _eldbus_model_arguments_argument_index_get(Eldbus_Model_Arguments_Data *pd, cons
404 Eina_Stringshare *name; 359 Eina_Stringshare *name;
405 Eina_Array_Iterator it; 360 Eina_Array_Iterator it;
406 unsigned int i = 0; 361 unsigned int i = 0;
362 _eldbus_model_arguments_properties_load(pd);
407 363
408 EINA_ARRAY_ITER_NEXT(pd->properties_array, i, name, it) 364 EINA_ARRAY_ITER_NEXT(pd->properties_array, i, name, it)
409 { 365 {
diff --git a/src/lib/eldbus/eldbus_model_arguments.eo b/src/lib/eldbus/eldbus_model_arguments.eo
index 3e4e51beed..e6278439de 100644
--- a/src/lib/eldbus/eldbus_model_arguments.eo
+++ b/src/lib/eldbus/eldbus_model_arguments.eo
@@ -27,17 +27,12 @@ class Eldbus.Model_Arguments (Eo.Base, Efl.Model.Base) {
27 Eo.Base.constructor; 27 Eo.Base.constructor;
28 Eo.Base.destructor; 28 Eo.Base.destructor;
29 Efl.Model.Base.properties.get; 29 Efl.Model.Base.properties.get;
30 Efl.Model.Base.properties_load; 30 Efl.Model.Base.property_set;
31 Efl.Model.Base.property.set; 31 Efl.Model.Base.property_get;
32 Efl.Model.Base.property.get;
33 Efl.Model.Base.load;
34 Efl.Model.Base.load_status.get;
35 Efl.Model.Base.unload;
36 Efl.Model.Base.child_add; 32 Efl.Model.Base.child_add;
37 Efl.Model.Base.child_del; 33 Efl.Model.Base.child_del;
38 Efl.Model.Base.children_slice.get; 34 Efl.Model.Base.children_slice_get;
39 Efl.Model.Base.children_count.get; 35 Efl.Model.Base.children_count_get;
40 Efl.Model.Base.children_load;
41 } 36 }
42 constructors { 37 constructors {
43 .constructor; 38 .constructor;
diff --git a/src/lib/eldbus/eldbus_model_arguments_private.h b/src/lib/eldbus/eldbus_model_arguments_private.h
index 08e65d8437..06aa1aed9c 100644
--- a/src/lib/eldbus/eldbus_model_arguments_private.h
+++ b/src/lib/eldbus/eldbus_model_arguments_private.h
@@ -13,7 +13,6 @@ typedef struct _Eldbus_Model_Arguments_Data Eldbus_Model_Arguments_Data;
13struct _Eldbus_Model_Arguments_Data 13struct _Eldbus_Model_Arguments_Data
14{ 14{
15 Eo *obj; 15 Eo *obj;
16 Efl_Model_Load load;
17 Eldbus_Proxy *proxy; 16 Eldbus_Proxy *proxy;
18 Eina_Array *properties_array; 17 Eina_Array *properties_array;
19 Eina_Hash *properties_hash; 18 Eina_Hash *properties_hash;
diff --git a/src/lib/eldbus/eldbus_model_connection.c b/src/lib/eldbus/eldbus_model_connection.c
index e8f93fe8d2..07da95d59a 100644
--- a/src/lib/eldbus/eldbus_model_connection.c
+++ b/src/lib/eldbus/eldbus_model_connection.c
@@ -2,6 +2,7 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <Ecore.h>
5#include "eldbus_model_connection_private.h" 6#include "eldbus_model_connection_private.h"
6#include "eldbus_model_private.h" 7#include "eldbus_model_private.h"
7 8
@@ -10,8 +11,7 @@
10 11
11#define UNIQUE_NAME_PROPERTY "unique_name" 12#define UNIQUE_NAME_PROPERTY "unique_name"
12 13
13static void _eldbus_model_connection_efl_model_base_properties_load(Eo *, Eldbus_Model_Connection_Data *); 14
14static void _eldbus_model_connection_efl_model_base_children_load(Eo *, Eldbus_Model_Connection_Data *);
15static void _eldbus_model_connection_names_list_cb(void *, const Eldbus_Message *, Eldbus_Pending *); 15static void _eldbus_model_connection_names_list_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
16static void _eldbus_model_connection_connect(Eldbus_Model_Connection_Data *); 16static void _eldbus_model_connection_connect(Eldbus_Model_Connection_Data *);
17static void _eldbus_model_connection_disconnect(Eldbus_Model_Connection_Data *); 17static void _eldbus_model_connection_disconnect(Eldbus_Model_Connection_Data *);
@@ -23,7 +23,7 @@ _eldbus_model_connection_eo_base_constructor(Eo *obj, Eldbus_Model_Connection_Da
23 obj = eo_constructor(eo_super(obj, MY_CLASS)); 23 obj = eo_constructor(eo_super(obj, MY_CLASS));
24 24
25 pd->obj = obj; 25 pd->obj = obj;
26 pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED; 26 pd->is_listed = EINA_FALSE;
27 pd->connection = NULL; 27 pd->connection = NULL;
28 pd->properties_array = NULL; 28 pd->properties_array = NULL;
29 pd->children_list = NULL; 29 pd->children_list = NULL;
@@ -58,104 +58,66 @@ _eldbus_model_connection_eo_base_destructor(Eo *obj, Eldbus_Model_Connection_Dat
58 eo_destructor(eo_super(obj, MY_CLASS)); 58 eo_destructor(eo_super(obj, MY_CLASS));
59} 59}
60 60
61static Efl_Model_Load_Status 61static Eina_Array const *
62_eldbus_model_connection_efl_model_base_properties_get(Eo *obj EINA_UNUSED, 62_eldbus_model_connection_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
63 Eldbus_Model_Connection_Data *pd, 63 Eldbus_Model_Connection_Data *pd)
64 Eina_Array * const* properties_array)
65{ 64{
66 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR); 65 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
67 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR); 66 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, NULL);
68 67
69 if (pd->properties_array == NULL) 68 if (pd->properties_array == NULL)
70 { 69 {
71 Eina_Bool ret; 70 Eina_Bool ret;
72 71
73 pd->properties_array = eina_array_new(1); 72 pd->properties_array = eina_array_new(1);
74 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, EFL_MODEL_LOAD_STATUS_ERROR); 73 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, NULL);
75 74
76 ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY); 75 ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY);
77 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR); 76 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, NULL);
78 } 77 }
79 78
80 *(Eina_Array**)properties_array = pd->properties_array; 79 return pd->properties_array;
81 return pd->load.status;
82} 80}
83 81
84static void
85_eldbus_model_connection_efl_model_base_properties_load(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
86{
87 const char *unique_name;
88 Eina_Bool ret;
89
90 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
91 return;
92
93 if (!pd->connection)
94 _eldbus_model_connection_connect(pd);
95
96 pd->unique_name = eina_value_new(EINA_VALUE_TYPE_STRING);
97 EINA_SAFETY_ON_NULL_RETURN(pd->unique_name);
98 82
99 unique_name = eldbus_connection_unique_name_get(pd->connection); 83static void
100 ret = eina_value_set(pd->unique_name, unique_name);
101 EINA_SAFETY_ON_FALSE_RETURN(ret);
102
103 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
104}
105
106static Efl_Model_Load_Status
107_eldbus_model_connection_efl_model_base_property_set(Eo *obj EINA_UNUSED, 84_eldbus_model_connection_efl_model_base_property_set(Eo *obj EINA_UNUSED,
108 Eldbus_Model_Connection_Data *pd EINA_UNUSED, 85 Eldbus_Model_Connection_Data *pd EINA_UNUSED,
109 const char *property EINA_UNUSED, 86 const char *property,
110 Eina_Value const* value EINA_UNUSED) 87 Eina_Value const* value EINA_UNUSED,
88 Eina_Promise_Owner *promise)
111{ 89{
112 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 90 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET((strcmp(property, UNIQUE_NAME_PROPERTY) == 0), promise, EFL_MODEL_ERROR_NOT_FOUND);
113 DBG("(%p): property=%s", obj, property); 91 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_READ_ONLY);
114 return EFL_MODEL_LOAD_STATUS_ERROR;
115} 92}
116 93
117static Efl_Model_Load_Status 94static void
118_eldbus_model_connection_efl_model_base_property_get(Eo *obj EINA_UNUSED, 95_eldbus_model_connection_efl_model_base_property_get(Eo *obj EINA_UNUSED,
119 Eldbus_Model_Connection_Data *pd, 96 Eldbus_Model_Connection_Data *pd,
120 const char *property, 97 const char *property,
121 Eina_Value const **value) 98 Eina_Promise_Owner *promise)
122{ 99{
123 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 100 EINA_SAFETY_ON_NULL_RETURN(promise);
124 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
125 DBG("(%p): property=%s", obj, property); 101 DBG("(%p): property=%s", obj, property);
126 102
127 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
128 return EFL_MODEL_LOAD_STATUS_ERROR;
129
130 if (strcmp(property, UNIQUE_NAME_PROPERTY) != 0)
131 return EFL_MODEL_LOAD_STATUS_ERROR;
132
133 *value = pd->unique_name;
134 return pd->load.status;
135}
136
137static void
138_eldbus_model_connection_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
139{
140 if (!pd->connection) 103 if (!pd->connection)
141 _eldbus_model_connection_connect(pd); 104 _eldbus_model_connection_connect(pd);
142 105
143 _eldbus_model_connection_efl_model_base_properties_load(obj, pd); 106 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET((strcmp(property, UNIQUE_NAME_PROPERTY) == 0), promise, EFL_MODEL_ERROR_NOT_FOUND);
144 _eldbus_model_connection_efl_model_base_children_load(obj, pd);
145}
146 107
147static Efl_Model_Load_Status 108 if (pd->unique_name == NULL)
148_eldbus_model_connection_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd) 109 {
149{ 110 const char *unique_name;
150 return pd->load.status;
151}
152 111
153static void 112 unique_name = eldbus_connection_unique_name_get(pd->connection);
154_eldbus_model_connection_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd) 113 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(unique_name, promise, EFL_MODEL_ERROR_NOT_FOUND);
155{ 114 pd->unique_name = strdup(unique_name);
156 _eldbus_model_connection_clear(pd); 115 }
157 116
158 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED); 117 Eina_Value* v = eina_promise_owner_buffer_get(promise);
118 eina_value_setup(v, EINA_VALUE_TYPE_STRING);
119 eina_value_set(v, pd->unique_name);
120 eina_promise_owner_value_set(promise, NULL, (Eina_Promise_Free_Cb)&eina_value_flush);
159} 121}
160 122
161static Eo * 123static Eo *
@@ -164,56 +126,70 @@ _eldbus_model_connection_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Mo
164 return NULL; 126 return NULL;
165} 127}
166 128
167static Efl_Model_Load_Status 129static void
168_eldbus_model_connection_efl_model_base_child_del(Eo *obj EINA_UNUSED, 130_eldbus_model_connection_efl_model_base_child_del(Eo *obj EINA_UNUSED,
169 Eldbus_Model_Connection_Data *pd EINA_UNUSED, 131 Eldbus_Model_Connection_Data *pd EINA_UNUSED,
170 Eo *child EINA_UNUSED) 132 Eo *child EINA_UNUSED)
171{ 133{
172 return EFL_MODEL_LOAD_STATUS_ERROR;
173} 134}
174 135
175static Efl_Model_Load_Status 136static void
176_eldbus_model_connection_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED, 137_eldbus_model_connection_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
177 Eldbus_Model_Connection_Data *pd, 138 Eldbus_Model_Connection_Data *pd,
178 unsigned start, 139 unsigned start,
179 unsigned count, 140 unsigned count,
180 Eina_Accessor **children_accessor) 141 Eina_Promise_Owner *promise)
181{ 142{
182 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)) 143 _Eldbus_Children_Slice_Promise* data;
144 Eldbus_Pending *pending;
145
146 if (!pd->connection)
147 _eldbus_model_connection_connect(pd);
148
149 if (pd->is_listed)
183 { 150 {
184 WRN("(%p): Children not loaded", obj); 151 Eina_Accessor *ac = efl_model_list_slice(pd->children_list, start, count);
185 *children_accessor = NULL; 152 eina_promise_owner_value_set(promise, &ac, (Eina_Promise_Free_Cb)&_accessor_free);
186 return pd->load.status; 153 return;
187 } 154 }
188 155
189 *children_accessor = efl_model_list_slice(pd->children_list, start, count); 156 data = calloc(1, sizeof(struct _Eldbus_Children_Slice_Promise));
190 return pd->load.status; 157 EINA_SAFETY_ON_NULL_RETURN(data);
191} 158 data->promise = promise;
159 data->start = start;
160 data->count = count;
192 161
193static Efl_Model_Load_Status 162 pd->children_promises = eina_list_prepend(pd->children_promises, data);
194_eldbus_model_connection_efl_model_base_children_count_get(Eo *obj EINA_UNUSED, 163
195 Eldbus_Model_Connection_Data *pd, 164 if (pd->pending_list == NULL)
196 unsigned *children_count) 165 {
197{ 166 pending = eldbus_names_list(pd->connection, &_eldbus_model_connection_names_list_cb, pd);
198 *children_count = eina_list_count(pd->children_list); 167 pd->pending_list = eina_list_append(pd->pending_list, pending);
199 return pd->load.status; 168 }
200} 169}
201 170
202static void 171static void
203_eldbus_model_connection_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd) 172_eldbus_model_connection_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
173 Eldbus_Model_Connection_Data *pd,
174 Eina_Promise_Owner *promise)
204{ 175{
205 Eldbus_Pending *pending; 176 Eldbus_Pending *pending;
206
207 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
208 return;
209
210 if (!pd->connection) 177 if (!pd->connection)
211 _eldbus_model_connection_connect(pd); 178 _eldbus_model_connection_connect(pd);
212 179
213 pending = eldbus_names_list(pd->connection, &_eldbus_model_connection_names_list_cb, pd); 180 if (pd->is_listed)
214 pd->pending_list = eina_list_append(pd->pending_list, pending); 181 {
182 unsigned int c = eina_list_count(pd->children_list);
183 eina_promise_owner_value_set(promise, &c, NULL);
184 return;
185 }
215 186
216 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN); 187 pd->count_promises = eina_list_prepend(pd->count_promises, promise);
188 if (pd->pending_list == NULL)
189 {
190 pending = eldbus_names_list(pd->connection, &_eldbus_model_connection_names_list_cb, pd);
191 pd->pending_list = eina_list_append(pd->pending_list, pending);
192 }
217} 193}
218 194
219static const char * 195static const char *
@@ -297,7 +273,7 @@ _eldbus_model_connection_clear(Eldbus_Model_Connection_Data *pd)
297 if (!pd->connection) 273 if (!pd->connection)
298 return; 274 return;
299 275
300 eina_value_free(pd->unique_name); 276 free(pd->unique_name);
301 pd->unique_name = NULL; 277 pd->unique_name = NULL;
302 278
303 EINA_LIST_FREE(pd->children_list, child) 279 EINA_LIST_FREE(pd->children_list, child)
@@ -321,17 +297,19 @@ _eldbus_model_connection_names_list_cb(void *data,
321 Eldbus_Pending *pending) 297 Eldbus_Pending *pending)
322{ 298{
323 Eldbus_Model_Connection_Data *pd = (Eldbus_Model_Connection_Data*)data; 299 Eldbus_Model_Connection_Data *pd = (Eldbus_Model_Connection_Data*)data;
300 _Eldbus_Children_Slice_Promise * p;
324 const char *error_name, *error_text; 301 const char *error_name, *error_text;
325 Eldbus_Message_Iter *array = NULL; 302 Eldbus_Message_Iter *array = NULL;
326 const char *bus; 303 const char *bus;
327 unsigned int count; 304 unsigned int count;
305 Eina_List* i;
328 306
329 pd->pending_list = eina_list_remove(pd->pending_list, pending); 307 pd->pending_list = eina_list_remove(pd->pending_list, pending);
330 308
331 if (eldbus_message_error_get(msg, &error_name, &error_text)) 309 if (eldbus_message_error_get(msg, &error_name, &error_text))
332 { 310 {
333 ERR("%s: %s", error_name, error_text); 311 ERR("%s: %s", error_name, error_text);
334 efl_model_error_notify(pd->obj); 312 //efl_model_error_notify(pd->obj);
335 return; 313 return;
336 } 314 }
337 315
@@ -350,11 +328,29 @@ _eldbus_model_connection_names_list_cb(void *data,
350 pd->children_list = eina_list_append(pd->children_list, child); 328 pd->children_list = eina_list_append(pd->children_list, child);
351 } 329 }
352 330
353 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
354
355 count = eina_list_count(pd->children_list); 331 count = eina_list_count(pd->children_list);
332
356 if (count) 333 if (count)
357 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count); 334 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count);
335
336 pd->is_listed = EINA_TRUE;
337
338 EINA_LIST_FOREACH(pd->children_promises, i, p)
339 {
340 Eina_Accessor *ac = efl_model_list_slice(pd->children_list, p->start, p->count);
341 eina_promise_owner_value_set(p->promise, &ac, (Eina_Promise_Free_Cb)&_accessor_free);
342 free(p);
343 }
344 eina_list_free(pd->children_promises);
345
346 Eina_Promise_Owner *ep;
347 EINA_LIST_FOREACH(pd->count_promises, i, ep)
348 {
349 unsigned c = eina_list_count(pd->children_list);
350 eina_promise_owner_value_set(ep, &c, NULL);
351 }
352 eina_list_free(pd->count_promises);
358} 353}
359 354
355
360#include "eldbus_model_connection.eo.c" 356#include "eldbus_model_connection.eo.c"
diff --git a/src/lib/eldbus/eldbus_model_connection.eo b/src/lib/eldbus/eldbus_model_connection.eo
index 5e4de6a97c..3d797cb385 100644
--- a/src/lib/eldbus/eldbus_model_connection.eo
+++ b/src/lib/eldbus/eldbus_model_connection.eo
@@ -36,17 +36,12 @@ class Eldbus.Model_Connection (Eo.Base, Efl.Model.Base) {
36 Eo.Base.constructor; 36 Eo.Base.constructor;
37 Eo.Base.destructor; 37 Eo.Base.destructor;
38 Efl.Model.Base.properties.get; 38 Efl.Model.Base.properties.get;
39 Efl.Model.Base.properties_load; 39 Efl.Model.Base.property_set;
40 Efl.Model.Base.property.set; 40 Efl.Model.Base.property_get;
41 Efl.Model.Base.property.get;
42 Efl.Model.Base.load;
43 Efl.Model.Base.load_status.get;
44 Efl.Model.Base.unload;
45 Efl.Model.Base.child_add; 41 Efl.Model.Base.child_add;
46 Efl.Model.Base.child_del; 42 Efl.Model.Base.child_del;
47 Efl.Model.Base.children_slice.get; 43 Efl.Model.Base.children_slice_get;
48 Efl.Model.Base.children_count.get; 44 Efl.Model.Base.children_count_get;
49 Efl.Model.Base.children_load;
50 } 45 }
51 constructors { 46 constructors {
52 .constructor; 47 .constructor;
diff --git a/src/lib/eldbus/eldbus_model_connection_private.h b/src/lib/eldbus/eldbus_model_connection_private.h
index 4123f92b07..a1636b94be 100644
--- a/src/lib/eldbus/eldbus_model_connection_private.h
+++ b/src/lib/eldbus/eldbus_model_connection_private.h
@@ -13,14 +13,16 @@ typedef struct _Eldbus_Model_Connection_Data Eldbus_Model_Connection_Data;
13struct _Eldbus_Model_Connection_Data 13struct _Eldbus_Model_Connection_Data
14{ 14{
15 Eo *obj; 15 Eo *obj;
16 Efl_Model_Load load; 16 Eina_Bool is_listed : 1;
17 Eldbus_Connection *connection; 17 Eldbus_Connection *connection;
18 Eina_Array *properties_array; 18 Eina_Array *properties_array;
19 Eina_List *children_list; 19 Eina_List *children_list;
20 Eina_List *children_promises;
21 Eina_List *count_promises;
20 Eldbus_Connection_Type type; 22 Eldbus_Connection_Type type;
21 Eina_Stringshare *address; 23 Eina_Stringshare *address;
22 bool private; 24 bool private;
23 Eina_Value *unique_name; 25 char *unique_name;
24 Eina_List *pending_list; 26 Eina_List *pending_list;
25}; 27};
26 28
diff --git a/src/lib/eldbus/eldbus_model_method.c b/src/lib/eldbus/eldbus_model_method.c
index d62b8eb9c7..76292ecdad 100644
--- a/src/lib/eldbus/eldbus_model_method.c
+++ b/src/lib/eldbus/eldbus_model_method.c
@@ -40,7 +40,7 @@ _eldbus_model_method_constructor(Eo *obj EINA_UNUSED,
40 pd->method = method; 40 pd->method = method;
41} 41}
42 42
43static Efl_Model_Load_Status 43static void
44_eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA_UNUSED) 44_eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA_UNUSED)
45{ 45{
46 Eldbus_Model_Arguments_Data *data = eo_data_scope_get(obj, ELDBUS_MODEL_ARGUMENTS_CLASS); 46 Eldbus_Model_Arguments_Data *data = eo_data_scope_get(obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
@@ -82,11 +82,10 @@ _eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA
82 pending = eldbus_proxy_send(data->proxy, msg, _eldbus_model_method_call_cb, pd, -1); 82 pending = eldbus_proxy_send(data->proxy, msg, _eldbus_model_method_call_cb, pd, -1);
83 data->pending_list = eina_list_append(data->pending_list, pending); 83 data->pending_list = eina_list_append(data->pending_list, pending);
84 84
85 return data->load.status; 85 return;
86 86
87on_error: 87on_error:
88 eldbus_message_unref(msg); 88 eldbus_message_unref(msg);
89 return EFL_MODEL_LOAD_STATUS_ERROR;
90} 89}
91 90
92static void 91static void
diff --git a/src/lib/eldbus/eldbus_model_method.eo b/src/lib/eldbus/eldbus_model_method.eo
index 5cc05d9e54..b0829a6025 100644
--- a/src/lib/eldbus/eldbus_model_method.eo
+++ b/src/lib/eldbus/eldbus_model_method.eo
@@ -19,10 +19,8 @@ class Eldbus.Model_Method (Eldbus.Model_Arguments) {
19 The event EMODEL_EVENT_PROPERTIES_CHANGED is raised for output arguments (properties). 19 The event EMODEL_EVENT_PROPERTIES_CHANGED is raised for output arguments (properties).
20 20
21 The event ELDBUS_MODEL_METHOD_EVENT_METHOD_CALLED is raised for a successful call. Otherwise 21 The event ELDBUS_MODEL_METHOD_EVENT_METHOD_CALLED is raised for a successful call. Otherwise
22 the event EMODEL_EVENT_LOAD_STATUS with the status set to EMODEL_LOAD_STATUS_ERROR is raised.
23 22
24 @since 1.16]] 23 @since 1.16]]
25 return: Efl.Model.Load_Status; [[#Emodel_Load_Status on success, #EMODEL_LOAD_STATUS_ERROR otherwise.]]
26 } 24 }
27 } 25 }
28 implements { 26 implements {
diff --git a/src/lib/eldbus/eldbus_model_object.c b/src/lib/eldbus/eldbus_model_object.c
index e1462b789e..8791576060 100644
--- a/src/lib/eldbus/eldbus_model_object.c
+++ b/src/lib/eldbus/eldbus_model_object.c
@@ -5,6 +5,7 @@
5#include "eldbus_model_object_private.h" 5#include "eldbus_model_object_private.h"
6#include "eldbus_model_private.h" 6#include "eldbus_model_private.h"
7 7
8#include <Ecore.h>
8#include <Eina.h> 9#include <Eina.h>
9 10
10#define MY_CLASS ELDBUS_MODEL_OBJECT_CLASS 11#define MY_CLASS ELDBUS_MODEL_OBJECT_CLASS
@@ -12,8 +13,6 @@
12 13
13#define UNIQUE_NAME_PROPERTY "unique_name" 14#define UNIQUE_NAME_PROPERTY "unique_name"
14 15
15static void _eldbus_model_object_efl_model_base_properties_load(Eo *, Eldbus_Model_Object_Data *);
16static void _eldbus_model_object_efl_model_base_children_load(Eo *, Eldbus_Model_Object_Data *);
17static bool _eldbus_model_object_introspect(Eldbus_Model_Object_Data *, const char *, const char *); 16static bool _eldbus_model_object_introspect(Eldbus_Model_Object_Data *, const char *, const char *);
18static void _eldbus_model_object_introspect_cb(void *, const Eldbus_Message *, Eldbus_Pending *); 17static void _eldbus_model_object_introspect_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
19static void _eldbus_model_object_connect(Eldbus_Model_Object_Data *); 18static void _eldbus_model_object_connect(Eldbus_Model_Object_Data *);
@@ -23,13 +22,20 @@ static void _eldbus_model_object_introspect_nodes(Eldbus_Model_Object_Data *, co
23static char *_eldbus_model_object_concatenate_path(const char *, const char *); 22static char *_eldbus_model_object_concatenate_path(const char *, const char *);
24static void _eldbus_model_object_create_children(Eldbus_Model_Object_Data *, Eldbus_Object *, Eina_List *); 23static void _eldbus_model_object_create_children(Eldbus_Model_Object_Data *, Eldbus_Object *, Eina_List *);
25 24
25void
26_accessor_free(void *data)
27{
28 Eina_Accessor **ac = data;
29 eina_accessor_free(*ac);
30}
31
26static Eo_Base* 32static Eo_Base*
27_eldbus_model_object_eo_base_constructor(Eo *obj, Eldbus_Model_Object_Data *pd) 33_eldbus_model_object_eo_base_constructor(Eo *obj, Eldbus_Model_Object_Data *pd)
28{ 34{
29 obj = eo_constructor(eo_super(obj, MY_CLASS)); 35 obj = eo_constructor(eo_super(obj, MY_CLASS));
30 36
31 pd->obj = obj; 37 pd->obj = obj;
32 pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED; 38 pd->is_listed = EINA_FALSE;
33 pd->connection = NULL; 39 pd->connection = NULL;
34 pd->object_list = NULL; 40 pd->object_list = NULL;
35 pd->properties_array = NULL; 41 pd->properties_array = NULL;
@@ -93,104 +99,67 @@ _eldbus_model_object_eo_base_destructor(Eo *obj, Eldbus_Model_Object_Data *pd)
93 eo_destructor(eo_super(obj, MY_CLASS)); 99 eo_destructor(eo_super(obj, MY_CLASS));
94} 100}
95 101
96static Efl_Model_Load_Status 102static Eina_Array const *
97_eldbus_model_object_efl_model_base_properties_get(Eo *obj EINA_UNUSED, 103_eldbus_model_object_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
98 Eldbus_Model_Object_Data *pd, 104 Eldbus_Model_Object_Data *pd)
99 Eina_Array * const* properties_array)
100{ 105{
101 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR); 106 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
102 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR); 107 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, NULL);
103 108
104 if (pd->properties_array == NULL) 109 if (pd->properties_array == NULL)
105 { 110 {
106 Eina_Bool ret; 111 Eina_Bool ret;
107 112
108 pd->properties_array = eina_array_new(1); 113 pd->properties_array = eina_array_new(1);
109 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, EFL_MODEL_LOAD_STATUS_ERROR); 114 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, NULL);
110 115
111 ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY); 116 ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY);
112 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR); 117 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, NULL);
113 } 118 }
114 119
115 *(Eina_Array**)properties_array = pd->properties_array; 120 return pd->properties_array;
116 return pd->load.status;
117} 121}
118 122
119static void 123static void
120_eldbus_model_object_efl_model_base_properties_load(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
121{
122 const char *unique_name;
123 Eina_Bool ret;
124
125 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
126 return;
127
128 if (!pd->connection)
129 _eldbus_model_object_connect(pd);
130
131 pd->unique_name = eina_value_new(EINA_VALUE_TYPE_STRING);
132 EINA_SAFETY_ON_NULL_RETURN(pd->unique_name);
133
134 unique_name = eldbus_connection_unique_name_get(pd->connection);
135 ret = eina_value_set(pd->unique_name, unique_name);
136 EINA_SAFETY_ON_FALSE_RETURN(ret);
137
138 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
139}
140
141static Efl_Model_Load_Status
142_eldbus_model_object_efl_model_base_property_set(Eo *obj EINA_UNUSED, 124_eldbus_model_object_efl_model_base_property_set(Eo *obj EINA_UNUSED,
143 Eldbus_Model_Object_Data *pd EINA_UNUSED, 125 Eldbus_Model_Object_Data *pd EINA_UNUSED,
144 const char *property EINA_UNUSED, 126 const char *property,
145 Eina_Value const* value EINA_UNUSED) 127 const Eina_Value *value EINA_UNUSED,
128 Eina_Promise_Owner *promise)
146{ 129{
147 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 130 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET((strcmp(property, UNIQUE_NAME_PROPERTY) == 0), promise, EFL_MODEL_ERROR_NOT_FOUND);
148 DBG("(%p): property=%s", obj, property); 131 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_SUPPORTED);
149 return EFL_MODEL_LOAD_STATUS_ERROR;
150} 132}
151 133
152static Efl_Model_Load_Status 134static void
153_eldbus_model_object_efl_model_base_property_get(Eo *obj EINA_UNUSED, 135_eldbus_model_object_efl_model_base_property_get(Eo *obj EINA_UNUSED,
154 Eldbus_Model_Object_Data *pd, 136 Eldbus_Model_Object_Data *pd,
155 const char *property, 137 const char *property,
156 Eina_Value const**value) 138 Eina_Promise_Owner *promise)
157{ 139{
158 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 140 EINA_SAFETY_ON_NULL_RETURN(promise);
159 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
160 DBG("(%p): property=%s", obj, property);
161
162 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
163 return EFL_MODEL_LOAD_STATUS_ERROR;
164
165 if (strcmp(property, UNIQUE_NAME_PROPERTY) != 0)
166 return EFL_MODEL_LOAD_STATUS_ERROR;
167 141
168 *value = pd->unique_name; 142 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(property, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
169 return pd->load.status; 143 DBG("(%p): property=%s", obj, property);
170}
171 144
172static void
173_eldbus_model_object_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
174{
175 if (!pd->connection) 145 if (!pd->connection)
176 _eldbus_model_object_connect(pd); 146 _eldbus_model_object_connect(pd);
177 147
178 _eldbus_model_object_efl_model_base_properties_load(obj, pd); 148 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET((strcmp(property, UNIQUE_NAME_PROPERTY) == 0), promise, EFL_MODEL_ERROR_NOT_FOUND);
179 _eldbus_model_object_efl_model_base_children_load(obj, pd);
180}
181 149
182static Efl_Model_Load_Status 150 if (pd->unique_name == NULL)
183_eldbus_model_object_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd) 151 {
184{ 152 const char *unique_name;
185 return pd->load.status;
186}
187 153
188static void 154 unique_name = eldbus_connection_unique_name_get(pd->connection);
189_eldbus_model_object_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd) 155 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(unique_name, promise, EFL_MODEL_ERROR_NOT_FOUND);
190{ 156 pd->unique_name = strdup(unique_name);
191 _eldbus_model_object_clear(pd); 157 }
192 158
193 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED); 159 Eina_Value* v = eina_promise_owner_buffer_get(promise);
160 eina_value_setup(v, EINA_VALUE_TYPE_STRING);
161 eina_value_set(v, pd->unique_name);
162 eina_promise_owner_value_set(promise, NULL, (Eina_Promise_Free_Cb)&eina_value_flush);
194} 163}
195 164
196static Eo * 165static Eo *
@@ -199,56 +168,61 @@ _eldbus_model_object_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_
199 return NULL; 168 return NULL;
200} 169}
201 170
202static Efl_Model_Load_Status 171static void
203_eldbus_model_object_efl_model_base_child_del(Eo *obj EINA_UNUSED, 172_eldbus_model_object_efl_model_base_child_del(Eo *obj EINA_UNUSED,
204 Eldbus_Model_Object_Data *pd EINA_UNUSED, 173 Eldbus_Model_Object_Data *pd EINA_UNUSED,
205 Eo *child EINA_UNUSED) 174 Eo *child EINA_UNUSED)
206{ 175{
207 return EFL_MODEL_LOAD_STATUS_ERROR;
208} 176}
209 177
210static Efl_Model_Load_Status 178static void
211_eldbus_model_object_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED, 179_eldbus_model_object_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
212 Eldbus_Model_Object_Data *pd, 180 Eldbus_Model_Object_Data *pd,
213 unsigned start, 181 unsigned start,
214 unsigned count, 182 unsigned count,
215 Eina_Accessor **children_accessor) 183 Eina_Promise_Owner *promise)
216{ 184{
217 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)) 185 _Eldbus_Children_Slice_Promise* p;
186
187 if (!pd->connection)
188 _eldbus_model_object_connect(pd);
189
190 if (pd->is_listed)
218 { 191 {
219 WRN("(%p): Children not loaded", obj); 192 Eina_Accessor* ac = efl_model_list_slice(pd->children_list, start, count);
220 *children_accessor = NULL; 193 eina_promise_owner_value_set(promise, &ac, &_accessor_free);
221 return pd->load.status; 194 return;
222 } 195 }
223 else
224 WRN("(%p): Children already loaded", obj);
225 196
226 *children_accessor = efl_model_list_slice(pd->children_list, start, count); 197 p = calloc(1, sizeof(struct _Eldbus_Children_Slice_Promise));
227 return pd->load.status; 198 EINA_SAFETY_ON_NULL_RETURN(p);
228} 199 p->promise = promise;
200 p->start = start;
201 p->count = count;
229 202
230static Efl_Model_Load_Status 203 pd->children_promises = eina_list_prepend(pd->children_promises, p);
231_eldbus_model_object_efl_model_base_children_count_get(Eo *obj EINA_UNUSED, 204 if (pd->pending_list == NULL)
232 Eldbus_Model_Object_Data *pd, 205 _eldbus_model_object_introspect(pd, pd->bus, pd->path);
233 unsigned *children_count)
234{
235 *children_count = eina_list_count(pd->children_list);
236 return pd->load.status;
237} 206}
238 207
239static void 208static void
240_eldbus_model_object_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd) 209_eldbus_model_object_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
210 Eldbus_Model_Object_Data *pd,
211 Eina_Promise_Owner *promise)
241{ 212{
242 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
243 return;
244
245 if (!pd->connection) 213 if (!pd->connection)
246 _eldbus_model_object_connect(pd); 214 _eldbus_model_object_connect(pd);
247 215
248 if (!_eldbus_model_object_introspect(pd, pd->bus, pd->path)) 216 if (pd->is_listed)
249 return; 217 {
218 unsigned int c = eina_list_count(pd->children_list);
219 eina_promise_owner_value_set(promise, &c, NULL);
220 return;
221 }
250 222
251 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN); 223 pd->count_promises = eina_list_prepend(pd->count_promises, promise);
224 if (pd->pending_list == NULL)
225 _eldbus_model_object_introspect(pd, pd->bus, pd->path);
252} 226}
253 227
254static const char * 228static const char *
@@ -358,7 +332,7 @@ _eldbus_model_object_clear(Eldbus_Model_Object_Data *pd)
358 if (!pd->connection) 332 if (!pd->connection)
359 return; 333 return;
360 334
361 eina_value_free(pd->unique_name); 335 free(pd->unique_name);
362 pd->unique_name = NULL; 336 pd->unique_name = NULL;
363 337
364 EINA_LIST_FREE(pd->children_list, child) 338 EINA_LIST_FREE(pd->children_list, child)
@@ -432,7 +406,7 @@ _eldbus_model_object_introspect_cb(void *data,
432 if (eldbus_message_error_get(msg, &error_name, &error_text)) 406 if (eldbus_message_error_get(msg, &error_name, &error_text))
433 { 407 {
434 ERR("%s: %s", error_name, error_text); 408 ERR("%s: %s", error_name, error_text);
435 efl_model_error_notify(pd->obj); 409 //efl_model_error_notify(pd->obj);
436 return; 410 return;
437 } 411 }
438 412
@@ -456,13 +430,26 @@ _eldbus_model_object_introspect_cb(void *data,
456 430
457 if (eina_list_count(pd->pending_list) == 0) 431 if (eina_list_count(pd->pending_list) == 0)
458 { 432 {
459 unsigned int count; 433 Eina_List* i;
460 434
461 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN); 435 pd->is_listed = EINA_TRUE;
436 _Eldbus_Children_Slice_Promise* p;
437 EINA_LIST_FOREACH(pd->children_promises, i, p)
438 {
439 Eina_Accessor* ac = efl_model_list_slice(pd->children_list, p->start, p->count);
440 eina_promise_owner_value_set(p->promise, &ac, &_accessor_free);
441 free(p);
442 }
443 eina_list_free(pd->children_promises);
444
445 Eina_Promise_Owner *ep;
446 EINA_LIST_FOREACH(pd->count_promises, i, ep)
447 {
448 unsigned c = eina_list_count(pd->children_list);
449 eina_promise_owner_value_set(ep, &c, NULL);
450 }
451 eina_list_free(pd->count_promises);
462 452
463 count = eina_list_count(pd->children_list);
464 if (count)
465 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count);
466 } 453 }
467} 454}
468 455
diff --git a/src/lib/eldbus/eldbus_model_object.eo b/src/lib/eldbus/eldbus_model_object.eo
index 3cb4a2c580..b3a8b73651 100644
--- a/src/lib/eldbus/eldbus_model_object.eo
+++ b/src/lib/eldbus/eldbus_model_object.eo
@@ -63,17 +63,12 @@ class Eldbus.Model_Object (Eo.Base, Efl.Model.Base) {
63 Eo.Base.constructor; 63 Eo.Base.constructor;
64 Eo.Base.destructor; 64 Eo.Base.destructor;
65 Efl.Model.Base.properties.get; 65 Efl.Model.Base.properties.get;
66 Efl.Model.Base.properties_load; 66 Efl.Model.Base.property_set;
67 Efl.Model.Base.property.set; 67 Efl.Model.Base.property_get;
68 Efl.Model.Base.property.get;
69 Efl.Model.Base.load;
70 Efl.Model.Base.load_status.get;
71 Efl.Model.Base.unload;
72 Efl.Model.Base.child_add; 68 Efl.Model.Base.child_add;
73 Efl.Model.Base.child_del; 69 Efl.Model.Base.child_del;
74 Efl.Model.Base.children_slice.get; 70 Efl.Model.Base.children_slice_get;
75 Efl.Model.Base.children_count.get; 71 Efl.Model.Base.children_count_get;
76 Efl.Model.Base.children_load;
77 } 72 }
78 constructors { 73 constructors {
79 .constructor; 74 .constructor;
diff --git a/src/lib/eldbus/eldbus_model_object_private.h b/src/lib/eldbus/eldbus_model_object_private.h
index 745492143e..4330a2ffb9 100644
--- a/src/lib/eldbus/eldbus_model_object_private.h
+++ b/src/lib/eldbus/eldbus_model_object_private.h
@@ -5,25 +5,26 @@
5 5
6#include <stdbool.h> 6#include <stdbool.h>
7 7
8typedef struct _Eldbus_Model_Object_Data Eldbus_Model_Object_Data;
9
10/** 8/**
11 * eldbus_model_object 9 * eldbus_model_object
12 */ 10 */
11typedef struct _Eldbus_Model_Object_Data Eldbus_Model_Object_Data;
13struct _Eldbus_Model_Object_Data 12struct _Eldbus_Model_Object_Data
14{ 13{
15 Eo *obj; 14 Eo *obj;
16 Efl_Model_Load load; 15 Eina_Bool is_listed : 1;
17 Eldbus_Connection *connection; 16 Eldbus_Connection *connection;
18 Eina_List *object_list; 17 Eina_List *object_list;
19 Eina_Array *properties_array; 18 Eina_Array *properties_array;
20 Eina_List *children_list; 19 Eina_List *children_list;
20 Eina_List *children_promises;
21 Eina_List *count_promises;
21 Eldbus_Connection_Type type; 22 Eldbus_Connection_Type type;
22 Eina_Stringshare *address; 23 Eina_Stringshare *address;
23 bool private; 24 bool private;
24 Eina_Stringshare *bus; 25 Eina_Stringshare *bus;
25 Eina_Stringshare *path; 26 Eina_Stringshare *path;
26 Eina_Value *unique_name; 27 char *unique_name;
27 Eina_List *pending_list; 28 Eina_List *pending_list;
28 Eldbus_Introspection_Node *introspection; 29 Eldbus_Introspection_Node *introspection;
29}; 30};
diff --git a/src/lib/eldbus/eldbus_model_private.h b/src/lib/eldbus/eldbus_model_private.h
index 784b4226b5..29d7bddb18 100644
--- a/src/lib/eldbus/eldbus_model_private.h
+++ b/src/lib/eldbus/eldbus_model_private.h
@@ -3,12 +3,42 @@
3 3
4#include "eldbus_private.h" 4#include "eldbus_private.h"
5 5
6#include <Ecore.h>
7#include <Eina.h>
6#include <Eo.h> 8#include <Eo.h>
7#include <Efl.h> 9#include <Efl.h>
8 10
11typedef struct _Eldbus_Children_Slice_Promise _Eldbus_Children_Slice_Promise;
12struct _Eldbus_Children_Slice_Promise
13{
14 unsigned start;
15 unsigned count;
16 Eina_Promise_Owner* promise;
17};
18
19typedef struct _Eldbus_Property_Promise _Eldbus_Property_Promise;
20struct _Eldbus_Property_Promise
21{
22 char *property;
23 Eina_Promise_Owner* promise;
24};
25
26void _accessor_free(void *data);
27
9/* logging support */ 28/* logging support */
10extern int eldbus_model_log_dom; 29extern int eldbus_model_log_dom;
11 30
31#define ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(exp, promise, err) \
32 do \
33 { \
34 if (EINA_UNLIKELY(!(exp))) \
35 { \
36 eina_promise_owner_error_set(promise, err); \
37 return; \
38 } \
39 } \
40 while(0)
41
12#ifdef CRI 42#ifdef CRI
13# undef CRI 43# undef CRI
14#endif 44#endif
diff --git a/src/lib/eldbus/eldbus_model_proxy.c b/src/lib/eldbus/eldbus_model_proxy.c
index 9196e4b995..0caa4b3e57 100644
--- a/src/lib/eldbus/eldbus_model_proxy.c
+++ b/src/lib/eldbus/eldbus_model_proxy.c
@@ -10,9 +10,7 @@
10#define MY_CLASS ELDBUS_MODEL_PROXY_CLASS 10#define MY_CLASS ELDBUS_MODEL_PROXY_CLASS
11#define MY_CLASS_NAME "Eldbus_Model_Proxy" 11#define MY_CLASS_NAME "Eldbus_Model_Proxy"
12 12
13static void _eldbus_model_proxy_efl_model_base_properties_load(Eo *, Eldbus_Model_Proxy_Data *); 13static Eina_Bool _eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *);
14static void _eldbus_model_proxy_efl_model_base_children_load(Eo *, Eldbus_Model_Proxy_Data *);
15static bool _eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *);
16static void _eldbus_model_proxy_unload(Eldbus_Model_Proxy_Data *); 14static void _eldbus_model_proxy_unload(Eldbus_Model_Proxy_Data *);
17static void _eldbus_model_proxy_property_get_all_cb(void *, const Eldbus_Message *, Eldbus_Pending *); 15static void _eldbus_model_proxy_property_get_all_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
18static void _eldbus_model_proxy_property_set_cb(void *, const Eldbus_Message *, Eldbus_Pending *); 16static void _eldbus_model_proxy_property_set_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
@@ -50,14 +48,15 @@ _eldbus_model_proxy_eo_base_constructor(Eo *obj, Eldbus_Model_Proxy_Data *pd)
50 obj = eo_constructor(eo_super(obj, MY_CLASS)); 48 obj = eo_constructor(eo_super(obj, MY_CLASS));
51 49
52 pd->obj = obj; 50 pd->obj = obj;
53 pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
54 pd->object = NULL; 51 pd->object = NULL;
55 pd->proxy = NULL; 52 pd->proxy = NULL;
53 pd->is_listed = pd->is_loaded = EINA_FALSE;
56 pd->properties_array = NULL; 54 pd->properties_array = NULL;
57 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_proxy_hash_free)); 55 pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_proxy_hash_free));
58 pd->children_list = NULL; 56 pd->children_list = NULL;
59 pd->name = NULL; 57 pd->name = NULL;
60 pd->pending_list = NULL; 58 pd->pending_list = NULL;
59 pd->promise_list = NULL;
61 pd->monitoring = false; 60 pd->monitoring = false;
62 pd->interface = NULL; 61 pd->interface = NULL;
63 62
@@ -91,210 +90,143 @@ _eldbus_model_proxy_eo_base_destructor(Eo *obj, Eldbus_Model_Proxy_Data *pd)
91 eo_destructor(eo_super(obj, MY_CLASS)); 90 eo_destructor(eo_super(obj, MY_CLASS));
92} 91}
93 92
94static Efl_Model_Load_Status 93static Eina_Array const *
95_eldbus_model_proxy_efl_model_base_properties_get(Eo *obj EINA_UNUSED, 94_eldbus_model_proxy_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
96 Eldbus_Model_Proxy_Data *pd, 95 Eldbus_Model_Proxy_Data *pd)
97 Eina_Array * const* properties_array)
98{ 96{
99 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR); 97 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
100 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
101 98
102 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)) 99 _eldbus_model_proxy_load(pd);
103 { 100 return pd->properties_array;
104 WRN("%s", "Properties not loaded.");
105 return EFL_MODEL_LOAD_STATUS_ERROR;
106 }
107
108 *(Eina_Array**)properties_array = pd->properties_array;
109 return pd->load.status;
110} 101}
111 102
112static void 103static void
113_eldbus_model_proxy_efl_model_base_properties_load(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
114{
115 Eldbus_Introspection_Property *property;
116 Eina_List *it;
117 Eldbus_Pending *pending;
118
119 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
120 return;
121
122 if (!_eldbus_model_proxy_load(pd))
123 return;
124
125 const unsigned int properties_count = eina_list_count(pd->interface->properties);
126
127 pd->properties_array = eina_array_new(properties_count);
128 EINA_SAFETY_ON_NULL_RETURN(pd->properties_array);
129
130 if (!properties_count)
131 {
132 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
133 return;
134 }
135
136 EINA_LIST_FOREACH(pd->interface->properties, it, property)
137 {
138 Eina_Stringshare *name;
139 Eina_Bool ret;
140
141 name = eina_stringshare_add(property->name);
142 ret = eina_array_push(pd->properties_array, name);
143 EINA_SAFETY_ON_FALSE_RETURN(ret);
144 }
145
146 pending = eldbus_proxy_property_get_all(pd->proxy, _eldbus_model_proxy_property_get_all_cb, pd);
147 pd->pending_list = eina_list_append(pd->pending_list, pending);
148
149 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES);
150}
151
152static Efl_Model_Load_Status
153_eldbus_model_proxy_efl_model_base_property_set(Eo *obj EINA_UNUSED, 104_eldbus_model_proxy_efl_model_base_property_set(Eo *obj EINA_UNUSED,
154 Eldbus_Model_Proxy_Data *pd, 105 Eldbus_Model_Proxy_Data *pd,
155 const char *property, 106 const char *property,
156 Eina_Value const* value) 107 Eina_Value const* value,
108 Eina_Promise_Owner *promise)
157{ 109{
158 Eldbus_Model_Proxy_Property_Set_Data *data; 110 Eldbus_Model_Proxy_Property_Set_Data *data;
159 const char *signature; 111 const char *signature;
160 Eldbus_Pending *pending; 112 Eldbus_Pending *pending;
113 Eina_Bool ret;
161 114
162 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 115 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(property, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
163 116
164 DBG("(%p): property=%s", obj, property); 117 DBG("(%p): property=%s", obj, property);
118 ret = _eldbus_model_proxy_load(pd);
119 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_INIT_FAILED);
165 120
166 if (!_eldbus_model_proxy_is_property_writeable(pd, property)) 121 ret = _eldbus_model_proxy_is_property_writeable(pd, property);
167 { 122 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_READ_ONLY);
168 WRN("Property is read-only: %s", property);
169 return EFL_MODEL_LOAD_STATUS_ERROR;
170 }
171 123
172 data = _eldbus_model_proxy_property_set_data_new(pd, property, value); 124 data = _eldbus_model_proxy_property_set_data_new(pd, property, value);
173 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EFL_MODEL_LOAD_STATUS_ERROR); 125 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(data, promise, EFL_MODEL_ERROR_UNKNOWN);
174 126
175 signature = _eldbus_model_proxy_property_type_get(pd, property); 127 signature = _eldbus_model_proxy_property_type_get(pd, property);
176 EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EFL_MODEL_LOAD_STATUS_ERROR); 128 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(data, promise, EFL_MODEL_ERROR_UNKNOWN);
177 129
130 pd->promises_set = eina_list_append(pd->promises_set, promise);
178 pending = eldbus_proxy_property_value_set 131 pending = eldbus_proxy_property_value_set
179 (pd->proxy, property, signature, (Eina_Value*)value, _eldbus_model_proxy_property_set_cb, data); 132 (pd->proxy, property, signature, (Eina_Value*)value, _eldbus_model_proxy_property_set_cb, data);
180 pd->pending_list = eina_list_append(pd->pending_list, pending); 133 pd->pending_list = eina_list_append(pd->pending_list, pending);
181
182 return pd->load.status;
183} 134}
184 135
185static Efl_Model_Load_Status 136static void
186_eldbus_model_proxy_efl_model_base_property_get(Eo *obj EINA_UNUSED, 137_eldbus_model_proxy_efl_model_base_property_get(Eo *obj EINA_UNUSED,
187 Eldbus_Model_Proxy_Data *pd, 138 Eldbus_Model_Proxy_Data *pd,
188 const char *property, 139 const char *property,
189 Eina_Value const **value) 140 Eina_Promise_Owner *promise)
190{ 141{
191 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR); 142 Eina_Bool ret;
192 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR); 143 EINA_SAFETY_ON_NULL_RETURN(promise);
193
194 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
195 return EFL_MODEL_LOAD_STATUS_ERROR;
196 144
197 if (!_eldbus_model_proxy_is_property_readable(pd, property)) 145 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(property, promise, EFL_MODEL_ERROR_INCORRECT_VALUE);
198 {
199 WRN("Property is write-only: %s", property);
200 return EFL_MODEL_LOAD_STATUS_ERROR;
201 }
202 146
203 *value = eina_hash_find(pd->properties_hash, property); 147 ret = _eldbus_model_proxy_load(pd);
148 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_INIT_FAILED);
204 149
205 if(!*value) 150 if (!pd->is_loaded)
206 { 151 {
207 *value = &pd->tmp_value; 152 Eldbus_Pending *pending;
208 return EFL_MODEL_LOAD_STATUS_ERROR; 153 _Eldbus_Property_Promise *p = calloc(1, sizeof(_Eldbus_Property_Promise));
154 EINA_SAFETY_ON_NULL_RETURN(p);
155
156 p->promise = promise;
157 p->property = strdup(property);
158 pd->promise_list = eina_list_append(pd->promise_list, p);
159
160 if (!pd->pending_list)
161 {
162 pending = eldbus_proxy_property_get_all(pd->proxy, _eldbus_model_proxy_property_get_all_cb, pd);
163 pd->pending_list = eina_list_append(pd->pending_list, pending);
164 }
165 return;
209 } 166 }
210 167
211 return pd->load.status; 168 Eina_Value* value = eina_hash_find(pd->properties_hash, property);
212} 169 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_NOT_FOUND);
213
214static void
215_eldbus_model_proxy_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
216{
217 if (!_eldbus_model_proxy_load(pd))
218 return;
219
220 _eldbus_model_proxy_efl_model_base_properties_load(obj, pd);
221 _eldbus_model_proxy_efl_model_base_children_load(obj, pd);
222}
223
224static Efl_Model_Load_Status
225_eldbus_model_proxy_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
226{
227 return pd->load.status;
228}
229 170
230static void 171 ret = _eldbus_model_proxy_is_property_writeable(pd, property);
231_eldbus_model_proxy_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd) 172 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_READ_ONLY);
232{
233 _eldbus_model_proxy_unload(pd);
234 173
235 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED); 174 eina_value_copy(value, eina_promise_owner_buffer_get(promise));
175 eina_promise_owner_value_set(promise, NULL, (Eina_Promise_Free_Cb)&eina_value_flush);
236} 176}
237 177
238static Eo * 178static Eo *
239_eldbus_model_proxy_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd EINA_UNUSED) 179_eldbus_model_proxy_efl_model_base_child_add(Eo *obj EINA_UNUSED,
180 Eldbus_Model_Proxy_Data *pd EINA_UNUSED)
240{ 181{
241 return NULL; 182 return NULL;
242} 183}
243 184
244static Efl_Model_Load_Status 185static void
245_eldbus_model_proxy_efl_model_base_child_del(Eo *obj EINA_UNUSED, 186_eldbus_model_proxy_efl_model_base_child_del(Eo *obj EINA_UNUSED,
246 Eldbus_Model_Proxy_Data *pd EINA_UNUSED, 187 Eldbus_Model_Proxy_Data *pd EINA_UNUSED,
247 Eo *child EINA_UNUSED) 188 Eo *child EINA_UNUSED)
248{ 189{
249 return EFL_MODEL_LOAD_STATUS_ERROR;
250} 190}
251 191
252static Efl_Model_Load_Status 192static void
253_eldbus_model_proxy_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED, 193_eldbus_model_proxy_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
254 Eldbus_Model_Proxy_Data *pd, 194 Eldbus_Model_Proxy_Data *pd,
255 unsigned start, 195 unsigned start,
256 unsigned count, 196 unsigned count,
257 Eina_Accessor **children_accessor) 197 Eina_Promise_Owner *promise)
258{ 198{
259 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)) 199 Eina_Bool ret = _eldbus_model_proxy_load(pd);
200 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_INIT_FAILED);
201
202 if (!pd->is_listed)
260 { 203 {
261 WRN("(%p): Children not loaded", obj); 204 _eldbus_model_proxy_create_methods_children(pd);
262 *children_accessor = NULL; 205 _eldbus_model_proxy_create_signals_children(pd);
263 return pd->load.status; 206 pd->is_listed = EINA_TRUE;
264 } 207 }
265 208
266 *children_accessor = efl_model_list_slice(pd->children_list, start, count); 209 Eina_Accessor *ac = efl_model_list_slice(pd->children_list, start, count);
267 return pd->load.status; 210 eina_promise_owner_value_set(promise, &ac, (Eina_Promise_Free_Cb)&_accessor_free);
268} 211}
269 212
270static Efl_Model_Load_Status 213static void
271_eldbus_model_proxy_efl_model_base_children_count_get(Eo *obj EINA_UNUSED, 214_eldbus_model_proxy_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
272 Eldbus_Model_Proxy_Data *pd, 215 Eldbus_Model_Proxy_Data *pd,
273 unsigned *children_count) 216 Eina_Promise_Owner *promise)
274{
275 *children_count = eina_list_count(pd->children_list);
276 return pd->load.status;
277}
278
279static void
280_eldbus_model_proxy_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
281{ 217{
282 unsigned int count; 218 Eina_Bool ret = _eldbus_model_proxy_load(pd);
283 219 ELDBUS_MODEL_ON_ERROR_EXIT_PROMISE_SET(ret, promise, EFL_MODEL_ERROR_INIT_FAILED);
284 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
285 return;
286
287 if (!_eldbus_model_proxy_load(pd))
288 return;
289
290 _eldbus_model_proxy_create_methods_children(pd);
291 _eldbus_model_proxy_create_signals_children(pd);
292 220
293 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN); 221 if (!pd->is_listed)
222 {
223 _eldbus_model_proxy_create_methods_children(pd);
224 _eldbus_model_proxy_create_signals_children(pd);
225 pd->is_listed = EINA_TRUE;
226 }
294 227
295 count = eina_list_count(pd->children_list); 228 unsigned int c = eina_list_count(pd->children_list);
296 if (count) 229 eina_promise_owner_value_set(promise, &c, NULL);
297 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count);
298} 230}
299 231
300static void 232static void
@@ -323,7 +255,8 @@ _eldbus_model_proxy_create_methods_children(Eldbus_Model_Proxy_Data *pd)
323 method_name = method->name; 255 method_name = method->name;
324 if (!method_name) continue; 256 if (!method_name) continue;
325 257
326 INF("(%p) Creating method child: bus = %s, path = %s, method = %s::%s", pd->obj, bus, path, interface_name, method_name); 258 INF("(%p) Creating method child: bus = %s, path = %s, method = %s::%s",
259 pd->obj, bus, path, interface_name, method_name);
327 260
328 child = eo_add(ELDBUS_MODEL_METHOD_CLASS, NULL, eldbus_model_method_constructor(eo_self, pd->proxy, method)); 261 child = eo_add(ELDBUS_MODEL_METHOD_CLASS, NULL, eldbus_model_method_constructor(eo_self, pd->proxy, method));
329 262
@@ -357,7 +290,8 @@ _eldbus_model_proxy_create_signals_children(Eldbus_Model_Proxy_Data *pd)
357 signal_name = signal->name; 290 signal_name = signal->name;
358 if (!signal_name) continue; 291 if (!signal_name) continue;
359 292
360 DBG("(%p) Creating signal child: bus = %s, path = %s, signal = %s::%s", pd->obj, bus, path, interface_name, signal_name); 293 DBG("(%p) Creating signal child: bus = %s, path = %s, signal = %s::%s",
294 pd->obj, bus, path, interface_name, signal_name);
361 295
362 child = eo_add(ELDBUS_MODEL_SIGNAL_CLASS, NULL, eldbus_model_signal_constructor(eo_self, pd->proxy, signal)); 296 child = eo_add(ELDBUS_MODEL_SIGNAL_CLASS, NULL, eldbus_model_signal_constructor(eo_self, pd->proxy, signal));
363 297
@@ -371,22 +305,42 @@ _eldbus_model_proxy_name_get(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
371 return pd->name; 305 return pd->name;
372} 306}
373 307
374static bool 308static Eina_Bool
375_eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *pd) 309_eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *pd)
376{ 310{
377 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false); 311 Eldbus_Introspection_Property *property;
312 Eina_List *it;
313
314 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EINA_FALSE);
378 315
379 if (pd->proxy) 316 if (pd->proxy)
380 return true; 317 return EINA_TRUE;
318
319 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->object, EINA_FALSE);
320 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->name, EINA_FALSE);
321 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->interface, EINA_FALSE);
381 322
382 pd->proxy = eldbus_proxy_get(pd->object, pd->name); 323 pd->proxy = eldbus_proxy_get(pd->object, pd->name);
383 if (!pd->proxy) 324 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->proxy, EINA_FALSE);
325
326 const unsigned int properties_count = eina_list_count(pd->interface->properties);
327
328 pd->properties_array = eina_array_new(properties_count);
329 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, EINA_FALSE);
330
331 if (!properties_count) return EINA_TRUE;
332
333 EINA_LIST_FOREACH(pd->interface->properties, it, property)
384 { 334 {
385 ERR("Cannot get proxy for interface: %s", pd->name); 335 Eina_Stringshare *name;
386 return false; 336 Eina_Bool ret;
337
338 name = eina_stringshare_add(property->name);
339 ret = eina_array_push(pd->properties_array, name);
340 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EINA_FALSE);
387 } 341 }
388 342
389 return true; 343 return EINA_TRUE;
390} 344}
391 345
392static void 346static void
@@ -401,7 +355,9 @@ _eldbus_model_proxy_unload(Eldbus_Model_Proxy_Data *pd)
401 eo_unref(child); 355 eo_unref(child);
402 356
403 EINA_LIST_FREE(pd->pending_list, pending) 357 EINA_LIST_FREE(pd->pending_list, pending)
358 {
404 eldbus_pending_cancel(pending); 359 eldbus_pending_cancel(pending);
360 }
405 361
406 if (pd->properties_array) 362 if (pd->properties_array)
407 { 363 {
@@ -491,18 +447,6 @@ _eldbus_model_proxy_property_invalidated_cb(void *data,
491 Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data; 447 Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data;
492 Eldbus_Proxy_Event_Property_Changed *event = (Eldbus_Proxy_Event_Property_Changed*)event_info; 448 Eldbus_Proxy_Event_Property_Changed *event = (Eldbus_Proxy_Event_Property_Changed*)event_info;
493 449
494#if 0
495 Efl_Model_Property_Event evt = {0};
496
497 // TODO: eldbus_proxy_property_get(event->name) ?
498
499 evt.invalidated_properties = eina_array_new(1);
500 EINA_SAFETY_ON_NULL_RETURN(evt.invalidated_properties);
501
502 eina_array_push(evt.invalidated_properties, event->name);
503 eina_array_free(evt.invalidated_properties);
504#endif
505
506 efl_model_property_invalidated_notify(pd->obj, event->name); 450 efl_model_property_invalidated_notify(pd->obj, event->name);
507} 451}
508 452
@@ -524,7 +468,14 @@ _eldbus_model_proxy_property_get_all_cb(void *data,
524 if (eldbus_message_error_get(msg, &error_name, &error_text)) 468 if (eldbus_message_error_get(msg, &error_name, &error_text))
525 { 469 {
526 ERR("%s: %s", error_name, error_text); 470 ERR("%s: %s", error_name, error_text);
527 efl_model_error_notify(pd->obj); 471 Eina_List* i;
472 _Eldbus_Property_Promise* p;
473 EINA_LIST_FOREACH(pd->promise_list, i, p)
474 {
475 eina_promise_owner_error_set(p->promise, EFL_MODEL_ERROR_UNKNOWN);
476 free(p->property);
477 }
478 eina_list_free(pd->promise_list);
528 return; 479 return;
529 } 480 }
530 481
@@ -577,6 +528,28 @@ _eldbus_model_proxy_property_get_all_cb(void *data,
577 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); 528 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
578 } 529 }
579 530
531 pd->is_loaded = EINA_TRUE;
532
533 Eina_List* i;
534 _Eldbus_Property_Promise* p;
535 EINA_LIST_FOREACH(pd->promise_list, i, p)
536 {
537 Eina_Value* value = eina_hash_find(pd->properties_hash, p->property);
538 if (!value || !_eldbus_model_proxy_is_property_readable(pd, p->property))
539 {
540 eina_promise_owner_error_set(p->promise, EFL_MODEL_ERROR_READ_ONLY);
541 free(p->property);
542 continue;
543 }
544
545 free(p->property);
546
547 eina_value_copy(value, eina_promise_owner_buffer_get(p->promise));
548 eina_promise_owner_value_set(p->promise, NULL, (Eina_Promise_Free_Cb)&eina_value_flush);
549 }
550 eina_list_free(pd->promise_list);
551
552
580 _eldbus_model_proxy_start_monitor(pd); 553 _eldbus_model_proxy_start_monitor(pd);
581 554
582 if (eina_array_count(changed_properties)) 555 if (eina_array_count(changed_properties))
@@ -588,8 +561,6 @@ _eldbus_model_proxy_property_get_all_cb(void *data,
588 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt); 561 eo_event_callback_call(pd->obj, EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt);
589 } 562 }
590 563
591 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
592
593 on_error: 564 on_error:
594 eina_array_free(changed_properties); 565 eina_array_free(changed_properties);
595} 566}
@@ -611,7 +582,6 @@ _eldbus_model_proxy_property_set_cb(void *data,
611 if (eldbus_message_error_get(msg, &error_name, &error_text)) 582 if (eldbus_message_error_get(msg, &error_name, &error_text))
612 { 583 {
613 ERR("%s: %s", error_name, error_text); 584 ERR("%s: %s", error_name, error_text);
614 efl_model_error_notify(pd->obj);
615 goto on_error; 585 goto on_error;
616 } 586 }
617 587
@@ -622,6 +592,7 @@ _eldbus_model_proxy_property_set_cb(void *data,
622 ret = eina_value_copy(&property_set_data->value, prop_value); 592 ret = eina_value_copy(&property_set_data->value, prop_value);
623 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error); 593 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
624 594
595 on_error:
625 { 596 {
626 Efl_Model_Property_Event evt = { 597 Efl_Model_Property_Event evt = {
627 .changed_properties = pd->properties_array 598 .changed_properties = pd->properties_array
@@ -631,7 +602,6 @@ _eldbus_model_proxy_property_set_cb(void *data,
631 efl_model_property_changed_notify(pd->obj, property_set_data->property); 602 efl_model_property_changed_notify(pd->obj, property_set_data->property);
632 } 603 }
633 604
634 on_error:
635 _eldbus_model_proxy_property_set_data_free(property_set_data); 605 _eldbus_model_proxy_property_set_data_free(property_set_data);
636} 606}
637 607
diff --git a/src/lib/eldbus/eldbus_model_proxy.eo b/src/lib/eldbus/eldbus_model_proxy.eo
index a5b51b702c..fb0f26c7f8 100644
--- a/src/lib/eldbus/eldbus_model_proxy.eo
+++ b/src/lib/eldbus/eldbus_model_proxy.eo
@@ -26,17 +26,12 @@ class Eldbus.Model_Proxy (Eo.Base, Efl.Model.Base) {
26 Eo.Base.constructor; 26 Eo.Base.constructor;
27 Eo.Base.destructor; 27 Eo.Base.destructor;
28 Efl.Model.Base.properties.get; 28 Efl.Model.Base.properties.get;
29 Efl.Model.Base.properties_load; 29 Efl.Model.Base.property_set;
30 Efl.Model.Base.property.set; 30 Efl.Model.Base.property_get;
31 Efl.Model.Base.property.get;
32 Efl.Model.Base.load;
33 Efl.Model.Base.load_status.get;
34 Efl.Model.Base.unload;
35 Efl.Model.Base.child_add; 31 Efl.Model.Base.child_add;
36 Efl.Model.Base.child_del; 32 Efl.Model.Base.child_del;
37 Efl.Model.Base.children_slice.get; 33 Efl.Model.Base.children_slice_get;
38 Efl.Model.Base.children_count.get; 34 Efl.Model.Base.children_count_get;
39 Efl.Model.Base.children_load;
40 } 35 }
41 constructors { 36 constructors {
42 .constructor; 37 .constructor;
diff --git a/src/lib/eldbus/eldbus_model_proxy_private.h b/src/lib/eldbus/eldbus_model_proxy_private.h
index 02153fc2b9..8308a099ba 100644
--- a/src/lib/eldbus/eldbus_model_proxy_private.h
+++ b/src/lib/eldbus/eldbus_model_proxy_private.h
@@ -13,7 +13,8 @@ typedef struct _Eldbus_Model_Proxy_Data Eldbus_Model_Proxy_Data;
13struct _Eldbus_Model_Proxy_Data 13struct _Eldbus_Model_Proxy_Data
14{ 14{
15 Eo *obj; 15 Eo *obj;
16 Efl_Model_Load load; 16 Eina_Bool is_listed : 1;
17 Eina_Bool is_loaded : 1;
17 Eldbus_Object *object; 18 Eldbus_Object *object;
18 Eldbus_Proxy *proxy; 19 Eldbus_Proxy *proxy;
19 Eina_Array *properties_array; 20 Eina_Array *properties_array;
@@ -21,6 +22,8 @@ struct _Eldbus_Model_Proxy_Data
21 Eina_List *children_list; 22 Eina_List *children_list;
22 Eina_Stringshare *name; 23 Eina_Stringshare *name;
23 Eina_List *pending_list; 24 Eina_List *pending_list;
25 Eina_List *promise_list;
26 Eina_List *promises_set;
24 bool monitoring; 27 bool monitoring;
25 const Eldbus_Introspection_Interface *interface; 28 const Eldbus_Introspection_Interface *interface;
26 Eina_Value tmp_value; 29 Eina_Value tmp_value;
diff --git a/src/lib/eldbus/eldbus_model_signal.c b/src/lib/eldbus/eldbus_model_signal.c
index 406c451398..24a69f8c5e 100644
--- a/src/lib/eldbus/eldbus_model_signal.c
+++ b/src/lib/eldbus/eldbus_model_signal.c
@@ -6,6 +6,7 @@
6#include "eldbus_model_signal_private.h" 6#include "eldbus_model_signal_private.h"
7#include "eldbus_model_private.h" 7#include "eldbus_model_private.h"
8 8
9#include <Ecore.h>
9#include <Eina.h> 10#include <Eina.h>
10 11
11#define MY_CLASS ELDBUS_MODEL_SIGNAL_CLASS 12#define MY_CLASS ELDBUS_MODEL_SIGNAL_CLASS
@@ -38,6 +39,7 @@ _eldbus_model_signal_constructor(Eo *obj EINA_UNUSED,
38 eldbus_model_arguments_constructor(eo_super(obj, MY_CLASS), proxy, signal->name, signal->arguments); 39 eldbus_model_arguments_constructor(eo_super(obj, MY_CLASS), proxy, signal->name, signal->arguments);
39 40
40 pd->signal = signal; 41 pd->signal = signal;
42 _eldbus_model_signal_callback_add(pd);
41} 43}
42 44
43static void 45static void
@@ -48,26 +50,6 @@ _eldbus_model_signal_eo_base_destructor(Eo *obj, Eldbus_Model_Signal_Data *pd)
48 eo_destructor(eo_super(obj, MY_CLASS)); 50 eo_destructor(eo_super(obj, MY_CLASS));
49} 51}
50 52
51static void
52_eldbus_model_signal_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Signal_Data *pd)
53{
54 Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
55 EINA_SAFETY_ON_NULL_RETURN(args_data);
56
57 if (args_data->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
58 return;
59
60 _eldbus_model_signal_callback_add(pd);
61
62 efl_model_properties_load(eo_super(obj, MY_CLASS));
63}
64
65static void
66_eldbus_model_signal_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Signal_Data *pd)
67{
68 _eldbus_model_signal_callback_del(pd);
69 efl_model_unload(eo_super(obj, MY_CLASS));
70}
71 53
72static void 54static void
73_eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *pd) 55_eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *pd)
diff --git a/src/lib/eldbus/eldbus_model_signal.eo b/src/lib/eldbus/eldbus_model_signal.eo
index 633e99cba4..9e390609c0 100644
--- a/src/lib/eldbus/eldbus_model_signal.eo
+++ b/src/lib/eldbus/eldbus_model_signal.eo
@@ -16,8 +16,6 @@ class Eldbus.Model_Signal (Eldbus.Model_Arguments) {
16 implements { 16 implements {
17 Eo.Base.constructor; 17 Eo.Base.constructor;
18 Eo.Base.destructor; 18 Eo.Base.destructor;
19 Efl.Model.Base.properties_load;
20 Efl.Model.Base.unload;
21 } 19 }
22 constructors { 20 constructors {
23 .constructor; 21 .constructor;