summaryrefslogtreecommitdiff
path: root/src/lib/eio
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
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')
-rw-r--r--src/lib/eio/efl_io_manager.c29
-rw-r--r--src/lib/eio/eio_model.c80
-rw-r--r--src/lib/eio/eio_model_private.h4
3 files changed, 66 insertions, 47 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 1d6d3fbdb2..0740f35896 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -43,7 +43,7 @@ struct _Job_Closure
43{ 43{
44 Eo *object; 44 Eo *object;
45 Efl_Io_Manager_Data *pdata; 45 Efl_Io_Manager_Data *pdata;
46 Eina_Promise_Owner *promise; 46 Efl_Promise *promise;
47 Eio_File *file; 47 Eio_File *file;
48 Eina_Bool delete_me; 48 Eina_Bool delete_me;
49 void *delayed_arg; 49 void *delayed_arg;
@@ -260,7 +260,8 @@ _efl_io_manager_direct_ls(Eo *obj,
260 Efl_Promise *p; 260 Efl_Promise *p;
261 Eio_File *h; 261 Eio_File *h;
262 262
263 p = efl_add(EFL_PROMISE_CLASS, obj); 263 Eo *loop = efl_loop_user_loop_get(obj);
264 p = efl_add(EFL_PROMISE_CLASS, loop);
264 if (!p) return NULL; 265 if (!p) return NULL;
265 266
266 if (!recursive) 267 if (!recursive)
@@ -299,7 +300,8 @@ _efl_io_manager_stat_ls(Eo *obj,
299 Efl_Promise *p; 300 Efl_Promise *p;
300 Eio_File *h; 301 Eio_File *h;
301 302
302 p = efl_add(EFL_PROMISE_CLASS, obj); 303 Eo *loop = efl_loop_user_loop_get(obj);
304 p = efl_add(EFL_PROMISE_CLASS, loop);
303 if (!p) return NULL; 305 if (!p) return NULL;
304 306
305 if (!recursive) 307 if (!recursive)
@@ -337,7 +339,8 @@ _efl_io_manager_ls(Eo *obj,
337 Efl_Promise *p; 339 Efl_Promise *p;
338 Eio_File *h; 340 Eio_File *h;
339 341
340 p = efl_add(EFL_PROMISE_CLASS, obj); 342 Eo *loop = efl_loop_user_loop_get(obj);
343 p = efl_add(EFL_PROMISE_CLASS, loop);
341 if (!p) return NULL; 344 if (!p) return NULL;
342 345
343 h = _eio_file_ls(path, 346 h = _eio_file_ls(path,
@@ -384,7 +387,8 @@ _efl_io_manager_stat(Eo *obj,
384 Efl_Promise *p; 387 Efl_Promise *p;
385 Eio_File *h; 388 Eio_File *h;
386 389
387 p = efl_add(EFL_PROMISE_CLASS, obj); 390 Eo *loop = efl_loop_user_loop_get(obj);
391 p = efl_add(EFL_PROMISE_CLASS, loop);
388 if (!p) return NULL; 392 if (!p) return NULL;
389 393
390 h = eio_file_direct_stat(path, 394 h = eio_file_direct_stat(path,
@@ -411,7 +415,8 @@ _efl_io_manager_xattr_ls(Eo *obj,
411 Efl_Promise *p; 415 Efl_Promise *p;
412 Eio_File *h; 416 Eio_File *h;
413 417
414 p = efl_add(EFL_PROMISE_CLASS, obj); 418 Eo *loop = efl_loop_user_loop_get(obj);
419 p = efl_add(EFL_PROMISE_CLASS, loop);
415 if (!p) return NULL; 420 if (!p) return NULL;
416 421
417 h = _eio_file_xattr(path, 422 h = _eio_file_xattr(path,
@@ -440,7 +445,8 @@ _efl_io_manager_xattr_set(Eo *obj,
440 Efl_Promise *p; 445 Efl_Promise *p;
441 Eio_File *h; 446 Eio_File *h;
442 447
443 p = efl_add(EFL_PROMISE_CLASS, obj); 448 Eo *loop = efl_loop_user_loop_get(obj);
449 p = efl_add(EFL_PROMISE_CLASS, loop);
444 if (!p) return NULL; 450 if (!p) return NULL;
445 451
446 h = eio_file_xattr_set(path, attribute, 452 h = eio_file_xattr_set(path, attribute,
@@ -469,7 +475,8 @@ _efl_io_manager_xattr_get(Eo *obj,
469 Efl_Promise *p; 475 Efl_Promise *p;
470 Eio_File *h; 476 Eio_File *h;
471 477
472 p = efl_add(EFL_PROMISE_CLASS, obj); 478 Eo *loop = efl_loop_user_loop_get(obj);
479 p = efl_add(EFL_PROMISE_CLASS, loop);
473 if (!p) return NULL; 480 if (!p) return NULL;
474 481
475 h = eio_file_xattr_get(path, attribute, 482 h = eio_file_xattr_get(path, attribute,
@@ -507,7 +514,8 @@ _efl_io_manager_open(Eo *obj,
507 Efl_Promise *p; 514 Efl_Promise *p;
508 Eio_File *h; 515 Eio_File *h;
509 516
510 p = efl_add(EFL_PROMISE_CLASS, obj); 517 Eo *loop = efl_loop_user_loop_get(obj);
518 p = efl_add(EFL_PROMISE_CLASS, loop);
511 if (!p) return NULL; 519 if (!p) return NULL;
512 520
513 h = eio_file_open(path, shared, 521 h = eio_file_open(path, shared,
@@ -533,7 +541,8 @@ _efl_io_manager_close(Eo *obj,
533 Efl_Promise *p; 541 Efl_Promise *p;
534 Eio_File *h; 542 Eio_File *h;
535 543
536 p = efl_add(EFL_PROMISE_CLASS, obj); 544 Eo *loop = efl_loop_user_loop_get(obj);
545 p = efl_add(EFL_PROMISE_CLASS, loop);
537 if (!p) return NULL; 546 if (!p) return NULL;
538 547
539 h = eio_file_close(file, 548 h = eio_file_close(file,
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index 300000be88..56395b7cec 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
diff --git a/src/lib/eio/eio_model_private.h b/src/lib/eio/eio_model_private.h
index 0fb40888d0..79442742c3 100644
--- a/src/lib/eio/eio_model_private.h
+++ b/src/lib/eio/eio_model_private.h
@@ -40,7 +40,7 @@ typedef struct _Eio_Property_Promise _Eio_Property_Promise;
40struct _Eio_Property_Promise 40struct _Eio_Property_Promise
41{ 41{
42 _Eio_Property_Name property; 42 _Eio_Property_Name property;
43 Eina_Promise_Owner* promise; 43 Efl_Promise* promise;
44}; 44};
45 45
46typedef struct _Eio_Children_Slice_Promise _Eio_Children_Slice_Promise; 46typedef struct _Eio_Children_Slice_Promise _Eio_Children_Slice_Promise;
@@ -48,7 +48,7 @@ struct _Eio_Children_Slice_Promise
48{ 48{
49 unsigned start; 49 unsigned start;
50 unsigned count; 50 unsigned count;
51 Eina_Promise_Owner* promise; 51 Efl_Promise* promise;
52}; 52};
53 53
54typedef struct _Eio_Model_Data _Eio_Model_Data; 54typedef struct _Eio_Model_Data _Eio_Model_Data;