summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-07-31 15:25:18 -0300
committerGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-08-03 11:31:16 -0300
commit57e390e1537841116e92e9140dbd1993b141aee3 (patch)
tree93420908e08f09fb9caad72d275e7f5690aac052
parent802cddc8d3a9564f42ff2973a475eb8a9e7014eb (diff)
esoap_model: Soap Model implementationdevs/felipealmeida/esoap-model
-rw-r--r--Makefile.am16
-rw-r--r--cmakeconfig/EsoapModelConfig.cmake.in32
-rw-r--r--cmakeconfig/EsoapModelCxxConfig.cmake.in30
-rw-r--r--configure.ac51
-rw-r--r--pc/esoap_model-cxx.pc.in12
-rw-r--r--pc/esoap_model.pc.in12
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile_EsoapModel.am84
-rw-r--r--src/Makefile_EsoapModel_Cxx.am22
-rw-r--r--src/lib/esoap_model/Esoap_Model.h63
-rw-r--r--src/lib/esoap_model/esoap_model.c470
-rw-r--r--src/lib/esoap_model/esoap_model.eo36
-rw-r--r--src/lib/esoap_model/esoap_model_private.h35
-rw-r--r--src/tests/esoap_model/esoap_model_suite.c119
-rw-r--r--src/tests/esoap_model/esoap_model_suite.h16
-rw-r--r--src/tests/esoap_model/esoap_model_test_esoap_model.c238
-rw-r--r--src/tests/esoap_model/esoap_model_test_esoap_model.h6
17 files changed, 1242 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 1fc5897382..22a191227d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -152,7 +152,8 @@ pc/emotion.pc \
152pc/ethumb.pc \ 152pc/ethumb.pc \
153pc/ethumb_client.pc \ 153pc/ethumb_client.pc \
154pc/elocation.pc \ 154pc/elocation.pc \
155pc/eflat_xml_model.pc 155pc/eflat_xml_model.pc \
156pc/esoap_model.pc
156 157
157if HAVE_CXX11 158if HAVE_CXX11
158pkgconfig_DATA += \ 159pkgconfig_DATA += \
@@ -165,7 +166,8 @@ pc/edje-cxx.pc \
165pc/eet-cxx.pc \ 166pc/eet-cxx.pc \
166pc/eo-cxx.pc \ 167pc/eo-cxx.pc \
167pc/eio-cxx.pc \ 168pc/eio-cxx.pc \
168pc/eflat_xml_model-cxx.pc 169pc/eflat_xml_model-cxx.pc \
170pc/esoap_model-cxx.pc
169endif 171endif
170 172
171if HAVE_ELUA 173if HAVE_ELUA
@@ -394,6 +396,16 @@ eflat_xml_model_cmakeconfig_DATA = \
394cmakeconfig/EflatXmlModelConfig.cmake \ 396cmakeconfig/EflatXmlModelConfig.cmake \
395cmakeconfig/EflatXmlModelConfigVersion.cmake 397cmakeconfig/EflatXmlModelConfigVersion.cmake
396 398
399esoap_model_cxx_cmakeconfigdir = $(libdir)/cmake/EsoapModelCxx/
400esoap_model_cxx_cmakeconfig_DATA = \
401cmakeconfig/EsoapModelCxxConfig.cmake \
402cmakeconfig/EsoapModelCxxConfigVersion.cmake
403
404esoap_model_cmakeconfigdir = $(libdir)/cmake/EsoapModel/
405esoap_model_cmakeconfig_DATA = \
406cmakeconfig/EsoapModelConfig.cmake \
407cmakeconfig/EsoapModelConfigVersion.cmake
408
397# D-Bus services: 409# D-Bus services:
398 410
399servicedir = @dbusservicedir@ 411servicedir = @dbusservicedir@
diff --git a/cmakeconfig/EsoapModelConfig.cmake.in b/cmakeconfig/EsoapModelConfig.cmake.in
new file mode 100644
index 0000000000..701d07054e
--- /dev/null
+++ b/cmakeconfig/EsoapModelConfig.cmake.in
@@ -0,0 +1,32 @@
1# - Try to find esoap_model
2# Once done this will define
3# ESOAP_MODEL_FOUND - System has esoap_model
4# ESOAP_MODEL_INCLUDE_DIRS - The esoap_model include directories
5# ESOAP_MODEL_LIBRARIES - The libraries needed to use esoap_model
6# ESOAP_MODEL_DEFINITIONS - Compiler switches required for using esoap_model
7
8set(MY_PKG esoap_model)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBESOAP_MODEL ${_QUIET} ${MY_PKG})
16
17find_library(ESOAP_MODEL_LIBRARY
18 NAMES ${PC_LIBESOAP_MODEL_LIBRARIES}
19 HINTS ${PC_LIBESOAP_MODEL_LIBDIR} ${PC_LIBESOAP_MODEL_LIBRARY_DIRS} )
20
21set(ESOAP_MODEL_DEFINITIONS ${PC_LIBESOAP_MODEL_CFLAGS_OTHER})
22set(ESOAP_MODEL_LIBRARIES ${ESOAP_MODEL_LIBRARY})
23set(ESOAP_MODEL_INCLUDE_DIRS ${PC_LIBESOAP_MODEL_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set ESOAP_MODEL_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 ESOAP_MODEL_LIBRARIES ESOAP_MODEL_INCLUDE_DIRS)
30
31mark_as_advanced(ESOAP_MODEL_INCLUDE_DIRS ESOAP_MODEL_LIBRARY ESOAP_MODEL_LIBRARIES ESOAP_MODEL_DEFINITIONS)
32
diff --git a/cmakeconfig/EsoapModelCxxConfig.cmake.in b/cmakeconfig/EsoapModelCxxConfig.cmake.in
new file mode 100644
index 0000000000..4a91e04b73
--- /dev/null
+++ b/cmakeconfig/EsoapModelCxxConfig.cmake.in
@@ -0,0 +1,30 @@
1# - Try to find esoap_model
2# Once done this will define
3# ESOAP_MODEL_CXX_FOUND - System has esoap_model
4# ESOAP_MODEL_CXX_INCLUDE_DIRS - The esoap_model include directories
5# ESOAP_MODEL_CXX_LIBRARIES - The libraries needed to use esoap_model
6# ESOAP_MODEL_CXX_DEFINITIONS - Compiler switches required for using esoap_model
7
8set(MY_PKG esoap_model_cxx)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_ESOAP_MODEL_CXX ${_QUIET} ${MY_PKG})
16find_library(ESOAP_MODEL_CXX_LIBRARY
17 NAMES ${PC_ESOAP_MODEL_CXX_LIBRARIES}
18 HINTS ${PC_ESOAP_MODEL_CXX_LIBDIR} ${PC_ESOAP_MODEL_CXX_LIBRARY_DIRS} )
19
20set(ESOAP_MODEL_CXX_DEFINITIONS ${PC_ESOAP_MODEL_CXX_CFLAGS_OTHER})
21set(ESOAP_MODEL_CXX_LIBRARIES ${ESOAP_MODEL_CXX_LIBRARY})
22set(ESOAP_MODEL_CXX_INCLUDE_DIRS ${PC_ESOAP_MODEL_CXX_INCLUDE_DIRS})
23
24include(FindPackageHandleStandardArgs)
25# handle the QUIETLY and REQUIRED arguments and set ESOAP_MODEL_CXX_FOUND to TRUE
26# if all listed variables are TRUE
27find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
28 ESOAP_MODEL_CXX_LIBRARIES ESOAP_MODEL_CXX_INCLUDE_DIRS)
29
30mark_as_advanced(ESOAP_MODEL_CXX_INCLUDE_DIRS ESOAP_MODEL_CXX_LIBRARY ESOAP_MODEL_CXX_LIBRARIES ESOAP_MODEL_CXX_DEFINITIONS)
diff --git a/configure.ac b/configure.ac
index 3937baaa9e..f883701d1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4608,6 +4608,50 @@ EFL_LIB_END([Eflat_Xml_Model_Cxx])
4608#### End of Eflat_Xml_Model CXX 4608#### End of Eflat_Xml_Model CXX
4609 4609
4610 4610
4611
4612#### Esoap_Model
4613EFL_LIB_START([Esoap_Model])
4614
4615### Additional options to configure
4616
4617### Default values
4618
4619### Checks for programs
4620
4621### Checks for libraries
4622EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eo])
4623EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [efl])
4624EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [ecore])
4625EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eflat_xml_model])
4626
4627EFL_DEPEND_PKG([ESOAP_MODEL], [CURL], [libcurl >= 7.40])
4628
4629EFL_EVAL_PKGS([ESOAP_MODEL])
4630
4631### Checks for header files
4632
4633### Checks for types
4634
4635### Checks for structures
4636
4637### Checks for compiler characteristics
4638
4639### Checks for linker characteristics
4640
4641### Checks for library functions
4642
4643EFL_LIB_END([Esoap_Model])
4644#### End of Esoap_Model
4645
4646#### Esoap_Model CXX
4647EFL_LIB_START([Esoap_Model_Cxx])
4648
4649EFL_EVAL_PKGS([ESOAP_MODEL_CXX])
4650
4651EFL_LIB_END([Esoap_Model_Cxx])
4652#### End of Esoap_Model CXX
4653
4654
4611### Add Wayland server library if test is enabled 4655### Add Wayland server library if test is enabled
4612if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then 4656if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then
4613 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0]) 4657 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0])
@@ -4798,6 +4842,8 @@ pc/elocation.pc
4798pc/elua.pc 4842pc/elua.pc
4799pc/eflat_xml_model.pc 4843pc/eflat_xml_model.pc
4800pc/eflat_xml_model-cxx.pc 4844pc/eflat_xml_model-cxx.pc
4845pc/esoap_model.pc
4846pc/esoap_model-cxx.pc
4801dbus-services/org.enlightenment.Ethumb.service 4847dbus-services/org.enlightenment.Ethumb.service
4802systemd-services/ethumb.service 4848systemd-services/ethumb.service
4803$po_makefile_in 4849$po_makefile_in
@@ -4851,6 +4897,10 @@ cmakeconfig/EflatXmlModelConfig.cmake
4851cmakeconfig/EflatXmlModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4897cmakeconfig/EflatXmlModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4852cmakeconfig/EflatXmlModelCxxConfig.cmake 4898cmakeconfig/EflatXmlModelCxxConfig.cmake
4853cmakeconfig/EflatXmlModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4899cmakeconfig/EflatXmlModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4900cmakeconfig/EsoapModelConfig.cmake
4901cmakeconfig/EsoapModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4902cmakeconfig/EsoapModelCxxConfig.cmake
4903cmakeconfig/EsoapModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4854]) 4904])
4855 4905
4856AC_OUTPUT 4906AC_OUTPUT
@@ -4965,6 +5015,7 @@ echo "Ethumb..........: yes"
4965echo "Ethumb_Client...: yes" 5015echo "Ethumb_Client...: yes"
4966echo "Elua............: $have_elua" 5016echo "Elua............: $have_elua"
4967echo "Eflat_Xml_Model.: yes" 5017echo "Eflat_Xml_Model.: yes"
5018echo "Esoap_Model.....: yes"
4968if test "${build_tests}" = "none"; then 5019if test "${build_tests}" = "none"; then
4969echo "Tests...........: no" 5020echo "Tests...........: no"
4970elif test "${build_tests}" = "auto"; then 5021elif test "${build_tests}" = "auto"; then
diff --git a/pc/esoap_model-cxx.pc.in b/pc/esoap_model-cxx.pc.in
new file mode 100644
index 0000000000..17446ab0a9
--- /dev/null
+++ b/pc/esoap_model-cxx.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: Esoap-model C++
7Description: SOAP model for EFL
8Requires.private: @requirements_pc_esoap_model@ @requirements_pc_eo@
9Version: @VERSION@
10Libs: -L${libdir} -lesoap_model @requirements_public_libs_esoap_model@ @requirements_public_libs_eo@
11Libs.private: @requirements_libs_esoap_model@ @requirements_libs_eo@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/esoap_model-@VMAJ@ -I${includedir}/esoap_model-cxx-@VMAJ@
diff --git a/pc/esoap_model.pc.in b/pc/esoap_model.pc.in
new file mode 100644
index 0000000000..22813e9089
--- /dev/null
+++ b/pc/esoap_model.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: Esoap-model
7Description: SOAP model for EFL
8Requires.private: @requirements_pc_esoap_model@
9Version: @VERSION@
10Libs: -L${libdir} -lesoap_model @requirements_public_libs_esoap_model@
11Libs.private: @requirements_libs_esoap_model@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/esoap_model-@VMAJ@
diff --git a/src/Makefile.am b/src/Makefile.am
index 964dc531f0..cb0faae980 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,6 +61,7 @@ include Makefile_Emotion.am
61include Makefile_Ethumb.am 61include Makefile_Ethumb.am
62include Makefile_Ethumb_Client.am 62include Makefile_Ethumb_Client.am
63include Makefile_EflatXmlModel.am 63include Makefile_EflatXmlModel.am
64include Makefile_EsoapModel.am
64 65
65include Makefile_Eina_Cxx.am 66include Makefile_Eina_Cxx.am
66include Makefile_Ecore_Cxx.am 67include Makefile_Ecore_Cxx.am
@@ -73,6 +74,7 @@ include Makefile_Edje_Cxx.am
73include Makefile_Evas_Cxx.am 74include Makefile_Evas_Cxx.am
74include Makefile_Eio_Cxx.am 75include Makefile_Eio_Cxx.am
75include Makefile_EflatXmlModel_Cxx.am 76include Makefile_EflatXmlModel_Cxx.am
77include Makefile_EsoapModel_Cxx.am
76 78
77include Makefile_Elua.am 79include Makefile_Elua.am
78include Makefile_Elocation.am 80include Makefile_Elocation.am
diff --git a/src/Makefile_EsoapModel.am b/src/Makefile_EsoapModel.am
new file mode 100644
index 0000000000..85af9292f4
--- /dev/null
+++ b/src/Makefile_EsoapModel.am
@@ -0,0 +1,84 @@
1### Library
2
3esoap_model_eolian_files = \
4lib/esoap_model/esoap_model.eo
5
6esoap_model_eolian_c = $(esoap_model_eolian_files:%.eo=%.eo.c)
7esoap_model_eolian_h = $(esoap_model_eolian_files:%.eo=%.eo.h)
8
9BUILT_SOURCES += \
10 $(esoap_model_eolian_c) \
11 $(esoap_model_eolian_h)
12
13CLEANFILES += \
14 $(esoap_model_eolian_c) \
15 $(esoap_model_eolian_h)
16
17esoap_modeleolianfilesdir = $(datadir)/eolian/include/esoap_model-@VMAJ@
18esoap_modeleolianfiles_DATA = \
19 $(esoap_model_eolian_files)
20
21EXTRA_DIST += \
22 ${esoap_modeleolianfiles_DATA}
23
24lib_LTLIBRARIES += lib/esoap_model/libesoap_model.la
25
26installed_esoap_modelmainheadersdir = $(includedir)/esoap_model-@VMAJ@
27dist_installed_esoap_modelmainheaders_DATA = \
28lib/esoap_model/Esoap_Model.h
29
30nodist_installed_esoap_modelmainheaders_DATA = \
31 $(esoap_model_eolian_h)
32
33lib_esoap_model_libesoap_model_la_SOURCES = \
34lib/esoap_model/esoap_model_private.h \
35lib/esoap_model/esoap_model.c
36
37lib_esoap_model_libesoap_model_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ESOAP_MODEL_CFLAGS@ @EFL_CFLAGS@
38lib_esoap_model_libesoap_model_la_LIBADD = @ESOAP_MODEL_LIBS@ @EFL_LIBS@
39lib_esoap_model_libesoap_model_la_DEPENDENCIES = @ESOAP_MODEL_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
40lib_esoap_model_libesoap_model_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
41
42### Unit tests
43
44if EFL_ENABLE_TESTS
45
46check_PROGRAMS += tests/esoap_model/esoap_model_suite
47TESTS += tests/esoap_model/esoap_model_suite
48
49tests_esoap_model_esoap_model_suite_SOURCES = \
50tests/esoap_model/esoap_model_suite.c \
51tests/esoap_model/esoap_model_suite.h \
52tests/esoap_model/esoap_model_test_esoap_model.c \
53tests/esoap_model/esoap_model_test_esoap_model.h
54
55tests_esoap_model_esoap_model_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
56-DTESTS_SRC_DIR=\"$(abs_top_srcdir)/src/tests/esoap_model\" \
57-DTESTS_BUILD_DIR=\"$(abs_top_builddir)/src/tests/esoap_model\" \
58@CHECK_CFLAGS@ \
59@ESOAP_MODEL_CFLAGS@ @EFL_CFLAGS@
60
61tests_esoap_model_esoap_model_suite_LDADD = \
62@CHECK_LIBS@ \
63@USE_ESOAP_MODEL_LIBS@ \
64@USE_EFL_LIBS@
65
66tests_esoap_model_esoap_model_suite_DEPENDENCIES = \
67@USE_ESOAP_MODEL_INTERNAL_LIBS@
68
69endif
70
71EXTRA_DIST += $(ESOAP_MODEL_DATA_FILES)
72
73if HAVE_ELUA
74
75esoap_model_eolian_lua = $(esoap_model_eolian_files:%.eo=%.eo.lua)
76
77generated_esoap_model_lua_all = $(esoap_model_eolian_lua)
78
79CLEANFILES += $(generated_esoap_model_lua_all)
80
81installed_esoap_modelluadir = $(datadir)/elua/modules/esoap_model
82nodist_installed_esoap_modellua_DATA = $(generated_esoap_model_lua_all)
83
84endif
diff --git a/src/Makefile_EsoapModel_Cxx.am b/src/Makefile_EsoapModel_Cxx.am
new file mode 100644
index 0000000000..16c6749ced
--- /dev/null
+++ b/src/Makefile_EsoapModel_Cxx.am
@@ -0,0 +1,22 @@
1if HAVE_CXX11
2
3### Generated headers
4
5generated_esoap_model_cxx_bindings = $(esoap_model_eolian_files:%.eo=%.eo.hh)
6
7lib/esoap_model/Esoap_Model.hh: $(generated_esoap_model_cxx_bindings)
8 @echo @ECHO_E@ "#ifndef EFL_CXX_ESOAP_MODEL_HH\n#define EFL_CXX_ESOAP_MODEL_HH\n" > $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh
9 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh
10 @for i in $(generated_esoap_model_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh; done
11 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh
12
13generated_esoap_model_cxx_all = \
14 $(generated_esoap_model_cxx_bindings) \
15 lib/esoap_model/Esoap_Model.hh
16
17CLEANFILES += $(generated_esoap_model_cxx_all)
18
19installed_esoap_modelcxxmainheadersdir = $(includedir)/esoap_model-cxx-@VMAJ@/
20nodist_installed_esoap_modelcxxmainheaders_DATA = $(generated_esoap_model_cxx_all)
21
22endif
diff --git a/src/lib/esoap_model/Esoap_Model.h b/src/lib/esoap_model/Esoap_Model.h
new file mode 100644
index 0000000000..22be6a811b
--- /dev/null
+++ b/src/lib/esoap_model/Esoap_Model.h
@@ -0,0 +1,63 @@
1#ifndef ESOAP_MODEL_H
2#define ESOAP_MODEL_H
3
4#include <Ecore.h>
5#include <Efl.h>
6#include <Efl_Config.h>
7
8#ifdef EAPI
9# undef EAPI
10#endif
11
12#ifdef _WIN32
13# ifdef EFL_ESOAP_MODEL_BUILD
14# ifdef DLL_EXPORT
15# define EAPI __declspec(dllexport)
16# else
17# define EAPI
18# endif /* ! DLL_EXPORT */
19# else
20# define EAPI __declspec(dllimport)
21# endif /* ! EFL_ESOAP_MODEL_BUILD */
22#else
23# ifdef __GNUC__
24# if __GNUC__ >= 4
25# define EAPI __attribute__ ((visibility("default")))
26# else
27# define EAPI
28# endif
29# else
30# define EAPI
31# endif
32#endif /* ! _WIN32 */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/**
39 * @brief Initialize esoap_model.
40 *
41 * @return 1 or greater on success, 0 otherwise
42 */
43EAPI int esoap_model_init(void);
44
45/**
46 * @brief Shutdown esoap_model.
47 *
48 * @return 0 if esoap_model shuts down, greater than 0 otherwise.
49 */
50EAPI int esoap_model_shutdown(void);
51
52#ifdef EFL_EO_API_SUPPORT
53# include <esoap_model.eo.h>
54#endif
55
56#ifdef __cplusplus
57}
58#endif
59
60#undef EAPI
61#define EAPI
62
63#endif
diff --git a/src/lib/esoap_model/esoap_model.c b/src/lib/esoap_model/esoap_model.c
new file mode 100644
index 0000000000..a5b1e49b17
--- /dev/null
+++ b/src/lib/esoap_model/esoap_model.c
@@ -0,0 +1,470 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "esoap_model_private.h"
6
7#include <curl/curl.h>
8
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdlib.h>
12
13#define MY_CLASS ESOAP_MODEL_CLASS
14#define MY_CLASS_NAME "Esoap_Model"
15
16typedef struct
17{
18 Esoap_Model_Data *pd;
19 Eina_Strbuf *response;
20 struct curl_slist *header;
21 char *soap_action;
22 CURL *curl;
23 Ecore_Thread *thread;
24} Esoap_Model_Perform_Data;
25
26static void _properties_load(Esoap_Model_Data *);
27static void _children_load(Esoap_Model_Data *);
28static bool _init(Esoap_Model_Data *);
29static void _clear(Esoap_Model_Data *);
30static void _perform(Esoap_Model_Data *, const char *);
31static void _perform_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
32static void _perform_end_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
33static void _perform_cancel_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
34static Eina_Bool _properties_changed_cb(void *, Eo *, const Eo_Event_Description *, void *);
35static size_t _write_data_cb(void *, size_t, size_t, void *);
36static void _perform_data_free(Esoap_Model_Perform_Data *data);
37
38static int _esoap_model_init_count = 0;
39int _esoap_model_log_dom = -1;
40
41EAPI int
42esoap_model_init(void)
43{
44 if (_esoap_model_init_count++ > 0)
45 return _esoap_model_init_count;
46
47 if (!eina_init())
48 {
49 fputs("Esoap_Model: Unable to initialize eina\n", stderr);
50 return 0;
51 }
52
53 _esoap_model_log_dom = eina_log_domain_register("Esoap_Model", EINA_COLOR_CYAN);
54 if (_esoap_model_log_dom < 0)
55 {
56 EINA_LOG_ERR("Unable to create an 'Esoap_Model' log domain");
57 _esoap_model_log_dom = -1;
58 eina_shutdown();
59 return 0;
60 }
61
62 if (!ecore_init())
63 {
64 ERR("Unable to initialize ecore");
65 goto on_error;
66 }
67
68 if (!eflat_xml_model_init())
69 {
70 ERR("Unable to initialize eflat_xml_model");
71 goto on_error;
72 }
73
74 CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
75 if (CURLE_OK != code)
76 {
77 ERR("Unable to initialize curl");
78 goto on_error;
79 }
80
81 return _esoap_model_init_count;
82
83on_error:
84 eina_log_domain_unregister(_esoap_model_log_dom);
85 _esoap_model_log_dom = -1;
86 eina_shutdown();
87 return 0;
88}
89
90EAPI int
91esoap_model_shutdown(void)
92{
93 if (_esoap_model_init_count <= 0)
94 {
95 ERR("Init count not greater than 0 in shutdown.");
96 _esoap_model_init_count = 0;
97 return 0;
98 }
99
100 if (--_esoap_model_init_count)
101 return _esoap_model_init_count;
102
103 curl_global_cleanup();
104 eflat_xml_model_shutdown();
105 ecore_shutdown();
106 eina_log_domain_unregister(_esoap_model_log_dom);
107 _esoap_model_log_dom = -1;
108 eina_shutdown();
109 return 0;
110}
111
112static Eo_Base *
113_esoap_model_eo_base_constructor(Eo *obj, Esoap_Model_Data *pd)
114{
115 DBG("(%p)", obj);
116
117 pd->obj = obj;
118 pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
119 pd->children_list = NULL;
120 pd->xml = NULL;
121
122 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
123}
124
125static void
126_esoap_model_constructor(Eo *obj EINA_UNUSED,
127 Esoap_Model_Data *pd EINA_UNUSED,
128 const char *url,
129 const char *action)
130{
131 DBG("(%p)", obj);
132 EINA_SAFETY_ON_NULL_RETURN(url);
133 EINA_SAFETY_ON_NULL_RETURN(action);
134
135 pd->url = strdup(url);
136 pd->action = strdup(action);
137}
138
139static void
140_esoap_model_eo_base_destructor(Eo *obj, Esoap_Model_Data *pd)
141{
142 DBG("(%p)", obj);
143
144 _clear(pd);
145 free(pd->url);
146 free(pd->action);
147
148 eo_do_super(obj, MY_CLASS, eo_destructor());
149}
150
151static Efl_Model_Load_Status
152_esoap_model_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
153 Esoap_Model_Data *pd,
154 Eina_Array * const* properties_array)
155{
156 DBG("(%p)", obj);
157 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
158 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
159
160 eo_do(pd->xml, efl_model_properties_get(properties_array));
161 return pd->load.status;
162}
163
164static void
165_esoap_model_efl_model_base_properties_load(Eo *obj, Esoap_Model_Data *pd)
166{
167 DBG("(%p)", obj);
168
169 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
170 return;
171
172 if (!_init(pd))
173 return;
174
175 _properties_load(pd);
176}
177
178static void
179_properties_load(Esoap_Model_Data *pd)
180{
181 DBG("(%p)", pd->obj);
182 efl_model_load_set(pd->obj,
183 &pd->load,
184 EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES);
185 eo_do(pd->xml, efl_model_properties_load());
186 efl_model_load_set(pd->obj,
187 &pd->load,
188 EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
189}
190
191static Efl_Model_Load_Status
192_esoap_model_efl_model_base_property_set(Eo *obj EINA_UNUSED,
193 Esoap_Model_Data *pd,
194 const char *property,
195 const Eina_Value *value)
196{
197 Efl_Model_Load_Status status;
198 eo_do(pd->xml, status = efl_model_property_set(property, value));
199 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
200 return pd->load.status;
201}
202
203static Efl_Model_Load_Status
204_esoap_model_efl_model_base_property_get(Eo *obj EINA_UNUSED,
205 Esoap_Model_Data *pd,
206 const char *property,
207 const Eina_Value **value)
208{
209 Efl_Model_Load_Status status;
210 eo_do(pd->xml, status = efl_model_property_get(property, value));
211 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
212 return pd->load.status;
213}
214
215static void
216_esoap_model_efl_model_base_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
217{
218 DBG("(%p)", obj);
219
220 if ((pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED) == EFL_MODEL_LOAD_STATUS_LOADED)
221 return;
222
223 if (!_init(pd))
224 return;
225
226 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
227 _properties_load(pd);
228
229 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
230 _children_load(pd);
231}
232
233static Efl_Model_Load_Status
234_esoap_model_efl_model_base_load_status_get(Eo *obj EINA_UNUSED,
235 Esoap_Model_Data *pd)
236{
237 DBG("(%p)", obj);
238 return pd->load.status;
239}
240
241static void
242_esoap_model_efl_model_base_unload(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
243{
244 DBG("(%p)", obj);
245
246 _clear(pd);
247
248 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
249}
250
251Eo *
252_esoap_model_efl_model_base_child_add(Eo *obj, Esoap_Model_Data *pd EINA_UNUSED)
253{
254 DBG("(%p)", obj);
255 return NULL;
256}
257
258static Efl_Model_Load_Status
259_esoap_model_efl_model_base_child_del(Eo *obj,
260 Esoap_Model_Data *pd EINA_UNUSED,
261 Eo *child EINA_UNUSED)
262{
263 DBG("(%p)", obj);
264 return EFL_MODEL_LOAD_STATUS_ERROR;
265}
266
267static Efl_Model_Load_Status
268_esoap_model_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
269 Esoap_Model_Data *pd,
270 unsigned start EINA_UNUSED,
271 unsigned count EINA_UNUSED,
272 Eina_Accessor **children_accessor)
273{
274 DBG("(%p)", obj);
275
276 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
277 {
278 WRN("(%p): Children not loaded", obj);
279 *children_accessor = NULL;
280 return pd->load.status;
281 }
282
283 *children_accessor = efl_model_list_slice(pd->children_list, start, count);
284 return pd->load.status;
285}
286
287static Efl_Model_Load_Status
288_esoap_model_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
289 Esoap_Model_Data *pd,
290 unsigned *children_count)
291{
292 DBG("(%p)", obj);
293 *children_count = eina_list_count(pd->children_list);
294 return pd->load.status;
295}
296
297static void
298_esoap_model_efl_model_base_children_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
299{
300 DBG("(%p)", obj);
301
302 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
303 return;
304
305 if (!_init(pd))
306 return;
307
308 _children_load(pd);
309}
310
311static void
312_children_load(Esoap_Model_Data *pd)
313{
314 DBG("(%p)", pd->obj);
315
316 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
317
318 const Eina_Value *xml_value;
319 Efl_Model_Load_Status status;
320 eo_do(pd->xml, status = efl_model_property_get("/", &xml_value));
321 EINA_SAFETY_ON_FALSE_RETURN(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
322
323 const char *xml = NULL;
324 eina_value_get(xml_value, &xml);
325 _perform(pd, xml);
326}
327
328static Eina_Bool
329_properties_changed_cb(void *data,
330 Eo *child EINA_UNUSED,
331 const Eo_Event_Description *desc EINA_UNUSED,
332 void *event_info)
333{
334 eo_do(data, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, event_info));
335 return EO_CALLBACK_CONTINUE;
336}
337
338static bool
339_init(Esoap_Model_Data *pd)
340{
341 if (pd->xml)
342 return true;
343
344 pd->xml = eo_add(EFLAT_XML_MODEL_CLASS,
345 NULL,
346 eflat_xml_model_constructor(NULL));
347
348 eo_do(pd->xml, eo_event_callback_add(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED,
349 _properties_changed_cb,
350 pd->obj));
351 return true;
352}
353
354static void
355_clear(Esoap_Model_Data *pd)
356{
357 EINA_SAFETY_ON_NULL_RETURN(pd);
358
359 if (pd->xml)
360 {
361 eo_unref(pd->xml);
362 pd->xml = NULL;
363 }
364
365 Eo *child;
366 EINA_LIST_FREE(pd->children_list, child)
367 eo_del(child);
368}
369
370static size_t
371_write_data_cb(void *ptr, size_t size, size_t nmeb, void *data)
372{
373 Eina_Strbuf *buf = (Eina_Strbuf *)data;
374 Eina_Bool ret = eina_strbuf_append_length(buf, ptr, size * nmeb);
375 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, 0);
376 return size * nmeb;
377}
378
379static void
380_perform(Esoap_Model_Data *pd, const char *xml)
381{
382 DBG("(%p)", pd->obj);
383 Esoap_Model_Perform_Data *data = calloc(1, sizeof(Esoap_Model_Perform_Data));
384 data->pd = pd;
385 data->response = eina_strbuf_new();
386
387 const char *SOAP_ACTION = "SOAPAction:";
388 const size_t soap_action_lenght = strlen(SOAP_ACTION) + strlen(pd->action) + 1;
389 data->soap_action = malloc(soap_action_lenght);
390 snprintf(data->soap_action, soap_action_lenght, "%s%s", SOAP_ACTION, pd->action);
391
392 data->header = curl_slist_append(data->header, "Content-Type:application/soap+xml");
393 data->header = curl_slist_append(data->header, data->soap_action);
394 data->header = curl_slist_append(data->header, "Transfer-Encoding: chunked");
395 data->header = curl_slist_append(data->header, "Expect:");
396
397 data->curl = curl_easy_init();
398 EINA_SAFETY_ON_NULL_RETURN(data->curl);
399
400 curl_easy_setopt(data->curl, CURLOPT_URL, pd->url);
401 curl_easy_setopt(data->curl, CURLOPT_POST, 1L);
402 curl_easy_setopt(data->curl, CURLOPT_WRITEFUNCTION, _write_data_cb);
403 curl_easy_setopt(data->curl, CURLOPT_WRITEDATA, data->response);
404 curl_easy_setopt(data->curl, CURLOPT_HTTPHEADER, data->header);
405 curl_easy_setopt(data->curl, CURLOPT_COPYPOSTFIELDS, xml);
406 curl_easy_setopt(data->curl, CURLOPT_VERBOSE, 1L);
407
408 data->thread = ecore_thread_run((Ecore_Thread_Cb)_perform_cb,
409 (Ecore_Thread_Cb)_perform_end_cb,
410 (Ecore_Thread_Cb)_perform_cancel_cb, data);
411 EINA_SAFETY_ON_NULL_RETURN(data->thread);
412}
413
414static void
415_perform_cb(Esoap_Model_Perform_Data *data, Ecore_Thread *thread)
416{
417 DBG("(%p)", data->pd->obj);
418 CURLcode res = curl_easy_perform(data->curl);
419 if (CURLE_OK != res)
420 {
421 ERR("Could not perform: %d", res);
422 ecore_thread_cancel(thread);
423 }
424}
425
426static void
427_perform_end_cb(Esoap_Model_Perform_Data *data,
428 Ecore_Thread *thread EINA_UNUSED)
429{
430 DBG("(%p)", data->pd->obj);
431 const char *response = eina_strbuf_string_get(data->response);
432
433 DBG("(%p) response: %s", data->pd->obj, response);
434
435 Eo *child = eo_add(EFLAT_XML_MODEL_CLASS,
436 NULL,
437 eflat_xml_model_constructor(response));
438 data->pd->children_list = eina_list_append(data->pd->children_list, child);
439
440 unsigned int count = eina_list_count(data->pd->children_list);
441 Efl_Model_Children_Event evt = {.child = child, .index = count};
442 eo_do(data->pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILD_ADDED, &evt),
443 eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
444
445 efl_model_load_set(data->pd->obj, &data->pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
446
447 _perform_data_free(data);
448}
449
450static void
451_perform_cancel_cb(Esoap_Model_Perform_Data *data,
452 Ecore_Thread *thread EINA_UNUSED)
453{
454 DBG("(%p)", data->pd->obj);
455 efl_model_error_notify(data->pd->obj);
456 _perform_data_free(data);
457}
458
459static void
460_perform_data_free(Esoap_Model_Perform_Data *data)
461{
462 DBG("(%p)", data->pd->obj);
463 curl_easy_cleanup(data->curl);
464 eina_strbuf_free(data->response);
465 curl_slist_free_all(data->header);
466 free(data->soap_action);
467 free(data);
468}
469
470#include "Esoap_Model.eo.c"
diff --git a/src/lib/esoap_model/esoap_model.eo b/src/lib/esoap_model/esoap_model.eo
new file mode 100644
index 0000000000..971e8fc4ce
--- /dev/null
+++ b/src/lib/esoap_model/esoap_model.eo
@@ -0,0 +1,36 @@
1class Esoap.Model (Eo.Base, Efl.Model.Base) {
2 legacy_prefix: null;
3 methods {
4 constructor {
5 [[
6 Custom Soap_Model constructor.
7 @.constructor
8
9 @since 1.13
10 ]]
11 params {
12 url: const(char)*; [[The webservice URL]]
13 action: const(char)*; [[The soap action]]
14 }
15 }
16 }
17 implements {
18 Eo.Base.constructor;
19 Eo.Base.destructor;
20 Efl.Model.Base.properties.get;
21 Efl.Model.Base.properties_load;
22 Efl.Model.Base.property.set;
23 Efl.Model.Base.property.get;
24 Efl.Model.Base.load;
25 Efl.Model.Base.load_status.get;
26 Efl.Model.Base.unload;
27 Efl.Model.Base.child_add;
28 Efl.Model.Base.child_del;
29 Efl.Model.Base.children_slice.get;
30 Efl.Model.Base.children_count.get;
31 Efl.Model.Base.children_load;
32 }
33 constructors {
34 .constructor;
35 }
36}
diff --git a/src/lib/esoap_model/esoap_model_private.h b/src/lib/esoap_model/esoap_model_private.h
new file mode 100644
index 0000000000..98c6c65ebb
--- /dev/null
+++ b/src/lib/esoap_model/esoap_model_private.h
@@ -0,0 +1,35 @@
1#ifndef _ESOAP_MODEL_PRIVATE_H
2#define _ESOAP_MODEL_PRIVATE_H
3
4#include "Esoap_Model.h"
5
6#include <Eflat_Xml_Model.h>
7
8#include <stdbool.h>
9
10/* logging support */
11extern int _esoap_model_log_dom;
12
13#define CRI(...) EINA_LOG_DOM_CRIT(_esoap_model_log_dom, __VA_ARGS__)
14#define ERR(...) EINA_LOG_DOM_ERR(_esoap_model_log_dom, __VA_ARGS__)
15#define WRN(...) EINA_LOG_DOM_WARN(_esoap_model_log_dom, __VA_ARGS__)
16#define INF(...) EINA_LOG_DOM_INFO(_esoap_model_log_dom, __VA_ARGS__)
17#define DBG(...) EINA_LOG_DOM_DBG(_esoap_model_log_dom, __VA_ARGS__)
18
19typedef struct _Esoap_Model_Data Esoap_Model_Data;
20
21/**
22 * esoap_model
23 */
24struct _Esoap_Model_Data
25{
26 Eo *obj;
27 Efl_Model_Load load;
28 Eina_List *children_list;
29 Eflat_Xml_Model *xml;
30 char *url;
31 char *action;
32};
33
34#endif
35
diff --git a/src/tests/esoap_model/esoap_model_suite.c b/src/tests/esoap_model/esoap_model_suite.c
new file mode 100644
index 0000000000..5810b6a781
--- /dev/null
+++ b/src/tests/esoap_model/esoap_model_suite.c
@@ -0,0 +1,119 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "esoap_model_suite.h"
6
7#include <Eina.h>
8
9#include <stdbool.h>
10#include <stdio.h>
11#include <stdlib.h>
12
13int _test_esoap_model_log_dom = -1;
14
15typedef struct
16{
17 const char *test_case;
18 void (*build)(TCase *tc);
19} Esoap_Model_Test_Case;
20
21static const Esoap_Model_Test_Case etc[] = {
22 { "Esoap_Model", esoap_model_test_esoap_model },
23 { NULL, NULL }
24};
25
26static void
27_list_tests(void)
28{
29 const Esoap_Model_Test_Case *it = etc;
30 fputs("Available Test Cases:\n", stderr);
31 for (; it->test_case; it++)
32 fprintf(stderr, "\t%s\n", it->test_case);
33}
34
35static bool
36_use_test(int argc, const char **argv, const char *test_case)
37{
38 if (argc < 1)
39 return true;
40
41 for (; argc > 0; argc--, argv++)
42 if (strcmp(test_case, *argv) == 0)
43 return true;
44 return false;
45}
46
47static Suite *
48_esoap_suite_build(int argc, const char **argv)
49{
50 Suite *s = suite_create("Esoap");
51
52 for (int i = 0; etc[i].test_case; ++i)
53 {
54 if (!_use_test(argc, argv, etc[i].test_case)) continue;
55 TCase *tc = tcase_create(etc[i].test_case);
56
57 etc[i].build(tc);
58
59 suite_add_tcase(s, tc);
60 //tcase_set_timeout(tc, 0);
61 }
62
63 return s;
64}
65
66static void
67_init_logging(void)
68{
69 _test_esoap_model_log_dom = eina_log_domain_register("test_esoap_model", EINA_COLOR_LIGHTBLUE);
70 if (_test_esoap_model_log_dom < 0)
71 ck_abort_msg("Could not register log domain: test_esoap_model");
72
73 //eina_log_domain_level_set("esskyuehl", EINA_LOG_LEVEL_DBG);
74 //eina_log_domain_level_set("esoap_model", EINA_LOG_LEVEL_DBG);
75 eina_log_domain_level_set("test_esoap_model", EINA_LOG_LEVEL_DBG);
76}
77
78static void
79_shutdown_logging(void)
80{
81 eina_log_domain_unregister(_test_esoap_model_log_dom);
82 _test_esoap_model_log_dom = -1;
83}
84
85int
86main(int argc, char **argv)
87{
88 for (int i = 1; i < argc; ++i)
89 {
90 if ((strcmp(argv[i], "-h") == 0) ||
91 (strcmp(argv[i], "--help") == 0))
92 {
93 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]);
94 _list_tests();
95 return 0;
96 }
97 else if ((strcmp(argv[i], "-l") == 0) ||
98 (strcmp(argv[i], "--list") == 0))
99 {
100 _list_tests();
101 return 0;
102 }
103 }
104
105 _init_logging();
106
107 Suite *s = _esoap_suite_build(argc - 1, (const char **)argv + 1);
108 SRunner *sr = srunner_create(s);
109
110 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
111
112 srunner_run_all(sr, CK_ENV);
113 int failed_count = srunner_ntests_failed(sr);
114 srunner_free(sr);
115
116 _shutdown_logging();
117
118 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
119}
diff --git a/src/tests/esoap_model/esoap_model_suite.h b/src/tests/esoap_model/esoap_model_suite.h
new file mode 100644
index 0000000000..e1bcaa2902
--- /dev/null
+++ b/src/tests/esoap_model/esoap_model_suite.h
@@ -0,0 +1,16 @@
1#ifndef _ESOAP_MODEL_SUITE_H
2#define _ESOAP_MODEL_SUITE_H
3
4#include <check.h>
5
6extern int _test_esoap_model_log_dom;
7
8#define CRI(...) EINA_LOG_DOM_CRIT(_test_esoap_model_log_dom, __VA_ARGS__)
9#define ERR(...) EINA_LOG_DOM_ERR(_test_esoap_model_log_dom, __VA_ARGS__)
10#define WRN(...) EINA_LOG_DOM_WARN(_test_esoap_model_log_dom, __VA_ARGS__)
11#define INF(...) EINA_LOG_DOM_INFO(_test_esoap_model_log_dom, __VA_ARGS__)
12#define DBG(...) EINA_LOG_DOM_DBG(_test_esoap_model_log_dom, __VA_ARGS__)
13
14void esoap_model_test_esoap_model(TCase *tc);
15
16#endif
diff --git a/src/tests/esoap_model/esoap_model_test_esoap_model.c b/src/tests/esoap_model/esoap_model_test_esoap_model.c
new file mode 100644
index 0000000000..2a7ed543ca
--- /dev/null
+++ b/src/tests/esoap_model/esoap_model_test_esoap_model.c
@@ -0,0 +1,238 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "esoap_model_test_esoap_model.h"
6#include "esoap_model_suite.h"
7
8#include <Ecore.h>
9#include <Eina.h>
10#include <Esoap_Model.h>
11
12#include <stdbool.h>
13
14static void
15_setup(void)
16{
17 int ret = esoap_model_init();
18 ck_assert_int_ge(ret, 1);
19}
20
21static void
22_teardown(void)
23{
24 int ret = esoap_model_shutdown();
25 ck_assert_int_eq(ret, 0);
26}
27
28static Eina_Bool
29_eo_event_load_status_cb(void *data,
30 Eo *obj EINA_UNUSED,
31 const Eo_Event_Description *desc EINA_UNUSED,
32 void *event_info EINA_UNUSED)
33{
34 Efl_Model_Load_Status expected_status = *((Efl_Model_Load_Status*)data);
35 Efl_Model_Load load = *((Efl_Model_Load*)event_info);
36 if ((load.status & expected_status) != expected_status)
37 return EINA_TRUE;
38
39 ecore_main_loop_quit();
40 return EINA_FALSE;
41}
42
43static void
44_wait_until_load_status(Efl_Model_Base *model, Efl_Model_Load_Status expected_status)
45{
46 Efl_Model_Load_Status actual_status;
47 eo_do(model, actual_status = efl_model_load_status_get());
48 if ((expected_status & actual_status) == expected_status) return;
49
50 eo_do(model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
51 ecore_main_loop_begin();
52 eo_do(model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
53}
54
55static void
56_check_value_type_cannot_have_children(Efl_Model_Base *model)
57{
58 Efl_Model_Base *child = eo_do_ret(model, child, efl_model_child_add());
59 ck_assert_ptr_eq(NULL, child);
60}
61
62static void
63_check_model_children_count_eq(Efl_Model_Base *model, unsigned int expected_children_count)
64{
65 unsigned int actual_children_count = 0;
66 eo_do(model, efl_model_children_count_get(&actual_children_count));
67 ck_assert_int_eq(expected_children_count, actual_children_count);
68}
69
70static void
71_check_model_property_int_eq(Efl_Model_Base *model, const char *property, int64_t expected_value)
72{
73 const Eina_Value *value;
74 Efl_Model_Load_Status status;
75 eo_do(model, status = efl_model_property_get(property, &value));
76 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
77 ck_assert_ptr_ne(NULL, value);
78
79 const Eina_Value_Type *property_type = eina_value_type_get(value);
80 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type);
81
82 int64_t actual_value = 0;
83 eina_value_get(value, &actual_value);
84 ck_assert_int_eq(expected_value, actual_value);
85}
86
87static void
88_check_model_property_str_eq(Efl_Model_Base *model, const char *property, const char *expected_value)
89{
90 const Eina_Value *value;
91 Efl_Model_Load_Status status;
92 eo_do(model, status = efl_model_property_get(property, &value));
93 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
94 ck_assert_ptr_ne(NULL, value);
95
96 const Eina_Value_Type *property_type = eina_value_type_get(value);
97 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
98
99 const char *actual_value = NULL;
100 eina_value_get(value, &actual_value);
101 ck_assert_str_eq(expected_value, actual_value);
102}
103
104static Efl_Model_Base *
105_efl_model_nth_child_get(Efl_Model_Base *model, unsigned int n)
106{
107 Eina_Accessor *accessor;
108 Efl_Model_Load_Status status;
109 eo_do(model, status = efl_model_children_slice_get(n, 1, &accessor));
110 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
111 ck_assert_ptr_ne(NULL, accessor);
112 Efl_Model_Base *child = NULL;
113 Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
114 eina_accessor_free(accessor);
115 ck_assert(ret);
116 ck_assert_ptr_ne(NULL, child);
117 return child;
118}
119
120static void
121_check_model_load(Efl_Model_Base *model)
122{
123 eo_do(model, efl_model_load());
124 _wait_until_load_status(model, EFL_MODEL_LOAD_STATUS_LOADED);
125}
126
127static void
128_check_model_properties(Efl_Model_Base *model, const char *expected_properties[])
129{
130 Eina_Array *properties = NULL;
131 Efl_Model_Load_Status status;
132 eo_do(model, status = efl_model_properties_get(&properties));
133 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
134 ck_assert_ptr_ne(NULL, properties);
135
136 unsigned int actual_properties_count = eina_array_count(properties);
137
138 unsigned int expected_properties_count = 0;
139 const char *expected_property = NULL;
140 while ((expected_property = *expected_properties++))
141 {
142 const char *actual_property = eina_array_data_get(properties,
143 expected_properties_count);
144 ck_assert_str_eq(expected_property, actual_property);
145 ++expected_properties_count;
146 ck_assert_int_le(expected_properties_count, actual_properties_count);
147 }
148
149 ck_assert_int_eq(expected_properties_count, actual_properties_count);
150}
151
152static void
153_check_properties_count_eq(Efl_Model_Base *model, unsigned int expected_properties_count)
154{
155 Eina_Array *properties = NULL;
156 Efl_Model_Load_Status status;
157 eo_do(model, status = efl_model_properties_get(&properties));
158 ck_assert_int_ne(EFL_MODEL_LOAD_STATUS_ERROR, status);
159 if (!expected_properties_count && !properties)
160 return;
161
162 ck_assert_ptr_ne(NULL, properties);
163
164 unsigned int actual_properties_count = eina_array_count(properties);
165 ck_assert_int_eq(expected_properties_count, actual_properties_count);
166}
167
168static Esoap_Model *
169_create_esoap_model()
170{
171 Efl_Model_Base *esoap = eo_add(ESOAP_MODEL_CLASS, NULL,
172 esoap_model_constructor("http://127.0.0.1:9090/axis2/services/echo",
173 "http://ws.apache.org/axis2/c/samples/echoString"));
174 ck_assert_ptr_ne(NULL, esoap);
175 return esoap;
176}
177
178START_TEST(smoke)
179{
180 Efl_Model_Base *esoap = _create_esoap_model();
181 eo_unref(esoap);
182}
183END_TEST
184
185static void
186_check_string_property_set(Efl_Model_Base *model, const char *property, const char *v)
187{
188 Eina_Value value;
189 eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
190 eina_value_set(&value, v);
191 Efl_Model_Load_Status status;
192 eo_do(model, status = efl_model_property_set(property, &value));
193 eina_value_flush(&value);
194 ck_assert(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
195}
196
197START_TEST(load_children)
198{
199 Efl_Model_Base *esoap = _create_esoap_model();
200
201 eo_do(esoap, efl_model_properties_load());
202 _wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
203
204 _check_string_property_set(esoap, "esoap:Envelope@xmlns:esoap", "http://www.w3.org/2003/05/esoap-envelope");
205 _check_string_property_set(esoap, "esoap:Envelope@esoap:encodingStyle", "http://www.w3.org/2001/12/esoap-encoding");
206 _check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/services/echo");
207 _check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString/ns1:text", "Hello World!");
208
209 // make the call loading the children
210 eo_do(esoap, efl_model_children_load());
211 _wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
212
213 _check_model_children_count_eq(esoap, 1);
214
215 Efl_Model_Base *child = _efl_model_nth_child_get(esoap, 1);
216 _check_model_load(child);
217
218 _check_model_properties(child, (const char*[]){
219 "esoapenv:Envelope@xmlns:esoapenv",
220 "esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1",
221 "esoapenv:Envelope/esoapenv:Body/ns1:echoString/text",
222 NULL});
223
224 _check_model_property_str_eq(child, "esoapenv:Envelope@xmlns:esoapenv", "http://www.w3.org/2003/05/esoap-envelope");
225 _check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/c/samples");
226 _check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString/text", "Hello World!");
227
228 eo_unref(esoap);
229}
230END_TEST
231
232void
233esoap_model_test_esoap_model(TCase *tc)
234{
235 tcase_add_checked_fixture(tc, _setup, _teardown);
236 tcase_add_test(tc, smoke);
237 tcase_add_test(tc, load_children);
238}
diff --git a/src/tests/esoap_model/esoap_model_test_esoap_model.h b/src/tests/esoap_model/esoap_model_test_esoap_model.h
new file mode 100644
index 0000000000..e1d1396c06
--- /dev/null
+++ b/src/tests/esoap_model/esoap_model_test_esoap_model.h
@@ -0,0 +1,6 @@
1#ifndef _ESOAP_MODEL_TEST_ESOAP_MODEL_H
2#define _ESOAP_MODEL_TEST_ESOAP_MODEL_H
3
4#include <Esoap_Model.h>
5
6#endif