summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-07-31 15:25:18 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-09-23 13:45:47 -0700
commit6732e02838a73735ca1e04bedb2e7a59b561a81b (patch)
treedc91624085008ef937d45df322215075122d78e0
parent4e5a7227da7179a8a798967d0b8a9fc4ed61414f (diff)
esoap_model: Soap Model implementation
-rw-r--r--Makefile.am16
-rw-r--r--cmakeconfig/EsoapModelConfig.cmake.in32
-rw-r--r--cmakeconfig/EsoapModelCxxConfig.cmake.in30
-rw-r--r--configure.ac49
-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.c498
-rw-r--r--src/lib/esoap_model/esoap_model.eo48
-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.c270
-rw-r--r--src/tests/esoap_model/esoap_model_test_esoap_model.h6
17 files changed, 1312 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index f2fcd8119a..bbbaac39a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -153,7 +153,8 @@ pc/emotion.pc \
153pc/ethumb.pc \ 153pc/ethumb.pc \
154pc/ethumb_client.pc \ 154pc/ethumb_client.pc \
155pc/elocation.pc \ 155pc/elocation.pc \
156pc/eflat_xml_model.pc 156pc/eflat_xml_model.pc \
157pc/esoap_model.pc
157 158
158if HAVE_CXX11 159if HAVE_CXX11
159pkgconfig_DATA += \ 160pkgconfig_DATA += \
@@ -166,7 +167,8 @@ pc/edje-cxx.pc \
166pc/eet-cxx.pc \ 167pc/eet-cxx.pc \
167pc/eo-cxx.pc \ 168pc/eo-cxx.pc \
168pc/eio-cxx.pc \ 169pc/eio-cxx.pc \
169pc/eflat_xml_model-cxx.pc 170pc/eflat_xml_model-cxx.pc \
171pc/esoap_model-cxx.pc
170endif 172endif
171 173
172if HAVE_ELUA 174if HAVE_ELUA
@@ -395,6 +397,16 @@ eflat_xml_model_cmakeconfig_DATA = \
395cmakeconfig/EflatXmlModelConfig.cmake \ 397cmakeconfig/EflatXmlModelConfig.cmake \
396cmakeconfig/EflatXmlModelConfigVersion.cmake 398cmakeconfig/EflatXmlModelConfigVersion.cmake
397 399
400esoap_model_cxx_cmakeconfigdir = $(libdir)/cmake/EsoapModelCxx/
401esoap_model_cxx_cmakeconfig_DATA = \
402cmakeconfig/EsoapModelCxxConfig.cmake \
403cmakeconfig/EsoapModelCxxConfigVersion.cmake
404
405esoap_model_cmakeconfigdir = $(libdir)/cmake/EsoapModel/
406esoap_model_cmakeconfig_DATA = \
407cmakeconfig/EsoapModelConfig.cmake \
408cmakeconfig/EsoapModelConfigVersion.cmake
409
398# D-Bus services: 410# D-Bus services:
399 411
400servicedir = @dbusservicedir@ 412servicedir = @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 5951df9612..54a76f4b0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4624,6 +4624,48 @@ EFL_EVAL_PKGS([EFLAT_XML_MODEL_CXX])
4624EFL_LIB_END([Eflat_Xml_Model_Cxx]) 4624EFL_LIB_END([Eflat_Xml_Model_Cxx])
4625#### End of Eflat_Xml_Model CXX 4625#### End of Eflat_Xml_Model CXX
4626 4626
4627#### Esoap_Model
4628EFL_LIB_START([Esoap_Model])
4629
4630### Additional options to configure
4631
4632### Default values
4633
4634### Checks for programs
4635
4636### Checks for libraries
4637EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eo])
4638EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [efl])
4639EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [ecore])
4640EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eflat_xml_model])
4641
4642EFL_DEPEND_PKG([ESOAP_MODEL], [CURL], [libcurl >= 7.40])
4643
4644EFL_EVAL_PKGS([ESOAP_MODEL])
4645
4646### Checks for header files
4647
4648### Checks for types
4649
4650### Checks for structures
4651
4652### Checks for compiler characteristics
4653
4654### Checks for linker characteristics
4655
4656### Checks for library functions
4657
4658EFL_LIB_END([Esoap_Model])
4659#### End of Esoap_Model
4660
4661#### Esoap_Model CXX
4662EFL_LIB_START([Esoap_Model_Cxx])
4663
4664EFL_EVAL_PKGS([ESOAP_MODEL_CXX])
4665
4666EFL_LIB_END([Esoap_Model_Cxx])
4667#### End of Esoap_Model CXX
4668
4627### Add Wayland server library if test is enabled 4669### Add Wayland server library if test is enabled
4628if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then 4670if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then
4629 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0]) 4671 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0])
@@ -4816,6 +4858,8 @@ pc/ejson.pc
4816pc/ejson-cxx.pc 4858pc/ejson-cxx.pc
4817pc/eflat_xml_model.pc 4859pc/eflat_xml_model.pc
4818pc/eflat_xml_model-cxx.pc 4860pc/eflat_xml_model-cxx.pc
4861pc/esoap_model.pc
4862pc/esoap_model-cxx.pc
4819dbus-services/org.enlightenment.Ethumb.service 4863dbus-services/org.enlightenment.Ethumb.service
4820systemd-services/ethumb.service 4864systemd-services/ethumb.service
4821$po_makefile_in 4865$po_makefile_in
@@ -4873,6 +4917,10 @@ cmakeconfig/EflatXmlModelConfig.cmake
4873cmakeconfig/EflatXmlModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4917cmakeconfig/EflatXmlModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4874cmakeconfig/EflatXmlModelCxxConfig.cmake 4918cmakeconfig/EflatXmlModelCxxConfig.cmake
4875cmakeconfig/EflatXmlModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4919cmakeconfig/EflatXmlModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4920cmakeconfig/EsoapModelConfig.cmake
4921cmakeconfig/EsoapModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4922cmakeconfig/EsoapModelCxxConfig.cmake
4923cmakeconfig/EsoapModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4876]) 4924])
4877 4925
4878AC_OUTPUT 4926AC_OUTPUT
@@ -4988,6 +5036,7 @@ echo "Ethumb_Client...: yes"
4988echo "Elua............: $have_elua" 5036echo "Elua............: $have_elua"
4989echo "Ejson...........: yes" 5037echo "Ejson...........: yes"
4990echo "Eflat_Xml_Model.: yes" 5038echo "Eflat_Xml_Model.: yes"
5039echo "Esoap_Model.....: yes"
4991if test "${build_tests}" = "none"; then 5040if test "${build_tests}" = "none"; then
4992echo "Tests...........: no" 5041echo "Tests...........: no"
4993elif test "${build_tests}" = "auto"; then 5042elif 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 cb8398a0a1..12c4c30ed3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,6 +62,7 @@ include Makefile_Ethumb.am
62include Makefile_Ethumb_Client.am 62include Makefile_Ethumb_Client.am
63include Makefile_Ejson.am 63include Makefile_Ejson.am
64include Makefile_EflatXmlModel.am 64include Makefile_EflatXmlModel.am
65include Makefile_EsoapModel.am
65 66
66include Makefile_Eina_Cxx.am 67include Makefile_Eina_Cxx.am
67include Makefile_Ecore_Cxx.am 68include Makefile_Ecore_Cxx.am
@@ -75,6 +76,7 @@ include Makefile_Evas_Cxx.am
75include Makefile_Eio_Cxx.am 76include Makefile_Eio_Cxx.am
76include Makefile_Ejson_Cxx.am 77include Makefile_Ejson_Cxx.am
77include Makefile_EflatXmlModel_Cxx.am 78include Makefile_EflatXmlModel_Cxx.am
79include Makefile_EsoapModel_Cxx.am
78 80
79include Makefile_Elua.am 81include Makefile_Elua.am
80include Makefile_Elocation.am 82include Makefile_Elocation.am
diff --git a/src/Makefile_EsoapModel.am b/src/Makefile_EsoapModel.am
new file mode 100644
index 0000000000..d1a2180816
--- /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@ @ECORE_CON_CFLAGS@
60
61tests_esoap_model_esoap_model_suite_LDADD = \
62@CHECK_LIBS@ \
63@USE_ESOAP_MODEL_LIBS@ \
64@USE_EFL_LIBS@ @USE_ECORE_CON_LIBS@
65
66tests_esoap_model_esoap_model_suite_DEPENDENCIES = \
67@USE_ESOAP_MODEL_INTERNAL_LIBS@ @USE_ECORE_CON_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..5ae753f4fc
--- /dev/null
+++ b/src/lib/esoap_model/esoap_model.c
@@ -0,0 +1,498 @@
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 pd->url = NULL;
122 pd->action = NULL;
123
124 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
125}
126
127static void
128_esoap_model_url_set(Eo *obj EINA_UNUSED,
129 Esoap_Model_Data *pd EINA_UNUSED,
130 const char *url)
131{
132 DBG("(%p)", obj);
133 EINA_SAFETY_ON_NULL_RETURN(url);
134
135 pd->url = strdup(url);
136}
137
138static const char*
139_esoap_model_url_get(Eo *obj EINA_UNUSED,
140 Esoap_Model_Data *pd EINA_UNUSED)
141{
142 DBG("(%p)", obj);
143
144 return pd->url;
145}
146
147static void
148_esoap_model_action_set(Eo *obj EINA_UNUSED,
149 Esoap_Model_Data *pd EINA_UNUSED,
150 const char *action)
151{
152 DBG("(%p)", obj);
153 EINA_SAFETY_ON_NULL_RETURN(action);
154
155 pd->action = strdup(action);
156}
157
158static const char*
159_esoap_model_action_get(Eo *obj EINA_UNUSED,
160 Esoap_Model_Data *pd EINA_UNUSED)
161{
162 DBG("(%p)", obj);
163
164 return pd->action;
165}
166
167static void
168_esoap_model_eo_base_destructor(Eo *obj, Esoap_Model_Data *pd)
169{
170 DBG("(%p)", obj);
171
172 _clear(pd);
173 free(pd->url);
174 free(pd->action);
175
176 eo_do_super(obj, MY_CLASS, eo_destructor());
177}
178
179static Efl_Model_Load_Status
180_esoap_model_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
181 Esoap_Model_Data *pd,
182 Eina_Array * const* properties_array)
183{
184 DBG("(%p)", obj);
185 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
186 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
187
188 eo_do(pd->xml, efl_model_properties_get(properties_array));
189 return pd->load.status;
190}
191
192static void
193_esoap_model_efl_model_base_properties_load(Eo *obj, Esoap_Model_Data *pd)
194{
195 DBG("(%p)", obj);
196
197 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
198 return;
199
200 if (!_init(pd))
201 return;
202
203 _properties_load(pd);
204}
205
206static void
207_properties_load(Esoap_Model_Data *pd)
208{
209 DBG("(%p)", pd->obj);
210 efl_model_load_set(pd->obj,
211 &pd->load,
212 EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES);
213 eo_do(pd->xml, efl_model_properties_load());
214 efl_model_load_set(pd->obj,
215 &pd->load,
216 EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
217}
218
219static Efl_Model_Load_Status
220_esoap_model_efl_model_base_property_set(Eo *obj EINA_UNUSED,
221 Esoap_Model_Data *pd,
222 const char *property,
223 const Eina_Value *value)
224{
225 Efl_Model_Load_Status status;
226 eo_do(pd->xml, status = efl_model_property_set(property, value));
227 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
228 return pd->load.status;
229}
230
231static Efl_Model_Load_Status
232_esoap_model_efl_model_base_property_get(Eo *obj EINA_UNUSED,
233 Esoap_Model_Data *pd,
234 const char *property,
235 const Eina_Value **value)
236{
237 Efl_Model_Load_Status status;
238 eo_do(pd->xml, status = efl_model_property_get(property, value));
239 EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
240 return pd->load.status;
241}
242
243static void
244_esoap_model_efl_model_base_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
245{
246 DBG("(%p)", obj);
247
248 if ((pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED) == EFL_MODEL_LOAD_STATUS_LOADED)
249 return;
250
251 if (!_init(pd))
252 return;
253
254 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
255 _properties_load(pd);
256
257 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
258 _children_load(pd);
259}
260
261static Efl_Model_Load_Status
262_esoap_model_efl_model_base_load_status_get(Eo *obj EINA_UNUSED,
263 Esoap_Model_Data *pd)
264{
265 DBG("(%p)", obj);
266 return pd->load.status;
267}
268
269static void
270_esoap_model_efl_model_base_unload(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
271{
272 DBG("(%p)", obj);
273
274 _clear(pd);
275
276 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
277}
278
279Eo *
280_esoap_model_efl_model_base_child_add(Eo *obj, Esoap_Model_Data *pd EINA_UNUSED)
281{
282 DBG("(%p)", obj);
283 return NULL;
284}
285
286static Efl_Model_Load_Status
287_esoap_model_efl_model_base_child_del(Eo *obj,
288 Esoap_Model_Data *pd EINA_UNUSED,
289 Eo *child EINA_UNUSED)
290{
291 DBG("(%p)", obj);
292 return EFL_MODEL_LOAD_STATUS_ERROR;
293}
294
295static Efl_Model_Load_Status
296_esoap_model_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
297 Esoap_Model_Data *pd,
298 unsigned start EINA_UNUSED,
299 unsigned count EINA_UNUSED,
300 Eina_Accessor **children_accessor)
301{
302 DBG("(%p)", obj);
303
304 if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
305 {
306 WRN("(%p): Children not loaded", obj);
307 *children_accessor = NULL;
308 return pd->load.status;
309 }
310
311 *children_accessor = efl_model_list_slice(pd->children_list, start, count);
312 return pd->load.status;
313}
314
315static Efl_Model_Load_Status
316_esoap_model_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
317 Esoap_Model_Data *pd,
318 unsigned *children_count)
319{
320 DBG("(%p)", obj);
321 *children_count = eina_list_count(pd->children_list);
322 return pd->load.status;
323}
324
325static void
326_esoap_model_efl_model_base_children_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
327{
328 DBG("(%p)", obj);
329
330 if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
331 return;
332
333 if (!_init(pd))
334 return;
335
336 _children_load(pd);
337}
338
339static void
340_children_load(Esoap_Model_Data *pd)
341{
342 DBG("(%p)", pd->obj);
343
344 efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
345
346 const Eina_Value *xml_value;
347 Efl_Model_Load_Status status;
348 eo_do(pd->xml, status = efl_model_property_get("/", &xml_value));
349 EINA_SAFETY_ON_FALSE_RETURN(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
350
351 const char *xml = NULL;
352 eina_value_get(xml_value, &xml);
353 _perform(pd, xml);
354}
355
356static Eina_Bool
357_properties_changed_cb(void *data,
358 Eo *child EINA_UNUSED,
359 const Eo_Event_Description *desc EINA_UNUSED,
360 void *event_info)
361{
362 eo_do(data, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, event_info));
363 return EO_CALLBACK_CONTINUE;
364}
365
366static bool
367_init(Esoap_Model_Data *pd)
368{
369 if (pd->xml)
370 return true;
371
372 pd->xml = eo_add(EFLAT_XML_MODEL_CLASS,
373 NULL,
374 eflat_xml_model_constructor(NULL));
375
376 eo_do(pd->xml, eo_event_callback_add(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED,
377 _properties_changed_cb,
378 pd->obj));
379 return true;
380}
381
382static void
383_clear(Esoap_Model_Data *pd)
384{
385 EINA_SAFETY_ON_NULL_RETURN(pd);
386
387 if (pd->xml)
388 {
389 eo_unref(pd->xml);
390 pd->xml = NULL;
391 }
392
393 Eo *child;
394 EINA_LIST_FREE(pd->children_list, child)
395 eo_del(child);
396}
397
398static size_t
399_write_data_cb(void *ptr, size_t size, size_t nmeb, void *data)
400{
401 Eina_Strbuf *buf = (Eina_Strbuf *)data;
402 Eina_Bool ret = eina_strbuf_append_length(buf, ptr, size * nmeb);
403 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, 0);
404 return size * nmeb;
405}
406
407static void
408_perform(Esoap_Model_Data *pd, const char *xml)
409{
410 DBG("(%p)", pd->obj);
411 Esoap_Model_Perform_Data *data = calloc(1, sizeof(Esoap_Model_Perform_Data));
412 data->pd = pd;
413 data->response = eina_strbuf_new();
414
415 const char *SOAP_ACTION = "SOAPAction:";
416 const size_t soap_action_lenght = strlen(SOAP_ACTION) + strlen(pd->action) + 1;
417 data->soap_action = malloc(soap_action_lenght);
418 snprintf(data->soap_action, soap_action_lenght, "%s%s", SOAP_ACTION, pd->action);
419
420 data->header = curl_slist_append(data->header, "Content-Type:application/soap+xml");
421 data->header = curl_slist_append(data->header, data->soap_action);
422 data->header = curl_slist_append(data->header, "Transfer-Encoding: chunked");
423 data->header = curl_slist_append(data->header, "Expect:");
424
425 data->curl = curl_easy_init();
426 EINA_SAFETY_ON_NULL_RETURN(data->curl);
427
428 curl_easy_setopt(data->curl, CURLOPT_URL, pd->url);
429 curl_easy_setopt(data->curl, CURLOPT_POST, 1L);
430 curl_easy_setopt(data->curl, CURLOPT_WRITEFUNCTION, _write_data_cb);
431 curl_easy_setopt(data->curl, CURLOPT_WRITEDATA, data->response);
432 curl_easy_setopt(data->curl, CURLOPT_HTTPHEADER, data->header);
433 curl_easy_setopt(data->curl, CURLOPT_COPYPOSTFIELDS, xml);
434 curl_easy_setopt(data->curl, CURLOPT_VERBOSE, 1L);
435
436 data->thread = ecore_thread_run((Ecore_Thread_Cb)_perform_cb,
437 (Ecore_Thread_Cb)_perform_end_cb,
438 (Ecore_Thread_Cb)_perform_cancel_cb, data);
439 EINA_SAFETY_ON_NULL_RETURN(data->thread);
440}
441
442static void
443_perform_cb(Esoap_Model_Perform_Data *data, Ecore_Thread *thread)
444{
445 DBG("(%p)", data->pd->obj);
446 CURLcode res = curl_easy_perform(data->curl);
447 if (CURLE_OK != res)
448 {
449 ERR("Could not perform: %d", res);
450 ecore_thread_cancel(thread);
451 }
452}
453
454static void
455_perform_end_cb(Esoap_Model_Perform_Data *data,
456 Ecore_Thread *thread EINA_UNUSED)
457{
458 DBG("(%p)", data->pd->obj);
459 const char *response = eina_strbuf_string_get(data->response);
460
461 DBG("(%p) response: %s", data->pd->obj, response);
462
463 Eo *child = eo_add(EFLAT_XML_MODEL_CLASS,
464 NULL,
465 eflat_xml_model_constructor(response));
466 data->pd->children_list = eina_list_append(data->pd->children_list, child);
467
468 unsigned int count = eina_list_count(data->pd->children_list);
469 Efl_Model_Children_Event evt = {.child = child, .index = count};
470 eo_do(data->pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILD_ADDED, &evt),
471 eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
472
473 efl_model_load_set(data->pd->obj, &data->pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
474
475 _perform_data_free(data);
476}
477
478static void
479_perform_cancel_cb(Esoap_Model_Perform_Data *data,
480 Ecore_Thread *thread EINA_UNUSED)
481{
482 DBG("(%p)", data->pd->obj);
483 efl_model_error_notify(data->pd->obj);
484 _perform_data_free(data);
485}
486
487static void
488_perform_data_free(Esoap_Model_Perform_Data *data)
489{
490 DBG("(%p)", data->pd->obj);
491 curl_easy_cleanup(data->curl);
492 eina_strbuf_free(data->response);
493 curl_slist_free_all(data->header);
494 free(data->soap_action);
495 free(data);
496}
497
498#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..18b40f302c
--- /dev/null
+++ b/src/lib/esoap_model/esoap_model.eo
@@ -0,0 +1,48 @@
1class Esoap.Model (Eo.Base, Efl.Model.Base) {
2 legacy_prefix: null;
3 methods {
4 @property url {
5 [[
6 Custom Soap_Model constructor.
7
8 @since 1.16
9 ]]
10 set {}
11 get {}
12 values {
13 url: const(char)*; [[The webservice URL]]
14 }
15 }
16 @property action {
17 [[
18 Custom Soap_Model constructor.
19
20 @since 1.16
21 ]]
22 set {}
23 get {}
24 values {
25 action: const(char)*; [[The soap action]]
26 }
27 }
28 }
29 implements {
30 Eo.Base.constructor;
31 Eo.Base.destructor;
32 Efl.Model.Base.properties.get;
33 Efl.Model.Base.properties_load;
34 Efl.Model.Base.property.set;
35 Efl.Model.Base.property.get;
36 Efl.Model.Base.load;
37 Efl.Model.Base.load_status.get;
38 Efl.Model.Base.unload;
39 Efl.Model.Base.child_add;
40 Efl.Model.Base.child_del;
41 Efl.Model.Base.children_slice.get;
42 Efl.Model.Base.children_count.get;
43 Efl.Model.Base.children_load;
44 }
45 constructors {
46 .url;
47 }
48}
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..db56a33daf
--- /dev/null
+++ b/src/tests/esoap_model/esoap_model_test_esoap_model.c
@@ -0,0 +1,270 @@
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 <Ecore_Con.h>
10#include <Eina.h>
11#include <Esoap_Model.h>
12
13#include <stdbool.h>
14
15static Eina_Bool
16server_data_callback(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
17{
18 Ecore_Con_Event_Client_Data* client_event = event;
19
20 const char check_data[] =
21 "POST /axis2/services/echo HTTP/1.1\r\n"
22 "Host: 127.0.0.1:9090\r\n"
23 "Accept: */*\r\n"
24 "Content-Type:application/soap+xml\r\n"
25 "SOAPAction:http://ws.apache.org/axis2/c/samples/echoString\r\n"
26 "Transfer-Encoding: chunked\r\n"
27 "\r\n"
28 "150\r\n"
29 "<esoap:Envelope xmlns:esoap=\"http://www.w3.org/2003/05/esoap-envelope\" esoap:encodingStyle=\"http://www.w3.org/2001/12/esoap-encoding\">\n"
30 " <esoap:Body>\n"
31 " <ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/services/echo\">\n"
32 " <ns1:text>\n"
33 " Hello World!\n"
34 " </ns1:text>\n"
35 " </ns1:echoString>\n"
36 " </esoap:Body>\n"
37 "</esoap:Envelope>\n"
38 "\r\n"
39 "0\r\n"
40 "\r\n";
41
42 // static check that check_data is at least 545 bytes
43 char a[545-sizeof(check_data)]; (void)a;
44 // static check that check_data is at most 545 bytes
45 char b[sizeof(check_data) - 545]; (void)b;
46
47 ck_assert(client_event->size == 544);
48 ck_assert(!memcmp(check_data, client_event->data, sizeof(check_data)-1));
49
50 const char data_to_send[] =
51 "HTTP/1.1 200\r\n"
52 "Host: 127.0.0.1:9090\r\n"
53 "Content-Type:application/soap+xml\r\n"
54 "Content-Length: 276\r\n"
55 "\r\n"
56 "<esoapenv:Envelope xmlns:esoapenv=\"http://www.w3.org/2003/05/esoap-envelope\">\n"
57 " <esoapenv:Body>\n"
58 " <ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/c/samples\">\n"
59 " <text>\n"
60 " Hello World!\n"
61 " </text>\n"
62 " </ns1:echoString>\n"
63 " </esoapenv:Body>\n"
64 "</esoapenv:Envelope>\n";
65
66 ecore_con_client_send(client_event->client, data_to_send, sizeof(data_to_send)-1);
67
68 return EINA_TRUE;
69}
70
71static Ecore_Con_Server* server;
72
73static void
74_setup(void)
75{
76 int ret = esoap_model_init();
77 ck_assert_int_ge(ret, 1);
78 ecore_con_init();
79
80 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
81 server_data_callback,
82 NULL);
83
84 server = ecore_con_server_add
85 (ECORE_CON_REMOTE_TCP, "0.0.0.0", 9090, NULL);
86
87}
88
89static void
90_teardown(void)
91{
92 int ret = esoap_model_shutdown();
93 ck_assert_int_eq(ret, 0);
94
95 ecore_con_server_del(server);
96
97 ecore_con_shutdown();
98}
99
100static Eina_Bool
101_eo_event_load_status_cb(void *data,
102 Eo *obj EINA_UNUSED,
103 const Eo_Event_Description *desc EINA_UNUSED,
104 void *event_info EINA_UNUSED)
105{
106 Efl_Model_Load_Status expected_status = *((Efl_Model_Load_Status*)data);
107 Efl_Model_Load load = *((Efl_Model_Load*)event_info);
108 if ((load.status & expected_status) != expected_status)
109 return EINA_TRUE;
110
111 ecore_main_loop_quit();
112 return EINA_FALSE;
113}
114
115static void
116_wait_until_load_status(Efl_Model_Base *model, Efl_Model_Load_Status expected_status)
117{
118 Efl_Model_Load_Status actual_status;
119 eo_do(model, actual_status = efl_model_load_status_get());
120 if ((expected_status & actual_status) == expected_status) return;
121
122 eo_do(model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
123 ecore_main_loop_begin();
124 eo_do(model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
125}
126
127static void
128_check_model_children_count_eq(Efl_Model_Base *model, unsigned int expected_children_count)
129{
130 unsigned int actual_children_count = 0;
131 eo_do(model, efl_model_children_count_get(&actual_children_count));
132 ck_assert_int_eq(expected_children_count, actual_children_count);
133}
134
135static void
136_check_model_property_str_eq(Efl_Model_Base *model, const char *property, const char *expected_value)
137{
138 const Eina_Value *value;
139 Efl_Model_Load_Status status;
140 eo_do(model, status = efl_model_property_get(property, &value));
141 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
142 ck_assert_ptr_ne(NULL, value);
143
144 const Eina_Value_Type *property_type = eina_value_type_get(value);
145 fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
146
147 const char *actual_value = NULL;
148 eina_value_get(value, &actual_value);
149 ck_assert_str_eq(expected_value, actual_value);
150}
151
152static Efl_Model_Base *
153_efl_model_nth_child_get(Efl_Model_Base *model, unsigned int n)
154{
155 Eina_Accessor *accessor;
156 Efl_Model_Load_Status status;
157 eo_do(model, status = efl_model_children_slice_get(n, 1, &accessor));
158 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
159 ck_assert_ptr_ne(NULL, accessor);
160 Efl_Model_Base *child = NULL;
161 Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
162 eina_accessor_free(accessor);
163 ck_assert(ret);
164 ck_assert_ptr_ne(NULL, child);
165 return child;
166}
167
168static void
169_check_model_load(Efl_Model_Base *model)
170{
171 eo_do(model, efl_model_load());
172 _wait_until_load_status(model, EFL_MODEL_LOAD_STATUS_LOADED);
173}
174
175static void
176_check_model_properties(Efl_Model_Base *model, const char *expected_properties[])
177{
178 Eina_Array *properties = NULL;
179 Efl_Model_Load_Status status;
180 eo_do(model, status = efl_model_properties_get(&properties));
181 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
182 ck_assert_ptr_ne(NULL, properties);
183
184 unsigned int actual_properties_count = eina_array_count(properties);
185
186 unsigned int expected_properties_count = 0;
187 const char *expected_property = NULL;
188 while ((expected_property = *expected_properties++))
189 {
190 const char *actual_property = eina_array_data_get(properties,
191 expected_properties_count);
192 ck_assert_str_eq(expected_property, actual_property);
193 ++expected_properties_count;
194 ck_assert_int_le(expected_properties_count, actual_properties_count);
195 }
196
197 ck_assert_int_eq(expected_properties_count, actual_properties_count);
198}
199
200static Esoap_Model *
201_create_esoap_model()
202{
203 Efl_Model_Base *esoap = eo_add(ESOAP_MODEL_CLASS, NULL,
204 esoap_model_url_set("http://127.0.0.1:9090/axis2/services/echo"),
205 esoap_model_action_set("http://ws.apache.org/axis2/c/samples/echoString"));
206 ck_assert_ptr_ne(NULL, esoap);
207 return esoap;
208}
209
210START_TEST(smoke)
211{
212 Efl_Model_Base *esoap = _create_esoap_model();
213 eo_unref(esoap);
214}
215END_TEST
216
217static void
218_check_string_property_set(Efl_Model_Base *model, const char *property, const char *v)
219{
220 Eina_Value value;
221 eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
222 eina_value_set(&value, v);
223 Efl_Model_Load_Status status;
224 eo_do(model, status = efl_model_property_set(property, &value));
225 eina_value_flush(&value);
226 ck_assert(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
227}
228
229START_TEST(load_children)
230{
231 Efl_Model_Base *esoap = _create_esoap_model();
232
233 eo_do(esoap, efl_model_properties_load());
234 _wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
235
236 _check_string_property_set(esoap, "esoap:Envelope@xmlns:esoap", "http://www.w3.org/2003/05/esoap-envelope");
237 _check_string_property_set(esoap, "esoap:Envelope@esoap:encodingStyle", "http://www.w3.org/2001/12/esoap-encoding");
238 _check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/services/echo");
239 _check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString/ns1:text", "Hello World!");
240
241 // make the call loading the children
242 eo_do(esoap, efl_model_children_load());
243 _wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
244
245 _check_model_children_count_eq(esoap, 1);
246
247 Efl_Model_Base *child = _efl_model_nth_child_get(esoap, 1);
248 _check_model_load(child);
249
250 _check_model_properties(child, (const char*[]){
251 "esoapenv:Envelope@xmlns:esoapenv",
252 "esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1",
253 "esoapenv:Envelope/esoapenv:Body/ns1:echoString/text",
254 NULL});
255
256 _check_model_property_str_eq(child, "esoapenv:Envelope@xmlns:esoapenv", "http://www.w3.org/2003/05/esoap-envelope");
257 _check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/c/samples");
258 _check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString/text", "Hello World!");
259
260 eo_unref(esoap);
261}
262END_TEST
263
264void
265esoap_model_test_esoap_model(TCase *tc)
266{
267 tcase_add_checked_fixture(tc, _setup, _teardown);
268 tcase_add_test(tc, smoke);
269 tcase_add_test(tc, load_children);
270}
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