summaryrefslogtreecommitdiff
path: root/src/examples/eio/efl_io_manager_ls.c
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@osg.samsung.com>2016-06-23 10:30:57 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2016-06-23 10:32:59 +0200
commit433a351cbbbfdadb75037138423ad7774a14fc97 (patch)
treee28f1a8cbc7c0d1e5d54e569fc5f07d7ad707b3d /src/examples/eio/efl_io_manager_ls.c
parentfb352e17c65fb26624e01ed1558d8614bf593f93 (diff)
examples: rename eio_job to efl_io_manager, finish a job half done
This rename was missing in the examples. Running make examples or even a simple grep shows this. I expect higher b0rking skills by now. :)
Diffstat (limited to 'src/examples/eio/efl_io_manager_ls.c')
-rw-r--r--src/examples/eio/efl_io_manager_ls.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/examples/eio/efl_io_manager_ls.c b/src/examples/eio/efl_io_manager_ls.c
new file mode 100644
index 0000000000..c231badb44
--- /dev/null
+++ b/src/examples/eio/efl_io_manager_ls.c
@@ -0,0 +1,78 @@
1#if HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5
6#include <stdlib.h>
7#include <stdio.h>
8
9#include <Eina.h>
10#include <Eio.h>
11#include <Ecore.h>
12
13void done_cb(void *data, void *value EINA_UNUSED)
14{
15 Efl_Io_Manager *job = data;
16 printf("%s done listing files.\n", __FUNCTION__);
17 ecore_main_loop_quit();
18 eo_unref(job);
19}
20
21void error_cb(void *data, Eina_Error error)
22{
23 Efl_Io_Manager *job = data;
24 const char *msg = eina_error_msg_get(error);
25 printf("%s error: %s\n", __FUNCTION__, msg);
26 ecore_main_loop_quit();
27
28 eo_unref(job);
29}
30
31void filter_cb(void *data EINA_UNUSED, const Eo_Event *event)
32{
33 Eio_Filter_Name_Data *event_info = event->info;
34 static Eina_Bool should_filter = EINA_FALSE;
35
36 printf("Filtering file %s\n", event_info->file);
37
38 should_filter = !should_filter;
39 event_info->filter = should_filter;
40}
41
42// Progress used to be the "Eio_Main_Cb" family of callbacks in the legacy API.
43void progress_cb(void *data EINA_UNUSED, const char *filename)
44{
45 EINA_SAFETY_ON_NULL_RETURN(filename);
46 printf("%s listing filename: %s\n", __FUNCTION__, filename);
47}
48
49void list_files(void *data)
50{
51 Eina_Promise *promise;
52 const char *path = data;
53
54 Efl_Io_Manager *job = eo_add(EFL_IO_MANAGER_CLASS, NULL);
55 eo_event_callback_add(job, EFL_IO_MANAGER_EVENT_FILTER_NAME, (Eo_Event_Cb)&filter_cb, NULL);
56 promise = efl_io_manager_file_ls(job, path);
57 eina_promise_progress_cb_add(promise, (Eina_Promise_Progress_Cb)&progress_cb, NULL, NULL);
58 eina_promise_then(promise, &done_cb, &error_cb, job);
59}
60
61int main(int argc, char const *argv[])
62{
63 eio_init();
64 ecore_init();
65
66 const char *path = getenv("HOME");
67
68 if (argc > 1)
69 path = argv[1];
70
71 Ecore_Job *job = ecore_job_add(&list_files, path);
72
73 ecore_main_loop_begin();
74
75 ecore_shutdown();
76 eio_shutdown();
77 return 0;
78}