summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_model.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-09-29 13:12:09 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-09-29 13:12:27 -0300
commit1a2014a12234593f4ba27f2f76f87dc481447e7c (patch)
treee7d76fed06f8d4981dbb84c827b1c45970d0b1d3 /src/lib/eio/eio_model.c
parent6a5ae00ffaa20b6c1ccdd7891039d76b51099ced (diff)
efl: Update Efl.Model to use new Efl_Promise and Efl_Future
Replaced all Eina_Promise_Owner and Eina_Promise with Efl_Promise and Efl_Future.
Diffstat (limited to 'src/lib/eio/eio_model.c')
-rw-r--r--src/lib/eio/eio_model.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index 300000b..56395b7 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -64,7 +64,7 @@ _eio_stat_done_cb(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *st
64 break; 64 break;
65 }; 65 };
66 66
67 eina_promise_owner_value_set(p->promise, v, (Eina_Promise_Free_Cb)&eina_value_free); 67 efl_promise_value_set(p->promise, v, (Eina_Free_Cb)&eina_value_free);
68 free(p); 68 free(p);
69 } 69 }
70 eina_list_free(priv->property_promises); 70 eina_list_free(priv->property_promises);
@@ -111,7 +111,7 @@ _eio_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
111 111
112 EINA_LIST_FOREACH(priv->property_promises, l, p) 112 EINA_LIST_FOREACH(priv->property_promises, l, p)
113 { 113 {
114 eina_promise_owner_error_set(p->promise, EFL_MODEL_ERROR_UNKNOWN); 114 efl_promise_failed_set(p->promise, EFL_MODEL_ERROR_UNKNOWN);
115 } 115 }
116 eina_list_free(priv->property_promises); 116 eina_list_free(priv->property_promises);
117 priv->property_promises = NULL; 117 priv->property_promises = NULL;
@@ -289,20 +289,24 @@ _eio_model_efl_model_properties_get(Eo *obj EINA_UNUSED, Eio_Model_Data *_pd)
289/** 289/**
290 * Property Get 290 * Property Get
291 */ 291 */
292static Eina_Promise* 292static Efl_Future*
293_eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *property) 293_eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *property)
294{ 294{
295 _Eio_Property_Name property_name; 295 _Eio_Property_Name property_name;
296 const char* value = NULL; 296 const char* value = NULL;
297 Eina_Promise_Owner *promise = eina_promise_add(); 297 Efl_Promise *promise;
298 Eina_Promise *rpromise = eina_promise_owner_promise_get(promise); 298 Efl_Future *future;
299
300 Eo *loop = efl_provider_find(obj, EFL_LOOP_CLASS);
301 promise = efl_add(EFL_PROMISE_CLASS, loop);
302 future = efl_promise_future_get(promise);
299 303
300 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, rpromise); 304 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, future);
301 305
302 if (property == NULL) 306 if (property == NULL)
303 { 307 {
304 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 308 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
305 return rpromise; 309 return future;
306 } 310 }
307 311
308 if(strcmp(_eio_model_prop_names[EIO_MODEL_PROP_FILENAME], property) == 0) 312 if(strcmp(_eio_model_prop_names[EIO_MODEL_PROP_FILENAME], property) == 0)
@@ -338,8 +342,8 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
338 property_name = EIO_MODEL_PROP_SIZE; 342 property_name = EIO_MODEL_PROP_SIZE;
339 else 343 else
340 { 344 {
341 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 345 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
342 return rpromise; 346 return future;
343 } 347 }
344 348
345 switch(property_name) 349 switch(property_name)
@@ -350,7 +354,7 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
350 { 354 {
351 Eina_Value* v = eina_value_new(EINA_VALUE_TYPE_STRING); 355 Eina_Value* v = eina_value_new(EINA_VALUE_TYPE_STRING);
352 eina_value_set(v, value); 356 eina_value_set(v, value);
353 eina_promise_owner_value_set(promise, v, (Eina_Promise_Free_Cb)&eina_value_free); 357 efl_promise_value_set(promise, v, (Eina_Free_Cb)&eina_value_free);
354 } 358 }
355 break; 359 break;
356 default: 360 default:
@@ -365,27 +369,30 @@ _eio_model_efl_model_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, con
365 } 369 }
366 break; 370 break;
367 } 371 }
368 return rpromise; 372 return future;
369} 373}
370 374
371/** 375/**
372 * Property Set 376 * Property Set
373 */ 377 */
374static void 378static Efl_Future*
375_eio_model_efl_model_property_set(Eo *obj EINA_UNUSED, 379_eio_model_efl_model_property_set(Eo *obj EINA_UNUSED,
376 Eio_Model_Data *priv, 380 Eio_Model_Data *priv,
377 const char * property, 381 const char * property,
378 const Eina_Value *value, 382 const Eina_Value *value)
379 Eina_Promise_Owner *promise)
380{ 383{
381 char *dest; 384 char *dest;
382 385
383 EINA_SAFETY_ON_NULL_RETURN(property); 386 Eo *loop = efl_provider_find(obj, EFL_LOOP_CLASS);
387 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, loop);
388 Efl_Future* future = efl_promise_future_get(promise);
389
390 EINA_SAFETY_ON_NULL_RETURN_VAL(property, future);
384 391
385 if (strcmp(property, "path") != 0) 392 if (strcmp(property, "path") != 0)
386 { 393 {
387 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_SUPPORTED); 394 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_SUPPORTED);
388 return; 395 return future;
389 } 396 }
390 397
391 eina_value_get(value, &dest); 398 eina_value_get(value, &dest);
@@ -395,8 +402,8 @@ _eio_model_efl_model_property_set(Eo *obj EINA_UNUSED,
395 402
396 if (!ecore_file_exists(priv->path)) 403 if (!ecore_file_exists(priv->path))
397 { 404 {
398 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 405 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
399 return; 406 return future;
400 } 407 }
401 408
402 char* tmp = strdup(priv->path); 409 char* tmp = strdup(priv->path);
@@ -415,21 +422,23 @@ _eio_model_efl_model_property_set(Eo *obj EINA_UNUSED,
415 eina_stringshare_replace(&priv->path, dest); 422 eina_stringshare_replace(&priv->path, dest);
416 } 423 }
417 424
418 eina_promise_owner_value_set(promise, &value, NULL); 425 efl_promise_value_set(promise, &value, NULL);
426 return future;
419} 427}
420 428
421/** 429/**
422 * Children Count Get 430 * Children Count Get
423 */ 431 */
424static Eina_Promise* 432static Efl_Future*
425_eio_model_efl_model_children_count_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv) 433_eio_model_efl_model_children_count_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
426{ 434{
427 Eina_Promise_Owner *promise = eina_promise_add(); 435 Eo *loop = efl_provider_find(obj, EFL_LOOP_CLASS);
428 Eina_Promise* rpromise = eina_promise_owner_promise_get(promise); 436 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, loop);
437 Efl_Future* future = efl_promise_future_get(promise);
429 unsigned int *c = calloc(sizeof(unsigned int), 1); 438 unsigned int *c = calloc(sizeof(unsigned int), 1);
430 *c = eina_list_count(priv->children_list); 439 *c = eina_list_count(priv->children_list);
431 eina_promise_owner_value_set(promise, c, free); 440 efl_promise_value_set(promise, c, free);
432 return rpromise; 441 return future;
433} 442}
434 443
435static void 444static void
@@ -524,7 +533,7 @@ _eio_done_children_load_cb(void *data, Eio_File *handler EINA_UNUSED)
524 EINA_LIST_FOREACH(priv->children_promises, i, p) 533 EINA_LIST_FOREACH(priv->children_promises, i, p)
525 { 534 {
526 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, p->start, p->count); 535 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, p->start, p->count);
527 eina_promise_owner_value_set(p->promise, accessor, (Eina_Promise_Free_Cb)&eina_accessor_free); 536 efl_promise_value_set(p->promise, accessor, (Eina_Free_Cb)&eina_accessor_free);
528 free(p); 537 free(p);
529 } 538 }
530 539
@@ -603,20 +612,21 @@ _eio_model_efl_model_child_del(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eo *ch
603/** 612/**
604 * Children Slice Get 613 * Children Slice Get
605 */ 614 */
606static Eina_Promise* 615static Efl_Future*
607_eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, 616_eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv,
608 unsigned int start, unsigned int count) 617 unsigned int start, unsigned int count)
609{ 618{
610 Eina_Promise_Owner *promise = eina_promise_add(); 619 Eo *loop = efl_provider_find(obj, EFL_LOOP_CLASS);
611 Eina_Promise* rpromise = eina_promise_owner_promise_get(promise); 620 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, loop);
621 Efl_Future* future = efl_promise_future_get(promise);
612 /** 622 /**
613 * children must be already loaded otherwise we do nothing 623 * children must be already loaded otherwise we do nothing
614 * and parameter is set to NULL. 624 * and parameter is set to NULL.
615 */ 625 */
616 if (!priv->path) 626 if (!priv->path)
617 { 627 {
618 eina_promise_owner_error_set(promise, EFL_MODEL_ERROR_INIT_FAILED); 628 efl_promise_failed_set(promise, EFL_MODEL_ERROR_INIT_FAILED);
619 return rpromise; 629 return future;
620 } 630 }
621 631
622 if (!(priv->is_listed)) 632 if (!(priv->is_listed))
@@ -636,12 +646,12 @@ _eio_model_efl_model_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *pri
636 _eio_main_children_load_cb, _eio_done_children_load_cb, 646 _eio_main_children_load_cb, _eio_done_children_load_cb,
637 _eio_error_children_load_cb, priv); 647 _eio_error_children_load_cb, priv);
638 } 648 }
639 return rpromise; 649 return future;
640 } 650 }
641 651
642 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, start, count); 652 Eina_Accessor* accessor = efl_model_list_slice(priv->children_list, start, count);
643 eina_promise_owner_value_set(promise, accessor, (Eina_Promise_Free_Cb)&eina_accessor_free); 653 efl_promise_value_set(promise, accessor, (Eina_Free_Cb)&eina_accessor_free);
644 return rpromise; 654 return future;
645} 655}
646 656
647 657