summaryrefslogtreecommitdiff
path: root/src/examples/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-10-05 14:21:23 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-10-05 14:21:23 -0700
commit8f3e860e8e45931f1f4b7b9cf058f10d862d5944 (patch)
tree19703dc731109f42986829e46a83840100dd116e /src/examples/eio
parent91957a41193319844bf446a5be9a4397fa2d433a (diff)
eio: migrate example to use Eina_Future.
Diffstat (limited to 'src/examples/eio')
-rw-r--r--src/examples/eio/efl_io_manager_ls.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/examples/eio/efl_io_manager_ls.c b/src/examples/eio/efl_io_manager_ls.c
index ab5acd5af9..9649a28e4e 100644
--- a/src/examples/eio/efl_io_manager_ls.c
+++ b/src/examples/eio/efl_io_manager_ls.c
@@ -10,43 +10,42 @@
10#include <Eio.h> 10#include <Eio.h>
11#include <Ecore.h> 11#include <Ecore.h>
12 12
13void leave(Efl_Io_Manager *job EINA_UNUSED) 13static Eina_Value
14done_cb(void *data EINA_UNUSED,
15 const Eina_Value file,
16 const Eina_Future *dead EINA_UNUSED)
14{ 17{
15 ecore_main_loop_quit(); 18 if (file.type == EINA_VALUE_TYPE_ERROR)
16} 19 {
20 Eina_Error err;
17 21
18void done_cb(void *data, const Efl_Event *ev) 22 eina_value_get(&file, &err);
19{ 23 fprintf(stderr, "Something has gone wrong: %s\n", eina_error_msg_get(err));
20 Efl_Future_Event_Success *success = ev->info; 24 abort();
21 uint64_t *count = success->value; 25 }
26 if (file.type == EINA_VALUE_TYPE_UINT64)
27 {
28 uint64_t value;
22 29
23 printf("%s done listing files %"PRIu64".\n", __FUNCTION__, *count); 30 eina_value_get(&file, &value);
24 31
25 leave(data); 32 printf("%s done listing files %"PRIu64".\n", __FUNCTION__, value);
26} 33 }
27 34
28void error_cb(void *data, const Efl_Event *ev) 35 ecore_main_loop_quit();
29{
30 Efl_Future_Event_Failure *failure = ev->info;
31 const char *msg = eina_error_msg_get(failure->error);
32
33 printf("%s error: %s\n", __FUNCTION__, msg);
34 36
35 leave(data); 37 return file;
36} 38}
37 39
38// Progress used to be the "Eio_Main_Cb" family of callbacks in the legacy API. 40// Progress used to be the "Eio_Main_Cb" family of callbacks in the legacy API.
39void progress_cb(void *data EINA_UNUSED, const Efl_Event *ev) 41static void
42progress_cb(void *data EINA_UNUSED, Eina_Accessor *access)
40{ 43{
41 Efl_Future_Event_Progress *p = ev->info;
42 const Eina_Array *batch = p->progress;
43 Eina_Iterator *it;
44 const char *filename; 44 const char *filename;
45 unsigned int count;
45 46
46 it = eina_array_iterator_new(batch); 47 EINA_ACCESSOR_FOREACH(access, count, filename)
47 EINA_ITERATOR_FOREACH(it, filename)
48 printf("%s listing filename: %s\n", __FUNCTION__, filename); 48 printf("%s listing filename: %s\n", __FUNCTION__, filename);
49 eina_iterator_free(it);
50} 49}
51 50
52void list_files(void *data) 51void list_files(void *data)
@@ -54,7 +53,7 @@ void list_files(void *data)
54 Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get()); 53 Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get());
55 const char *path = data; 54 const char *path = data;
56 55
57 efl_future_then(efl_io_manager_ls(job, path), &done_cb, &error_cb, &progress_cb, job); 56 eina_future_then(efl_io_manager_ls(job, path, NULL, progress_cb, NULL), done_cb, NULL);
58} 57}
59 58
60int main(int argc, char const *argv[]) 59int main(int argc, char const *argv[])