summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac12
-rw-r--r--pc/.gitignore3
-rw-r--r--pc/eio-cxx.pc.in12
-rw-r--r--pc/emodel-cxx.pc.in12
-rw-r--r--pc/emodel.pc.in12
-rw-r--r--pkgbuild/PKGBUILD2
-rw-r--r--src/Makefile.am7
-rw-r--r--src/Makefile_Efl_Cxx.am2
-rw-r--r--src/Makefile_Eio.am22
-rw-r--r--src/Makefile_Eio_Cxx.am22
-rw-r--r--src/Makefile_Emodel.am78
-rw-r--r--src/Makefile_Emodel_Cxx.am22
-rw-r--r--src/examples/eio/Makefile.am2
-rw-r--r--src/lib/eio/eio_model.c774
-rw-r--r--src/lib/eio/eio_model.eo49
-rw-r--r--src/lib/eio/eio_model.h45
-rw-r--r--src/lib/eio/eio_model_private.h62
-rw-r--r--src/lib/emodel/Emodel.h127
-rw-r--r--src/lib/emodel/Emodel_Common.h106
-rw-r--r--src/lib/emodel/emodel.c6
-rw-r--r--src/lib/emodel/emodel.eo326
-rw-r--r--src/tests/emodel/emodel_suite.c138
-rw-r--r--src/tests/emodel/emodel_test_file.c273
-rw-r--r--src/tests/emodel/emodel_test_monitor_add.c105
25 files changed, 2217 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index dee94789e5..14b8572bb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -143,6 +143,7 @@ pc/ecore-evas.pc \
143pc/ecore-avahi.pc \ 143pc/ecore-avahi.pc \
144pc/ector.pc \ 144pc/ector.pc \
145pc/embryo.pc \ 145pc/embryo.pc \
146pc/emodel.pc \
146pc/eio.pc \ 147pc/eio.pc \
147pc/eldbus.pc \ 148pc/eldbus.pc \
148pc/efreet.pc \ 149pc/efreet.pc \
@@ -162,7 +163,9 @@ pc/ecore-cxx.pc \
162pc/eolian-cxx.pc \ 163pc/eolian-cxx.pc \
163pc/edje-cxx.pc \ 164pc/edje-cxx.pc \
164pc/eet-cxx.pc \ 165pc/eet-cxx.pc \
165pc/eo-cxx.pc 166pc/eo-cxx.pc \
167pc/emodel-cxx.pc \
168pc/eio-cxx.pc
166endif 169endif
167 170
168if HAVE_ELUA 171if HAVE_ELUA
diff --git a/configure.ac b/configure.ac
index 9f4b269a6e..da6abf853a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3944,6 +3944,14 @@ EFL_EVAL_PKGS([ECORE_EVAS])
3944EFL_LIB_END([Ecore_Evas]) 3944EFL_LIB_END([Ecore_Evas])
3945#### End of Ecore_Evas 3945#### End of Ecore_Evas
3946 3946
3947#### Emodel
3948EFL_LIB_START([Emodel])
3949EFL_ADD_LIBS([EMODEL], [])
3950EFL_INTERNAL_DEPEND_PKG([EMODEL], [eo])
3951EFL_INTERNAL_DEPEND_PKG([EMODEL], [eina])
3952EFL_LIB_END([Emodel])
3953#### End of Emodel
3954
3947#### Eio 3955#### Eio
3948EFL_LIB_START([Eio]) 3956EFL_LIB_START([Eio])
3949 3957
@@ -3957,6 +3965,7 @@ EFL_LIB_START([Eio])
3957EFL_PLATFORM_DEPEND([EIO], [evil]) 3965EFL_PLATFORM_DEPEND([EIO], [evil])
3958 3966
3959### Checks for libraries 3967### Checks for libraries
3968EFL_INTERNAL_DEPEND_PKG([EIO], [emodel])
3960EFL_INTERNAL_DEPEND_PKG([EIO], [ecore]) 3969EFL_INTERNAL_DEPEND_PKG([EIO], [ecore])
3961EFL_INTERNAL_DEPEND_PKG([EIO], [eet]) 3970EFL_INTERNAL_DEPEND_PKG([EIO], [eet])
3962EFL_INTERNAL_DEPEND_PKG([EIO], [eo]) 3971EFL_INTERNAL_DEPEND_PKG([EIO], [eo])
@@ -4534,6 +4543,8 @@ pc/eolian.pc
4534pc/eolian-cxx.pc 4543pc/eolian-cxx.pc
4535pc/efl.pc 4544pc/efl.pc
4536pc/efl-cxx.pc 4545pc/efl-cxx.pc
4546pc/emodel.pc
4547pc/emodel-cxx.pc
4537pc/evas-fb.pc 4548pc/evas-fb.pc
4538pc/evas-opengl-x11.pc 4549pc/evas-opengl-x11.pc
4539pc/evas-opengl-sdl.pc 4550pc/evas-opengl-sdl.pc
@@ -4573,6 +4584,7 @@ pc/ecore-avahi.pc
4573pc/ector.pc 4584pc/ector.pc
4574pc/embryo.pc 4585pc/embryo.pc
4575pc/eio.pc 4586pc/eio.pc
4587pc/eio-cxx.pc
4576pc/eldbus.pc 4588pc/eldbus.pc
4577pc/efreet.pc 4589pc/efreet.pc
4578pc/efreet-mime.pc 4590pc/efreet-mime.pc
diff --git a/pc/.gitignore b/pc/.gitignore
index 25049d8fa9..447b41789b 100644
--- a/pc/.gitignore
+++ b/pc/.gitignore
@@ -28,9 +28,12 @@
28/eina-cxx.pc 28/eina-cxx.pc
29/eet-cxx.pc 29/eet-cxx.pc
30/eio.pc 30/eio.pc
31/eio-cxx.pc
31/eldbus.pc 32/eldbus.pc
32/elocation.pc 33/elocation.pc
33/embryo.pc 34/embryo.pc
35/emodel.pc
36/emodel-cxx.pc
34/emotion.pc 37/emotion.pc
35/eo.pc 38/eo.pc
36/ephysics.pc 39/ephysics.pc
diff --git a/pc/eio-cxx.pc.in b/pc/eio-cxx.pc.in
new file mode 100644
index 0000000000..82c6cfa84e
--- /dev/null
+++ b/pc/eio-cxx.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: eio C++ API
7Description: Enlightenned Asynchronous Input Output library C++ API.
8Requires.private: @requirements_pc_eio@
9Version: @VERSION@
10Libs: -L${libdir} -leio
11Libs.private: @requirements_libs_eio@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eio-@VMAJ@ -I${includedir}/eio-cxx-@VMAJ@
diff --git a/pc/emodel-cxx.pc.in b/pc/emodel-cxx.pc.in
new file mode 100644
index 0000000000..dce37642ad
--- /dev/null
+++ b/pc/emodel-cxx.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: emodel C++ API
7Description: MVC Library C++ API.
8Version: @PACKAGE_VERSION@
9Requires.private: @requirements_pc_emodel@
10Libs: -L${libdir} -lemodel
11Libs.private: @requirements_libs_emodel@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/emodel-@VMAJ@ -I${includedir}/emodel-cxx-@VMAJ@
diff --git a/pc/emodel.pc.in b/pc/emodel.pc.in
new file mode 100644
index 0000000000..0d68f11152
--- /dev/null
+++ b/pc/emodel.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: emodel
7Description: MVC Library
8Version: @PACKAGE_VERSION@
9Requires.private: @requirements_pc_emodel@
10Libs: -L${libdir} -lemodel
11Libs.private: @requirements_libs_emodel@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/emodel-@VMAJ@
diff --git a/pkgbuild/PKGBUILD b/pkgbuild/PKGBUILD
index afa8ae2d7d..6a17c0b951 100644
--- a/pkgbuild/PKGBUILD
+++ b/pkgbuild/PKGBUILD
@@ -60,7 +60,7 @@ build() {
60package_efl() { 60package_efl() {
61 provides+=("ecore=$pkgver" "eldbus=$pkgver" "edje=$pkgver" 61 provides+=("ecore=$pkgver" "eldbus=$pkgver" "edje=$pkgver"
62 "eet=$pkgver" "eeze=$pkgver" "efreet=$pkgver" 62 "eet=$pkgver" "eeze=$pkgver" "efreet=$pkgver"
63 "eina=$pkgver" "eio=$pkgver" "embryo=$pkgver" "emotion=$pkgver" 63 "eina=$pkgver" "eio=$pkgver" "embryo=$pkgver" "emotion=$pkgver" "emodel=$pkgver"
64 "ephysics=$pkgver" "ethumb=$pkgver" "evas=$pkgver") 64 "ephysics=$pkgver" "ethumb=$pkgver" "evas=$pkgver")
65 conflicts+=('ecore' 'edje' 'eet' 'eeze' 'efreet' 'eina' 'eio' 'embryo' 'emotion' 65 conflicts+=('ecore' 'edje' 'eet' 'eeze' 'efreet' 'eina' 'eio' 'embryo' 'emotion'
66 'ethumb' 'evas') 66 'ethumb' 'evas')
diff --git a/src/Makefile.am b/src/Makefile.am
index 77403a7d87..8462c3a589 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,7 +10,9 @@ EOLIAN_FLAGS = -I$(srcdir)\
10 -I$(srcdir)/lib/efl/interfaces \ 10 -I$(srcdir)/lib/efl/interfaces \
11 -I$(srcdir)/lib/ecore_audio \ 11 -I$(srcdir)/lib/ecore_audio \
12 -I$(srcdir)/lib/ecore \ 12 -I$(srcdir)/lib/ecore \
13 -I$(srcdir)/lib/ecore_con 13 -I$(srcdir)/lib/ecore_con \
14 -I$(srcdir)/lib/emodel \
15 -I$(srcdir)/lib/eio
14 16
15DIST_SUBDIRS = 17DIST_SUBDIRS =
16SUBDIRS = 18SUBDIRS =
@@ -65,6 +67,7 @@ include Makefile_Eeze.am
65include Makefile_EPhysics.am 67include Makefile_EPhysics.am
66include Makefile_Edje.am 68include Makefile_Edje.am
67include Makefile_Emotion.am 69include Makefile_Emotion.am
70include Makefile_Emodel.am
68include Makefile_Ethumb.am 71include Makefile_Ethumb.am
69include Makefile_Ethumb_Client.am 72include Makefile_Ethumb_Client.am
70 73
@@ -77,6 +80,8 @@ include Makefile_Eo_Cxx.am
77include Makefile_Efl_Cxx.am 80include Makefile_Efl_Cxx.am
78include Makefile_Edje_Cxx.am 81include Makefile_Edje_Cxx.am
79include Makefile_Evas_Cxx.am 82include Makefile_Evas_Cxx.am
83include Makefile_Emodel_Cxx.am
84include Makefile_Eio_Cxx.am
80 85
81include Makefile_Elua.am 86include Makefile_Elua.am
82include Makefile_Elocation.am 87include Makefile_Elocation.am
diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am
index fbcc5632ca..9df7c60bdd 100644
--- a/src/Makefile_Efl_Cxx.am
+++ b/src/Makefile_Efl_Cxx.am
@@ -19,7 +19,7 @@ generated_efl_cxx_bindings = \
19 lib/efl/interfaces/efl_gfx_gradient_radial.eo.hh 19 lib/efl/interfaces/efl_gfx_gradient_radial.eo.hh
20 20
21lib/efl/Efl.hh: $(generated_efl_cxx_bindings) 21lib/efl/Efl.hh: $(generated_efl_cxx_bindings)
22 @echo @ECHO_E@ "#ifndef EFL_CXX_EDJE_HH\n#define EFL_CXX_EDJE_HH\n" > $(top_builddir)/src/lib/efl/Efl.hh 22 @echo @ECHO_E@ "#ifndef EFL_CXX_HH\n#define EFL_CXX_HH\n" > $(top_builddir)/src/lib/efl/Efl.hh
23 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/efl/Efl.hh 23 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/efl/Efl.hh
24 @for i in $(generated_efl_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/efl/Efl.hh; done 24 @for i in $(generated_efl_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/efl/Efl.hh; done
25 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/efl/Efl.hh 25 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/efl/Efl.hh
diff --git a/src/Makefile_Eio.am b/src/Makefile_Eio.am
index 47f746f2c8..c42c5eb292 100644
--- a/src/Makefile_Eio.am
+++ b/src/Makefile_Eio.am
@@ -1,10 +1,24 @@
1 1
2### Library 2### Library
3 3
4EIO_EOS = \
5 lib/eio/eio_model.eo
6
7EIO_EOS_H = $(EIO_EOS:%.eo=%.eo.h)
8EIO_EOS_C = $(EIO_EOS:%.eo=%.eo.c)
9
10BUILT_SOURCES += $(EIO_EOS_C) $(EIO_EOS_H)
11
12eioeolianfilesdir = $(datadir)/eolian/include/eio-@VMAJ@
13eioeolianfiles_DATA = $(EIO_EOS)
14
4lib_LTLIBRARIES += lib/eio/libeio.la 15lib_LTLIBRARIES += lib/eio/libeio.la
16EXTRA_DIST += $(eioeolianfiles_DATA)
5 17
6installed_eiomainheadersdir = $(includedir)/eio-@VMAJ@ 18installed_eiomainheadersdir = $(includedir)/eio-@VMAJ@
19
7dist_installed_eiomainheaders_DATA = lib/eio/Eio.h lib/eio/eio_inline_helper.x 20dist_installed_eiomainheaders_DATA = lib/eio/Eio.h lib/eio/eio_inline_helper.x
21nodist_installed_eiomainheaders_DATA = $(EIO_EOS_H)
8 22
9lib_eio_libeio_la_SOURCES = \ 23lib_eio_libeio_la_SOURCES = \
10lib/eio/eio_dir.c \ 24lib/eio/eio_dir.c \
@@ -16,6 +30,8 @@ lib/eio/eio_monitor.c \
16lib/eio/eio_monitor_poll.c \ 30lib/eio/eio_monitor_poll.c \
17lib/eio/eio_single.c \ 31lib/eio/eio_single.c \
18lib/eio/eio_xattr.c \ 32lib/eio/eio_xattr.c \
33lib/eio/eio_model.c \
34lib/eio/eio_model_private.h \
19lib/eio/eio_private.h 35lib/eio/eio_private.h
20 36
21if HAVE_INOTIFY 37if HAVE_INOTIFY
@@ -30,9 +46,9 @@ endif
30endif 46endif
31endif 47endif
32 48
33lib_eio_libeio_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EIO_CFLAGS@ 49lib_eio_libeio_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EIO_CFLAGS@ @EMODEL_CFLAGS@
34lib_eio_libeio_la_LIBADD = @EIO_LIBS@ 50lib_eio_libeio_la_LIBADD = @EIO_LIBS@ @EMODEL_LIBS@
35lib_eio_libeio_la_DEPENDENCIES = @EIO_INTERNAL_LIBS@ 51lib_eio_libeio_la_DEPENDENCIES = @EIO_INTERNAL_LIBS@ @EMODEL_INTERNAL_LIBS@
36lib_eio_libeio_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ 52lib_eio_libeio_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
37if HAVE_NOTIFY_COCOA 53if HAVE_NOTIFY_COCOA
38lib_eio_libeio_la_LDFLAGS += -framework CoreServices 54lib_eio_libeio_la_LDFLAGS += -framework CoreServices
diff --git a/src/Makefile_Eio_Cxx.am b/src/Makefile_Eio_Cxx.am
new file mode 100644
index 0000000000..3f5237169c
--- /dev/null
+++ b/src/Makefile_Eio_Cxx.am
@@ -0,0 +1,22 @@
1if HAVE_CXX11
2
3### Generated headers
4
5generated_eio_cxx_bindings = lib/eio/eio_model.eo.hh
6
7lib/eio/Eio.hh: $(generated_eio_cxx_bindings)
8 @echo @ECHO_E@ "#ifndef EFL_CXX_EIO_HH\n#define EFL_CXX_EIO_HH\n" > $(top_builddir)/src/lib/eio/Eio.hh
9 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/eio/Eio.hh
10 @for i in $(generated_eio_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/eio/Eio.hh; done
11 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/eio/Eio.hh
12
13generated_eio_cxx_all = \
14 $(generated_eio_cxx_bindings) \
15 lib/eio/Eio.hh
16
17CLEANFILES += $(generated_eio_cxx_all)
18
19installed_eiocxxmainheadersdir = $(includedir)/eio-cxx-@VMAJ@/
20nodist_installed_eiocxxmainheaders_DATA = $(generated_eio_cxx_all)
21
22endif
diff --git a/src/Makefile_Emodel.am b/src/Makefile_Emodel.am
new file mode 100644
index 0000000000..4585af429f
--- /dev/null
+++ b/src/Makefile_Emodel.am
@@ -0,0 +1,78 @@
1
2### Library
3
4EMODEL_EOS = lib/emodel/emodel.eo
5
6EMODEL_EOS_H = $(EMODEL_EOS:%.eo=%.eo.h)
7EMODEL_EOS_C = $(EMODEL_EOS:%.eo=%.eo.c)
8
9BUILT_SOURCES += $(EMODEL_EOS_C) $(EMODEL_EOS_H)
10
11dist_installed_emodelmainheaders_DATA = \
12lib/emodel/Emodel.h \
13lib/emodel/Emodel_Common.h
14
15nodist_installed_emodelmainheaders_DATA = $(EMODEL_EOS_H)
16
17emodeleolianfilesdir = $(datadir)/eolian/include/emodel-@VMAJ@
18emodeleolianfiles_DATA = $(EMODEL_EOS)
19
20lib_LTLIBRARIES += lib/emodel/libemodel.la
21EXTRA_DIST += $(emodeleolianfiles_DATA)
22
23installed_emodelmainheadersdir = $(includedir)/emodel-@VMAJ@
24
25lib_emodel_libemodel_la_SOURCES = \
26lib/emodel/emodel.c
27
28lib_emodel_libemodel_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
29-I$(top_builddir)/src/lib/emodel \
30-I$(top_srcdir)/src/lib/emodel \
31-I$(top_builddir)/src/lib/eo \
32-I$(top_srcdir)/src/lib/eo \
33-I$(top_builddir)/src/lib/ecore \
34-I$(top_srcdir)/src/lib/ecore \
35-I$(top_builddir)/src/lib/eina \
36-I$(top_srcdir)/src/lib/eina \
37-DPACKAGE_BIN_DIR=\"$(bindir)\" \
38-DPACKAGE_LIB_DIR=\"$(libdir)\" \
39-DPACKAGE_DATA_DIR=\"$(datadir)/edje\" \
40-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)\" \
41-DPACKAGE_SRC_DIR=\"`pwd`/$(top_srcdir)\" \
42@EMODEL_CFLAGS@
43lib_emodel_libemodel_la_LIBADD = @EMODEL_LIBS@
44lib_emodel_libemodel_la_DEPENDENCIES = @EMODEL_INTERNAL_LIBS@ @EINA_INTERNAL_LIBS@ @EO_INTERNAL_LIBS@ @ECORE_INTERNAL_LIBS@
45
46if EFL_ENABLE_TESTS
47EXTRA_DIST += $(emodeleolianfiles_DATA)
48
49check_PROGRAMS += tests/emodel/emodel_suite
50TESTS += tests/emodel/emodel_suite
51
52tests_emodel_emodel_suite_SOURCES = \
53tests/emodel/emodel_suite.c \
54tests/emodel/emodel_test_file.c \
55tests/emodel/emodel_test_monitor_add.c
56
57tests_emodel_emodel_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
58-I$(top_builddir)/src/lib/emodel \
59-I$(top_srcdir)/src/lib/emodel \
60-I$(top_builddir)/src/lib/ecore \
61-I$(top_srcdir)/src/lib/ecore \
62-I$(top_builddir)/src/lib/eio \
63-I$(top_srcdir)/src/lib/eio \
64-I$(top_builddir)/src/lib/eina \
65-I$(top_srcdir)/src/lib/eina \
66-DTESTS_WD=\"`pwd`\" \
67-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/emodel\" \
68-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)/src/tests/emodel\" \
69-DTESTS_BUILD_DIR=PACKAGE_BUILD_DIR \
70@CHECK_CFLAGS@ \
71@EINA_CFLAGS@ \
72@EMODEL_CFLAGS@ \
73@EO_CFLAGS@ \
74@EIO_CFLAGS@
75tests_emodel_emodel_suite_LDADD = @CHECK_LIBS@ @USE_EMODEL_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@ @USE_EIO_LIBS@ @USE_ECORE_LIBS@
76tests_emodel_emodel_suite_DEPENDENCIES = @USE_EMODEL_INTERNAL_LIBS@ @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EIO_INTERNAL_LIBS@ @USE_ECORE_INTERNAL_LIBS@
77
78endif
diff --git a/src/Makefile_Emodel_Cxx.am b/src/Makefile_Emodel_Cxx.am
new file mode 100644
index 0000000000..f6984b48a9
--- /dev/null
+++ b/src/Makefile_Emodel_Cxx.am
@@ -0,0 +1,22 @@
1if HAVE_CXX11
2
3### Generated headers
4
5generated_emodel_cxx_bindings = lib/emodel/emodel.eo.hh
6
7lib/emodel/Emodel.hh: $(generated_emodel_cxx_bindings)
8 @echo @ECHO_E@ "#ifndef EFL_CXX_EMODEL_HH\n#define EFL_CXX_EMODEL_HH\n" > $(top_builddir)/src/lib/emodel/Emodel.hh
9 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/emodel/Emodel.hh
10 @for i in $(generated_emodel_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/emodel/Emodel.hh; done
11 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/emodel/Emodel.hh
12
13generated_emodel_cxx_all = \
14 $(generated_emodel_cxx_bindings) \
15 lib/emodel/Emodel.hh
16
17CLEANFILES += $(generated_emodel_cxx_all)
18
19installed_emodelcxxmainheadersdir = $(includedir)/emodel-cxx-@VMAJ@/
20nodist_installed_emodelcxxmainheaders_DATA = $(generated_emodel_cxx_all)
21
22endif
diff --git a/src/examples/eio/Makefile.am b/src/examples/eio/Makefile.am
index a424f77084..c80f74739a 100644
--- a/src/examples/eio/Makefile.am
+++ b/src/examples/eio/Makefile.am
@@ -22,6 +22,7 @@ eio_file_copy
22eio_file_ls_SOURCES = eio_file_ls.c 22eio_file_ls_SOURCES = eio_file_ls.c
23eio_file_ls_LDADD = \ 23eio_file_ls_LDADD = \
24$(top_builddir)/src/lib/eio/libeio.la \ 24$(top_builddir)/src/lib/eio/libeio.la \
25$(top_builddir)/src/lib/emodel/libemodel.la \
25$(top_builddir)/src/lib/eo/libeo.la \ 26$(top_builddir)/src/lib/eo/libeo.la \
26$(top_builddir)/src/lib/ecore/libecore.la \ 27$(top_builddir)/src/lib/ecore/libecore.la \
27$(top_builddir)/src/lib/eet/libeet.la \ 28$(top_builddir)/src/lib/eet/libeet.la \
@@ -32,6 +33,7 @@ $(top_builddir)/src/lib/eina/libeina.la \
32eio_file_copy_SOURCES = eio_file_copy.c 33eio_file_copy_SOURCES = eio_file_copy.c
33eio_file_copy_LDADD = \ 34eio_file_copy_LDADD = \
34$(top_builddir)/src/lib/eio/libeio.la \ 35$(top_builddir)/src/lib/eio/libeio.la \
36$(top_builddir)/src/lib/emodel/libemodel.la \
35$(top_builddir)/src/lib/eo/libeo.la \ 37$(top_builddir)/src/lib/eo/libeo.la \
36$(top_builddir)/src/lib/ecore/libecore.la \ 38$(top_builddir)/src/lib/ecore/libecore.la \
37$(top_builddir)/src/lib/eet/libeet.la \ 39$(top_builddir)/src/lib/eet/libeet.la \
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
new file mode 100644
index 0000000000..454f1b1a31
--- /dev/null
+++ b/src/lib/eio/eio_model.c
@@ -0,0 +1,774 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Emodel.h>
6#include <Eina.h>
7#include <eio_model.h>
8#include <Eio.h>
9#include <Ecore.h>
10#include <Eo.h>
11
12#include "eio_model_private.h"
13
14#define MY_CLASS EIO_MODEL_CLASS
15#define MY_CLASS_NAME "Eio_Model"
16
17static Eina_Value_Struct_Desc *EIO_MODEL_PROPERTIES_DESC = NULL;
18static void _eio_prop_set_error_cb(void *, Eio_File *, int);
19static void _eio_model_emodel_properties_load(Eo *, Eio_Model_Data *);
20static void _eio_model_emodel_children_load(Eo *, Eio_Model_Data *);
21
22static void
23_load_set(Eio_Model_Data *priv, Emodel_Load load)
24{
25 if ((priv->load.status & (EMODEL_LOAD_STATUS_LOADED | EMODEL_LOAD_STATUS_LOADING)) &&
26 (load.status & (EMODEL_LOAD_STATUS_LOADED | EMODEL_LOAD_STATUS_LOADING)))
27 {
28 load.status = priv->load.status | load.status;
29 switch (load.status)
30 {
31 case EMODEL_LOAD_STATUS_LOADED_PROPERTIES:
32 load.status &= ~EMODEL_LOAD_STATUS_LOADING_PROPERTIES;
33 break;
34 case EMODEL_LOAD_STATUS_LOADING_PROPERTIES:
35 load.status &= ~EMODEL_LOAD_STATUS_LOADED_PROPERTIES;
36 break;
37 case EMODEL_LOAD_STATUS_LOADED_CHILDREN:
38 load.status &= ~EMODEL_LOAD_STATUS_LOADING_CHILDREN;
39 break;
40 case EMODEL_LOAD_STATUS_LOADING_CHILDREN:
41 load.status &= ~EMODEL_LOAD_STATUS_LOADED_CHILDREN;
42 break;
43 default: break;
44 }
45 }
46
47 if (priv->load.status != load.status)
48 {
49 priv->load.status = load.status;
50 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_LOAD_STATUS, &load));
51 }
52}
53
54static void
55_stat_pro_set(Eio_Model_Data *priv, int prop_id, const Eina_Value *value, Emodel_Property_Event *evt)
56{
57 Eina_Value old_value;
58 int changed;
59 Emodel_Property_Pair *pair = NULL;
60 const char *prop = EIO_MODEL_PROPERTIES_DESC->members[prop_id].name;
61
62 eina_value_struct_value_get(priv->properties, prop, &old_value);
63 changed = eina_value_compare(&old_value, value);
64
65 if(changed) eina_value_struct_value_set(priv->properties, prop, value);
66 eina_value_flush(&old_value);
67 if(!changed) return;
68
69 pair = calloc(1, sizeof(Emodel_Property_Pair));
70 EINA_SAFETY_ON_NULL_RETURN(pair);
71 if(!eina_value_copy((Eina_Value*)value, &pair->value))
72 {
73 free(pair);
74 return;
75 }
76
77 pair->property = eina_stringshare_add(prop);
78 evt->changed_properties = eina_list_append(evt->changed_properties, pair);
79}
80
81/**
82 * Callbacks
83 * Property
84 */
85static void
86_eio_stat_done_cb(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *stat)
87{
88 Emodel_Property_Event evt;
89 Eina_Value value;
90 Eio_Model_Data *priv = data;
91 Emodel_Load load;
92 EINA_SAFETY_ON_FALSE_RETURN(eo_ref_get(priv->obj));
93
94 priv->stat = stat;
95 memset(&evt, 0, sizeof(Emodel_Property_Event));
96
97 // Setup for Eina_Bool
98 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
99 eina_value_set(&value, eio_file_is_dir(stat));
100 _stat_pro_set(priv, EIO_MODEL_PROP_IS_DIR, (const Eina_Value*)&value, &evt);
101 eina_value_flush(&value);
102
103 // Setup for Eina_Bool
104 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
105 eina_value_set(&value, eio_file_is_lnk(stat));
106 _stat_pro_set(priv, EIO_MODEL_PROP_IS_LNK, (const Eina_Value*)&value, &evt);
107 eina_value_flush(&value);
108
109 // Setup for double
110 eina_value_setup(&value, EINA_VALUE_TYPE_TIMEVAL);
111 eina_value_set(&value, eio_file_mtime(stat));
112 _stat_pro_set(priv, EIO_MODEL_PROP_MTIME, (const Eina_Value*)&value, &evt);
113 eina_value_flush(&value);
114
115 // Setup for long long
116 eina_value_setup(&value, EINA_VALUE_TYPE_INT64);
117 eina_value_set(&value, eio_file_size(stat));
118 _stat_pro_set(priv, EIO_MODEL_PROP_SIZE, (const Eina_Value*)&value, &evt);
119 eina_value_flush(&value);
120
121 if (evt.changed_properties != NULL)
122 {
123 Emodel_Property_Pair *pair;
124 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt));
125 EINA_LIST_FREE(evt.changed_properties, pair)
126 {
127 eina_stringshare_del(pair->property);
128 eina_value_flush(&pair->value);
129 free(pair);
130 }
131 }
132
133 load.status = EMODEL_LOAD_STATUS_LOADED_PROPERTIES;
134 _load_set(priv, load);
135
136 if (priv->load_pending & EMODEL_LOAD_STATUS_LOADED_CHILDREN)
137 _eio_model_emodel_children_load(priv->obj, priv);
138}
139
140static void
141_eio_progress_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const Eio_Progress *info EINA_UNUSED)
142{
143 //TODO: implement
144}
145
146static void
147_eio_move_done_cb(void *data, Eio_File *handler EINA_UNUSED)
148{
149 Emodel_Property_Event evt;
150 Emodel_Property_Pair pair_path, pair_filename;
151 Eio_Model_Data *priv = data;
152 Eina_Value_Struct_Desc *desc = EIO_MODEL_PROPERTIES_DESC;
153
154 EINA_SAFETY_ON_FALSE_RETURN(eo_ref_get(priv->obj));
155
156 memset(&evt, 0, sizeof(Emodel_Property_Event));
157
158 /**
159 * When mv is executed we update our values and
160 * notify both path and filename properties listeners.
161 */
162 pair_path.property = eina_stringshare_add(desc->members[EIO_MODEL_PROP_PATH].name);
163 eina_value_struct_set(priv->properties, pair_path.property, priv->path);
164 eina_value_struct_value_get(priv->properties, pair_path.property, &pair_path.value);
165 evt.changed_properties = eina_list_append(evt.changed_properties, &pair_path);
166
167 pair_filename.property = eina_stringshare_add(desc->members[EIO_MODEL_PROP_FILENAME].name);
168 eina_value_struct_set(priv->properties, pair_filename.property, basename(priv->path));
169 eina_value_struct_value_get(priv->properties, pair_filename.property, &pair_filename.value);
170 evt.changed_properties = eina_list_append(evt.changed_properties, &pair_filename);
171
172 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_PROPERTIES_CHANGED, &evt));
173
174 eina_stringshare_del(pair_path.property);
175 eina_stringshare_del(pair_filename.property);
176 eina_value_flush(&pair_filename.value);
177 eina_value_flush(&pair_path.value);
178
179 eina_list_free(evt.changed_properties);
180}
181
182static void
183_eio_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
184{
185 if(error != 0)
186 {
187 fprintf(stderr, "Error: %s : %d: %s\n", __FUNCTION__, error, strerror(errno));
188 EINA_SAFETY_ON_FALSE_RETURN(EINA_FALSE); /**< force check error only to be more verbose */
189 }
190 fprintf(stdout, "%s : %d\n", __FUNCTION__, error);
191}
192
193static void
194_eio_prop_set_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error EINA_UNUSED)
195{
196 fprintf(stdout, "%s : %d\n", __FUNCTION__, error);
197}
198
199
200/**
201 * Callbacks
202 * Ecore Events
203 */
204static Eina_Bool
205 _emodel_evt_added_ecore_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
206{
207 Eio_Monitor_Event *evt = (Eio_Monitor_Event*)event;
208 Eio_Model_Data *priv = data;
209 Emodel_Children_Event cevt;
210 Eina_Value path;
211
212 if(priv->children_list)
213 {
214 cevt.child = eo_add_ref(EIO_MODEL_CLASS, priv->obj, eio_model_path_set(evt->filename));
215 priv->children_list = eina_list_append(priv->children_list, cevt.child);
216 cevt.index = eina_list_count(priv->children_list);
217
218 eina_value_setup(&path, EINA_VALUE_TYPE_STRING);
219 eina_value_set(&path, evt->filename);
220 eo_do(cevt.child, eio_model_children_filter_set(priv->filter_cb, priv->filter_userdata));
221 eina_value_flush(&path);
222
223 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_CHILD_ADDED, &cevt));
224 }
225
226 return EINA_TRUE;
227}
228
229static Eina_Bool
230_emodel_evt_deleted_ecore_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
231{
232 Eio_Monitor_Event *evt = (Eio_Monitor_Event*)event;
233 Eio_Model_Data *priv = data;
234
235 if(priv->children_list)
236 {
237 Eina_List* cur = priv->children_list;
238 int i;
239 for(i = 0; cur; ++i, cur = cur->next)
240 {
241 Eio_Model_Data *cur_priv = eo_data_scope_get(cur->data, MY_CLASS);
242 if(strcmp(cur_priv->path, evt->filename) == 0)
243 break;
244 }
245 if(cur)
246 {
247 Emodel_Children_Event cevt;
248
249
250 cevt.index = i;
251 cevt.child = cur->data;
252
253 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_CHILD_REMOVED, &cevt));
254
255 priv->children_list = eina_list_remove_list(priv->children_list, cur);
256 eo_unref(cevt.child);
257 }
258 }
259
260 return EINA_TRUE;
261}
262
263static void
264_eio_monitors_list_load(Eio_Model_Data *priv)
265{
266 priv->mon.mon_event_child_add[0] = EIO_MONITOR_DIRECTORY_CREATED;
267 priv->mon.mon_event_child_add[1] = EIO_MONITOR_FILE_CREATED;
268 priv->mon.mon_event_child_add[2] = EIO_MONITOR_ERROR;
269 priv->mon.mon_event_child_del[0] = EIO_MONITOR_DIRECTORY_DELETED;
270 priv->mon.mon_event_child_del[1] = EIO_MONITOR_FILE_DELETED;
271 priv->mon.mon_event_child_del[2] = EIO_MONITOR_ERROR;
272}
273
274/**
275 * Callbacks
276 * Child Del
277 */
278static Eina_Bool
279_eio_filter_child_del_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info EINA_UNUSED)
280{
281 return EINA_TRUE;
282}
283
284static void
285_eio_progress_child_del_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const Eio_Progress *info EINA_UNUSED)
286{}
287
288static void
289_eio_done_unlink_cb(void *data, Eio_File *handler EINA_UNUSED)
290{
291 Eio_Model_Data *priv = data;
292
293 EINA_SAFETY_ON_NULL_RETURN(priv);
294 EINA_SAFETY_ON_NULL_RETURN(priv->obj);
295
296 eo_unref(priv->obj);
297}
298
299static void
300_eio_error_unlink_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
301{
302 Eio_Model_Data *priv = data;
303
304 fprintf(stdout, "%s : %d\n", __FUNCTION__, error);
305
306 eo_unref(priv->obj);
307}
308
309
310/**
311 * Interfaces impl.
312 */
313static Emodel_Load_Status
314_eio_model_emodel_properties_list_get(Eo *obj EINA_UNUSED,
315 Eio_Model_Data *_pd, Eina_List * const* properties_list)
316{
317 Eio_Model_Data *priv = _pd;
318 unsigned int i;
319
320 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, EINA_FALSE);
321 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->obj, EINA_FALSE);
322
323 if(priv->properties_list == NULL)
324 {
325 Eina_Value_Struct_Desc *desc = EIO_MODEL_PROPERTIES_DESC;
326 for(i = 0; i < desc->member_count; ++i)
327 priv->properties_list = eina_list_append(priv->properties_list, desc->members[i].name);
328 }
329
330 *(Eina_List **)properties_list = priv->properties_list;
331
332 return priv->load.status;
333}
334
335/**
336 * Property Fetch //carlos
337 */
338static Emodel_Load_Status
339_eio_model_emodel_property_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *property, Eina_Value *value)
340{
341 Eina_Value _v;
342 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EMODEL_LOAD_STATUS_ERROR);
343 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, EMODEL_LOAD_STATUS_ERROR);
344 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->obj, EMODEL_LOAD_STATUS_ERROR);
345
346 if (eina_value_struct_value_get(priv->properties, property, &_v) == EINA_TRUE)
347 {
348 eina_value_copy(&_v, value);
349 }
350
351 return priv->load.status;
352}
353
354/**
355 * Property Set
356 */
357static Emodel_Load_Status
358_eio_model_emodel_property_set(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char * property, Eina_Value value)
359{
360 char *dest;
361 Eina_Value v = value;
362
363 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EINA_FALSE);
364
365 if (strcmp(property, "path") != 0)
366 return EINA_FALSE;
367
368 dest = eina_value_to_string(&v);
369 if (priv->path == NULL)
370 {
371 priv->path = dest;
372
373 fprintf(stdout, " path %s filename %s\n", priv->path, basename(priv->path));
374
375 eina_value_struct_set(priv->properties, "path", priv->path);
376 eina_value_struct_set(priv->properties, "filename", eina_stringshare_add(basename(priv->path)));
377
378 _eio_monitors_list_load(priv);
379
380 _eio_move_done_cb(priv, NULL);
381
382 if (priv->load_pending & EMODEL_LOAD_STATUS_LOADED_PROPERTIES)
383 _eio_model_emodel_properties_load(obj, priv);
384
385 if (priv->load_pending & EMODEL_LOAD_STATUS_LOADED_CHILDREN)
386 _eio_model_emodel_children_load(obj, priv);
387
388 return priv->load.status;
389 }
390
391 priv->file = eio_file_move(priv->path, dest, _eio_progress_cb, _eio_move_done_cb, _eio_prop_set_error_cb, priv);
392 free(priv->path);
393 priv->path = dest;
394
395 return priv->load.status;
396}
397/**
398 * Children Count Get
399 */
400static Emodel_Load_Status
401_eio_model_emodel_children_count_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, unsigned int *children_count)
402{
403 /**< eina_list_count returns 'unsigned int' */
404 *children_count = eina_list_count(priv->children_list);
405 return priv->load.status;
406}
407
408/**
409 * Properties Load
410 */
411 static void
412_eio_model_emodel_properties_load(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
413{
414 Emodel_Load load;
415 if (priv->path == NULL)
416 {
417 priv->load_pending |= EMODEL_LOAD_STATUS_LOADED_PROPERTIES;
418 return;
419 }
420 priv->load_pending &= ~EMODEL_LOAD_STATUS_LOADED_PROPERTIES;
421
422 if (!(priv->load.status & (EMODEL_LOAD_STATUS_LOADED_PROPERTIES | EMODEL_LOAD_STATUS_LOADING_PROPERTIES)))
423 {
424 load.status = EMODEL_LOAD_STATUS_LOADING_PROPERTIES;
425 _load_set(priv, load);
426 priv->file = eio_file_direct_stat(priv->path, _eio_stat_done_cb, _eio_error_cb, priv);
427 }
428}
429
430static void
431_eio_model_emodel_monitor_add(Eio_Model_Data *priv)
432{
433 if(!priv->monitor)
434 {
435 priv->monitor = eio_monitor_add(priv->path);
436 int i = 0;
437 for(i = 0; priv->mon.mon_event_child_add[i] != EIO_MONITOR_ERROR ; ++i)
438 priv->mon.ecore_child_add_handler[i] =
439 ecore_event_handler_add(priv->mon.mon_event_child_add[i], _emodel_evt_added_ecore_cb, priv);
440 for(i = 0; priv->mon.mon_event_child_del[i] != EIO_MONITOR_ERROR ; ++i)
441 priv->mon.ecore_child_add_handler[i] =
442 ecore_event_handler_add(priv->mon.mon_event_child_del[i], _emodel_evt_deleted_ecore_cb, priv);
443 }
444}
445
446/*
447 * Callbacks
448 * Children Load
449 */
450static Eina_Bool
451_eio_filter_children_load_cb(void *data, Eio_File *handler, const Eina_File_Direct_Info *info)
452{
453 Eio_Model_Data *priv = data;
454 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, EINA_FALSE);
455
456 if (priv->filter_cb)
457 {
458 return priv->filter_cb(priv->filter_userdata, handler, info);
459 }
460
461 return EINA_TRUE;
462}
463
464static void
465_eio_main_children_load_cb(void *data, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
466{
467 Eo *child;
468 Eio_Model_Data *priv = data;
469 EINA_SAFETY_ON_NULL_RETURN(priv);
470
471 child = eo_add_ref(MY_CLASS, NULL, eio_model_path_set(info->path));
472 if (priv->filter_cb)
473 {
474 eo_do(child, eio_model_children_filter_set(priv->filter_cb, priv->filter_userdata));
475 }
476 priv->children_list = eina_list_append(priv->children_list, child);
477}
478
479static void
480_eio_done_children_load_cb(void *data, Eio_File *handler EINA_UNUSED)
481{
482 unsigned long count;
483 Eio_Model_Data *priv = data;
484 Emodel_Load load;
485 EINA_SAFETY_ON_NULL_RETURN(priv);
486
487 count = eina_list_count(priv->children_list);
488 load.status = EMODEL_LOAD_STATUS_LOADED_CHILDREN;
489
490 _load_set(priv, load);
491 eo_do(priv->obj, eo_event_callback_call(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, &count));
492}
493
494static void
495_eio_error_children_load_cb(void *data, Eio_File *handler EINA_UNUSED, int error)
496{
497 Eio_Model_Data *priv = data;
498 Eo *child;
499 Emodel_Load load;
500 fprintf(stderr, "%s: err=%d\n", __FUNCTION__, error);
501 EINA_LIST_FREE(priv->children_list, child)
502 eo_unref(child);
503
504 load.status = EMODEL_LOAD_STATUS_LOADED_CHILDREN;
505
506 _load_set(priv, load);
507}
508
509/**
510 * Children Load
511 */
512static void
513_eio_model_emodel_children_load(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
514{
515 Emodel_Load load;
516 if (priv->path == NULL)
517 {
518 priv->load_pending |= EMODEL_LOAD_STATUS_LOADED_CHILDREN;
519 return;
520 }
521 priv->load_pending &= ~EMODEL_LOAD_STATUS_LOADED_CHILDREN;
522
523 if (!(priv->load.status & (EMODEL_LOAD_STATUS_LOADED_CHILDREN | EMODEL_LOAD_STATUS_LOADING_CHILDREN)))
524 {
525 _eio_model_emodel_monitor_add(priv);
526
527 load.status = EMODEL_LOAD_STATUS_LOADING_CHILDREN;
528 _load_set(priv, load);
529 eio_file_direct_ls(priv->path, _eio_filter_children_load_cb,
530 _eio_main_children_load_cb, _eio_done_children_load_cb,
531 _eio_error_children_load_cb, priv);
532 }
533}
534
535/**
536 * Load
537 */
538 static void
539_eio_model_emodel_load(Eo *obj, Eio_Model_Data *priv)
540{
541 priv->load_pending |= EMODEL_LOAD_STATUS_LOADED_CHILDREN;
542 _eio_model_emodel_properties_load(obj, priv);
543}
544
545/**
546 * Load status get
547 */
548static Emodel_Load_Status
549_eio_model_emodel_load_status_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
550{
551 return priv->load.status;
552}
553
554/**
555 * Unload
556 */
557static void
558_eio_model_emodel_unload(Eo *obj EINA_UNUSED, Eio_Model_Data *priv)
559{
560 Emodel_Load load;
561 if (!(priv->load.status & EMODEL_LOAD_STATUS_UNLOADED))
562 {
563 Eo *child;
564 EINA_LIST_FREE(priv->children_list, child)
565 {
566 eo_unref(child);
567 }
568
569 load.status = EMODEL_LOAD_STATUS_UNLOADED;
570 _load_set(priv, load);
571 }
572}
573
574static void
575_eio_model_children_filter_set(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eio_Filter_Direct_Cb filter_cb, void *data)
576{
577 priv->filter_cb = filter_cb;
578 priv->filter_userdata = data;
579}
580
581/**
582 * Child Add
583 */
584static Eo *
585_eio_model_emodel_child_add(Eo *obj EINA_UNUSED, Eio_Model_Data *priv EINA_UNUSED)
586{
587 return eo_add(EIO_MODEL_CLASS, obj);
588}
589
590static void
591_eio_model_emodel_child_del_stat(void* data, Eio_File* handler EINA_UNUSED, const Eina_Stat* stat)
592{
593 Eo* child = data;
594 Eio_Model_Data *child_priv = eo_data_scope_get(child, MY_CLASS);
595
596 if(eio_file_is_dir(stat))
597 eio_dir_unlink(child_priv->path,
598 _eio_filter_child_del_cb,
599 _eio_progress_child_del_cb,
600 _eio_done_unlink_cb,
601 _eio_error_unlink_cb,
602 child_priv);
603 else
604 eio_file_unlink(child_priv->path, _eio_done_unlink_cb, _eio_error_unlink_cb, child_priv);
605}
606
607/**
608 * Child Remove
609 */
610static Emodel_Load_Status
611_eio_model_emodel_child_del(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eo *child)
612{
613 Eio_Model_Data *child_priv;
614 EINA_SAFETY_ON_NULL_RETURN_VAL(child, EMODEL_LOAD_STATUS_ERROR);
615
616 if (priv->children_list != NULL)
617 {
618 priv->children_list = eina_list_remove(priv->children_list, child);
619 }
620
621 child_priv = eo_data_scope_get(child, MY_CLASS);
622 EINA_SAFETY_ON_NULL_RETURN_VAL(child_priv, EMODEL_LOAD_STATUS_ERROR);
623
624 eio_file_direct_stat(child_priv->path, &_eio_model_emodel_child_del_stat
625 , &_eio_error_unlink_cb, child);
626 eo_ref(child);
627 return priv->load.status;
628}
629
630/**
631 * Children Slice Get
632 * TODO/XXX/FIXME: Untested code - validate this implementation
633 */
634static Emodel_Load_Status
635_eio_model_emodel_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv,
636 unsigned start, unsigned count, Eina_Accessor **children_accessor)
637{
638 Eo *child;
639 Eina_List *l, *ln, *lr = NULL;
640
641 /**
642 * children must be already loaded otherwise we do nothing
643 * and parameter is set to NULL.
644 */
645
646 if(!(priv->load.status & EMODEL_LOAD_STATUS_LOADED_CHILDREN))
647 {
648 /**
649 * Status should be in either unloaded state or unitialized
650 * so we simply return without much alarm.
651 */
652 *children_accessor = NULL;
653 return priv->load.status;
654 }
655
656 if((start == 0) && (count == 0)) /* this is full data */
657 {
658 /*
659 * children_accessor will be set to NULL by
660 * eina_list_accessor_new if the later fails.
661 */
662 *children_accessor = eina_list_accessor_new(priv->children_list);
663 }
664 else /* this is only slice */
665 {
666 ln = eina_list_nth_list(priv->children_list, (start-1));
667 if(!ln)
668 {
669 /**
670 * In error, we make it more verbose
671 * by forcing warning to be displayed on terminal.
672 */
673 *children_accessor = NULL;
674 EINA_SAFETY_ON_NULL_RETURN_VAL(NULL, priv->load.status);
675 }
676 EINA_LIST_FOREACH(ln, l, child)
677 {
678 eo_ref(child);
679 lr = eina_list_append(lr, child);
680 if (eina_list_count(lr) == count)
681 break;
682 }
683 *children_accessor = eina_list_accessor_new(lr);
684 }
685
686 return priv->load.status;
687}
688
689static void
690_struct_properties_init(void)
691{
692 typedef struct _This_Eio_Properties
693 {
694 const char *filename;
695 const char *path;
696 double mtime;
697 int is_dir;
698 int is_lnk;
699 int size;
700 } This_Eio_Properties;
701
702 static Eina_Value_Struct_Member prop_members[] = {
703 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, filename),
704 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, path),
705 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, mtime),
706 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, is_dir),
707 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, is_lnk),
708 EINA_VALUE_STRUCT_MEMBER(NULL, This_Eio_Properties, size)
709 };
710 //XXX: Check data types
711 prop_members[EIO_MODEL_PROP_FILENAME].type = EINA_VALUE_TYPE_STRING;
712 prop_members[EIO_MODEL_PROP_PATH].type = EINA_VALUE_TYPE_STRING;
713 prop_members[EIO_MODEL_PROP_MTIME].type = EINA_VALUE_TYPE_TIMEVAL;
714 prop_members[EIO_MODEL_PROP_IS_DIR].type = EINA_VALUE_TYPE_INT;
715 prop_members[EIO_MODEL_PROP_IS_LNK].type = EINA_VALUE_TYPE_INT;
716 prop_members[EIO_MODEL_PROP_SIZE].type = EINA_VALUE_TYPE_INT64;
717
718 static Eina_Value_Struct_Desc prop_desc = {
719 EINA_VALUE_STRUCT_DESC_VERSION,
720 NULL, // no special operations
721 prop_members,
722 EINA_C_ARRAY_LENGTH(prop_members),
723 sizeof(This_Eio_Properties)
724 };
725 EIO_MODEL_PROPERTIES_DESC = &prop_desc;
726}
727
728/**
729 * Class definitions
730 */
731static void
732_eio_model_eo_base_constructor(Eo *obj, Eio_Model_Data *priv)
733{
734 eo_do_super(obj, MY_CLASS, eo_constructor());
735 priv->obj = obj;
736 _struct_properties_init();
737 priv->properties = eina_value_struct_new(EIO_MODEL_PROPERTIES_DESC);
738 EINA_SAFETY_ON_NULL_RETURN(priv->properties);
739
740 priv->load.status = EMODEL_LOAD_STATUS_UNLOADED;
741 priv->monitor = NULL;
742}
743
744static void
745_eio_model_path_set(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, const char *path)
746{
747 //_eio_model_eo_base_constructor(obj, priv);
748 priv->path = strdup(path);
749
750 eina_value_struct_set(priv->properties, "path", priv->path);
751 eina_value_struct_set(priv->properties, "filename", basename(priv->path));
752
753 priv->monitor = NULL;
754 _eio_monitors_list_load(priv);
755}
756
757static void
758_eio_model_eo_base_destructor(Eo *obj , Eio_Model_Data *priv)
759{
760 Eo *child;
761 if(priv->monitor)
762 eio_monitor_del(priv->monitor);
763
764 eina_list_free(priv->properties_list);
765 eina_value_free(priv->properties);
766
767 EINA_LIST_FREE(priv->children_list, child)
768 eo_unref(child);
769
770 free(priv->path);
771 eo_do_super(obj, MY_CLASS, eo_destructor());
772}
773
774#include "eio_model.eo.c"
diff --git a/src/lib/eio/eio_model.eo b/src/lib/eio/eio_model.eo
new file mode 100644
index 0000000000..b8ac23672c
--- /dev/null
+++ b/src/lib/eio/eio_model.eo
@@ -0,0 +1,49 @@
1class Eio.Model (Eo.Base, Emodel)
2{
3 legacy_prefix: null;
4 methods {
5 children_filter_set {
6 /*@ Set children filter callback.
7 This function sets, along with user's private data userdata,
8 the Eio's Eio_Filter_Direct_Cb which is a mid-step
9 before receiving the real data. Once in filter
10 callback we can decide, by returning either EINA_FALSE, to abort
11 the notification or EINA_TRUE to keep it.
12 @see Eio.h
13 @see emodel_children_slice_fetch
14 @def emodel_children_filter_set
15 @since 1.11
16 @in filter_cb
17 @in userdata */
18 params {
19 Eio_Filter_Direct_Cb filter_cb; /*@ Filter callback */
20 void *userdata; /*@ User's private data */
21 }
22 }
23 path_set {
24 /*@ Custom Eio_Model constructor.
25 @def eio_model_constructor
26 @since 1.11
27 @in path */
28 params {
29 @in const(char)* path; /*@ Root path provided by caller */
30 }
31 }
32 }
33 implements {
34 Eo.Base.constructor;
35 Eo.Base.destructor;
36 Emodel.properties_list.get;
37 Emodel.properties_load;
38 Emodel.property.set;
39 Emodel.property.get;
40 Emodel.load;
41 Emodel.load_status.get;
42 Emodel.unload;
43 Emodel.child_add;
44 Emodel.child_del;
45 Emodel.children_slice.get;
46 Emodel.children_count.get;
47 Emodel.children_load;
48 }
49}
diff --git a/src/lib/eio/eio_model.h b/src/lib/eio/eio_model.h
new file mode 100644
index 0000000000..e0510702a7
--- /dev/null
+++ b/src/lib/eio/eio_model.h
@@ -0,0 +1,45 @@
1/**
2 * @page emodel_eio_main Emodel_Eio
3 *
4 * @date 2014 (created)
5 *
6 * @brief Emodel_Eio Library Public API Calls
7 *
8 * @section toc Table of Contents
9 *
10 * @li @ref emodel_eio_main_intro
11 *
12 * @section eo_main_intro Introduction
13 *
14 * This module targets file operations using Emodel.
15
16 *
17 * Recommended reading:
18 *
19 * @li @ref Emodel
20 * @li @ref Eo
21 * @li @ref Eina
22 *
23 * @defgroup Emodel_Eio EIO implementation wrapper for Emodel
24 *
25 * @addtogroup Emodel_Eio
26 * @{
27 */
28
29#ifndef _EMODEL_EIO_H
30#define _EMODEL_EIO_H
31
32#include <Eo.h>
33#include <Emodel.h>
34#include <Eio.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#include <eio_model.eo.h>
41
42#ifdef __cplusplus
43}
44#endif
45#endif //_EMODEL_EIO_H
diff --git a/src/lib/eio/eio_model_private.h b/src/lib/eio/eio_model_private.h
new file mode 100644
index 0000000000..26ebdfc819
--- /dev/null
+++ b/src/lib/eio/eio_model_private.h
@@ -0,0 +1,62 @@
1#ifndef _EIO_MODEL_PRIVATE_H
2#define _EIO_MODEL_PRIVATE_H
3
4#define PROP_LIST_SIZE 7
5
6typedef struct _Eio_Model_Data Eio_Model_Data;
7//typedef struct _Eio_Model_Child_Add Eio_Model_Child_Add;
8typedef struct _Eio_Model_Monitor_Data Eio_Model_Monitor_Data;
9
10struct _Eio_Model_Monitor_Data
11{
12 Ecore_Event_Handler *ecore_child_add_handler[3];
13 Ecore_Event_Handler *ecore_child_del_handler[3];
14 int mon_event_child_add[3]; /**< plus EIO_MONITOR_ERROR */
15 int mon_event_child_del[3]; /**< plus EIO_MONITOR_ERROR */
16};
17
18/**
19 * !! Warning: Do not change enum's order
20 * before checking _eio_model_constructor.
21 * @see Eina_Value_Struct_Member.
22 */
23enum {
24 EIO_MODEL_PROP_FILENAME = 0,
25 EIO_MODEL_PROP_PATH,
26 EIO_MODEL_PROP_MTIME,
27 EIO_MODEL_PROP_IS_DIR,
28 EIO_MODEL_PROP_IS_LNK,
29 EIO_MODEL_PROP_SIZE
30};
31
32struct _Eio_Model_Data
33{
34 Eo *obj;
35 char *path;
36 Eina_List *properties_list;
37 Eina_Value *properties;
38 Emodel_Load load;
39 int load_pending;
40 Eina_List *children_list;
41 /**< EIO data */
42 Eio_File *file;
43 const Eina_Stat *stat;
44 Eio_Monitor *monitor;
45 Eio_Model_Monitor_Data mon;
46 int cb_count_child_add; /**< monitor reference counter for child add event */
47 int cb_count_child_del; /**< monitor reference counter for child del event*/
48 Eio_Filter_Direct_Cb filter_cb;
49 void *filter_userdata;
50};
51
52/*
53struct _Eio_Model_Child_Add
54{
55 Eo *child;
56 Eio_Model_Data *priv;
57 char* fullpath;
58 char *name;
59};
60*/
61
62#endif
diff --git a/src/lib/emodel/Emodel.h b/src/lib/emodel/Emodel.h
new file mode 100644
index 0000000000..43c0b9c9b9
--- /dev/null
+++ b/src/lib/emodel/Emodel.h
@@ -0,0 +1,127 @@
1/**
2 @brief Emodel Library Public API Calls
3 These routines are used for MVC (Model View Controller) Library interaction.
4 */
5/**
6 * @page emodel_main Emodel
7 *
8 * @date 2014 (created)
9 * @section toc Table of Contents
10 *
11 * @li @ref emodel_main_intro
12 * @li @ref emodel_main_intro_example
13 *
14 * @section emodel_main_intro Introduction
15 *
16 * The Emodel(model) generic object system for Emodel View Controller.
17 *
18 * @section emodel_main_work How does Emodel work?
19 *
20 * The Model notifies Views and Controllers when there is a change in its state.
21 * The other way around is also true and the Model can be passive and be poolled
22 * for update rather than generating output representations.
23 *
24 * Concrete objects can implement functionalities by overriding Emodel's API, abstracting its complexities from
25 * applications that can keep focus on higher level implementation.
26 *
27 * Examples of concrete implementations that can make use Emodel:
28 *
29 * Filesystem and I/O operations;
30 * Database management;
31 * GUI forms, lists and trees.
32 *
33 * Application code tends to be small in number of lines,
34 * more simple and code readability is improved.
35 *
36 * Emodel use EO Events. Views and Controllers must register
37 * in events to be able to recieve notifications about state changes in Emodel.
38 * Some of currently available events are:
39 *
40 * EMODEL_EVENT_LOAD_STATUS
41 * EMODEL_EVENT_PROPERTIES_CHANGED
42 * EMODEL_EVENT_CHILD_ADDED
43 * EMODEL_EVENT_CHILD_REMOVED
44 * EMODEL_EVENT_CHILDREN_COUNT_CHANGED
45 *
46 * Example code using Emodel_Eio that returns the number of files in '/tmp' directory:
47 *
48 * @code
49 * static Eina_Bool
50 * _children_count_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
51 * {
52 * size_t *len = event_info;
53 * fprintf(stdout, "Children count len=%lu\n", *len);
54 * return EINA_TRUE;
55 * }
56 *
57 * int
58 * main(int argc, const char **argv)
59 * {
60 * size_t total;
61 * Eo *model;
62 * if(!ecore_init())
63 * {
64 * fprintf(stderr, "ERROR: Cannot init Ecore!\n");
65 * return 1;
66 * }
67 * if(!eio_init())
68 * {
69 * fprintf(stderr, "ERROR: Cannot init Eio!\n");
70 * return 1;
71 * }
72 *
73 * model = eo_add_custom(EIO_MODEL_CLASS, NULL, eio_model_constructor("/tmp"));
74 * eo_do(model, eo_event_callback_add(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _children_count_cb, NULL));
75 * eo_do(model, emodel_children_count_get(&total));
76 * fprintf(stdout, "total=%lu\n", total);
77 *
78 * ecore_main_loop_begin();
79 * eo_unref(model);
80 * eio_shutdown();
81 * ecore_shutdown();
82 * return 0;
83 * }
84 * @endcode
85 *
86 * In previous example the concrete Emodel_Eio counts, asynchronously, the number of files in given directory,
87 * emodel_children_count_get() returns into 'total' pointer the last known number of children. In the meantime
88 * when background count is finished _children_count_cb() is invoked receiving the number of files as event_info data.
89 * This is achieved by registering the Model as EMODEL_EVENT_CHILDREN_COUNT_CHANGED event listener and every time
90 * the count (number of children) changes, the event is disptached to listeners.
91 *
92 * The principles may remain the same for different events and the logic remains.
93 *
94 * @li @ref emodel_main_intro_example
95 *
96 * @include emodel_test_file.c
97 *
98 * Recommended reading:
99 *
100 * @li @ref Eo, where you'll understand how Eo Events work.
101 * @li @ref Eio, where you'll find EFL Eio implementation and interfaces.
102 * @li @ref Emodel_Eio, the concrete EIO implementation using both Emodel and Eio.
103 * @li @ref Ecore, You'll get more information about I/O filesystem events.
104 *
105 * @defgroup Emodel
106 *
107 * @addtogroup Emodel
108 * @{
109 */
110
111#ifndef _EMODEL_H
112#define _EMODEL_H
113
114#include <Efl_Config.h>
115#include <Eo.h>
116#include <Emodel_Common.h>
117
118#ifdef __cplusplus
119extern "C" {
120#endif
121
122#include <emodel.eo.h>
123
124#ifdef __cplusplus
125}
126#endif
127#endif //_EMODEL_H
diff --git a/src/lib/emodel/Emodel_Common.h b/src/lib/emodel/Emodel_Common.h
new file mode 100644
index 0000000000..d457c48afd
--- /dev/null
+++ b/src/lib/emodel/Emodel_Common.h
@@ -0,0 +1,106 @@
1#ifndef _EMODEL_COMMON_H
2#define _EMODEL_COMMON_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/**
9 * @enum _Emodel_Load_Status
10 * XXX/TODO/FIXME: Remove this enum (and possibly other data) from here
11 * as soon as eolian translates these data types in .eo's.
12 */
13enum _Emodel_Load_Status
14 {
15 EMODEL_LOAD_STATUS_ERROR = 0,
16 EMODEL_LOAD_STATUS_LOADING_PROPERTIES = (1 << 0),
17 EMODEL_LOAD_STATUS_LOADING_CHILDREN = (1 << 1),
18 EMODEL_LOAD_STATUS_LOADING = (1 << 0) | (1 << 1),
19
20 EMODEL_LOAD_STATUS_LOADED_PROPERTIES = (1 << 2),
21 EMODEL_LOAD_STATUS_LOADED_CHILDREN = (1 << 3),
22 EMODEL_LOAD_STATUS_LOADED = (1 << 2) | (1 << 3),
23
24 EMODEL_LOAD_STATUS_UNLOADING = (1 << 4),
25 EMODEL_LOAD_STATUS_UNLOADED = (1 << 5)
26 };
27/**
28 * @typedef Emodel_Load_Status
29 */
30typedef enum _Emodel_Load_Status Emodel_Load_Status;
31
32/**
33 * @struct _Emodel_Load
34 * Structure to hold Emodel_Load_Status enum
35 * (and possible other data) to avoid ABI break.
36 */
37struct _Emodel_Load
38 {
39 Emodel_Load_Status status;
40 /* add more data below here if necessary */
41 };
42
43/**
44 * @typedef Emodel_Load
45 */
46typedef struct _Emodel_Load Emodel_Load;
47
48/**
49 * @struct _Emodel_Property_Pair
50 */
51struct _Emodel_Property_Pair
52{
53 Eina_Value value; /**< the property value */
54 Eina_Stringshare *property; /**< the property name */
55};
56
57/**
58 * @typedef Emodel_Property_Pair
59 */
60typedef struct _Emodel_Property_Pair Emodel_Property_Pair;
61
62/**
63 * @struct _Emodel_Property_Event
64 */
65struct _Emodel_Property_Event
66{
67 Eina_List *changed_properties; /**< the property value */
68 Eina_List *invalidated_properties; /**< the property name */
69};
70
71/**
72 * @typedef Emodel_Property_Event
73 */
74typedef struct _Emodel_Property_Event Emodel_Property_Event;
75
76/**
77 * @struct _Emodel_Children_Event
78 * Every time a child id added the event
79 * EMODEL_EVENT_CHILD_ADDED is dispatched
80 * passing along this structure.
81 */
82struct _Emodel_Children_Event
83{
84 Eo *child; /**< child, for child_add */
85 /**
86 * index is a hint and is intended
87 * to provide a way for applications
88 * to control/know children relative
89 * positions through listings.
90 *
91 * NOTE: If listing is performed asynchronously
92 * exact order may not be guaranteed.
93 */
94 unsigned int index;
95};
96
97/**
98 * @struct Emodel_Children_Event
99 */
100typedef struct _Emodel_Children_Event Emodel_Children_Event;
101
102
103#ifdef __cplusplus
104}
105#endif
106#endif
diff --git a/src/lib/emodel/emodel.c b/src/lib/emodel/emodel.c
new file mode 100644
index 0000000000..c8df075bc5
--- /dev/null
+++ b/src/lib/emodel/emodel.c
@@ -0,0 +1,6 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Emodel.h"
6#include "emodel.eo.c"
diff --git a/src/lib/emodel/emodel.eo b/src/lib/emodel/emodel.eo
new file mode 100644
index 0000000000..39fccf239c
--- /dev/null
+++ b/src/lib/emodel/emodel.eo
@@ -0,0 +1,326 @@
1/*
2 * type Emodel_Load_Status: enum _Emodel_Load_Status
3 * {
4 * EMODEL_LOAD_STATUS_ERROR = 0, /*@ Error in Load Model *
5 * EMODEL_LOAD_STATUS_LOADING_PROPERTIES = (1 << 0), /*@ properties load in progress *
6 * EMODEL_LOAD_STATUS_LOADING_CHILDREN = (1 << 1), /*@ children load in progress *
7 * EMODEL_LOAD_STATUS_LOADING = (1 << 0) | (1 << 1), /*@ children and properties load in progress *
8 *
9 * EMODEL_LOAD_STATUS_LOADED_PROPERTIES = (1 << 2), /*@ Model as ready to fetch properties *
10 * EMODEL_LOAD_STATUS_LOADED_CHILDREN = (1 << 3), /*@ Model as ready to fetch children *
11 * EMODEL_LOAD_STATUS_LOADED = (1 << 2) | (1 << 3), /*@ Model as ready to fetch properties and children *
12 *
13 * EMODEL_LOAD_STATUS_UNLOADING = (1 << 4), /*@ Model Unload in progress *
14 * EMODEL_LOAD_STATUS_UNLOADED = (1 << 5) /*@ Model Unloaded *
15 * }
16 *
17 * type Emodel_Property_Pair: struct _Emodel_Property_Pair
18 * {
19 * value: Eina_Value; /*@ the new property value *
20 * property: const(char)*; /*@ the property name that has been changed *
21 * }
22 *
23 * type Emodel_Property_Event: struct _Emodel_Property_Event
24 * {
25 * changed_properties: Eina_List* <Emodel_Property_Pair*>; /*@ List of changed properties *
26 * invalidated_properties: Eina_List* <const(char)*>; /*@ Removed properties identified by name *
27 * }
28 */
29
30interface Emodel ()
31{
32 legacy_prefix: null;
33 properties {
34 load_status {
35 get {
36 /*@
37 Get a load emodel current status.
38
39 @return: @c Emodel_Load_Status
40
41 By convention this means get the current model status.
42 Possible values are defined Emodel_Load_Status enumerator.
43
44 @see Emodel_Load_Status
45 @see emodel_load
46
47 @since 1.11 */
48 return: Emodel_Load_Status;
49 }
50 }
51 properties_list {
52 get {
53 /*@
54 Get properties list from model.
55
56 @return: @c Emodel_Load_Status
57
58 properties_list_get is due to provide callers a way the fetch the current
59 properties implemented/used by the model.
60 The event EMODEL_EVENT_PROPERTIES_CHANGE will be raised to notify listeners
61 of any modifications in the properties list.
62
63 @see EMODEL_EVENT_PROPERTIES_CHANGE
64 @since 1.11 */
65
66 return: Emodel_Load_Status;
67 }
68 values {
69 const(list<const(char*)>*) properties_list; /*@ list of current properties */
70 }
71 }
72 property {
73 set {
74 /*@
75 Set a property value of a given property name.
76
77 @return: @c EINA_TRUE, on success, @c EINA_FALSE in readonly property or error
78
79 The caller must ensure to call at least emodel_prop_list before being
80 able to see/set properties.
81 This function sets a new property value into given property name. Once
82 the operation is completed the concrete implementation should raise
83 EMODEL_EVENT_PROPERTIES_CHANGE event in order to notify listeners of the
84 new value of the property.
85
86 If the model doesn't have the property then there are two possibilities,
87 either raise an error or create the new property in model
88
89 @see emodel_property_get
90 @see EMODEL_EVENT_PROPERTIES_CHANGE
91 @since 1.11 */
92
93 return: Emodel_Load_Status;
94 }
95 get {
96 /*@
97 Retrieve the value of a given property name.
98
99 @return: @c Load Status, on success, @c EMODEL_LOAD_STATUS_ERROR otherwise
100
101 property_get will only be available when load status is equal to
102 EMODEL_LOAD_STATUS_LOADED.
103
104 At this point the caller is free to get values from properties.
105 The event EMODEL_EVENT_PROPERTIES_CHANGE may be raised to notify
106 listeners of the property/value.
107
108 @see emodel_properties_list_get
109 @see EMODEL_EVENT_PROPERTIES_CHANGE
110
111 @since 1.11 */
112 return: Emodel_Load_Status;
113 }
114 keys {
115 const(char)* property; /*@ Property name */
116 }
117 values {
118 Eina_Value value; /*@ New value */
119 }
120 }
121 children_slice {
122 get {
123 /*@
124 Get children slice OR full range.
125
126 @return: @c Emodel_Load_Status. See below for more info.
127
128 Before being able to get the children list the model status must be
129 on loaded status (EMODEL_LOAD_STATUS_LOADED).
130 However there may be circunstancies where the model could be
131 in a different state, in such cases it is advisable
132 to simply return: its current state, which will be
133 of course, different than @c EMODEL_LOAD_STATUS_LOADED_CHILDREN.
134 When children accessor is return:ed as NULL one should then
135 test the current load status return:ed by @children_slice_get
136 in order to check against an empty list or real error.
137
138 children_slice_get behaves in two different ways, it may provide
139 the slice if both @c start AND @c count are non-zero OR full range otherwise.
140
141 The return:ed Eina_Accessor must be freed when it is no longer needed and
142 eo_unref() must be invoked for children if caller wants a copy.
143
144 Since 'slice' is a range, for example if we have 20 childs a slice could be
145 the range from 3(start) to 4(count), see:
146 child 0 [no]
147 child 1 [no]
148 child 2 [yes]
149 child 3 [yes]
150 child 4 [yes]
151 child 5 [yes]
152 child 6 [no]
153 child 7 [no]
154
155 Optionally the user can call children_count_get to know
156 the number of children so a valid range can be known in advance.
157
158 Below are examples of both usage types: slices and full ranges.
159 @code
160
161 // Returns full list
162 eo_do(obj, emodel_children_slice_get(0, 0, &children_accessor));
163
164 // Returns 5 items, counting from item #5
165 eo_do(obj, emodel_children_slice_get(5, 5, &children_accessor));
166
167 @endcode
168
169 @see emodel_children_get
170 @see emodel_children_count_get
171 @see emodel_load
172 @see emodel_load_status_get
173 @since 1.11 */
174
175 return: Emodel_Load_Status;
176 }
177 keys {
178 unsigned start; /*@ Range begin - start from here. If start and count are 0 slice is ignored.*/
179 unsigned count; /*@ Range size. If count and start are 0 slice is ignored.*/
180 }
181 values {
182 accessor<list*>* children_accessor;
183 }
184 }
185 children_count {
186 get {
187 /*@
188 Get children count.
189
190 @return: @c EINA_TRUE, on success, @c EINA_FALSE otherwise
191
192 When emodel_load is completed emodel_coildren_count_get can be use
193 to get the number of children. children_count_get can also be used
194 before calling children_slice_get so a valid range is known.
195 Event EMODEL_CHILDREN_COUNT_CHANGED is emitted when count is finished.
196
197 @see emodel_children_get
198 @see emodel_children_slice_get
199 @see emodel_load
200 @see emodel_load_status_get
201 @since 1.11 */
202
203 return: Emodel_Load_Status;
204 }
205 values {
206 unsigned children_count;
207 }
208 }
209 }
210 methods {
211 load {
212 /*@
213 Load emodel.
214
215 By convention this means loading data from an external source and populating
216 the models properties and children with it. For example in the case of file
217 system backed model, this means opening the relevant files and reading the
218 data from them(creating the properties and children from it).
219 the model emit EMODEL_EVENT_LOAD_STATUS after end with Emodel_Load_Status
220 @warning This convention should be followed, but no guarantees of behaviour
221 by user defined types can be given.
222
223 Alternatively is possible to use properties_load to load only properties
224 and children_load to load only children. If emodel_load is called then
225 calling properties_load and/or children_load is not necessary.
226
227 @see Emodel_Load_Status
228 @see emodel_properties_load
229 @see emodel_children_load
230 @see emodel_unload
231 @see emodel_load_status_get
232
233 @since 1.11 */
234 }
235 unload {
236 /*@
237 Unload emodel.
238
239 By convention this means releasing data received/read from an external source. For
240 example of a database backed model this might mean releasing the iterator for
241 the currently loaded data or deleting a temporary table.
242 the model emit EMODEL_EVENT_LOAD_STATUS after end with model load status
243 @warning This convention should be followed, but no guarantees of behaviour
244 by user defined types can be given.
245
246 @see Emodel_Load_Status
247 @see emodel_load
248 @see emodel_load_status_get
249
250 @since 1.11 */
251 }
252 properties_load {
253 /*@
254 Properties emodel load.
255
256 By convention this means loading data from an external source and populating
257 the models properties only. This method is a subset of emodel_load, meaning that
258 it won't load children, it is a hint.
259 For loadind both properties and children use emodel_load
260 instead.
261
262 @see emodel_load
263
264 @since 1.11 */
265 }
266 children_load {
267 /*@
268 Children emodel load.
269
270 By convention this means loading data from an external source and populating
271 the models children only. This method is a subset of emodel_load, meaning that
272 it won't load properties. For loadind both properties and children use emodel_load
273 instead.
274
275 @see emodel_load
276
277 @since 1.11 */
278 }
279 child_add {
280 /*@
281 Add a new child.
282
283 @return: @c Emodel* on success, @c NULL otherwise
284
285 Add a new child, possibly dummy, depending on the implementation,
286 of a internal keeping. When the child is effectively
287 added the event EMODEL_EVENT_CHILD_ADD is then raised and the new child
288 is kept along with other children.
289
290 @see EMODEL_EVENT_CHILD_ADD
291 @see load_status_get
292
293 @since 1.11 */
294
295 return: Eo *;
296 }
297 child_del {
298 /*@
299 Remove a child.
300
301 @return: @c Emodel_Load_Status on success, @c EMODEL_LOAD_STATUS_ERROR otherwise.
302
303 Remove a child of a internal keeping. When the child is effectively
304 removed the event EMODEL_EVENT_CHILD_REMOVED is then raised to give a
305 chance for listeners to perform any cleanup and/or update references.
306
307 @see EMODEL_EVENT_CHILD_REMOVED
308 @since 1.11 */
309
310 return: Emodel_Load_Status;
311
312 params {
313 @in Eo* child; /*@ Child to be removed */
314 }
315 }
316 }
317
318 events {
319 load,status: Emodel_Load_Status; /*@ Event dispatch when load status changes */
320 properties,changed: Emodel_Properties_Evt; /*@ Event dispatched when properties list is available. */
321 child,added; /*@ Event dispatched when new child is added. */
322 child,removed; /*@ Event dispatched when child is removed. */
323 children,count,changed; /*@ Event dispatched when children count is finished. */
324 }
325}
326
diff --git a/src/tests/emodel/emodel_suite.c b/src/tests/emodel/emodel_suite.c
new file mode 100644
index 0000000000..33b61e0e34
--- /dev/null
+++ b/src/tests/emodel/emodel_suite.c
@@ -0,0 +1,138 @@
1
2#ifdef HAVE_CONFIG_H
3# include "config.h"
4#endif
5
6#include <Eina.h>
7#include <stdio.h>
8#include <string.h>
9
10#include <check.h>
11
12void emodel_test_file(TCase* tc);
13void emodel_test_monitor_add(TCase* tc);
14
15typedef struct _Emodel_Test_Case Emodel_Test_Case;
16struct _Emodel_Test_Case
17{
18 const char *test_case;
19 void (*build)(TCase *tc);
20};
21
22static const Emodel_Test_Case etc[] = {
23 { "File", emodel_test_file },
24 { "Monitor Add", emodel_test_monitor_add },
25 { NULL, NULL }
26};
27
28static void
29_list_tests(void)
30{
31 const Emodel_Test_Case *itr = etc;
32 fputs("Available Test Cases:\n", stderr);
33 for (; itr->test_case; itr++)
34 fprintf(stderr, "\t%s\n", itr->test_case);
35}
36
37static Eina_Bool
38_use_test(int argc, const char **argv, const char *test_case)
39{
40 if (argc < 1)
41 return 1;
42
43 for (; argc > 0; argc--, argv++)
44 if (strcmp(test_case, *argv) == 0)
45 return 1;
46
47 return 0;
48}
49
50Suite *
51emodel_build_suite(int argc, const char **argv)
52{
53 TCase *tc;
54 Suite *s;
55 int i;
56
57 s = suite_create("Emodel");
58
59 for (i = 0; etc[i].test_case; ++i)
60 {
61 if (!_use_test(argc, argv, etc[i].test_case))
62 continue;
63
64 tc = tcase_create(etc[i].test_case);
65 tcase_set_timeout(tc, 0);
66
67 etc[i].build(tc);
68 suite_add_tcase(s, tc);
69 }
70
71 return s;
72}
73
74/* FIXME this is a copy from eina_test_mempool
75 * we should remove the duplication
76 */
77static Eina_Array *_modules;
78static void _mempool_init(void)
79{
80 eina_init();
81 /* force modules to be loaded in case they are not installed */
82 _modules = eina_module_list_get(NULL,
83 PACKAGE_BUILD_DIR "/src/modules",
84 EINA_TRUE,
85 NULL,
86 NULL);
87 eina_module_list_load(_modules);
88}
89
90static void _mempool_shutdown(void)
91{
92 eina_module_list_free(_modules);
93 if (_modules)
94 eina_array_free(_modules);
95 /* TODO delete the list */
96 eina_shutdown();
97}
98
99int
100main(int argc, char **argv)
101{
102 Suite *s;
103 SRunner *sr;
104 int i, failed_count;
105
106 for (i = 1; i < argc; i++)
107 if ((strcmp(argv[i], "-h") == 0) ||
108 (strcmp(argv[i], "--help") == 0))
109 {
110 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
111 argv[0]);
112 _list_tests();
113 return 0;
114 }
115 else if ((strcmp(argv[i], "-l") == 0) ||
116 (strcmp(argv[i], "--list") == 0))
117 {
118 _list_tests();
119 return 0;
120 }
121
122 putenv("EFL_RUN_IN_TREE=1");
123
124 s = emodel_build_suite(argc - 1, (const char **)argv + 1);
125 sr = srunner_create(s);
126
127 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
128
129 _mempool_init();
130
131 srunner_run_all(sr, CK_ENV);
132 failed_count = srunner_ntests_failed(sr);
133 srunner_free(sr);
134
135 _mempool_shutdown();
136
137 return (failed_count == 0) ? 0 : 255;
138}
diff --git a/src/tests/emodel/emodel_test_file.c b/src/tests/emodel/emodel_test_file.c
new file mode 100644
index 0000000000..029aa2e459
--- /dev/null
+++ b/src/tests/emodel/emodel_test_file.c
@@ -0,0 +1,273 @@
1//Compile with:
2// gcc -o emodel_test_file emodel_test_file.c `pkg-config --cflags --libs emodel`
3#ifdef HAVE_CONFIG_H
4# include <config.h>
5#endif
6
7#include <Eo.h>
8#include <Eio.h>
9#include <Ecore.h>
10#include <Emodel.h>
11#include <eio_model.h>
12#include <stdio.h>
13
14#include <check.h>
15
16#define EMODEL_TEST_FILENAME_PATH "/tmp"
17#define EMODEL_MAX_TEST_CHILDS 16
18
19/**
20 * The following test works however
21 * it is going to rename (move) the original directory to
22 * new one so '/tmp' as root dir doesn't work , you'll need to use
23 * '/tmp/some_other_dir' as root instead.
24 */
25//#define _RUN_LOCAL_TEST
26
27struct reqs_t {
28 /* property change */
29 int changed_is_dir;
30 int changed_is_lnk;
31 int changed_size;
32 int changed_mtime;
33 int changed_icon;
34
35 /* properties list */
36 int proplist_filename;
37 int proplist_path;
38 int proplist_icon;
39 int proplist_mtime;
40 int proplist_is_dir;
41 int proplist_is_lnk;
42 int proplist_size;
43
44 /* misc tests for data or propeties */
45 int properties;
46 int children;
47 int child_add;
48 int child_del;
49};
50
51static struct reqs_t reqs;
52static Ecore_Event_Handler *handler;
53
54static Eina_Bool
55 exit_func(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
56 {
57 Ecore_Event_Signal_Exit *e;
58
59 e = (Ecore_Event_Signal_Exit *)ev;
60 if (e->interrupt) fprintf(stdout, "Exit: interrupt\n");
61 else if (e->quit) fprintf(stdout, "Exit: quit\n");
62 else if (e->terminate) fprintf(stdout, "Exit: terminate\n");
63 ecore_main_loop_quit();
64 return ECORE_CALLBACK_CANCEL;
65 }
66
67static Eina_Bool
68_load_status_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
69{
70 Emodel_Load *st = event_info;
71 printf("Load CHANGE\n");
72
73 if (st->status & EMODEL_LOAD_STATUS_LOADED_CHILDREN)
74 printf("Children is Loaded\n");
75
76 if (st->status & EMODEL_LOAD_STATUS_LOADED_PROPERTIES)
77 printf("Properties is Loaded\n");
78
79 if ((st->status & EMODEL_LOAD_STATUS_LOADED) == EMODEL_LOAD_STATUS_LOADED)
80 {
81 Eina_Accessor *accessor;
82 Eina_Value value_prop;
83 Eo *child;
84 Emodel_Load_Status status;
85 unsigned int total, i;
86 char *str;
87
88 printf("Model is Loaded\n");
89 eo_do(obj, status = emodel_property_get("filename", &value_prop));
90 str = eina_value_to_string(&value_prop);
91 printf("emodel_loaded filename %s, status=%d\n", str, status);
92 eina_value_flush(&value_prop);
93 free(str);
94
95 eo_do(obj, status = emodel_property_get("size", &value_prop));
96 str = eina_value_to_string(&value_prop);
97 printf("emodel_loaded size %s, status=%d\n", str, status);
98 eina_value_flush(&value_prop);
99 free(str);
100
101 eo_do(obj, status = emodel_property_get("mtime", &value_prop));
102 str = eina_value_to_string(&value_prop);
103 printf("emodel_loaded mtime %s, status=%d\n", str, status);
104 eina_value_flush(&value_prop);
105 free(str);
106
107 eo_do(obj, emodel_children_count_get(&total));
108 printf("emodel_test count %d\n", (int)total);
109
110 /**< get full list */
111 eo_do(obj, status = emodel_children_slice_get(0 ,0 ,(Eina_Accessor **)&accessor));
112 EINA_ACCESSOR_FOREACH(accessor, i, child)
113 {
114 //XXX: check if there is memleak
115 eo_do(child, status = emodel_property_get("filename", &value_prop));
116 str = eina_value_to_string(&value_prop);
117 printf("(full) %d emodel_children_get filename %s\n", i, str);
118 eina_value_flush(&value_prop);
119 free(str);
120 }
121
122 i = 0;
123 eina_accessor_free(accessor);
124 eo_do(obj, status = emodel_children_slice_get(5 ,5 ,(Eina_Accessor **)&accessor));
125
126 EINA_ACCESSOR_FOREACH(accessor, i, child)
127 {
128 //XXX: check if there is memleak
129 eo_do(child, status = emodel_property_get("filename", &value_prop));
130 str = eina_value_to_string(&value_prop);
131 printf("(slice) %d emodel_chidlren_property_set filename %s\n", i, str);
132 eina_value_flush(&value_prop);
133 free(str);
134 eo_unref(child);
135 }
136 eina_accessor_free(accessor);
137 ecore_main_loop_quit();
138 }
139 return EINA_TRUE;
140}
141
142static Eina_Bool
143_properties_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
144{
145 const Emodel_Property_Event *evt = (Emodel_Property_Event *)event_info;
146 Emodel_Property_Pair *pair = NULL;
147 Eina_List *l = NULL;
148
149 EINA_LIST_FOREACH(evt->changed_properties, l, pair)
150 {
151 char *str;
152 str = eina_value_to_string(&pair->value);
153 fprintf(stdout, "Received changed property=%s, value=%s\n",
154 pair->property, str);
155 free(str);
156 if(!strcmp(pair->property, "is_dir"))
157 reqs.changed_is_dir = 1;
158 if(!strcmp(pair->property, "is_lnk"))
159 reqs.changed_is_lnk = 1;
160 if(!strcmp(pair->property, "size"))
161 reqs.changed_size = 1;
162 if(!strcmp(pair->property, "mtime"))
163 reqs.changed_mtime = 1;
164 if(!strcmp(pair->property, "icon"))
165 reqs.changed_icon = 1;
166 }
167
168 reqs.properties = 1;
169 return EINA_TRUE;
170}
171
172static Eina_Bool
173_children_count_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
174{
175 unsigned int *len = (unsigned int *)event_info;
176 unsigned int total;
177
178 fprintf(stdout, "Children count number=%d\n", *len);
179 reqs.children = *len;
180
181 eo_do(obj, emodel_children_count_get(&total));
182 fprintf(stdout, "New total children count number=%d\n", *len);
183
184 return EINA_TRUE;
185}
186
187START_TEST(emodel_test_test_file)
188{
189 Eo *filemodel = NULL;
190 Eina_Value value_prop;
191 Emodel_Load_Status status;
192#ifdef _RUN_LOCAL_TEST
193 Eina_Value nameset_value;
194#endif
195 Eina_List *properties_list;
196 Eina_List *l;
197 char *str;
198 int i;
199
200 memset(&reqs, -1, sizeof(struct reqs_t));
201
202 fail_if(!eina_init(), "ERROR: Cannot init Eina!\n");
203 fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
204 fail_if(!eio_init(), "ERROR: Cannot init EIO!\n");
205
206 filemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(EMODEL_TEST_FILENAME_PATH));
207 fail_if(!filemodel, "ERROR: Cannot init model!\n");
208
209 eo_do(filemodel, eo_event_callback_add(EMODEL_EVENT_LOAD_STATUS, _load_status_cb, NULL));
210 eo_do(filemodel, eo_event_callback_add(EMODEL_EVENT_PROPERTIES_CHANGED, _properties_cb, NULL));
211 eo_do(filemodel, eo_event_callback_add(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _children_count_cb, NULL));
212
213 eo_do(filemodel, emodel_load());
214
215 handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
216
217 eina_value_setup(&value_prop, EINA_VALUE_TYPE_STRING);
218
219 eo_do(filemodel, status = emodel_property_get("filename", &value_prop));
220 str = eina_value_to_string(&value_prop);
221 printf("emodel_test filename %s, load status %d\n", str, status);
222
223 eina_value_flush(&value_prop);
224 free(str);
225
226 i = 0;
227 eo_do(filemodel, emodel_properties_list_get(&properties_list));
228 EINA_LIST_FOREACH((Eina_List *)properties_list, l, str)
229 {
230 fprintf(stdout, "Returned property list %d: %s\n", i++, str);
231 if(!strcmp(str, "filename"))
232 reqs.proplist_filename = 1;
233 else if(!strcmp(str, "path"))
234 reqs.proplist_path = 1;
235 else if(!strcmp(str, "icon"))
236 reqs.proplist_icon = 1;
237 else if(!strcmp(str, "mtime"))
238 reqs.proplist_mtime = 1;
239 else if(!strcmp(str, "is_dir"))
240 reqs.proplist_is_dir = 1;
241 else if(!strcmp(str, "is_lnk"))
242 reqs.proplist_is_lnk = 1;
243 else if(!strcmp(str, "size"))
244 reqs.proplist_size = 1;
245 }
246
247 ecore_main_loop_begin();
248
249#ifdef _RUN_LOCAL_TEST
250 eina_value_setup(&nameset_value, EINA_VALUE_TYPE_STRING);
251 eina_value_setup(&value_prop, EINA_VALUE_TYPE_STRING);
252 eina_value_set(&nameset_value, "/tmp/emodel_test");
253 eo_do(filemodel, emodel_property_set("path", nameset_value));
254 eina_value_flush(&nameset_value);
255 //emodel_property_get("path", &value_prop);
256 eo_do(filemodel, status = emodel_property_get("path", &value_prop));
257 eina_value_flush(&value_prop);
258#endif
259
260 sleep(1); /**< EIO is asynchrounous so I must give some time for deletions to execute */
261 eo_unref(filemodel);
262 ecore_shutdown();
263 eina_shutdown();
264 eio_shutdown();
265}
266END_TEST
267
268void
269emodel_test_file(TCase *tc)
270{
271 /* tcase_add_test(tc, emodel_test_test_file); */
272}
273
diff --git a/src/tests/emodel/emodel_test_monitor_add.c b/src/tests/emodel/emodel_test_monitor_add.c
new file mode 100644
index 0000000000..166b3847ee
--- /dev/null
+++ b/src/tests/emodel/emodel_test_monitor_add.c
@@ -0,0 +1,105 @@
1//Compile with:
2// gcc -o emodel_test_file emodel_test_file.c `pkg-config --cflags --libs emodel`
3#ifdef HAVE_CONFIG_H
4# include <config.h>
5#endif
6
7#include <Eo.h>
8#include <Eio.h>
9#include <Ecore.h>
10#include <Emodel.h>
11#include <eio_model.h>
12#include <stdio.h>
13
14#include <check.h>
15
16#define EMODEL_TEST_FILENAME_PATH "/tmp"
17
18Eina_Bool children_added = EINA_FALSE;
19
20static Eina_Bool
21_children_added_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
22{
23 Emodel_Children_Event* evt = event_info;
24 Eo* child = evt->child;
25 Eina_Value value_prop;
26 const char* str;
27
28 eo_do(child, emodel_property_get("filename", &value_prop));
29 str = eina_value_to_string(&value_prop);
30 fprintf(stderr, "new children filename %s\n", str);
31 if(strcmp(str, "test_file_monitor_add") == 0)
32 {
33 fprintf(stderr, "is child that we want\n");
34 children_added = EINA_TRUE;
35 eo_do(obj, emodel_child_del(child));
36 ecore_main_loop_quit();
37 }
38 eina_value_flush(&value_prop);
39 return EINA_TRUE;
40}
41
42static Eina_Bool
43_children_count_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
44{
45 unsigned int *len = event_info;
46 Eina_Accessor *accessor;
47 Emodel_Load_Status status;
48 Eo *child;
49 unsigned int i = 0;
50
51 fprintf(stderr, "Children count number=%d\n", *len);
52
53 /**< get full list */
54 eo_do(obj, status = emodel_children_slice_get(0 ,0 ,(Eina_Accessor **)&accessor));
55 if(accessor != NULL)
56 {
57 EINA_ACCESSOR_FOREACH(accessor, i, child) {}
58 fprintf(stdout, "Got %d childs from Accessor. status=%d\n", i, status);
59 }
60
61 fclose(fopen(EMODEL_TEST_FILENAME_PATH "/test_file_monitor_add", "w+"));
62
63 return EINA_TRUE;
64}
65
66START_TEST(emodel_test_test_monitor_add)
67{
68 Eo *filemodel = NULL;
69
70 fprintf(stderr, "emodel_test_test_monitor_add\n");
71
72 fail_if(!eina_init(), "ERROR: Cannot init Eina!\n");
73 fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
74 fail_if(!eio_init(), "ERROR: Cannot init EIO!\n");
75
76 filemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(EMODEL_TEST_FILENAME_PATH));
77 fail_if(!filemodel, "ERROR: Cannot init model!\n");
78
79 eo_do(filemodel, eo_event_callback_add(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _children_count_cb, NULL));
80 eo_do(filemodel, eo_event_callback_add(EMODEL_EVENT_CHILD_ADDED, _children_added_cb, NULL));
81
82 eo_do(filemodel, emodel_load());
83
84 ecore_main_loop_begin();
85
86 sleep(1); /**< EIO is asynchrounous so I must give some time for deletions to execute */
87
88 ecore_main_loop_iterate(); /**< Give time to unlink file */
89
90 eo_unref(filemodel);
91
92 eio_shutdown();
93 ecore_shutdown();
94 eina_shutdown();
95
96 fail_if(!children_added);
97}
98END_TEST
99
100void
101emodel_test_monitor_add(TCase *tc)
102{
103 tcase_add_test(tc, emodel_test_test_monitor_add);
104}
105