Compare commits
12 Commits
master
...
devs/felip
Author | SHA1 | Date |
---|---|---|
Felipe Magno de Almeida | 96be303eee | |
Felipe Magno de Almeida | 09a1e75dcb | |
Felipe Magno de Almeida | 462ecf69d3 | |
Felipe Magno de Almeida | 7457f37df4 | |
Felipe Magno de Almeida | 1b9aeb529b | |
Felipe Magno de Almeida | 5cce0f2b22 | |
Guilherme Lepsch | 6732e02838 | |
Guilherme Lepsch | 4e5a7227da | |
Guilherme Lepsch | 132e320017 | |
Guilherme Lepsch | 6a1025c09e | |
Guilherme Lepsch | cb2cea98cd | |
Felipe Magno de Almeida | e0b12153c8 |
28
Makefile.am
28
Makefile.am
|
@ -152,7 +152,9 @@ pc/edje.pc \
|
||||||
pc/emotion.pc \
|
pc/emotion.pc \
|
||||||
pc/ethumb.pc \
|
pc/ethumb.pc \
|
||||||
pc/ethumb_client.pc \
|
pc/ethumb_client.pc \
|
||||||
pc/elocation.pc
|
pc/elocation.pc \
|
||||||
|
pc/eflat_xml_model.pc \
|
||||||
|
pc/esoap_model.pc
|
||||||
|
|
||||||
if HAVE_CXX11
|
if HAVE_CXX11
|
||||||
pkgconfig_DATA += \
|
pkgconfig_DATA += \
|
||||||
|
@ -164,7 +166,9 @@ pc/eolian-cxx.pc \
|
||||||
pc/edje-cxx.pc \
|
pc/edje-cxx.pc \
|
||||||
pc/eet-cxx.pc \
|
pc/eet-cxx.pc \
|
||||||
pc/eo-cxx.pc \
|
pc/eo-cxx.pc \
|
||||||
pc/eio-cxx.pc
|
pc/eio-cxx.pc \
|
||||||
|
pc/eflat_xml_model-cxx.pc \
|
||||||
|
pc/esoap_model-cxx.pc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_ELUA
|
if HAVE_ELUA
|
||||||
|
@ -383,6 +387,26 @@ emile_cmakeconfig_DATA = \
|
||||||
cmakeconfig/EmileConfig.cmake \
|
cmakeconfig/EmileConfig.cmake \
|
||||||
cmakeconfig/EmileConfigVersion.cmake
|
cmakeconfig/EmileConfigVersion.cmake
|
||||||
|
|
||||||
|
eflat_xml_model_cxx_cmakeconfigdir = $(libdir)/cmake/EflatXmlModelCxx/
|
||||||
|
eflat_xml_model_cxx_cmakeconfig_DATA = \
|
||||||
|
cmakeconfig/EflatXmlModelCxxConfig.cmake \
|
||||||
|
cmakeconfig/EflatXmlModelCxxConfigVersion.cmake
|
||||||
|
|
||||||
|
eflat_xml_model_cmakeconfigdir = $(libdir)/cmake/EflatXmlModel/
|
||||||
|
eflat_xml_model_cmakeconfig_DATA = \
|
||||||
|
cmakeconfig/EflatXmlModelConfig.cmake \
|
||||||
|
cmakeconfig/EflatXmlModelConfigVersion.cmake
|
||||||
|
|
||||||
|
esoap_model_cxx_cmakeconfigdir = $(libdir)/cmake/EsoapModelCxx/
|
||||||
|
esoap_model_cxx_cmakeconfig_DATA = \
|
||||||
|
cmakeconfig/EsoapModelCxxConfig.cmake \
|
||||||
|
cmakeconfig/EsoapModelCxxConfigVersion.cmake
|
||||||
|
|
||||||
|
esoap_model_cmakeconfigdir = $(libdir)/cmake/EsoapModel/
|
||||||
|
esoap_model_cmakeconfig_DATA = \
|
||||||
|
cmakeconfig/EsoapModelConfig.cmake \
|
||||||
|
cmakeconfig/EsoapModelConfigVersion.cmake
|
||||||
|
|
||||||
# D-Bus services:
|
# D-Bus services:
|
||||||
|
|
||||||
servicedir = @dbusservicedir@
|
servicedir = @dbusservicedir@
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# - Try to find eflat_xml_model
|
||||||
|
# Once done this will define
|
||||||
|
# EFLAT_XML_MODEL_FOUND - System has eflat_xml_model
|
||||||
|
# EFLAT_XML_MODEL_INCLUDE_DIRS - The eflat_xml_model include directories
|
||||||
|
# EFLAT_XML_MODEL_LIBRARIES - The libraries needed to use eflat_xml_model
|
||||||
|
# EFLAT_XML_MODEL_DEFINITIONS - Compiler switches required for using eflat_xml_model
|
||||||
|
|
||||||
|
set(MY_PKG eflat_xml_model)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_LIBEFLAT_XML_MODEL ${_QUIET} ${MY_PKG})
|
||||||
|
|
||||||
|
find_library(EFLAT_XML_MODEL_LIBRARY
|
||||||
|
NAMES ${PC_LIBEFLAT_XML_MODEL_LIBRARIES}
|
||||||
|
HINTS ${PC_LIBEFLAT_XML_MODEL_LIBDIR} ${PC_LIBEFLAT_XML_MODEL_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EFLAT_XML_MODEL_DEFINITIONS ${PC_LIBEFLAT_XML_MODEL_CFLAGS_OTHER})
|
||||||
|
set(EFLAT_XML_MODEL_LIBRARIES ${EFLAT_XML_MODEL_LIBRARY})
|
||||||
|
set(EFLAT_XML_MODEL_INCLUDE_DIRS ${PC_LIBEFLAT_XML_MODEL_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EFLAT_XML_MODEL_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
EFLAT_XML_MODEL_LIBRARIES EFLAT_XML_MODEL_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(EFLAT_XML_MODEL_INCLUDE_DIRS EFLAT_XML_MODEL_LIBRARY EFLAT_XML_MODEL_LIBRARIES EFLAT_XML_MODEL_DEFINITIONS)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# - Try to find eflat_xml_model
|
||||||
|
# Once done this will define
|
||||||
|
# EFLAT_XML_MODEL_CXX_FOUND - System has eflat_xml_model
|
||||||
|
# EFLAT_XML_MODEL_CXX_INCLUDE_DIRS - The eflat_xml_model include directories
|
||||||
|
# EFLAT_XML_MODEL_CXX_LIBRARIES - The libraries needed to use eflat_xml_model
|
||||||
|
# EFLAT_XML_MODEL_CXX_DEFINITIONS - Compiler switches required for using eflat_xml_model
|
||||||
|
|
||||||
|
set(MY_PKG eflat_xml_model_cxx)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_EFLAT_XML_MODEL_CXX ${_QUIET} ${MY_PKG})
|
||||||
|
find_library(EFLAT_XML_MODEL_CXX_LIBRARY
|
||||||
|
NAMES ${PC_EFLAT_XML_MODEL_CXX_LIBRARIES}
|
||||||
|
HINTS ${PC_EFLAT_XML_MODEL_CXX_LIBDIR} ${PC_EFLAT_XML_MODEL_CXX_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EFLAT_XML_MODEL_CXX_DEFINITIONS ${PC_EFLAT_XML_MODEL_CXX_CFLAGS_OTHER})
|
||||||
|
set(EFLAT_XML_MODEL_CXX_LIBRARIES ${EFLAT_XML_MODEL_CXX_LIBRARY})
|
||||||
|
set(EFLAT_XML_MODEL_CXX_INCLUDE_DIRS ${PC_EFLAT_XML_MODEL_CXX_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EFLAT_XML_MODEL_CXX_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
EFLAT_XML_MODEL_CXX_LIBRARIES EFLAT_XML_MODEL_CXX_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(EFLAT_XML_MODEL_CXX_INCLUDE_DIRS EFLAT_XML_MODEL_CXX_LIBRARY EFLAT_XML_MODEL_CXX_LIBRARIES EFLAT_XML_MODEL_CXX_DEFINITIONS)
|
|
@ -0,0 +1,32 @@
|
||||||
|
# - Try to find ejson
|
||||||
|
# Once done this will define
|
||||||
|
# EJSON_FOUND - System has ejson
|
||||||
|
# EJSON_INCLUDE_DIRS - The ejson include directories
|
||||||
|
# EJSON_LIBRARIES - The libraries needed to use ejson
|
||||||
|
# EJSON_DEFINITIONS - Compiler switches required for using ejson
|
||||||
|
|
||||||
|
set(MY_PKG ejson)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_LIBEJSON ${_QUIET} ${MY_PKG})
|
||||||
|
|
||||||
|
find_library(EJSON_LIBRARY
|
||||||
|
NAMES ${PC_LIBEJSON_LIBRARIES}
|
||||||
|
HINTS ${PC_LIBEJSON_LIBDIR} ${PC_LIBEJSON_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EJSON_DEFINITIONS ${PC_LIBEJSON_CFLAGS_OTHER})
|
||||||
|
set(EJSON_LIBRARIES ${EJSON_LIBRARY})
|
||||||
|
set(EJSON_INCLUDE_DIRS ${PC_LIBEJSON_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EJSON_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
EJSON_LIBRARIES EJSON_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(EJSON_INCLUDE_DIRS EJSON_LIBRARY EJSON_LIBRARIES EJSON_DEFINITIONS)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# - Try to find ejson
|
||||||
|
# Once done this will define
|
||||||
|
# EJSON_CXX_FOUND - System has ejson
|
||||||
|
# EJSON_CXX_INCLUDE_DIRS - The ejson include directories
|
||||||
|
# EJSON_CXX_LIBRARIES - The libraries needed to use ejson
|
||||||
|
# EJSON_CXX_DEFINITIONS - Compiler switches required for using ejson
|
||||||
|
|
||||||
|
set(MY_PKG ejson_cxx)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_EJSON_CXX ${_QUIET} ${MY_PKG})
|
||||||
|
find_library(EJSON_CXX_LIBRARY
|
||||||
|
NAMES ${PC_EJSON_CXX_LIBRARIES}
|
||||||
|
HINTS ${PC_EJSON_CXX_LIBDIR} ${PC_EJSON_CXX_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EJSON_CXX_DEFINITIONS ${PC_EJSON_CXX_CFLAGS_OTHER})
|
||||||
|
set(EJSON_CXX_LIBRARIES ${EJSON_CXX_LIBRARY})
|
||||||
|
set(EJSON_CXX_INCLUDE_DIRS ${PC_EJSON_CXX_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EJSON_CXX_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
EJSON_CXX_LIBRARIES EJSON_CXX_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(EJSON_CXX_INCLUDE_DIRS EJSON_CXX_LIBRARY EJSON_CXX_LIBRARIES EJSON_CXX_DEFINITIONS)
|
|
@ -0,0 +1,32 @@
|
||||||
|
# - Try to find esoap_model
|
||||||
|
# Once done this will define
|
||||||
|
# ESOAP_MODEL_FOUND - System has esoap_model
|
||||||
|
# ESOAP_MODEL_INCLUDE_DIRS - The esoap_model include directories
|
||||||
|
# ESOAP_MODEL_LIBRARIES - The libraries needed to use esoap_model
|
||||||
|
# ESOAP_MODEL_DEFINITIONS - Compiler switches required for using esoap_model
|
||||||
|
|
||||||
|
set(MY_PKG esoap_model)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_LIBESOAP_MODEL ${_QUIET} ${MY_PKG})
|
||||||
|
|
||||||
|
find_library(ESOAP_MODEL_LIBRARY
|
||||||
|
NAMES ${PC_LIBESOAP_MODEL_LIBRARIES}
|
||||||
|
HINTS ${PC_LIBESOAP_MODEL_LIBDIR} ${PC_LIBESOAP_MODEL_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(ESOAP_MODEL_DEFINITIONS ${PC_LIBESOAP_MODEL_CFLAGS_OTHER})
|
||||||
|
set(ESOAP_MODEL_LIBRARIES ${ESOAP_MODEL_LIBRARY})
|
||||||
|
set(ESOAP_MODEL_INCLUDE_DIRS ${PC_LIBESOAP_MODEL_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set ESOAP_MODEL_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
ESOAP_MODEL_LIBRARIES ESOAP_MODEL_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(ESOAP_MODEL_INCLUDE_DIRS ESOAP_MODEL_LIBRARY ESOAP_MODEL_LIBRARIES ESOAP_MODEL_DEFINITIONS)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# - Try to find esoap_model
|
||||||
|
# Once done this will define
|
||||||
|
# ESOAP_MODEL_CXX_FOUND - System has esoap_model
|
||||||
|
# ESOAP_MODEL_CXX_INCLUDE_DIRS - The esoap_model include directories
|
||||||
|
# ESOAP_MODEL_CXX_LIBRARIES - The libraries needed to use esoap_model
|
||||||
|
# ESOAP_MODEL_CXX_DEFINITIONS - Compiler switches required for using esoap_model
|
||||||
|
|
||||||
|
set(MY_PKG esoap_model_cxx)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
|
||||||
|
# "QUIET" was introduced in 2.8.2
|
||||||
|
set(_QUIET QUIET)
|
||||||
|
endif ()
|
||||||
|
pkg_check_modules(PC_ESOAP_MODEL_CXX ${_QUIET} ${MY_PKG})
|
||||||
|
find_library(ESOAP_MODEL_CXX_LIBRARY
|
||||||
|
NAMES ${PC_ESOAP_MODEL_CXX_LIBRARIES}
|
||||||
|
HINTS ${PC_ESOAP_MODEL_CXX_LIBDIR} ${PC_ESOAP_MODEL_CXX_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(ESOAP_MODEL_CXX_DEFINITIONS ${PC_ESOAP_MODEL_CXX_CFLAGS_OTHER})
|
||||||
|
set(ESOAP_MODEL_CXX_LIBRARIES ${ESOAP_MODEL_CXX_LIBRARY})
|
||||||
|
set(ESOAP_MODEL_CXX_INCLUDE_DIRS ${PC_ESOAP_MODEL_CXX_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set ESOAP_MODEL_CXX_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
|
||||||
|
ESOAP_MODEL_CXX_LIBRARIES ESOAP_MODEL_CXX_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
mark_as_advanced(ESOAP_MODEL_CXX_INCLUDE_DIRS ESOAP_MODEL_CXX_LIBRARY ESOAP_MODEL_CXX_LIBRARIES ESOAP_MODEL_CXX_DEFINITIONS)
|
129
configure.ac
129
configure.ac
|
@ -3911,7 +3911,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [emile])
|
||||||
ECORE_EVAS_MODULE([extn], [${want_ecore_evas_extn}])
|
ECORE_EVAS_MODULE([extn], [${want_ecore_evas_extn}])
|
||||||
ECORE_EVAS_MODULE([ews], [yes])
|
ECORE_EVAS_MODULE([ews], [yes])
|
||||||
ECORE_EVAS_MODULE([fb], [${want_fb}])
|
ECORE_EVAS_MODULE([fb], [${want_fb}])
|
||||||
ECORE_EVAS_MODULE([drm], [${want_drm}],
|
ECORE_EVAS_MODULE([drm], [${want_drm}],
|
||||||
[EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_drm}], [ecore-drm])])
|
[EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_drm}], [ecore-drm])])
|
||||||
ECORE_EVAS_MODULE([gl-drm], [${want_gl_drm}],
|
ECORE_EVAS_MODULE([gl-drm], [${want_gl_drm}],
|
||||||
[EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_gl_drm}], [ecore-drm])])
|
[EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_gl_drm}], [ecore-drm])])
|
||||||
|
@ -4560,6 +4560,112 @@ EFL_ADD_LIBS([ELOCATION], [-lm])
|
||||||
EFL_LIB_END([Elocation])
|
EFL_LIB_END([Elocation])
|
||||||
#### End of Elocation
|
#### End of Elocation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Ejson
|
||||||
|
EFL_LIB_START([Ejson])
|
||||||
|
|
||||||
|
### Additional options to configure
|
||||||
|
|
||||||
|
### Default values
|
||||||
|
|
||||||
|
### Checks for programs
|
||||||
|
|
||||||
|
### Checks for libraries
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EJSON], [eo])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EJSON], [efl])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EJSON], [ecore])
|
||||||
|
|
||||||
|
EFL_DEPEND_PKG([EJSON], [JSONC], [json-c >= 0.11])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([EJSON])
|
||||||
|
|
||||||
|
### Checks for header files
|
||||||
|
|
||||||
|
### Checks for types
|
||||||
|
|
||||||
|
### Checks for structures
|
||||||
|
|
||||||
|
### Checks for compiler characteristics
|
||||||
|
|
||||||
|
### Checks for linker characteristics
|
||||||
|
|
||||||
|
### Checks for library functions
|
||||||
|
|
||||||
|
EFL_LIB_END([Ejson])
|
||||||
|
#### End of Ejson
|
||||||
|
|
||||||
|
#### Ejson CXX
|
||||||
|
EFL_LIB_START([Ejson_Cxx])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([EJSON_CXX])
|
||||||
|
|
||||||
|
EFL_LIB_END([Ejson_Cxx])
|
||||||
|
#### End of Ejson CXX
|
||||||
|
|
||||||
|
#### Eflat_Xml_Model
|
||||||
|
EFL_LIB_START([Eflat_Xml_Model])
|
||||||
|
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EFLAT_XML_MODEL], [eo])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EFLAT_XML_MODEL], [efl])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EFLAT_XML_MODEL], [ecore])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([EFLAT_XML_MODEL])
|
||||||
|
|
||||||
|
EFL_LIB_END([Eflat_Xml_Model])
|
||||||
|
#### End of Eflat_Xml_Model
|
||||||
|
|
||||||
|
#### Eflat_Xml_Model CXX
|
||||||
|
EFL_LIB_START([Eflat_Xml_Model_Cxx])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([EFLAT_XML_MODEL_CXX])
|
||||||
|
|
||||||
|
EFL_LIB_END([Eflat_Xml_Model_Cxx])
|
||||||
|
#### End of Eflat_Xml_Model CXX
|
||||||
|
|
||||||
|
#### Esoap_Model
|
||||||
|
EFL_LIB_START([Esoap_Model])
|
||||||
|
|
||||||
|
### Additional options to configure
|
||||||
|
|
||||||
|
### Default values
|
||||||
|
|
||||||
|
### Checks for programs
|
||||||
|
|
||||||
|
### Checks for libraries
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eo])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [efl])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [ecore])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ESOAP_MODEL], [eflat_xml_model])
|
||||||
|
|
||||||
|
EFL_DEPEND_PKG([ESOAP_MODEL], [CURL], [libcurl >= 7.40])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([ESOAP_MODEL])
|
||||||
|
|
||||||
|
### Checks for header files
|
||||||
|
|
||||||
|
### Checks for types
|
||||||
|
|
||||||
|
### Checks for structures
|
||||||
|
|
||||||
|
### Checks for compiler characteristics
|
||||||
|
|
||||||
|
### Checks for linker characteristics
|
||||||
|
|
||||||
|
### Checks for library functions
|
||||||
|
|
||||||
|
EFL_LIB_END([Esoap_Model])
|
||||||
|
#### End of Esoap_Model
|
||||||
|
|
||||||
|
#### Esoap_Model CXX
|
||||||
|
EFL_LIB_START([Esoap_Model_Cxx])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([ESOAP_MODEL_CXX])
|
||||||
|
|
||||||
|
EFL_LIB_END([Esoap_Model_Cxx])
|
||||||
|
#### End of Esoap_Model CXX
|
||||||
|
|
||||||
### Add Wayland server library if test is enabled
|
### Add Wayland server library if test is enabled
|
||||||
if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then
|
if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then
|
||||||
EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0])
|
EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0])
|
||||||
|
@ -4748,6 +4854,12 @@ pc/ethumb.pc
|
||||||
pc/ethumb_client.pc
|
pc/ethumb_client.pc
|
||||||
pc/elocation.pc
|
pc/elocation.pc
|
||||||
pc/elua.pc
|
pc/elua.pc
|
||||||
|
pc/ejson.pc
|
||||||
|
pc/ejson-cxx.pc
|
||||||
|
pc/eflat_xml_model.pc
|
||||||
|
pc/eflat_xml_model-cxx.pc
|
||||||
|
pc/esoap_model.pc
|
||||||
|
pc/esoap_model-cxx.pc
|
||||||
dbus-services/org.enlightenment.Ethumb.service
|
dbus-services/org.enlightenment.Ethumb.service
|
||||||
systemd-services/ethumb.service
|
systemd-services/ethumb.service
|
||||||
$po_makefile_in
|
$po_makefile_in
|
||||||
|
@ -4797,6 +4909,18 @@ cmakeconfig/EluaConfig.cmake
|
||||||
cmakeconfig/EluaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
cmakeconfig/EluaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
cmakeconfig/EmileConfig.cmake
|
cmakeconfig/EmileConfig.cmake
|
||||||
cmakeconfig/EmileConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
cmakeconfig/EmileConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EjsonConfig.cmake
|
||||||
|
cmakeconfig/EjsonConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EjsonCxxConfig.cmake
|
||||||
|
cmakeconfig/EjsonCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EflatXmlModelConfig.cmake
|
||||||
|
cmakeconfig/EflatXmlModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EflatXmlModelCxxConfig.cmake
|
||||||
|
cmakeconfig/EflatXmlModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EsoapModelConfig.cmake
|
||||||
|
cmakeconfig/EsoapModelConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
|
cmakeconfig/EsoapModelCxxConfig.cmake
|
||||||
|
cmakeconfig/EsoapModelCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@ -4910,6 +5034,9 @@ echo "Emotion.........: yes (${features_emotion})"
|
||||||
echo "Ethumb..........: yes"
|
echo "Ethumb..........: yes"
|
||||||
echo "Ethumb_Client...: yes"
|
echo "Ethumb_Client...: yes"
|
||||||
echo "Elua............: $have_elua"
|
echo "Elua............: $have_elua"
|
||||||
|
echo "Ejson...........: yes"
|
||||||
|
echo "Eflat_Xml_Model.: yes"
|
||||||
|
echo "Esoap_Model.....: yes"
|
||||||
if test "${build_tests}" = "none"; then
|
if test "${build_tests}" = "none"; then
|
||||||
echo "Tests...........: no"
|
echo "Tests...........: no"
|
||||||
elif test "${build_tests}" = "auto"; then
|
elif test "${build_tests}" = "auto"; then
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Eflat_xml_model C++
|
||||||
|
Description: "Flat" XML model for EFL
|
||||||
|
Requires.private: @requirements_pc_eflat_xml_model@ @requirements_pc_eo@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -leflat_xml_model @requirements_public_libs_eflat_xml_model@ @requirements_public_libs_eo@
|
||||||
|
Libs.private: @requirements_libs_eflat_xml_model@ @requirements_libs_eo@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/eflat_xml_model-@VMAJ@ -I${includedir}/eflat_xml_model-cxx-@VMAJ@
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Eflat_xml_model
|
||||||
|
Description: "Flat" XML model for EFL
|
||||||
|
Requires.private: @requirements_pc_eflat_xml_model@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -leflat_xml_model @requirements_public_libs_eflat_xml_model@
|
||||||
|
Libs.private: @requirements_libs_eflat_xml_model@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eflat_xml_model-@VMAJ@
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Ejson C++
|
||||||
|
Description: Json convenience library for EFL
|
||||||
|
Requires.private: @requirements_pc_ejson@ @requirements_pc_eo@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -lejson @requirements_public_libs_ejson@ @requirements_public_libs_eo@
|
||||||
|
Libs.private: @requirements_libs_ejson@ @requirements_libs_eo@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/ejson-@VMAJ@ -I${includedir}/ejson-cxx-@VMAJ@
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Ejson
|
||||||
|
Description: Json convenience library for EFL
|
||||||
|
Requires.private: @requirements_pc_ejson@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -lejson @requirements_public_libs_ejson@
|
||||||
|
Libs.private: @requirements_libs_ejson@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/ejson-@VMAJ@
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Esoap-model C++
|
||||||
|
Description: SOAP model for EFL
|
||||||
|
Requires.private: @requirements_pc_esoap_model@ @requirements_pc_eo@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -lesoap_model @requirements_public_libs_esoap_model@ @requirements_public_libs_eo@
|
||||||
|
Libs.private: @requirements_libs_esoap_model@ @requirements_libs_eo@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/esoap_model-@VMAJ@ -I${includedir}/esoap_model-cxx-@VMAJ@
|
|
@ -0,0 +1,12 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: Esoap-model
|
||||||
|
Description: SOAP model for EFL
|
||||||
|
Requires.private: @requirements_pc_esoap_model@
|
||||||
|
Version: @VERSION@
|
||||||
|
Libs: -L${libdir} -lesoap_model @requirements_public_libs_esoap_model@
|
||||||
|
Libs.private: @requirements_libs_esoap_model@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/esoap_model-@VMAJ@
|
|
@ -60,6 +60,9 @@ include Makefile_Edje.am
|
||||||
include Makefile_Emotion.am
|
include Makefile_Emotion.am
|
||||||
include Makefile_Ethumb.am
|
include Makefile_Ethumb.am
|
||||||
include Makefile_Ethumb_Client.am
|
include Makefile_Ethumb_Client.am
|
||||||
|
include Makefile_Ejson.am
|
||||||
|
include Makefile_EflatXmlModel.am
|
||||||
|
include Makefile_EsoapModel.am
|
||||||
|
|
||||||
include Makefile_Eina_Cxx.am
|
include Makefile_Eina_Cxx.am
|
||||||
include Makefile_Ecore_Cxx.am
|
include Makefile_Ecore_Cxx.am
|
||||||
|
@ -71,6 +74,9 @@ include Makefile_Efl_Cxx.am
|
||||||
include Makefile_Edje_Cxx.am
|
include Makefile_Edje_Cxx.am
|
||||||
include Makefile_Evas_Cxx.am
|
include Makefile_Evas_Cxx.am
|
||||||
include Makefile_Eio_Cxx.am
|
include Makefile_Eio_Cxx.am
|
||||||
|
include Makefile_Ejson_Cxx.am
|
||||||
|
include Makefile_EflatXmlModel_Cxx.am
|
||||||
|
include Makefile_EsoapModel_Cxx.am
|
||||||
|
|
||||||
include Makefile_Elua.am
|
include Makefile_Elua.am
|
||||||
include Makefile_Elocation.am
|
include Makefile_Elocation.am
|
||||||
|
|
|
@ -40,6 +40,7 @@ lib_LTLIBRARIES += lib/efl/libefl.la
|
||||||
|
|
||||||
lib_efl_libefl_la_SOURCES = \
|
lib_efl_libefl_la_SOURCES = \
|
||||||
lib/efl/interfaces/efl_interfaces_main.c \
|
lib/efl/interfaces/efl_interfaces_main.c \
|
||||||
|
lib/efl/interfaces/efl_model_common.c \
|
||||||
lib/efl/interfaces/efl_gfx_shape.c
|
lib/efl/interfaces/efl_gfx_shape.c
|
||||||
|
|
||||||
lib_efl_libefl_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_srcdir)/src/lib/efl @EFL_CFLAGS@ -DEFL_GFX_FILTER_BETA
|
lib_efl_libefl_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_srcdir)/src/lib/efl @EFL_CFLAGS@ -DEFL_GFX_FILTER_BETA
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
### Library
|
||||||
|
|
||||||
|
eflat_xml_model_eolian_files = \
|
||||||
|
lib/eflat_xml_model/eflat_xml_model.eo
|
||||||
|
|
||||||
|
eflat_xml_model_eolian_c = $(eflat_xml_model_eolian_files:%.eo=%.eo.c)
|
||||||
|
eflat_xml_model_eolian_h = $(eflat_xml_model_eolian_files:%.eo=%.eo.h)
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
$(eflat_xml_model_eolian_c) \
|
||||||
|
$(eflat_xml_model_eolian_h)
|
||||||
|
|
||||||
|
CLEANFILES += \
|
||||||
|
$(eflat_xml_model_eolian_c) \
|
||||||
|
$(eflat_xml_model_eolian_h)
|
||||||
|
|
||||||
|
eflat_xml_modeleolianfilesdir = $(datadir)/eolian/include/eflat_xml_model-@VMAJ@
|
||||||
|
eflat_xml_modeleolianfiles_DATA = \
|
||||||
|
$(eflat_xml_model_eolian_files)
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
${eflat_xml_modeleolianfiles_DATA}
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += lib/eflat_xml_model/libeflat_xml_model.la
|
||||||
|
|
||||||
|
installed_eflat_xml_modelmainheadersdir = $(includedir)/eflat_xml_model-@VMAJ@
|
||||||
|
dist_installed_eflat_xml_modelmainheaders_DATA = \
|
||||||
|
lib/eflat_xml_model/Eflat_Xml_Model.h
|
||||||
|
|
||||||
|
nodist_installed_eflat_xml_modelmainheaders_DATA = \
|
||||||
|
$(eflat_xml_model_eolian_h)
|
||||||
|
|
||||||
|
lib_eflat_xml_model_libeflat_xml_model_la_SOURCES = \
|
||||||
|
lib/eflat_xml_model/eflat_xml_model_private.h \
|
||||||
|
lib/eflat_xml_model/eflat_xml_model.c
|
||||||
|
|
||||||
|
lib_eflat_xml_model_libeflat_xml_model_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EFLAT_XML_MODEL_CFLAGS@ @EFL_CFLAGS@
|
||||||
|
lib_eflat_xml_model_libeflat_xml_model_la_LIBADD = @EFLAT_XML_MODEL_LIBS@ @EFL_LIBS@
|
||||||
|
lib_eflat_xml_model_libeflat_xml_model_la_DEPENDENCIES = @EFLAT_XML_MODEL_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
|
||||||
|
lib_eflat_xml_model_libeflat_xml_model_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
check_PROGRAMS += tests/eflat_xml_model/eflat_xml_model_suite
|
||||||
|
TESTS += tests/eflat_xml_model/eflat_xml_model_suite
|
||||||
|
|
||||||
|
tests_eflat_xml_model_eflat_xml_model_suite_SOURCES = \
|
||||||
|
tests/eflat_xml_model/eflat_xml_model_suite.c \
|
||||||
|
tests/eflat_xml_model/eflat_xml_model_suite.h \
|
||||||
|
tests/eflat_xml_model/eflat_xml_model_test_eflat_xml_model.c \
|
||||||
|
tests/eflat_xml_model/eflat_xml_model_test_eflat_xml_model.h
|
||||||
|
|
||||||
|
tests_eflat_xml_model_eflat_xml_model_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_SRC_DIR=\"$(abs_top_srcdir)/src/tests/eflat_xml_model\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eflat_xml_model\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@EFLAT_XML_MODEL_CFLAGS@ @EFL_CFLAGS@
|
||||||
|
|
||||||
|
tests_eflat_xml_model_eflat_xml_model_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ \
|
||||||
|
@USE_EFLAT_XML_MODEL_LIBS@ \
|
||||||
|
@USE_EFL_LIBS@
|
||||||
|
|
||||||
|
tests_eflat_xml_model_eflat_xml_model_suite_DEPENDENCIES = \
|
||||||
|
@USE_EFLAT_XML_MODEL_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST += $(EFLAT_XML_MODEL_DATA_FILES)
|
||||||
|
|
||||||
|
if HAVE_ELUA
|
||||||
|
|
||||||
|
eflat_xml_model_eolian_lua = $(eflat_xml_model_eolian_files:%.eo=%.eo.lua)
|
||||||
|
|
||||||
|
generated_eflat_xml_model_lua_all = $(eflat_xml_model_eolian_lua)
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_eflat_xml_model_lua_all)
|
||||||
|
|
||||||
|
installed_eflat_xml_modelluadir = $(datadir)/elua/modules/eflat_xml_model
|
||||||
|
nodist_installed_eflat_xml_modellua_DATA = $(generated_eflat_xml_model_lua_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
if HAVE_CXX11
|
||||||
|
|
||||||
|
### Generated headers
|
||||||
|
|
||||||
|
generated_eflat_xml_model_cxx_bindings = $(eflat_xml_model_eolian_files:%.eo=%.eo.hh)
|
||||||
|
|
||||||
|
lib/eflat_xml_model/Eflat_xml_model.hh: $(generated_eflat_xml_model_cxx_bindings)
|
||||||
|
@echo @ECHO_E@ "#ifndef EFL_CXX_EFLAT_XML_MODEL_HH\n#define EFL_CXX_EFLAT_XML_MODEL_HH\n" > $(top_builddir)/src/lib/eflat_xml_model/Eflat_xml_model.hh
|
||||||
|
@echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/eflat_xml_model/Eflat_xml_model.hh
|
||||||
|
@for i in $(generated_eflat_xml_model_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/eflat_xml_model/Eflat_xml_model.hh; done
|
||||||
|
@echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/eflat_xml_model/Eflat_xml_model.hh
|
||||||
|
|
||||||
|
generated_eflat_xml_model_cxx_all = \
|
||||||
|
$(generated_eflat_xml_model_cxx_bindings) \
|
||||||
|
lib/eflat_xml_model/Eflat_xml_model.hh
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_eflat_xml_model_cxx_all)
|
||||||
|
|
||||||
|
installed_eflat_xml_modelcxxmainheadersdir = $(includedir)/eflat_xml_model-cxx-@VMAJ@/
|
||||||
|
nodist_installed_eflat_xml_modelcxxmainheaders_DATA = $(generated_eflat_xml_model_cxx_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -0,0 +1,86 @@
|
||||||
|
### Library
|
||||||
|
|
||||||
|
ejson_eolian_files = \
|
||||||
|
lib/ejson/ejson_model.eo
|
||||||
|
|
||||||
|
ejson_eolian_c = $(ejson_eolian_files:%.eo=%.eo.c)
|
||||||
|
ejson_eolian_h = $(ejson_eolian_files:%.eo=%.eo.h)
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
$(ejson_eolian_c) \
|
||||||
|
$(ejson_eolian_h)
|
||||||
|
|
||||||
|
CLEANFILES += \
|
||||||
|
$(ejson_eolian_c) \
|
||||||
|
$(ejson_eolian_h)
|
||||||
|
|
||||||
|
ejsoneolianfilesdir = $(datadir)/eolian/include/ejson-@VMAJ@
|
||||||
|
ejsoneolianfiles_DATA = \
|
||||||
|
$(ejson_eolian_files)
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
${ejsoneolianfiles_DATA}
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += lib/ejson/libejson.la
|
||||||
|
|
||||||
|
installed_ejsonmainheadersdir = $(includedir)/ejson-@VMAJ@
|
||||||
|
dist_installed_ejsonmainheaders_DATA = \
|
||||||
|
lib/ejson/Ejson.h
|
||||||
|
|
||||||
|
nodist_installed_ejsonmainheaders_DATA = \
|
||||||
|
$(ejson_eolian_h)
|
||||||
|
|
||||||
|
lib_ejson_libejson_la_SOURCES = \
|
||||||
|
lib/ejson/ejson_main.c \
|
||||||
|
lib/ejson/ejson_private.h \
|
||||||
|
lib/ejson/ejson_model.c \
|
||||||
|
lib/ejson/ejson_model_private.h
|
||||||
|
|
||||||
|
lib_ejson_libejson_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EJSON_CFLAGS@ @EFL_CFLAGS@
|
||||||
|
lib_ejson_libejson_la_LIBADD = @EJSON_LIBS@ @EFL_LIBS@
|
||||||
|
lib_ejson_libejson_la_DEPENDENCIES = @EJSON_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
|
||||||
|
lib_ejson_libejson_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
check_PROGRAMS += tests/ejson/ejson_suite
|
||||||
|
TESTS += tests/ejson/ejson_suite
|
||||||
|
|
||||||
|
tests_ejson_ejson_suite_SOURCES = \
|
||||||
|
tests/ejson/ejson_suite.c \
|
||||||
|
tests/ejson/ejson_suite.h \
|
||||||
|
tests/ejson/ejson_test_ejson_model.c \
|
||||||
|
tests/ejson/ejson_test_ejson_model.h
|
||||||
|
|
||||||
|
tests_ejson_ejson_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_SRC_DIR=\"$(abs_top_srcdir)/src/tests/ejson\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(abs_top_builddir)/src/tests/ejson\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@EJSON_CFLAGS@ @EFL_CFLAGS@
|
||||||
|
|
||||||
|
tests_ejson_ejson_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ \
|
||||||
|
@USE_EJSON_LIBS@ \
|
||||||
|
@USE_EFL_LIBS@
|
||||||
|
|
||||||
|
tests_ejson_ejson_suite_DEPENDENCIES = \
|
||||||
|
@USE_EJSON_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST += $(EJSON_DATA_FILES)
|
||||||
|
|
||||||
|
if HAVE_ELUA
|
||||||
|
|
||||||
|
ejson_eolian_lua = $(ejson_eolian_files:%.eo=%.eo.lua)
|
||||||
|
|
||||||
|
generated_ejson_lua_all = $(ejson_eolian_lua)
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_ejson_lua_all)
|
||||||
|
|
||||||
|
installed_ejsonluadir = $(datadir)/elua/modules/ejson
|
||||||
|
nodist_installed_ejsonlua_DATA = $(generated_ejson_lua_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
if HAVE_CXX11
|
||||||
|
|
||||||
|
### Generated headers
|
||||||
|
|
||||||
|
generated_ejson_cxx_bindings = $(ejson_eolian_files:%.eo=%.eo.hh)
|
||||||
|
|
||||||
|
lib/ejson/Ejson.hh: $(generated_ejson_cxx_bindings)
|
||||||
|
@echo @ECHO_E@ "#ifndef EFL_CXX_EJSON_HH\n#define EFL_CXX_EJSON_HH\n" > $(top_builddir)/src/lib/ejson/Ejson.hh
|
||||||
|
@echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/ejson/Ejson.hh
|
||||||
|
@for i in $(generated_ejson_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/ejson/Ejson.hh; done
|
||||||
|
@echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/ejson/Ejson.hh
|
||||||
|
|
||||||
|
generated_ejson_cxx_all = \
|
||||||
|
$(generated_ejson_cxx_bindings) \
|
||||||
|
lib/ejson/Ejson.hh
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_ejson_cxx_all)
|
||||||
|
|
||||||
|
installed_ejsoncxxmainheadersdir = $(includedir)/ejson-cxx-@VMAJ@/
|
||||||
|
nodist_installed_ejsoncxxmainheaders_DATA = $(generated_ejson_cxx_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -1,6 +1,31 @@
|
||||||
|
|
||||||
### Library
|
### Library
|
||||||
|
|
||||||
|
eldbus_eolian_files = \
|
||||||
|
lib/eldbus/eldbus_model_connection.eo \
|
||||||
|
lib/eldbus/eldbus_model_object.eo \
|
||||||
|
lib/eldbus/eldbus_model_proxy.eo \
|
||||||
|
lib/eldbus/eldbus_model_method.eo \
|
||||||
|
lib/eldbus/eldbus_model_arguments.eo \
|
||||||
|
lib/eldbus/eldbus_model_signal.eo
|
||||||
|
|
||||||
|
eldbus_eolian_c = $(eldbus_eolian_files:%.eo=%.eo.c)
|
||||||
|
eldbus_eolian_h = $(eldbus_eolian_files:%.eo=%.eo.h)
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
$(eldbus_eolian_c) \
|
||||||
|
$(eldbus_eolian_h)
|
||||||
|
|
||||||
|
CLEANFILES += \
|
||||||
|
$(eldbus_eolian_c) \
|
||||||
|
$(eldbus_eolian_h)
|
||||||
|
|
||||||
|
eldbuseolianfilesdir = $(datadir)/eolian/include/eldbus-@VMAJ@
|
||||||
|
eldbuseolianfiles_DATA = $(eldbus_eolian_files)
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
${eldbuseolianfiles_DATA}
|
||||||
|
|
||||||
lib_LTLIBRARIES += lib/eldbus/libeldbus.la
|
lib_LTLIBRARIES += lib/eldbus/libeldbus.la
|
||||||
|
|
||||||
installed_eldbusmainheadersdir = $(includedir)/eldbus-@VMAJ@
|
installed_eldbusmainheadersdir = $(includedir)/eldbus-@VMAJ@
|
||||||
|
@ -17,6 +42,8 @@ lib/eldbus/eldbus_signal_handler.h \
|
||||||
lib/eldbus/eldbus_message_helper.h \
|
lib/eldbus/eldbus_message_helper.h \
|
||||||
lib/eldbus/eldbus_message_eina_value.h
|
lib/eldbus/eldbus_message_eina_value.h
|
||||||
|
|
||||||
|
nodist_installed_eldbusmainheaders_DATA = $(eldbus_eolian_h)
|
||||||
|
|
||||||
lib_eldbus_libeldbus_la_SOURCES = \
|
lib_eldbus_libeldbus_la_SOURCES = \
|
||||||
lib/eldbus/eldbus_private.h \
|
lib/eldbus/eldbus_private.h \
|
||||||
lib/eldbus/eldbus_private_types.h \
|
lib/eldbus/eldbus_private_types.h \
|
||||||
|
@ -30,13 +57,20 @@ lib/eldbus/eldbus_service.c \
|
||||||
lib/eldbus/eldbus_signal_handler.c \
|
lib/eldbus/eldbus_signal_handler.c \
|
||||||
lib/eldbus/eldbus_message_helper.c \
|
lib/eldbus/eldbus_message_helper.c \
|
||||||
lib/eldbus/eldbus_message_to_eina_value.c \
|
lib/eldbus/eldbus_message_to_eina_value.c \
|
||||||
lib/eldbus/eldbus_message_from_eina_value.c
|
lib/eldbus/eldbus_message_from_eina_value.c \
|
||||||
|
lib/eldbus/eldbus_model_connection.c \
|
||||||
|
lib/eldbus/eldbus_model_object.c \
|
||||||
|
lib/eldbus/eldbus_model_proxy.c \
|
||||||
|
lib/eldbus/eldbus_model_method.c \
|
||||||
|
lib/eldbus/eldbus_model_arguments.c \
|
||||||
|
lib/eldbus/eldbus_model_signal.c \
|
||||||
|
lib/eldbus/eldbus_introspection.c
|
||||||
|
|
||||||
lib_eldbus_libeldbus_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
lib_eldbus_libeldbus_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
-include $(top_builddir)/config.h \
|
-include $(top_builddir)/config.h \
|
||||||
@ELDBUS_CFLAGS@
|
@ELDBUS_CFLAGS@ @EFL_CFLAGS@
|
||||||
lib_eldbus_libeldbus_la_LIBADD = @ELDBUS_LIBS@
|
lib_eldbus_libeldbus_la_LIBADD = @ELDBUS_LIBS@ @EFL_LIBS@
|
||||||
lib_eldbus_libeldbus_la_DEPENDENCIES = @ELDBUS_INTERNAL_LIBS@
|
lib_eldbus_libeldbus_la_DEPENDENCIES = @ELDBUS_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
|
||||||
lib_eldbus_libeldbus_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
lib_eldbus_libeldbus_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
### Binary
|
### Binary
|
||||||
|
@ -74,12 +108,20 @@ TESTS += tests/eldbus/eldbus_suite
|
||||||
tests_eldbus_eldbus_suite_SOURCES = \
|
tests_eldbus_eldbus_suite_SOURCES = \
|
||||||
tests/eldbus/eldbus_suite.c \
|
tests/eldbus/eldbus_suite.c \
|
||||||
tests/eldbus/eldbus_test_eldbus_init.c \
|
tests/eldbus/eldbus_test_eldbus_init.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model_connection.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model_object.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model_proxy.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model_method.c \
|
||||||
|
tests/eldbus/eldbus_test_eldbus_model_signal.c \
|
||||||
|
tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c \
|
||||||
|
tests/eldbus/eldbus_fake_server.c \
|
||||||
tests/eldbus/eldbus_suite.h
|
tests/eldbus/eldbus_suite.h
|
||||||
|
|
||||||
tests_eldbus_eldbus_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl @CHECK_CFLAGS@ @ELDBUS_CFLAGS@ \
|
tests_eldbus_eldbus_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl @CHECK_CFLAGS@ @ELDBUS_CFLAGS@ \
|
||||||
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eldbus\"
|
@EFL_CFLAGS@ -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eldbus\"
|
||||||
|
|
||||||
tests_eldbus_eldbus_suite_LDADD = @CHECK_LIBS@ @USE_ELDBUS_LIBS@
|
tests_eldbus_eldbus_suite_LDADD = @CHECK_LIBS@ @USE_ELDBUS_LIBS@ @USE_EFL_LIBS@
|
||||||
tests_eldbus_eldbus_suite_DEPENDENCIES = @USE_ELDBUS_INTERNAL_LIBS@
|
tests_eldbus_eldbus_suite_DEPENDENCIES = @USE_ELDBUS_INTERNAL_LIBS@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,6 +1,31 @@
|
||||||
|
|
||||||
if HAVE_CXX11
|
if HAVE_CXX11
|
||||||
|
|
||||||
|
### Generated headers
|
||||||
|
|
||||||
|
generated_eldbus_cxx_bindings = \
|
||||||
|
lib/eldbus/eldbus_model_connection.eo.hh \
|
||||||
|
lib/eldbus/eldbus_model_object.eo.hh \
|
||||||
|
lib/eldbus/eldbus_model_proxy.eo.hh \
|
||||||
|
lib/eldbus/eldbus_model_method.eo.hh \
|
||||||
|
lib/eldbus/eldbus_model_arguments.eo.hh \
|
||||||
|
lib/eldbus/eldbus_model_signal.eo.hh
|
||||||
|
|
||||||
|
lib/eldbus/Eldbus_Model.hh: $(generated_eldbus_cxx_bindings)
|
||||||
|
@echo @ECHO_E@ "#ifndef EFL_CXX_ELDBUS_MODEL_HH\n#define EFL_CXX_ELDBUS_MODEL_HH\n" > $(top_builddir)/src/lib/eldbus/Eldbus_Model.hh
|
||||||
|
@echo @ECHO_E@ "#include <Eldbus_Model.h>" >> $(top_builddir)/src/lib/eldbus/Eldbus_Model.hh
|
||||||
|
@echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/eldbus/Eldbus_Model.hh
|
||||||
|
@for i in $(generated_eldbus_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/eldbus/Eldbus_Model.hh; done
|
||||||
|
@echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/eldbus/Eldbus_Model.hh
|
||||||
|
|
||||||
|
generated_eldbus_cxx_all = \
|
||||||
|
$(generated_eldbus_cxx_bindings) \
|
||||||
|
lib/eldbus/Eldbus_Model.hh
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_eldbus_cxx_all)
|
||||||
|
|
||||||
|
nodist_installed_eldbuscxxmainheaders_DATA = $(generated_eldbus_cxx_all)
|
||||||
|
|
||||||
### Library
|
### Library
|
||||||
|
|
||||||
installed_eldbuscxxmainheadersdir = $(includedir)/eldbus_cxx-@VMAJ@
|
installed_eldbuscxxmainheadersdir = $(includedir)/eldbus_cxx-@VMAJ@
|
||||||
|
|
|
@ -17,7 +17,7 @@ lib/elocation/gen/eldbus_geo_clue2_client.c \
|
||||||
lib/elocation/gen/eldbus_geo_clue2_location.c \
|
lib/elocation/gen/eldbus_geo_clue2_location.c \
|
||||||
lib/elocation/gen/eldbus_geo_clue2_manager.c
|
lib/elocation/gen/eldbus_geo_clue2_manager.c
|
||||||
|
|
||||||
lib_elocation_libelocation_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELOCATION_CFLAGS@
|
lib_elocation_libelocation_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELOCATION_CFLAGS@ @EFL_CFLAGS@
|
||||||
lib_elocation_libelocation_la_LIBADD = @ELOCATION_LIBS@
|
lib_elocation_libelocation_la_LIBADD = @ELOCATION_LIBS@
|
||||||
lib_elocation_libelocation_la_DEPENDENCIES = @ELOCATION_INTERNAL_LIBS@
|
lib_elocation_libelocation_la_DEPENDENCIES = @ELOCATION_INTERNAL_LIBS@
|
||||||
lib_elocation_libelocation_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
lib_elocation_libelocation_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
### Library
|
||||||
|
|
||||||
|
esoap_model_eolian_files = \
|
||||||
|
lib/esoap_model/esoap_model.eo
|
||||||
|
|
||||||
|
esoap_model_eolian_c = $(esoap_model_eolian_files:%.eo=%.eo.c)
|
||||||
|
esoap_model_eolian_h = $(esoap_model_eolian_files:%.eo=%.eo.h)
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
$(esoap_model_eolian_c) \
|
||||||
|
$(esoap_model_eolian_h)
|
||||||
|
|
||||||
|
CLEANFILES += \
|
||||||
|
$(esoap_model_eolian_c) \
|
||||||
|
$(esoap_model_eolian_h)
|
||||||
|
|
||||||
|
esoap_modeleolianfilesdir = $(datadir)/eolian/include/esoap_model-@VMAJ@
|
||||||
|
esoap_modeleolianfiles_DATA = \
|
||||||
|
$(esoap_model_eolian_files)
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
${esoap_modeleolianfiles_DATA}
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += lib/esoap_model/libesoap_model.la
|
||||||
|
|
||||||
|
installed_esoap_modelmainheadersdir = $(includedir)/esoap_model-@VMAJ@
|
||||||
|
dist_installed_esoap_modelmainheaders_DATA = \
|
||||||
|
lib/esoap_model/Esoap_Model.h
|
||||||
|
|
||||||
|
nodist_installed_esoap_modelmainheaders_DATA = \
|
||||||
|
$(esoap_model_eolian_h)
|
||||||
|
|
||||||
|
lib_esoap_model_libesoap_model_la_SOURCES = \
|
||||||
|
lib/esoap_model/esoap_model_private.h \
|
||||||
|
lib/esoap_model/esoap_model.c
|
||||||
|
|
||||||
|
lib_esoap_model_libesoap_model_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ESOAP_MODEL_CFLAGS@ @EFL_CFLAGS@
|
||||||
|
lib_esoap_model_libesoap_model_la_LIBADD = @ESOAP_MODEL_LIBS@ @EFL_LIBS@
|
||||||
|
lib_esoap_model_libesoap_model_la_DEPENDENCIES = @ESOAP_MODEL_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
|
||||||
|
lib_esoap_model_libesoap_model_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
check_PROGRAMS += tests/esoap_model/esoap_model_suite
|
||||||
|
TESTS += tests/esoap_model/esoap_model_suite
|
||||||
|
|
||||||
|
tests_esoap_model_esoap_model_suite_SOURCES = \
|
||||||
|
tests/esoap_model/esoap_model_suite.c \
|
||||||
|
tests/esoap_model/esoap_model_suite.h \
|
||||||
|
tests/esoap_model/esoap_model_test_esoap_model.c \
|
||||||
|
tests/esoap_model/esoap_model_test_esoap_model.h
|
||||||
|
|
||||||
|
tests_esoap_model_esoap_model_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_SRC_DIR=\"$(abs_top_srcdir)/src/tests/esoap_model\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(abs_top_builddir)/src/tests/esoap_model\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@ESOAP_MODEL_CFLAGS@ @EFL_CFLAGS@ @ECORE_CON_CFLAGS@
|
||||||
|
|
||||||
|
tests_esoap_model_esoap_model_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ \
|
||||||
|
@USE_ESOAP_MODEL_LIBS@ \
|
||||||
|
@USE_EFL_LIBS@ @USE_ECORE_CON_LIBS@
|
||||||
|
|
||||||
|
tests_esoap_model_esoap_model_suite_DEPENDENCIES = \
|
||||||
|
@USE_ESOAP_MODEL_INTERNAL_LIBS@ @USE_ECORE_CON_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST += $(ESOAP_MODEL_DATA_FILES)
|
||||||
|
|
||||||
|
if HAVE_ELUA
|
||||||
|
|
||||||
|
esoap_model_eolian_lua = $(esoap_model_eolian_files:%.eo=%.eo.lua)
|
||||||
|
|
||||||
|
generated_esoap_model_lua_all = $(esoap_model_eolian_lua)
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_esoap_model_lua_all)
|
||||||
|
|
||||||
|
installed_esoap_modelluadir = $(datadir)/elua/modules/esoap_model
|
||||||
|
nodist_installed_esoap_modellua_DATA = $(generated_esoap_model_lua_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
if HAVE_CXX11
|
||||||
|
|
||||||
|
### Generated headers
|
||||||
|
|
||||||
|
generated_esoap_model_cxx_bindings = $(esoap_model_eolian_files:%.eo=%.eo.hh)
|
||||||
|
|
||||||
|
lib/esoap_model/Esoap_Model.hh: $(generated_esoap_model_cxx_bindings)
|
||||||
|
@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
|
||||||
|
@echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh
|
||||||
|
@for i in $(generated_esoap_model_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh; done
|
||||||
|
@echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/esoap_model/Esoap_Model.hh
|
||||||
|
|
||||||
|
generated_esoap_model_cxx_all = \
|
||||||
|
$(generated_esoap_model_cxx_bindings) \
|
||||||
|
lib/esoap_model/Esoap_Model.hh
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_esoap_model_cxx_all)
|
||||||
|
|
||||||
|
installed_esoap_modelcxxmainheadersdir = $(includedir)/esoap_model-cxx-@VMAJ@/
|
||||||
|
nodist_installed_esoap_modelcxxmainheaders_DATA = $(generated_esoap_model_cxx_all)
|
||||||
|
|
||||||
|
endif
|
|
@ -139,7 +139,7 @@ typedef enum _Efl_Gfx_Fill_Spread
|
||||||
#ifdef EFL_BETA_API_SUPPORT
|
#ifdef EFL_BETA_API_SUPPORT
|
||||||
|
|
||||||
#include <Efl_Model_Common.h>
|
#include <Efl_Model_Common.h>
|
||||||
|
|
||||||
/* Interfaces */
|
/* Interfaces */
|
||||||
#include "interfaces/efl_control.eo.h"
|
#include "interfaces/efl_control.eo.h"
|
||||||
#include "interfaces/efl_file.eo.h"
|
#include "interfaces/efl_file.eo.h"
|
||||||
|
@ -147,7 +147,6 @@ typedef enum _Efl_Gfx_Fill_Spread
|
||||||
#include "interfaces/efl_player.eo.h"
|
#include "interfaces/efl_player.eo.h"
|
||||||
#include "interfaces/efl_text.eo.h"
|
#include "interfaces/efl_text.eo.h"
|
||||||
#include "interfaces/efl_text_properties.eo.h"
|
#include "interfaces/efl_text_properties.eo.h"
|
||||||
#include "interfaces/efl_model_base.eo.h"
|
|
||||||
|
|
||||||
EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED;
|
EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED;
|
||||||
EAPI extern const Eo_Event_Description _EFL_GFX_PATH_CHANGED;
|
EAPI extern const Eo_Event_Description _EFL_GFX_PATH_CHANGED;
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
#ifndef _EFL_MODEL_COMMON_H
|
|
||||||
#define _EFL_MODEL_COMMON_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct _Efl_Model_Children_Event
|
* @struct _Efl_Model_Children_Event
|
||||||
* Every time a child id added the event
|
* Every time a child id added the event
|
||||||
|
@ -31,8 +24,79 @@ struct _Efl_Model_Children_Event
|
||||||
*/
|
*/
|
||||||
typedef struct _Efl_Model_Children_Event Efl_Model_Children_Event;
|
typedef struct _Efl_Model_Children_Event Efl_Model_Children_Event;
|
||||||
|
|
||||||
|
#include "interfaces/efl_model_base.eo.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the new load status signaling an event if changed
|
||||||
|
*
|
||||||
|
* @param model The model to call the event @c EFL_MODEL_EVENT_LOAD_STATUS
|
||||||
|
* @param load The load status to be changed
|
||||||
|
* @param status The new status
|
||||||
|
*/
|
||||||
|
EAPI void efl_model_load_set(Efl_Model_Base *model, Efl_Model_Load *load, Efl_Model_Load_Status status) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slices a list
|
||||||
|
*
|
||||||
|
* If the @p start and @p count are 0, a new accessor of the entire list is returned
|
||||||
|
*
|
||||||
|
* @param list The list to get the slice
|
||||||
|
* @param start The nth element to start the slice
|
||||||
|
* @param count The number of elements
|
||||||
|
* @return The accessor to the sliced elements or @c NULL if error
|
||||||
|
*/
|
||||||
|
EAPI Eina_Accessor *efl_model_list_slice(Eina_List *list, unsigned start, unsigned count) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Notifies an error with an @c EFL_MODEL_EVENT_LOAD_STATUS
|
||||||
|
*
|
||||||
|
* @param model The model to be notified
|
||||||
|
*/
|
||||||
|
EAPI void efl_model_error_notify(Efl_Model_Base *model) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Notifies a property changed event with an @c EFL_MODEL_EVENT_PROPERTIES_CHANGED
|
||||||
|
*
|
||||||
|
* @param model The model to be notified
|
||||||
|
* @param property The changed property
|
||||||
|
*/
|
||||||
|
EAPI void efl_model_property_changed_notify(Efl_Model_Base *model, const char *property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Notifies a property invalidated event with an @c EFL_MODEL_EVENT_PROPERTIES_CHANGED
|
||||||
|
*
|
||||||
|
* @param model The model to be notified
|
||||||
|
* @param property The invalidated property
|
||||||
|
*/
|
||||||
|
EAPI void efl_model_property_invalidated_notify(Efl_Model_Base *model, const char *property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback to setup a member of @c Eina_Value_Struct
|
||||||
|
*
|
||||||
|
* @param data The user data
|
||||||
|
* @param index The member index
|
||||||
|
* @param member The member to fill its name and type. Must use @c Eina_Stringshare for name.
|
||||||
|
*/
|
||||||
|
typedef void (*Efl_Model_Value_Struct_Member_Setup_Cb)(void *data, int index, Eina_Value_Struct_Member *member);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a new struct description
|
||||||
|
*
|
||||||
|
* @param member_count The number of struct members
|
||||||
|
* @param setup_cb The callback to setup struct members
|
||||||
|
* @param data The user data
|
||||||
|
* @return Returns the struct description
|
||||||
|
*/
|
||||||
|
EAPI Eina_Value_Struct_Desc *efl_model_value_struct_desc_new(unsigned int member_count, Efl_Model_Value_Struct_Member_Setup_Cb setup_cb, void *data) EINA_ARG_NONNULL(2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Frees the memory allocated to the struct description.
|
||||||
|
*
|
||||||
|
* @param desc The struct description. If @c NULL, the function returns immediately.
|
||||||
|
*/
|
||||||
|
EAPI void efl_model_value_struct_desc_free(Eina_Value_Struct_Desc *desc);
|
||||||
|
|
||||||
|
EAPI void efl_model_property_changed_notify(Efl_Model_Base *model, const char *property);
|
||||||
|
|
||||||
|
EAPI void efl_model_property_invalidated_notify(Efl_Model_Base *model, const char *property);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Efl.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_load_set(Efl_Model_Base *model, Efl_Model_Load *load, Efl_Model_Load_Status status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load new_load = {.status = status};
|
||||||
|
|
||||||
|
if ((load->status & (EFL_MODEL_LOAD_STATUS_LOADED | EFL_MODEL_LOAD_STATUS_LOADING)) &&
|
||||||
|
(new_load.status & (EFL_MODEL_LOAD_STATUS_LOADED | EFL_MODEL_LOAD_STATUS_LOADING)))
|
||||||
|
{
|
||||||
|
// Merge status
|
||||||
|
new_load.status = load->status | new_load.status;
|
||||||
|
|
||||||
|
// Removes incompatible statuses (LOADING vs LOADED)
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES;
|
||||||
|
break;
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES;
|
||||||
|
break;
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN;
|
||||||
|
break;
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN;
|
||||||
|
break;
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADED:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADING;
|
||||||
|
break;
|
||||||
|
case EFL_MODEL_LOAD_STATUS_LOADING:
|
||||||
|
new_load.status &= ~EFL_MODEL_LOAD_STATUS_LOADED;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (load->status != new_load.status)
|
||||||
|
{
|
||||||
|
load->status = new_load.status;
|
||||||
|
eo_do(model, eo_event_callback_call(EFL_MODEL_BASE_EVENT_LOAD_STATUS, load));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Accessor *
|
||||||
|
efl_model_list_slice(Eina_List *list, unsigned start, unsigned count)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "efl_model_list_slice\n");
|
||||||
|
if ((start == 0) && (count == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "efl_model_list_slice start == 0 count == 0\n");
|
||||||
|
return eina_list_accessor_new(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_List *nth_list = eina_list_nth_list(list, (start - 1));
|
||||||
|
if (!nth_list)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Eina_List *it, *result = NULL;
|
||||||
|
const void *data;
|
||||||
|
EINA_LIST_FOREACH(nth_list, it, data)
|
||||||
|
{
|
||||||
|
result = eina_list_append(result, data);
|
||||||
|
if (eina_list_count(result) == count)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return eina_list_accessor_new(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_error_notify(Efl_Model_Base *model)
|
||||||
|
{
|
||||||
|
Efl_Model_Load load = {.status = EFL_MODEL_LOAD_STATUS_ERROR};
|
||||||
|
eo_do(model, eo_event_callback_call(EFL_MODEL_BASE_EVENT_LOAD_STATUS, &load));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
efl_model_property_changed_notify(Efl_Model_Base *model, const char *property)
|
||||||
|
{
|
||||||
|
Eina_Array *changed_properties = eina_array_new(1);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(changed_properties);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(changed_properties, property);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
Efl_Model_Property_Event evt = {.changed_properties = changed_properties};
|
||||||
|
eo_do(model, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt));
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_array_free(changed_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
efl_model_property_invalidated_notify(Efl_Model_Base *model, const char *property)
|
||||||
|
{
|
||||||
|
Eina_Array *invalidated_properties = eina_array_new(1);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(invalidated_properties);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(invalidated_properties, property);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
Efl_Model_Property_Event evt = {.invalidated_properties = invalidated_properties};
|
||||||
|
eo_do(model, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt));
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_array_free(invalidated_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct _Efl_Model_Value_Struct_Desc
|
||||||
|
{
|
||||||
|
Eina_Value_Struct_Desc base;
|
||||||
|
void *data;
|
||||||
|
Eina_Value_Struct_Member members[];
|
||||||
|
} Efl_Model_Value_Struct_Desc;
|
||||||
|
|
||||||
|
Eina_Value_Struct_Desc *
|
||||||
|
efl_model_value_struct_desc_new(unsigned int member_count, Efl_Model_Value_Struct_Member_Setup_Cb setup_cb, void *data)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(member_count > 0, NULL);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(setup_cb, NULL);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
|
||||||
|
|
||||||
|
Efl_Model_Value_Struct_Desc *desc = malloc(sizeof(Efl_Model_Value_Struct_Desc) + member_count * sizeof(Eina_Value_Struct_Member));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL);
|
||||||
|
|
||||||
|
desc->base.version = EINA_VALUE_STRUCT_DESC_VERSION;
|
||||||
|
desc->base.ops = EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
|
||||||
|
desc->base.members = desc->members;
|
||||||
|
desc->base.member_count = member_count;
|
||||||
|
desc->base.size = 0;
|
||||||
|
desc->data = data;
|
||||||
|
|
||||||
|
unsigned int offset = 0;
|
||||||
|
for (size_t i = 0; i < member_count; ++i)
|
||||||
|
{
|
||||||
|
Eina_Value_Struct_Member *m = (Eina_Value_Struct_Member *)desc->members + i;
|
||||||
|
|
||||||
|
m->offset = offset;
|
||||||
|
setup_cb(data, i, m);
|
||||||
|
|
||||||
|
unsigned int size = m->type->value_size;
|
||||||
|
if (size % sizeof(void *) != 0)
|
||||||
|
size += size - (size % sizeof(void *));
|
||||||
|
|
||||||
|
offset += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc->base.size = offset;
|
||||||
|
return &desc->base;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_value_struct_desc_free(Eina_Value_Struct_Desc *desc)
|
||||||
|
{
|
||||||
|
if (!desc) return;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < desc->member_count; i++)
|
||||||
|
eina_stringshare_del(desc->members[i].name);
|
||||||
|
free(desc);
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
#ifndef EFLAT_XML_H
|
||||||
|
#define EFLAT_XML_H
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Efl_Config.h>
|
||||||
|
|
||||||
|
#ifdef EAPI
|
||||||
|
# undef EAPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifdef EFL_EFLAT_XML_MODEL_BUILD
|
||||||
|
# ifdef DLL_EXPORT
|
||||||
|
# define EAPI __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif /* ! DLL_EXPORT */
|
||||||
|
# else
|
||||||
|
# define EAPI __declspec(dllimport)
|
||||||
|
# endif /* ! EFL_EFLAT_XML_MODEL_BUILD */
|
||||||
|
#else
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# if __GNUC__ >= 4
|
||||||
|
# define EAPI __attribute__ ((visibility("default")))
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
#endif /* ! _WIN32 */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize eflat_xml_model.
|
||||||
|
*
|
||||||
|
* @return 1 or greater on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
EAPI int eflat_xml_model_init(void);
|
||||||
|
/**
|
||||||
|
* @brief Shutdown eflat_xml_model.
|
||||||
|
*
|
||||||
|
* @return 0 if eflat_xml_model shuts down, greater than 0 otherwise.
|
||||||
|
*/
|
||||||
|
EAPI int eflat_xml_model_shutdown(void);
|
||||||
|
|
||||||
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
|
# include <eflat_xml_model.eo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EAPI
|
||||||
|
#define EAPI
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,34 @@
|
||||||
|
class Eflat_Xml.Model (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
constructor {
|
||||||
|
[[Custom Eflat_Xml_Model constructor.
|
||||||
|
@.constructor
|
||||||
|
|
||||||
|
@since 1.13
|
||||||
|
]]
|
||||||
|
params {
|
||||||
|
xml: const(char)*; [[The XML document]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.constructor;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef _EFLAT_XML_MODEL_PRIVATE_H
|
||||||
|
#define _EFLAT_XML_MODEL_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eflat_Xml_Model.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* logging support */
|
||||||
|
extern int _eflat_xml_model_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
typedef struct _Eflat_Xml_Model_Data Eflat_Xml_Model_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eflat_xml_model
|
||||||
|
*/
|
||||||
|
struct _Eflat_Xml_Model_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_Hash *properties_hash;
|
||||||
|
Eina_Simple_XML_Node_Root *root;
|
||||||
|
char *xml;
|
||||||
|
Eina_Value xml_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1652,6 +1652,74 @@ eina_value_struct_member_value_set(Eina_Value *dst, const Eina_Value_Struct_Memb
|
||||||
|
|
||||||
#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
|
#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
|
||||||
|
|
||||||
|
#define EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, retval) \
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type->setup == EINA_VALUE_TYPE_OPTIONAL->setup, retval)
|
||||||
|
|
||||||
|
static inline Eina_Value*
|
||||||
|
eina_value_optional_empty_new()
|
||||||
|
{
|
||||||
|
return eina_value_new(EINA_VALUE_TYPE_OPTIONAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _Eina_Value_Optional_Outer
|
||||||
|
{
|
||||||
|
Eina_Value_Type const* subtype;
|
||||||
|
void* value;
|
||||||
|
};
|
||||||
|
typedef struct _Eina_Value_Optional_Outer Eina_Value_Optional_Outer;
|
||||||
|
|
||||||
|
struct _Eina_Value_Optional_Inner
|
||||||
|
{
|
||||||
|
Eina_Value_Type const* subtype;
|
||||||
|
char value[];
|
||||||
|
};
|
||||||
|
typedef struct _Eina_Value_Optional_Inner Eina_Value_Optional_Inner;
|
||||||
|
|
||||||
|
static inline Eina_Bool
|
||||||
|
eina_value_optional_empty_is(const Eina_Value *value, Eina_Bool *is_empty)
|
||||||
|
{
|
||||||
|
EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, EINA_FALSE);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(is_empty, EINA_FALSE);
|
||||||
|
|
||||||
|
void *mem = eina_value_memory_get(value);
|
||||||
|
if (!mem)
|
||||||
|
return EINA_FALSE;
|
||||||
|
if(2*sizeof(void*) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer* opt = (Eina_Value_Optional_Outer*)mem;
|
||||||
|
*is_empty = !opt->subtype;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*is_empty = ! *(void**)mem;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline const Eina_Value_Type *
|
||||||
|
eina_value_optional_type_get(Eina_Value *value)
|
||||||
|
{
|
||||||
|
EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, (const Eina_Value_Type *)NULL);
|
||||||
|
|
||||||
|
void *mem = eina_value_memory_get(value);
|
||||||
|
if (!mem)
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
if(2*sizeof(void*) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer* opt = (Eina_Value_Optional_Outer*)mem;
|
||||||
|
return opt->subtype;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner* opt = *(Eina_Value_Optional_Inner**)mem;
|
||||||
|
if(!opt)
|
||||||
|
return NULL;
|
||||||
|
return opt->subtype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#undef EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL
|
||||||
|
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
eina_value_type_setup(const Eina_Value_Type *type, void *mem)
|
eina_value_type_setup(const Eina_Value_Type *type, void *mem)
|
||||||
|
|
|
@ -4349,6 +4349,229 @@ static const Eina_Value_Type _EINA_VALUE_TYPE_STRUCT = {
|
||||||
_eina_value_type_struct_pget
|
_eina_value_type_struct_pget
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eina_value_type_optional_setup(const Eina_Value_Type *type EINA_UNUSED, void *mem)
|
||||||
|
{
|
||||||
|
memset(mem, 0, type->value_size);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eina_value_type_optional_flush(const Eina_Value_Type *type EINA_UNUSED, void *mem EINA_UNUSED)
|
||||||
|
{
|
||||||
|
if(sizeof(Eina_Value_Optional_Outer) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer* opt = mem;
|
||||||
|
if(opt->subtype)
|
||||||
|
{
|
||||||
|
if(!eina_value_type_flush(opt->subtype, opt->value))
|
||||||
|
return EINA_FALSE;
|
||||||
|
free(opt->value);
|
||||||
|
memset(mem, 0, sizeof(Eina_Value_Optional_Outer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner* opt = *(void**)mem;
|
||||||
|
if(opt)
|
||||||
|
{
|
||||||
|
if(!eina_value_type_flush(opt->subtype, opt->value))
|
||||||
|
return EINA_FALSE;
|
||||||
|
free(*(void**)mem);
|
||||||
|
*(void**)mem = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eina_value_optional_reset(Eina_Value *value)
|
||||||
|
{
|
||||||
|
void *mem = eina_value_memory_get(value);
|
||||||
|
if (!mem)
|
||||||
|
return EINA_FALSE;
|
||||||
|
return _eina_value_type_optional_flush(EINA_VALUE_TYPE_OPTIONAL, mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Value*
|
||||||
|
eina_value_optional_new(Eina_Value_Type const *subtype,
|
||||||
|
const void* initial_value) EINA_ARG_NONNULL(1, 2)
|
||||||
|
{
|
||||||
|
Eina_Value *value;
|
||||||
|
|
||||||
|
value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));
|
||||||
|
if (!value)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!eina_value_setup(value, EINA_VALUE_TYPE_OPTIONAL))
|
||||||
|
{
|
||||||
|
eina_mempool_free(_eina_value_mp, value);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
if (!eina_value_optional_pset(value, subtype, initial_value))
|
||||||
|
{
|
||||||
|
eina_mempool_free(_eina_value_mp, value);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eina_value_optional_pset(Eina_Value *value,
|
||||||
|
Eina_Value_Type const* subtype,
|
||||||
|
const void *subvalue) EINA_ARG_NONNULL(1, 2, 3)
|
||||||
|
{
|
||||||
|
eina_value_optional_reset(value);
|
||||||
|
|
||||||
|
if(sizeof(Eina_Value_Optional_Outer) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer outer;
|
||||||
|
outer.subtype = subtype;
|
||||||
|
outer.value = malloc(subtype->value_size);
|
||||||
|
eina_value_type_setup(subtype, outer.value);
|
||||||
|
eina_value_type_pset(subtype, outer.value, subvalue);
|
||||||
|
if (!eina_value_pset(value, &outer))
|
||||||
|
{
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner *inner =
|
||||||
|
malloc(sizeof(Eina_Value_Optional_Inner) + subtype->value_size);
|
||||||
|
inner->subtype = subtype;
|
||||||
|
eina_value_type_setup(subtype, inner->value);
|
||||||
|
eina_value_type_pset(subtype, inner->value, subvalue);
|
||||||
|
if (!eina_value_pset(value, &inner))
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eina_value_optional_pget(Eina_Value *value, void *subvalue) EINA_ARG_NONNULL(1, 2, 3)
|
||||||
|
{
|
||||||
|
if(sizeof(Eina_Value_Optional_Outer) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer outer;
|
||||||
|
|
||||||
|
if (!eina_value_pget(value, &outer))
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
if(outer.subtype)
|
||||||
|
eina_value_type_copy(outer.subtype, outer.value, subvalue);
|
||||||
|
else
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner *inner;
|
||||||
|
|
||||||
|
if (!eina_value_pget(value, &inner))
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
if(inner)
|
||||||
|
eina_value_type_copy(inner->subtype, inner->value, subvalue);
|
||||||
|
else
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eina_value_type_optional_copy(const Eina_Value_Type *type EINA_UNUSED, const void *src_raw, void *dst_raw)
|
||||||
|
{
|
||||||
|
if(sizeof(Eina_Value_Optional_Outer) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer const* src = src_raw;
|
||||||
|
Eina_Value_Optional_Outer* dst = dst_raw;
|
||||||
|
if(src->subtype)
|
||||||
|
{
|
||||||
|
dst->subtype = src->subtype;
|
||||||
|
dst->value = malloc(src->subtype->value_size);
|
||||||
|
eina_value_type_copy(src->subtype, src->value, dst->value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memset(dst_raw, 0, sizeof(Eina_Value_Optional_Outer));
|
||||||
|
}
|
||||||
|
else if(src_raw)
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner* src = *(void**)src_raw;
|
||||||
|
Eina_Value_Optional_Inner* dst = *(void**)dst_raw
|
||||||
|
= malloc(sizeof(Eina_Value_Optional_Inner) + src->subtype->value_size);
|
||||||
|
dst->subtype = src->subtype;
|
||||||
|
|
||||||
|
eina_value_type_copy(src->subtype, src->value, dst->value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*(void**)dst_raw = NULL;
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_eina_value_type_optional_compare(const Eina_Value_Type *type EINA_UNUSED, const void *lhs_raw, const void *rhs_raw)
|
||||||
|
{
|
||||||
|
if(sizeof(Eina_Value_Optional_Outer) <= sizeof(Eina_Value_Union))
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Outer const *lhs = lhs_raw
|
||||||
|
, *rhs = rhs_raw;
|
||||||
|
if(!lhs->subtype)
|
||||||
|
return !rhs->subtype ? 0 : -1;
|
||||||
|
else if(!rhs->subtype)
|
||||||
|
return 1;
|
||||||
|
else if(lhs->subtype != rhs->subtype)
|
||||||
|
return lhs->subtype < rhs->subtype ? -1 : 1;
|
||||||
|
else
|
||||||
|
return eina_value_type_compare(lhs->subtype, lhs->value, rhs->value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Eina_Value_Optional_Inner const * const* lhs_p = lhs_raw;
|
||||||
|
Eina_Value_Optional_Inner const * const* rhs_p = rhs_raw;
|
||||||
|
|
||||||
|
if(!*lhs_p)
|
||||||
|
return *rhs_p ? -1 : 0;
|
||||||
|
else if(!*rhs_p)
|
||||||
|
return 1;
|
||||||
|
else if((*lhs_p)->subtype != (*rhs_p)->subtype)
|
||||||
|
return (*lhs_p)->subtype < (*rhs_p)->subtype ? -1 : 1;
|
||||||
|
else
|
||||||
|
return eina_value_type_compare((*lhs_p)->subtype, (*lhs_p)->value, (*rhs_p)->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eina_value_type_optional_pset(const Eina_Value_Type *type EINA_UNUSED, void *mem, const void *ptr)
|
||||||
|
{
|
||||||
|
_eina_value_type_optional_flush(type, mem);
|
||||||
|
_eina_value_type_optional_copy(type, ptr, mem);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eina_value_type_optional_pget(const Eina_Value_Type *type EINA_UNUSED, const void *mem, void *ptr)
|
||||||
|
{
|
||||||
|
memcpy(ptr, mem, sizeof(Eina_Value_Union));
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI const Eina_Value_Type _EINA_VALUE_TYPE_OPTIONAL = {
|
||||||
|
EINA_VALUE_TYPE_VERSION,
|
||||||
|
sizeof(Eina_Value_Union),
|
||||||
|
"optional",
|
||||||
|
_eina_value_type_optional_setup,
|
||||||
|
_eina_value_type_optional_flush,
|
||||||
|
_eina_value_type_optional_copy,
|
||||||
|
_eina_value_type_optional_compare,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
_eina_value_type_optional_pset,
|
||||||
|
_eina_value_type_optional_pget
|
||||||
|
};
|
||||||
|
|
||||||
/* no model for now
|
/* no model for now
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_eina_value_type_model_setup(const Eina_Value_Type *type EINA_UNUSED, void *mem)
|
_eina_value_type_model_setup(const Eina_Value_Type *type EINA_UNUSED, void *mem)
|
||||||
|
@ -4911,6 +5134,8 @@ eina_value_init(void)
|
||||||
EINA_VALUE_TYPE_MODEL = &_EINA_VALUE_TYPE_MODEL;
|
EINA_VALUE_TYPE_MODEL = &_EINA_VALUE_TYPE_MODEL;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
EINA_VALUE_TYPE_OPTIONAL = &_EINA_VALUE_TYPE_OPTIONAL;
|
||||||
|
|
||||||
EINA_VALUE_BLOB_OPERATIONS_MALLOC = &_EINA_VALUE_BLOB_OPERATIONS_MALLOC;
|
EINA_VALUE_BLOB_OPERATIONS_MALLOC = &_EINA_VALUE_BLOB_OPERATIONS_MALLOC;
|
||||||
|
|
||||||
EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = &_EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
|
EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = &_EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
|
||||||
|
@ -4995,6 +5220,8 @@ EAPI const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT = NULL;
|
||||||
/* no model for now
|
/* no model for now
|
||||||
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_MODEL = NULL;
|
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_MODEL = NULL;
|
||||||
*/
|
*/
|
||||||
|
EAPI const Eina_Value_Type *EINA_VALUE_TYPE_OPTIONAL = NULL;
|
||||||
|
|
||||||
|
|
||||||
EAPI const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC = NULL;
|
EAPI const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC = NULL;
|
||||||
|
|
||||||
|
|
|
@ -3478,6 +3478,96 @@ static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr);
|
static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Value_Optional_Group Generic Value Optional management
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EINA_VALUE_TYPE_OPTIONAL
|
||||||
|
* manages optional type.
|
||||||
|
*
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef Eina_Value_Optional type to be used with Eina_Value_Struct
|
||||||
|
*
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
typedef Eina_Value_Union Eina_Value_Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create an empty optional. This is the same as eina_value_new(EINA_VALUE_TYPE_OPTIONAL).
|
||||||
|
* @return returns an empty optional eina value.
|
||||||
|
*/
|
||||||
|
static inline Eina_Value *eina_value_optional_empty_new();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create an optional eina value with the passed value
|
||||||
|
* @param subtype Eina_Value_Type of parameter value
|
||||||
|
* @param value The value to be used to construct optional eina value
|
||||||
|
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
EAPI Eina_Value *eina_value_optional_new(const Eina_Value_Type *subtype,
|
||||||
|
const void* value) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to know if an eina optional is empty or not
|
||||||
|
* @param value Eina Value Optional
|
||||||
|
* @param is_empty #EINA_TRUE if optional is empty, #EINA_FALSE otherwise.
|
||||||
|
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
static inline Eina_Bool eina_value_optional_empty_is(const Eina_Value *value,
|
||||||
|
Eina_Bool *is_empty) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the optional with a value
|
||||||
|
* @param value Eina Value Optional to be set with subvalue
|
||||||
|
* @param subtype Type of subvalue
|
||||||
|
* @param subvalue Value to be set in optional
|
||||||
|
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool eina_value_optional_pset(Eina_Value *value,
|
||||||
|
Eina_Value_Type const* subtype,
|
||||||
|
const void *subvalue) EINA_ARG_NONNULL(1, 2, 3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the value from an optional
|
||||||
|
* @param value Eina Value Optional to get value from
|
||||||
|
* @param subvalue Pointer to where value is to be copied to. You must use
|
||||||
|
* the correct type according to eina_value_optional_type_get
|
||||||
|
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool eina_value_optional_pget(Eina_Value *value,
|
||||||
|
void *subvalue) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resets eina optional to empty
|
||||||
|
* @param value Eina Value Optional
|
||||||
|
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool eina_value_optional_reset(Eina_Value *value) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get type from value that is stored on Eina Value Optional
|
||||||
|
* @param value Eina Value Optional
|
||||||
|
* @return The optional sub-type.
|
||||||
|
* @since 1.16
|
||||||
|
*/
|
||||||
|
static inline const Eina_Value_Type *eina_value_optional_type_get(Eina_Value *value) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef EJSON_H
|
||||||
|
#define EJSON_H
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Efl_Config.h>
|
||||||
|
|
||||||
|
#ifdef EAPI
|
||||||
|
# undef EAPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifdef EFL_EJSON_BUILD
|
||||||
|
# ifdef DLL_EXPORT
|
||||||
|
# define EAPI __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif /* ! DLL_EXPORT */
|
||||||
|
# else
|
||||||
|
# define EAPI __declspec(dllimport)
|
||||||
|
# endif /* ! EFL_EJSON_BUILD */
|
||||||
|
#else
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# if __GNUC__ >= 4
|
||||||
|
# define EAPI __attribute__ ((visibility("default")))
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
#endif /* ! _WIN32 */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EJSON_MODEL_NAME_PROPERTY "name"
|
||||||
|
#define EJSON_MODEL_VALUE_PROPERTY "value"
|
||||||
|
#define EJSON_MODEL_JSON_PROPERTY "json"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize ejson.
|
||||||
|
*
|
||||||
|
* @return 1 or greater on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
EAPI int ejson_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Shutdown ejson.
|
||||||
|
*
|
||||||
|
* @return 0 if ejson shuts down, greater than 0 otherwise.
|
||||||
|
*/
|
||||||
|
EAPI int ejson_shutdown(void);
|
||||||
|
|
||||||
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
|
# include <ejson_model.eo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EAPI
|
||||||
|
#define EAPI
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,65 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ejson_private.h"
|
||||||
|
|
||||||
|
static int _ejson_init_count = 0;
|
||||||
|
int _ejson_log_dom = -1;
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
ejson_init(void)
|
||||||
|
{
|
||||||
|
if (_ejson_init_count++ > 0)
|
||||||
|
return _ejson_init_count;
|
||||||
|
|
||||||
|
if (!eina_init())
|
||||||
|
{
|
||||||
|
fputs("Ejson: Unable to initialize eina\n", stderr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ejson_log_dom = eina_log_domain_register("ejson_model", EINA_COLOR_CYAN);
|
||||||
|
if (_ejson_log_dom < 0)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("Unable to create an 'ejson_model' log domain");
|
||||||
|
_ejson_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ecore_init())
|
||||||
|
{
|
||||||
|
ERR("Unable to initialize ecore");
|
||||||
|
eina_log_domain_unregister(_ejson_log_dom);
|
||||||
|
_ejson_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
return _ejson_init_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
ejson_shutdown(void)
|
||||||
|
{
|
||||||
|
if (_ejson_init_count <= 0)
|
||||||
|
{
|
||||||
|
ERR("Init count not greater than 0 in shutdown.");
|
||||||
|
_ejson_init_count = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--_ejson_init_count)
|
||||||
|
return _ejson_init_count;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
ecore_shutdown();
|
||||||
|
eina_log_domain_unregister(_ejson_log_dom);
|
||||||
|
_ejson_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,50 @@
|
||||||
|
enum Ejson.Model.Type {
|
||||||
|
NULL,
|
||||||
|
BOOLEAN,
|
||||||
|
DOUBLE,
|
||||||
|
INT,
|
||||||
|
STRING,
|
||||||
|
OBJECT,
|
||||||
|
ARRAY
|
||||||
|
}
|
||||||
|
|
||||||
|
class Ejson.Model (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
constructor {
|
||||||
|
[[
|
||||||
|
Custom Ejson_Model constructor.
|
||||||
|
@.constructor
|
||||||
|
|
||||||
|
@since 1.13
|
||||||
|
]]
|
||||||
|
params {
|
||||||
|
type: Ejson.Model.Type; [[Json object type]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property type {
|
||||||
|
values {
|
||||||
|
value: Ejson.Model.Type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.constructor;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef _EJSON_MODEL_PRIVATE_H
|
||||||
|
#define _EJSON_MODEL_PRIVATE_H
|
||||||
|
|
||||||
|
#include "ejson_private.h"
|
||||||
|
|
||||||
|
#include <json.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct _Ejson_Model_Data Ejson_Model_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ejson_model
|
||||||
|
*/
|
||||||
|
struct _Ejson_Model_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
json_object *json;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_Hash *properties_hash;
|
||||||
|
Eina_List *children_list;
|
||||||
|
Eina_Hash *children_hash;
|
||||||
|
Ejson_Model_Type type;
|
||||||
|
Eina_Array *properties_calc;
|
||||||
|
bool json_property_valid;
|
||||||
|
char *stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef _EJSON_PRIVATE_H
|
||||||
|
#define _EJSON_PRIVATE_H
|
||||||
|
|
||||||
|
#include <Ejson.h>
|
||||||
|
|
||||||
|
/* logging support */
|
||||||
|
extern int _ejson_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_ejson_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_ejson_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_ejson_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_ejson_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_ejson_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#endif
|
|
@ -79,6 +79,8 @@
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <Efl_Config.h>
|
#include <Efl_Config.h>
|
||||||
|
#include <Eo.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
|
||||||
#ifdef EAPI
|
#ifdef EAPI
|
||||||
# undef EAPI
|
# undef EAPI
|
||||||
|
@ -236,6 +238,13 @@ typedef void (*Eldbus_Signal_Cb)(void *data, const Eldbus_Message *msg);
|
||||||
#include "eldbus_proxy.h"
|
#include "eldbus_proxy.h"
|
||||||
#include "eldbus_freedesktop.h"
|
#include "eldbus_freedesktop.h"
|
||||||
#include "eldbus_service.h"
|
#include "eldbus_service.h"
|
||||||
|
#include "eldbus_introspection.h"
|
||||||
|
#include "eldbus_model_arguments.eo.h"
|
||||||
|
#include "eldbus_model_connection.eo.h"
|
||||||
|
#include "eldbus_model_method.eo.h"
|
||||||
|
#include "eldbus_model_object.eo.h"
|
||||||
|
#include "eldbus_model_proxy.eo.h"
|
||||||
|
#include "eldbus_model_signal.eo.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_H
|
||||||
|
#define _ELDBUS_MODEL_H
|
||||||
|
|
||||||
|
#include <Eldbus.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <eldbus_model_connection.eo.h>
|
||||||
|
#include <eldbus_model_object.eo.h>
|
||||||
|
#include <eldbus_model_proxy.eo.h>
|
||||||
|
#include <eldbus_model_arguments.eo.h>
|
||||||
|
#include <eldbus_model_method.eo.h>
|
||||||
|
#include <eldbus_model_signal.eo.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -73,6 +73,7 @@ EAPI const Eldbus_Version * eldbus_version = &_version;
|
||||||
|
|
||||||
static int _eldbus_init_count = 0;
|
static int _eldbus_init_count = 0;
|
||||||
int _eldbus_log_dom = -1;
|
int _eldbus_log_dom = -1;
|
||||||
|
int eldbus_model_log_dom = -1;
|
||||||
|
|
||||||
/* We don't save ELDBUS_CONNECTION_TYPE_UNKNOWN in here so we need room for
|
/* We don't save ELDBUS_CONNECTION_TYPE_UNKNOWN in here so we need room for
|
||||||
* last - 1 elements */
|
* last - 1 elements */
|
||||||
|
@ -104,6 +105,16 @@ eldbus_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eldbus_model_log_dom = eina_log_domain_register("eldbus_model", EINA_COLOR_CYAN);
|
||||||
|
if (eldbus_model_log_dom < 0)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("Unable to create an 'eldbus_model' log domain");
|
||||||
|
eina_log_domain_unregister(_eldbus_log_dom);
|
||||||
|
_eldbus_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ecore_init())
|
if (!ecore_init())
|
||||||
{
|
{
|
||||||
ERR("Unable to initialize ecore");
|
ERR("Unable to initialize ecore");
|
||||||
|
@ -144,6 +155,8 @@ signal_handler_failed:
|
||||||
eldbus_message_shutdown();
|
eldbus_message_shutdown();
|
||||||
message_failed:
|
message_failed:
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
|
eina_log_domain_unregister(eldbus_model_log_dom);
|
||||||
|
eldbus_model_log_dom = -1;
|
||||||
eina_log_domain_unregister(_eldbus_log_dom);
|
eina_log_domain_unregister(_eldbus_log_dom);
|
||||||
_eldbus_log_dom = -1;
|
_eldbus_log_dom = -1;
|
||||||
eina_shutdown();
|
eina_shutdown();
|
||||||
|
@ -245,6 +258,8 @@ eldbus_shutdown(void)
|
||||||
eldbus_message_shutdown();
|
eldbus_message_shutdown();
|
||||||
|
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
|
eina_log_domain_unregister(eldbus_model_log_dom);
|
||||||
|
eldbus_model_log_dom = -1;
|
||||||
eina_log_domain_unregister(_eldbus_log_dom);
|
eina_log_domain_unregister(_eldbus_log_dom);
|
||||||
_eldbus_log_dom = -1;
|
_eldbus_log_dom = -1;
|
||||||
eina_shutdown();
|
eina_shutdown();
|
||||||
|
|
|
@ -239,6 +239,19 @@ EAPI Eldbus_Pending *eldbus_proxy_property_get(Eldbus_Proxy *proxy, const
|
||||||
*/
|
*/
|
||||||
EAPI Eldbus_Pending *eldbus_proxy_property_set(Eldbus_Proxy *proxy, const char *name, const char *sig, const void *value, Eldbus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3, 4);
|
EAPI Eldbus_Pending *eldbus_proxy_property_set(Eldbus_Proxy *proxy, const char *name, const char *sig, const void *value, Eldbus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3, 4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property with a Eina_Value.
|
||||||
|
*
|
||||||
|
* @param proxy The proxy object on which to do the query.
|
||||||
|
* @param name The property name to get.
|
||||||
|
* @param sig
|
||||||
|
* @param value The value to set.
|
||||||
|
* @param cb The callback to be called when receiving an answer.
|
||||||
|
* @param data Data to be passed to the callback.
|
||||||
|
* @return Eldbus_Pending object corresponding to the message sent.
|
||||||
|
*/
|
||||||
|
EAPI Eldbus_Pending *eldbus_proxy_property_value_set(Eldbus_Proxy *proxy, const char *name, const char *sig, const Eina_Value *value, Eldbus_Message_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3, 4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all properties.
|
* Get all properties.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,419 @@
|
||||||
|
#include "eldbus_introspection.h"
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Introspection_Element_Parse_Table Eldbus_Introspection_Element_Parse_Table;
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Element_Parse_Table
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
void *(*parse)(Eina_Simple_XML_Node_Tag *tag);
|
||||||
|
Eina_List **list;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *_eldbus_introspection_attribute_value_get(Eina_Inlist *, const char *);
|
||||||
|
static void *_eldbus_introspection_parse_node(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_interface(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_method(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_signal(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_argument(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_property(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void *_eldbus_introspection_parse_annotation(Eina_Simple_XML_Node_Tag *);
|
||||||
|
static void _eldbus_introspection_parse_children(Eina_Inlist *, const Eldbus_Introspection_Element_Parse_Table[]);
|
||||||
|
static void _eldbus_introspection_interface_free(Eldbus_Introspection_Interface *);
|
||||||
|
static void _eldbus_introspection_method_free(Eldbus_Introspection_Method *);
|
||||||
|
static void _eldbus_introspection_signal_free(Eldbus_Introspection_Signal *);
|
||||||
|
static void _eldbus_introspection_argument_free(Eldbus_Introspection_Argument *);
|
||||||
|
static void _eldbus_introspection_property_free(Eldbus_Introspection_Property *);
|
||||||
|
static void _eldbus_introspection_annotation_free(Eldbus_Introspection_Annotation *);
|
||||||
|
|
||||||
|
EAPI Eldbus_Introspection_Node *
|
||||||
|
eldbus_introspection_parse(const char *xml)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(xml, NULL);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Node *node = NULL;
|
||||||
|
|
||||||
|
Eina_Simple_XML_Node_Root *xml_root = eina_simple_xml_node_load(xml, strlen(xml), EINA_TRUE);
|
||||||
|
|
||||||
|
Eina_Simple_XML_Node *xml_node = (Eina_Simple_XML_Node*)eina_inlist_last(xml_root->children);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(EINA_SIMPLE_XML_NODE_TAG == xml_node->type, free_root);
|
||||||
|
|
||||||
|
node = (Eldbus_Introspection_Node*)_eldbus_introspection_parse_node((Eina_Simple_XML_Node_Tag*)xml_node);
|
||||||
|
|
||||||
|
free_root:
|
||||||
|
eina_simple_xml_node_root_free(xml_root);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_node(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Node *node = calloc(1, sizeof(Eldbus_Introspection_Node));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(node, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
node->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Element_Parse_Table table[] = {
|
||||||
|
{"node", _eldbus_introspection_parse_node, &node->nodes},
|
||||||
|
{"interface", _eldbus_introspection_parse_interface, &node->interfaces},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
_eldbus_introspection_parse_children(tag->children, table);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
eldbus_introspection_node_free(Eldbus_Introspection_Node *node)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(node);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Node *child_node;
|
||||||
|
EINA_LIST_FREE(node->nodes, child_node)
|
||||||
|
eldbus_introspection_node_free(child_node);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Interface *interface;
|
||||||
|
EINA_LIST_FREE(node->interfaces, interface)
|
||||||
|
_eldbus_introspection_interface_free(interface);
|
||||||
|
|
||||||
|
eina_stringshare_del(node->name);
|
||||||
|
free(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_introspection_attribute_value_get(Eina_Inlist *attributes, const char *key)
|
||||||
|
{
|
||||||
|
Eina_Simple_XML_Attribute *attribute;
|
||||||
|
EINA_INLIST_FOREACH(attributes, attribute)
|
||||||
|
{
|
||||||
|
if (strcmp(attribute->key, key) == 0)
|
||||||
|
return attribute->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_interface(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Interface *interface = calloc(1, sizeof(Eldbus_Introspection_Interface));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(interface, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, error); // required
|
||||||
|
interface->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Element_Parse_Table table[] = {
|
||||||
|
{"method", _eldbus_introspection_parse_method, &interface->methods},
|
||||||
|
{"signal", _eldbus_introspection_parse_signal, &interface->signals},
|
||||||
|
{"property", _eldbus_introspection_parse_property, &interface->properties},
|
||||||
|
{"annotation", _eldbus_introspection_parse_annotation, &interface->annotations},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
_eldbus_introspection_parse_children(tag->children, table);
|
||||||
|
|
||||||
|
return interface;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_interface_free(interface);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_interface_free(Eldbus_Introspection_Interface *interface)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(interface);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Method *method;
|
||||||
|
EINA_LIST_FREE(interface->methods, method)
|
||||||
|
_eldbus_introspection_method_free(method);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Signal *signal;
|
||||||
|
EINA_LIST_FREE(interface->signals, signal)
|
||||||
|
_eldbus_introspection_signal_free(signal);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Property *property;
|
||||||
|
EINA_LIST_FREE(interface->properties, property)
|
||||||
|
_eldbus_introspection_property_free(property);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Annotation *annotation;
|
||||||
|
EINA_LIST_FREE(interface->annotations, annotation)
|
||||||
|
_eldbus_introspection_annotation_free(annotation);
|
||||||
|
|
||||||
|
eina_stringshare_del(interface->name);
|
||||||
|
free(interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_method(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Method *method = calloc(1, sizeof(Eldbus_Introspection_Method));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(method, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, error); // required
|
||||||
|
method->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Element_Parse_Table table[] = {
|
||||||
|
{"arg", _eldbus_introspection_parse_argument, &method->arguments},
|
||||||
|
{"annotation", _eldbus_introspection_parse_annotation, &method->annotations},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
_eldbus_introspection_parse_children(tag->children, table);
|
||||||
|
|
||||||
|
return method;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_method_free(method);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_method_free(Eldbus_Introspection_Method *method)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(method);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument *argument;
|
||||||
|
EINA_LIST_FREE(method->arguments, argument)
|
||||||
|
_eldbus_introspection_argument_free(argument);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Annotation *annotation;
|
||||||
|
EINA_LIST_FREE(method->annotations, annotation)
|
||||||
|
_eldbus_introspection_annotation_free(annotation);
|
||||||
|
|
||||||
|
eina_stringshare_del(method->name);
|
||||||
|
free(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_signal(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Signal *signal = calloc(1, sizeof(Eldbus_Introspection_Signal));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(signal, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, error); // required
|
||||||
|
signal->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Element_Parse_Table table[] = {
|
||||||
|
{"arg", _eldbus_introspection_parse_argument, &signal->arguments},
|
||||||
|
{"annotation", _eldbus_introspection_parse_annotation, &signal->annotations},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
_eldbus_introspection_parse_children(tag->children, table);
|
||||||
|
|
||||||
|
return signal;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_signal_free(signal);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_signal_free(Eldbus_Introspection_Signal *signal)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(signal);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument *argument;
|
||||||
|
EINA_LIST_FREE(signal->arguments, argument)
|
||||||
|
_eldbus_introspection_argument_free(argument);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Annotation *annotation;
|
||||||
|
EINA_LIST_FREE(signal->annotations, annotation)
|
||||||
|
_eldbus_introspection_annotation_free(annotation);
|
||||||
|
|
||||||
|
eina_stringshare_del(signal->name);
|
||||||
|
free(signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_argument(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Argument *argument = calloc(1, sizeof(Eldbus_Introspection_Argument));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(argument, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
argument->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
const char *type = _eldbus_introspection_attribute_value_get(tag->attributes, "type");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(type, error); // required
|
||||||
|
argument->type = eina_stringshare_add(type);
|
||||||
|
|
||||||
|
const char *direction = _eldbus_introspection_attribute_value_get(tag->attributes, "direction");
|
||||||
|
if (direction)
|
||||||
|
{
|
||||||
|
//EINA_SAFETY_ON_NULL_GOTO(direction, error); // required for methods only
|
||||||
|
if (strcmp(direction, "in") == 0)
|
||||||
|
argument->direction = ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN;
|
||||||
|
else
|
||||||
|
if (strcmp(direction, "out") == 0)
|
||||||
|
argument->direction = ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_OUT;
|
||||||
|
else
|
||||||
|
argument->direction = ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return argument;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_argument_free(argument);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_argument_free(Eldbus_Introspection_Argument *argument)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(argument);
|
||||||
|
eina_stringshare_del(argument->name);
|
||||||
|
eina_stringshare_del(argument->type);
|
||||||
|
free(argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_property(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Property *property = calloc(1, sizeof(Eldbus_Introspection_Property));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, error); // required
|
||||||
|
property->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
const char *type = _eldbus_introspection_attribute_value_get(tag->attributes, "type");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(type, error); // required
|
||||||
|
property->type = eina_stringshare_add(type);
|
||||||
|
|
||||||
|
const char *access = _eldbus_introspection_attribute_value_get(tag->attributes, "access");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(access, error); // required
|
||||||
|
if (strcmp(access, "read") == 0)
|
||||||
|
property->access = ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READ;
|
||||||
|
else
|
||||||
|
if (strcmp(access, "write") == 0)
|
||||||
|
property->access = ELDBUS_INTROSPECTION_PROPERTY_ACCESS_WRITE;
|
||||||
|
else
|
||||||
|
if (strcmp(access, "readwrite") == 0)
|
||||||
|
property->access = ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READWRITE;
|
||||||
|
else
|
||||||
|
EINA_SAFETY_ON_TRUE_GOTO(!!"Unknown property access", error);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Element_Parse_Table table[] = {
|
||||||
|
{"annotation", _eldbus_introspection_parse_annotation, &property->annotations},
|
||||||
|
{NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
_eldbus_introspection_parse_children(tag->children, table);
|
||||||
|
|
||||||
|
return property;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_property_free(property);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_property_free(Eldbus_Introspection_Property *property)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(property);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Annotation *annotation;
|
||||||
|
EINA_LIST_FREE(property->annotations, annotation)
|
||||||
|
_eldbus_introspection_annotation_free(annotation);
|
||||||
|
|
||||||
|
eina_stringshare_del(property->name);
|
||||||
|
eina_stringshare_del(property->type);
|
||||||
|
free(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_eldbus_introspection_parse_annotation(Eina_Simple_XML_Node_Tag *tag)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Annotation *annotation = calloc(1, sizeof(Eldbus_Introspection_Annotation));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(annotation, NULL);
|
||||||
|
|
||||||
|
const char *name = _eldbus_introspection_attribute_value_get(tag->attributes, "name");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, error); // required
|
||||||
|
annotation->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
const char *value = _eldbus_introspection_attribute_value_get(tag->attributes, "value");
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(value, error); // required
|
||||||
|
annotation->value = eina_stringshare_add(value);
|
||||||
|
|
||||||
|
return annotation;
|
||||||
|
|
||||||
|
error:
|
||||||
|
_eldbus_introspection_annotation_free(annotation);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_annotation_free(Eldbus_Introspection_Annotation *annotation)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(annotation);
|
||||||
|
eina_stringshare_del(annotation->name);
|
||||||
|
eina_stringshare_del(annotation->value);
|
||||||
|
free(annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_introspection_parse_children(Eina_Inlist *children, const Eldbus_Introspection_Element_Parse_Table table[])
|
||||||
|
{
|
||||||
|
Eina_Simple_XML_Node *child;
|
||||||
|
EINA_INLIST_FOREACH(children, child)
|
||||||
|
{
|
||||||
|
if (EINA_SIMPLE_XML_NODE_TAG != child->type)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Eina_Simple_XML_Node_Tag *tag = (Eina_Simple_XML_Node_Tag*)child;
|
||||||
|
|
||||||
|
for (const Eldbus_Introspection_Element_Parse_Table *it = table; it->name; ++it)
|
||||||
|
{
|
||||||
|
if (strcmp(tag->name, it->name) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
void *item = it->parse(tag);
|
||||||
|
if (item)
|
||||||
|
*it->list = eina_list_append(*it->list, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eldbus_Introspection_Interface *
|
||||||
|
eldbus_introspection_interface_find(Eina_List *interfaces, const char *name)
|
||||||
|
{
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Interface *interface;
|
||||||
|
EINA_LIST_FOREACH(interfaces, it, interface)
|
||||||
|
{
|
||||||
|
if (strcmp(interface->name, name) == 0)
|
||||||
|
return interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eldbus_Introspection_Property *
|
||||||
|
eldbus_introspection_property_find(Eina_List *properties, const char *name)
|
||||||
|
{
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Property *property;
|
||||||
|
EINA_LIST_FOREACH(properties, it, property)
|
||||||
|
{
|
||||||
|
if (strcmp(property->name, name) == 0)
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eldbus_Introspection_Argument *
|
||||||
|
eldbus_introspection_argument_find(Eina_List *arguments, const char *name)
|
||||||
|
{
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Argument *argument;
|
||||||
|
EINA_LIST_FOREACH(arguments, it, argument)
|
||||||
|
{
|
||||||
|
if (strcmp(argument->name, name) == 0)
|
||||||
|
return argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
#ifndef _ELDBUS_INTROSPECTION_INTROSPECTION_H
|
||||||
|
#define _ELDBUS_INTROSPECTION_INTROSPECTION_H
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
// DTD conversion form: http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Introspection_Node Eldbus_Introspection_Node;
|
||||||
|
typedef struct _Eldbus_Introspection_Interface Eldbus_Introspection_Interface;
|
||||||
|
typedef struct _Eldbus_Introspection_Method Eldbus_Introspection_Method;
|
||||||
|
typedef struct _Eldbus_Introspection_Signal Eldbus_Introspection_Signal;
|
||||||
|
typedef struct _Eldbus_Introspection_Argument Eldbus_Introspection_Argument;
|
||||||
|
typedef struct _Eldbus_Introspection_Property Eldbus_Introspection_Property;
|
||||||
|
typedef struct _Eldbus_Introspection_Annotation Eldbus_Introspection_Annotation;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_NONE = 0,
|
||||||
|
ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN,
|
||||||
|
ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_OUT,
|
||||||
|
|
||||||
|
} Eldbus_Introspection_Argument_Direction;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READ,
|
||||||
|
ELDBUS_INTROSPECTION_PROPERTY_ACCESS_WRITE,
|
||||||
|
ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READWRITE,
|
||||||
|
} Eldbus_Introspection_Property_Access;
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Node
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name; // optional
|
||||||
|
Eina_List *nodes;
|
||||||
|
Eina_List *interfaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Interface
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_List *methods;
|
||||||
|
Eina_List *signals;
|
||||||
|
Eina_List *properties;
|
||||||
|
Eina_List *annotations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Method
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_List *arguments;
|
||||||
|
Eina_List *annotations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Signal
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_List *arguments;
|
||||||
|
Eina_List *annotations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Argument
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name; // optional
|
||||||
|
Eina_Stringshare *type;
|
||||||
|
Eldbus_Introspection_Argument_Direction direction;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Property
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_Stringshare *type;
|
||||||
|
Eldbus_Introspection_Property_Access access;
|
||||||
|
Eina_List *annotations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Eldbus_Introspection_Annotation
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_Stringshare *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses the introspection xml abstracting it to an object tree
|
||||||
|
*
|
||||||
|
* @param xml The introspection xml
|
||||||
|
* @return The introspection object tree
|
||||||
|
*/
|
||||||
|
EAPI Eldbus_Introspection_Node *eldbus_introspection_parse(const char *xml);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Frees the introspection object tree
|
||||||
|
*
|
||||||
|
* @param node The root node of introspection tree
|
||||||
|
*/
|
||||||
|
EAPI void eldbus_introspection_node_free(Eldbus_Introspection_Node *node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finds an interface by name
|
||||||
|
*
|
||||||
|
* @param interfaces The list of interfaces of type @c Eldbus_Introspection_Interface
|
||||||
|
* @param name The interfaces's name to search for
|
||||||
|
* @return Returns the interface found or @c NULL if not
|
||||||
|
*/
|
||||||
|
EAPI Eldbus_Introspection_Interface *eldbus_introspection_interface_find(Eina_List *interfaces, const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finds a property by name
|
||||||
|
*
|
||||||
|
* @param properties The list of properties of type @c Eldbus_Introspection_Property
|
||||||
|
* @param name The properties's name to search for
|
||||||
|
* @return Returns the property found or @c NULL if not
|
||||||
|
*/
|
||||||
|
EAPI Eldbus_Introspection_Property *eldbus_introspection_property_find(Eina_List *properties, const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Finds an argument by name
|
||||||
|
*
|
||||||
|
* @param arguments The list of arguments of type @c Eldbus_Introspection_Property
|
||||||
|
* @param name The arguments's name to search for
|
||||||
|
* @return Returns the argument found or @c NULL if not
|
||||||
|
*/
|
||||||
|
EAPI Eldbus_Introspection_Argument *eldbus_introspection_argument_find(Eina_List *arguments, const char *name);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,8 @@
|
||||||
#include "eldbus_private.h"
|
#include "eldbus_private.h"
|
||||||
#include "eldbus_private_types.h"
|
#include "eldbus_private_types.h"
|
||||||
|
|
||||||
|
#include <dbus/dbus-protocol.h>
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_compatible_type(int dbus_type, const Eina_Value_Type *value_type)
|
_compatible_type(int dbus_type, const Eina_Value_Type *value_type)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +207,7 @@ _array_append(const char *type, const Eina_Value *value_array, Eldbus_Message_It
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_basic_append(char type, const Eina_Value *value, const Eina_Value_Struct_Desc *desc, unsigned idx, Eldbus_Message_Iter *iter)
|
_basic_append_value_struct(char type, const Eina_Value *value, const Eina_Value_Struct_Desc *desc, unsigned idx, Eldbus_Message_Iter *iter)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(
|
||||||
_compatible_type(type, desc->members[idx].type), EINA_FALSE);
|
_compatible_type(type, desc->members[idx].type), EINA_FALSE);
|
||||||
|
@ -305,7 +307,7 @@ _message_iter_from_eina_value_struct(const char *signature, Eldbus_Message_Iter
|
||||||
{
|
{
|
||||||
DBG("type: %s", type);
|
DBG("type: %s", type);
|
||||||
if (type[0] != 'v' && !type[1])
|
if (type[0] != 'v' && !type[1])
|
||||||
r = _basic_append(type[0], value, st.desc, i, iter);
|
r = _basic_append_value_struct(type[0], value, st.desc, i, iter);
|
||||||
else if (type[0] == 'a')
|
else if (type[0] == 'a')
|
||||||
{
|
{
|
||||||
Eina_Value value_array;
|
Eina_Value value_array;
|
||||||
|
@ -367,3 +369,121 @@ eldbus_message_from_eina_value(const char *signature, Eldbus_Message *msg, const
|
||||||
|
|
||||||
return _message_iter_from_eina_value_struct(signature, iter, value);
|
return _message_iter_from_eina_value_struct(signature, iter, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_basic_append_value(char type, const Eina_Value *value, Eldbus_Message_Iter *iter)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
|
||||||
|
const Eina_Value_Type *value_type = eina_value_type_get(value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(_compatible_type(type, value_type), EINA_FALSE);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 'i'://int
|
||||||
|
case 'h'://fd
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 's':
|
||||||
|
case 'o'://object path
|
||||||
|
case 'g'://signature
|
||||||
|
{
|
||||||
|
const char *txt;
|
||||||
|
eina_value_get(value, &txt);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, txt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'b'://boolean
|
||||||
|
case 'y'://byte
|
||||||
|
{
|
||||||
|
unsigned char byte;
|
||||||
|
eina_value_get(value, &byte);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, byte);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'n'://int16
|
||||||
|
{
|
||||||
|
int16_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'q'://uint16
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'u'://uint32
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'x'://int64
|
||||||
|
{
|
||||||
|
int64_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 't'://uint64
|
||||||
|
{
|
||||||
|
uint64_t i;
|
||||||
|
eina_value_get(value, &i);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'd'://double
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
eina_value_get(value, &d);
|
||||||
|
eldbus_message_iter_basic_append(iter, type, d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
ERR("Unexpected type %c", type);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_message_iter_from_eina_value(const char *signature, Eldbus_Message_Iter *iter, const Eina_Value *value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
|
||||||
|
|
||||||
|
const Eina_Value_Type *value_type = eina_value_type_get(value);
|
||||||
|
if (EINA_VALUE_TYPE_STRUCT == value_type || EINA_VALUE_TYPE_ARRAY == value_type)
|
||||||
|
return _message_iter_from_eina_value_struct(signature, iter, value);
|
||||||
|
|
||||||
|
Eina_Bool result = EINA_TRUE;
|
||||||
|
DBusSignatureIter signature_iter;
|
||||||
|
dbus_signature_iter_init(&signature_iter, signature);
|
||||||
|
char *type;
|
||||||
|
while ((type = dbus_signature_iter_get_signature(&signature_iter)))
|
||||||
|
{
|
||||||
|
DBG("type: %s", type);
|
||||||
|
if (DBUS_TYPE_VARIANT != type[0] && DBUS_TYPE_INVALID == type[1])
|
||||||
|
result = _basic_append_value(type[0], value, iter);
|
||||||
|
else if (DBUS_TYPE_ARRAY == type[0] ||
|
||||||
|
DBUS_STRUCT_BEGIN_CHAR == type[0] ||
|
||||||
|
DBUS_TYPE_VARIANT == type[0])
|
||||||
|
{
|
||||||
|
ERR("Not a basic type");
|
||||||
|
result = EINA_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERR("Unknown type %c", type[0]);
|
||||||
|
result = EINA_FALSE;
|
||||||
|
}
|
||||||
|
dbus_free(type);
|
||||||
|
if (!result || !dbus_signature_iter_next(&signature_iter)) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
static void _message_iter_basic_array_to_eina_value(char type, Eina_Value *value, Eldbus_Message_Iter *iter);
|
static void _message_iter_basic_array_to_eina_value(char type, Eina_Value *value, Eldbus_Message_Iter *iter);
|
||||||
|
|
||||||
static const Eina_Value_Type *
|
const Eina_Value_Type *
|
||||||
_dbus_type_to_eina_value_type(char type)
|
_dbus_type_to_eina_value_type(char type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -0,0 +1,474 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_arguments_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_ARGUMENTS_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Arguments"
|
||||||
|
|
||||||
|
#define ARGUMENT_FORMAT "arg%u"
|
||||||
|
|
||||||
|
static void _eldbus_model_arguments_efl_model_base_properties_load(Eo *, Eldbus_Model_Arguments_Data *);
|
||||||
|
static void _eldbus_model_arguments_efl_model_base_children_load(Eo *, Eldbus_Model_Arguments_Data *);
|
||||||
|
static void _eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *);
|
||||||
|
static bool _eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *, const char *);
|
||||||
|
static bool _eldbus_model_arguments_is_output_argument(Eldbus_Model_Arguments_Data *, const char *);
|
||||||
|
static Eina_Bool _eldbus_model_arguments_property_set(Eldbus_Model_Arguments_Data *, Eina_Value *, const char *);
|
||||||
|
static unsigned int _eldbus_model_arguments_argument_index_get(Eldbus_Model_Arguments_Data *, const char *);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_hash_free(Eina_Value *value)
|
||||||
|
{
|
||||||
|
eina_value_free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_arguments_eo_base_constructor(Eo *obj, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_arguments_hash_free));
|
||||||
|
pd->pending_list = NULL;
|
||||||
|
pd->proxy = NULL;
|
||||||
|
pd->arguments = NULL;
|
||||||
|
pd->name = NULL;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_arguments_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
const Eina_List *arguments)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument* data;
|
||||||
|
EINA_LIST_FREE(pd->arguments, data)
|
||||||
|
{
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
pd->arguments = eina_list_clone(arguments);
|
||||||
|
Eina_List* l;
|
||||||
|
EINA_LIST_FOREACH(pd->arguments, l, data)
|
||||||
|
{
|
||||||
|
void* cp = malloc(sizeof(Eldbus_Introspection_Argument));
|
||||||
|
memcpy(cp, data, sizeof(Eldbus_Introspection_Argument));
|
||||||
|
eina_list_data_set(l, cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Eina_List*
|
||||||
|
_eldbus_model_arguments_arguments_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_proxy_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
Eldbus_Proxy *proxy)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(proxy);
|
||||||
|
|
||||||
|
pd->proxy = eldbus_proxy_ref(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Proxy*
|
||||||
|
_eldbus_model_arguments_proxy_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_name_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(name);
|
||||||
|
|
||||||
|
pd->name = eina_stringshare_add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
_eldbus_model_arguments_name_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_eo_base_destructor(Eo *obj, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_arguments_unload(pd);
|
||||||
|
|
||||||
|
eina_hash_free(pd->properties_hash);
|
||||||
|
|
||||||
|
eina_stringshare_del(pd->name);
|
||||||
|
eldbus_proxy_unref(pd->proxy);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument* data;
|
||||||
|
EINA_LIST_FREE(pd->arguments, data)
|
||||||
|
{
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
Eina_Array * const* properties_array)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
{
|
||||||
|
ERR("%s", "o not loaded.");
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(Eina_Array**)properties_array = pd->properties_array;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsigned int arguments_count = eina_list_count(pd->arguments);
|
||||||
|
|
||||||
|
pd->properties_array = eina_array_new(arguments_count);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd->properties_array);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < arguments_count; ++i)
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name = eina_stringshare_printf(ARGUMENT_FORMAT, i);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(name);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(pd->properties_array, name);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument *arg = eina_list_nth(pd->arguments, i);
|
||||||
|
const Eina_Value_Type *type = _dbus_type_to_eina_value_type(arg->type[0]);
|
||||||
|
|
||||||
|
Eina_Value *value = eina_value_new(type);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(value);
|
||||||
|
|
||||||
|
ret = eina_hash_add(pd->properties_hash, name, value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_property_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const* value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
if (!_eldbus_model_arguments_is_input_argument(pd, property))
|
||||||
|
{
|
||||||
|
WRN("Property (argument) not found or it is for output only: %s", property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Value *prop_value = eina_hash_find(pd->properties_hash, property);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
eina_value_flush(prop_value);
|
||||||
|
Eina_Bool ret = eina_value_copy(value, prop_value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_property_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const ** value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
if (!_eldbus_model_arguments_is_output_argument(pd, property))
|
||||||
|
{
|
||||||
|
WRN("Property (argument) not found or it is for input only: %s", property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = eina_hash_find(pd->properties_hash, property);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(*value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_efl_model_base_load(Eo *obj, Eldbus_Model_Arguments_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
eo_do(obj, efl_model_properties_load());
|
||||||
|
eo_do(obj, efl_model_children_load());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_arguments_unload(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
_eldbus_model_arguments_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_Arguments_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_child_del(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd EINA_UNUSED,
|
||||||
|
Eo *child EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
unsigned start EINA_UNUSED,
|
||||||
|
unsigned count EINA_UNUSED,
|
||||||
|
Eina_Accessor **children_accessor)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_accessor = NULL;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_arguments_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Arguments_Data *pd,
|
||||||
|
unsigned *children_count)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_count = 0;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_efl_model_base_children_load(Eo *obj, Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_arguments_unload(Eldbus_Model_Arguments_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending;
|
||||||
|
EINA_LIST_FREE(pd->pending_list, pending)
|
||||||
|
eldbus_pending_cancel(pending);
|
||||||
|
|
||||||
|
if (pd->properties_array)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
Eina_Stringshare *property;
|
||||||
|
Eina_Array_Iterator it;
|
||||||
|
EINA_ARRAY_ITER_NEXT(pd->properties_array, i, property, it)
|
||||||
|
eina_stringshare_del(property);
|
||||||
|
eina_array_free(pd->properties_array);
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
eina_hash_free_buckets(pd->properties_hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *pd,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
pd->pending_list = eina_list_remove(pd->pending_list, pending);
|
||||||
|
|
||||||
|
const char *error_name, *error_text;
|
||||||
|
if (eldbus_message_error_get(msg, &error_name, &error_text))
|
||||||
|
{
|
||||||
|
ERR("%s: %s", error_name, error_text);
|
||||||
|
efl_model_error_notify(pd->obj);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Value *value_struct = eldbus_message_to_eina_value(msg);
|
||||||
|
if (NULL == value_struct)
|
||||||
|
{
|
||||||
|
INF("%s", "No output arguments");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Array *changed_properties = eina_array_new(1);
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
unsigned int i = 0;
|
||||||
|
const Eina_List *it;
|
||||||
|
const Eldbus_Introspection_Argument *argument;
|
||||||
|
EINA_LIST_FOREACH(pd->arguments, it, argument)
|
||||||
|
{
|
||||||
|
if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction)
|
||||||
|
{
|
||||||
|
const Eina_Stringshare *property = eina_array_data_get(pd->properties_array, i);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(property, on_error);
|
||||||
|
|
||||||
|
Eina_Bool ret = _eldbus_model_arguments_property_set(pd, value_struct, property);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
ret = eina_array_push(changed_properties, property);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eina_array_count(changed_properties))
|
||||||
|
{
|
||||||
|
Efl_Model_Property_Event evt = {.changed_properties = changed_properties};
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt));
|
||||||
|
}
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_array_free(changed_properties);
|
||||||
|
eina_value_free(value_struct);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eldbus_model_arguments_property_set(Eldbus_Model_Arguments_Data *pd,
|
||||||
|
Eina_Value *value_struct,
|
||||||
|
const char *property)
|
||||||
|
{
|
||||||
|
Eina_Value *prop_value = eina_hash_find(pd->properties_hash, property);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(prop_value, EINA_FALSE);
|
||||||
|
|
||||||
|
Eina_Value value;
|
||||||
|
Eina_Bool ret = eina_value_struct_value_get(value_struct, "arg0", &value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EINA_FALSE);
|
||||||
|
|
||||||
|
eina_value_flush(prop_value);
|
||||||
|
ret = eina_value_copy(&value, prop_value);
|
||||||
|
eina_value_flush(&value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EINA_FALSE);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_arguments_is_input_argument(Eldbus_Model_Arguments_Data *pd, const char *argument)
|
||||||
|
{
|
||||||
|
const unsigned int i = _eldbus_model_arguments_argument_index_get(pd, argument);
|
||||||
|
if (i >= eina_array_count(pd->properties_array))
|
||||||
|
{
|
||||||
|
WRN("Argument not found: %s", argument);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument *argument_introspection =
|
||||||
|
eina_list_nth(pd->arguments, i);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(argument_introspection, false);
|
||||||
|
|
||||||
|
return ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN == argument_introspection->direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_arguments_is_output_argument(Eldbus_Model_Arguments_Data *pd, const char *argument)
|
||||||
|
{
|
||||||
|
const unsigned int i = _eldbus_model_arguments_argument_index_get(pd, argument);
|
||||||
|
if (i >= eina_array_count(pd->properties_array))
|
||||||
|
{
|
||||||
|
WRN("Argument not found: %s", argument);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Introspection_Argument *argument_introspection =
|
||||||
|
eina_list_nth(pd->arguments, i);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(argument_introspection, false);
|
||||||
|
|
||||||
|
return ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument_introspection->direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int
|
||||||
|
_eldbus_model_arguments_argument_index_get(Eldbus_Model_Arguments_Data *pd, const char *argument)
|
||||||
|
{
|
||||||
|
unsigned int i = 0;
|
||||||
|
const Eina_Stringshare *name;
|
||||||
|
Eina_Array_Iterator it;
|
||||||
|
EINA_ARRAY_ITER_NEXT(pd->properties_array, i, name, it)
|
||||||
|
{
|
||||||
|
if (strcmp(name, argument) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_arguments.eo.c"
|
|
@ -0,0 +1,55 @@
|
||||||
|
class Eldbus.Model_Arguments (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property proxy {
|
||||||
|
[[Custom Eldbus_Model_Arguments constructor.
|
||||||
|
|
||||||
|
@since 1.16]]
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
proxy: Eldbus_Proxy*; [[Eldbus proxy]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property arguments {
|
||||||
|
[[Custom Eldbus_Model_Arguments constructor.
|
||||||
|
|
||||||
|
@since 1.16]]
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
}
|
||||||
|
values {
|
||||||
|
arguments: const(list<Eldbus_Introspection_Argument*>)* @optional; [[The introspected arguments]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property name {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
value: const(char)*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.proxy;
|
||||||
|
.name;
|
||||||
|
.arguments @optional;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_ARGUMENTS_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_ARGUMENTS_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Arguments_Data Eldbus_Model_Arguments_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_arguments
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Arguments_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eldbus_Proxy *proxy;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_Hash *properties_hash;
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_List *pending_list;
|
||||||
|
Eina_List *arguments;
|
||||||
|
Eina_Value tmp_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool eldbus_model_arguments_process_arguments(Eldbus_Model_Arguments_Data *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,363 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_connection_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_CONNECTION_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Connection"
|
||||||
|
|
||||||
|
#define UNIQUE_NAME_PROPERTY "unique_name"
|
||||||
|
|
||||||
|
static void _eldbus_model_connection_efl_model_base_properties_load(Eo *, Eldbus_Model_Connection_Data *);
|
||||||
|
static void _eldbus_model_connection_efl_model_base_children_load(Eo *, Eldbus_Model_Connection_Data *);
|
||||||
|
static void _eldbus_model_connection_names_list_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
static void _eldbus_model_connection_connect(Eldbus_Model_Connection_Data *);
|
||||||
|
static void _eldbus_model_connection_disconnect(Eldbus_Model_Connection_Data *);
|
||||||
|
static void _eldbus_model_connection_clear(Eldbus_Model_Connection_Data *);
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_connection_eo_base_constructor(Eo *obj, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
|
||||||
|
pd->connection = NULL;
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
pd->children_list = NULL;
|
||||||
|
pd->type = ELDBUS_CONNECTION_TYPE_UNKNOWN;
|
||||||
|
pd->address = NULL;
|
||||||
|
pd->private = false;
|
||||||
|
pd->unique_name = NULL;
|
||||||
|
pd->pending_list = NULL;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_eo_base_destructor(Eo *obj, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
eina_stringshare_del(pd->address);
|
||||||
|
|
||||||
|
_eldbus_model_connection_clear(pd);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd,
|
||||||
|
Eina_Array * const* properties_array)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
if (NULL == pd->properties_array)
|
||||||
|
{
|
||||||
|
pd->properties_array = eina_array_new(1);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(Eina_Array**)properties_array = pd->properties_array;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_connection_connect(pd);
|
||||||
|
|
||||||
|
pd->unique_name = eina_value_new(EINA_VALUE_TYPE_STRING);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd->unique_name);
|
||||||
|
|
||||||
|
const char *unique_name = eldbus_connection_unique_name_get(pd->connection);
|
||||||
|
Eina_Bool ret = eina_value_set(pd->unique_name, unique_name);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_property_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd EINA_UNUSED,
|
||||||
|
const char *property EINA_UNUSED,
|
||||||
|
Eina_Value const* value EINA_UNUSED)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_property_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const **value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
if (strcmp(property, UNIQUE_NAME_PROPERTY) != 0)
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
*value = pd->unique_name;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_connection_connect(pd);
|
||||||
|
|
||||||
|
_eldbus_model_connection_efl_model_base_properties_load(obj, pd);
|
||||||
|
_eldbus_model_connection_efl_model_base_children_load(obj, pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_connection_clear(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
_eldbus_model_connection_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_child_del(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd EINA_UNUSED,
|
||||||
|
Eo *child EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd,
|
||||||
|
unsigned start,
|
||||||
|
unsigned count,
|
||||||
|
Eina_Accessor **children_accessor)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
|
||||||
|
{
|
||||||
|
WRN("(%p): Children not loaded", obj);
|
||||||
|
*children_accessor = NULL;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*children_accessor = efl_model_list_slice(pd->children_list, start, count);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_connection_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Connection_Data *pd,
|
||||||
|
unsigned *children_count)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_count = eina_list_count(pd->children_list);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_connection_connect(pd);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending = eldbus_names_list(pd->connection, &_eldbus_model_connection_names_list_cb, pd);
|
||||||
|
pd->pending_list = eina_list_append(pd->pending_list, pending);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_model_connection_address_get(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->address;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_address_set(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd, const char *value)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(pd->address);
|
||||||
|
pd->address = eina_stringshare_add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eldbus_model_connection_private_get(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->private;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_private_set(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd, Eina_Bool value)
|
||||||
|
{
|
||||||
|
pd->private = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_eldbus_model_connection_type_get(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_type_set(Eo *obj EINA_UNUSED, Eldbus_Model_Connection_Data *pd, int value)
|
||||||
|
{
|
||||||
|
pd->type = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_connect(Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "connecting\n");
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
|
||||||
|
if (ELDBUS_CONNECTION_TYPE_ADDRESS == pd->type)
|
||||||
|
{
|
||||||
|
if (pd->private)
|
||||||
|
pd->connection = eldbus_address_connection_get(pd->address);
|
||||||
|
else
|
||||||
|
pd->connection = eldbus_private_address_connection_get(pd->address);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pd->private)
|
||||||
|
pd->connection = eldbus_private_connection_get(pd->type);
|
||||||
|
else
|
||||||
|
pd->connection = eldbus_connection_get(pd->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Register for disconnection event
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(NULL != pd->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_disconnect(Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
eldbus_connection_unref(pd->connection);
|
||||||
|
pd->connection = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_clear(Eldbus_Model_Connection_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
if (!pd->connection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eina_value_free(pd->unique_name);
|
||||||
|
pd->unique_name = NULL;
|
||||||
|
|
||||||
|
Eo *child;
|
||||||
|
EINA_LIST_FREE(pd->children_list, child)
|
||||||
|
eo_unref(child);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending;
|
||||||
|
EINA_LIST_FREE(pd->pending_list, pending)
|
||||||
|
eldbus_pending_cancel(pending);
|
||||||
|
|
||||||
|
if (pd->properties_array)
|
||||||
|
{
|
||||||
|
eina_array_free(pd->properties_array);
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_eldbus_model_connection_disconnect(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_connection_names_list_cb(void *data,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Connection_Data *pd = (Eldbus_Model_Connection_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
pd->pending_list = eina_list_remove(pd->pending_list, pending);
|
||||||
|
|
||||||
|
const char *error_name, *error_text;
|
||||||
|
if (eldbus_message_error_get(msg, &error_name, &error_text))
|
||||||
|
{
|
||||||
|
ERR("%s: %s", error_name, error_text);
|
||||||
|
efl_model_error_notify(pd->obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Message_Iter *array = NULL;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "as", &array))
|
||||||
|
{
|
||||||
|
ERR("%s", "Error getting arguments.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *bus;
|
||||||
|
while (eldbus_message_iter_get_and_next(array, 's', &bus))
|
||||||
|
{
|
||||||
|
DBG("(%p): bus = %s", pd->obj, bus);
|
||||||
|
|
||||||
|
Eo *child = eo_add(ELDBUS_MODEL_OBJECT_CLASS, NULL,
|
||||||
|
eldbus_model_object_connection_set(pd->connection),
|
||||||
|
eldbus_model_object_bus_set(bus),
|
||||||
|
eldbus_model_object_path_set("/"));
|
||||||
|
|
||||||
|
pd->children_list = eina_list_append(pd->children_list, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
unsigned int count = eina_list_count(pd->children_list);
|
||||||
|
if (count)
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_connection.eo.c"
|
|
@ -0,0 +1,47 @@
|
||||||
|
class Eldbus.Model_Connection (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property type {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
value: int;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property address {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
value: const(char)*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property private {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
value: bool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.type;
|
||||||
|
.address;
|
||||||
|
.private;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_CONNECTION_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_CONNECTION_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Connection_Data Eldbus_Model_Connection_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_connection
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Connection_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eldbus_Connection *connection;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_List *children_list;
|
||||||
|
Eldbus_Connection_Type type;
|
||||||
|
Eina_Stringshare *address;
|
||||||
|
bool private;
|
||||||
|
Eina_Value *unique_name;
|
||||||
|
Eina_List *pending_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_arguments_private.h"
|
||||||
|
#include "eldbus_model_method_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
#include "eldbus_proxy.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_METHOD_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Method"
|
||||||
|
|
||||||
|
static void _eldbus_model_method_call_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_method_eo_base_constructor(Eo *obj, Eldbus_Model_Method_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->method = NULL;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_method_method_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Method_Data *pd,
|
||||||
|
const Eldbus_Introspection_Method *method)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(method);
|
||||||
|
|
||||||
|
pd->method = method;
|
||||||
|
eo_do(obj,
|
||||||
|
eldbus_model_arguments_name_set(method->name),
|
||||||
|
eldbus_model_arguments_set(method->arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Eldbus_Introspection_Method *
|
||||||
|
_eldbus_model_method_method_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Method_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->method;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_method_call(Eo *obj EINA_UNUSED, Eldbus_Model_Method_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
Eldbus_Model_Arguments_Data *data = eo_data_scope_get(obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
Eldbus_Message *msg = eldbus_proxy_method_call_new(data->proxy, data->name);
|
||||||
|
Eldbus_Message_Iter *iter = eldbus_message_iter_get(msg);
|
||||||
|
|
||||||
|
unsigned int i = 0;
|
||||||
|
const Eina_List *it;
|
||||||
|
const Eldbus_Introspection_Argument *argument;
|
||||||
|
EINA_LIST_FOREACH(data->arguments, it, argument)
|
||||||
|
{
|
||||||
|
if (ELDBUS_INTROSPECTION_ARGUMENT_DIRECTION_IN != argument->direction)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const Eina_Stringshare *name = eina_array_data_get(data->properties_array, i);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(name, on_error);
|
||||||
|
|
||||||
|
const Eina_Value *value = eina_hash_find(data->properties_hash, name);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(value, on_error);
|
||||||
|
|
||||||
|
Eina_Bool ret;
|
||||||
|
const char *signature = argument->type;
|
||||||
|
if (dbus_type_is_basic(signature[0]))
|
||||||
|
ret = _message_iter_from_eina_value(signature, iter, value);
|
||||||
|
else
|
||||||
|
ret = _message_iter_from_eina_value_struct(signature, iter, value);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Pending *pending = eldbus_proxy_send(data->proxy, msg, _eldbus_model_method_call_cb, pd, -1);
|
||||||
|
data->pending_list = eina_list_append(data->pending_list, pending);
|
||||||
|
|
||||||
|
return data->load.status;
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eldbus_message_unref(msg);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_method_call_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Method_Data *pd = (Eldbus_Model_Method_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(args_data);
|
||||||
|
|
||||||
|
if (eldbus_model_arguments_process_arguments(args_data, msg, pending))
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(ELDBUS_MODEL_METHOD_EVENT_SUCCESSFUL_CALL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_method.eo.c"
|
|
@ -0,0 +1,34 @@
|
||||||
|
class Eldbus.Model_Method (Eldbus.Model_Arguments) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property method {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
method: const(Eldbus_Introspection_Method)*; [[The introspected method]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
call {
|
||||||
|
[[Calls the method. The properties must have been set.
|
||||||
|
|
||||||
|
The event EMODEL_EVENT_PROPERTIES_CHANGED is raised for output arguments (properties).
|
||||||
|
|
||||||
|
The event ELDBUS_MODEL_METHOD_EVENT_METHOD_CALLED is raised for a successful call. Otherwise
|
||||||
|
the event EMODEL_EVENT_LOAD_STATUS with the status set to EMODEL_LOAD_STATUS_ERROR is raised.
|
||||||
|
|
||||||
|
@since 1.16]]
|
||||||
|
return: Efl.Model.Load_Status; [[#Emodel_Load_Status on success, #EMODEL_LOAD_STATUS_ERROR otherwise.]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
Eldbus.Model_Arguments.proxy;
|
||||||
|
.method;
|
||||||
|
}
|
||||||
|
events {
|
||||||
|
successful,call; [[Event dispatched for a successful method call.]]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_METHOD_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_METHOD_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Method_Data Eldbus_Model_Method_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_method
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Method_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
const Eldbus_Introspection_Method *method;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,507 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_object_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
#include "eldbus_model_connection_private.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_OBJECT_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Object"
|
||||||
|
|
||||||
|
#define UNIQUE_NAME_PROPERTY "unique_name"
|
||||||
|
|
||||||
|
static void _eldbus_model_object_efl_model_base_properties_load(Eo *, Eldbus_Model_Object_Data *);
|
||||||
|
static void _eldbus_model_object_efl_model_base_children_load(Eo *, Eldbus_Model_Object_Data *);
|
||||||
|
static bool _eldbus_model_object_introspect(Eldbus_Model_Object_Data *, const char *, const char *);
|
||||||
|
static void _eldbus_model_object_introspect_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
static void _eldbus_model_object_connect(Eldbus_Model_Object_Data *);
|
||||||
|
static void _eldbus_model_object_disconnect(Eldbus_Model_Object_Data *);
|
||||||
|
static void _eldbus_model_object_clear(Eldbus_Model_Object_Data *);
|
||||||
|
static void _eldbus_model_object_introspect_nodes(Eldbus_Model_Object_Data *, const char *, Eina_List *);
|
||||||
|
static char *_eldbus_model_object_concatenate_path(const char *, const char *);
|
||||||
|
static void _eldbus_model_object_create_children(Eldbus_Model_Object_Data *, Eldbus_Object *, Eina_List *);
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_object_eo_base_constructor(Eo *obj, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
|
||||||
|
pd->connection = NULL;
|
||||||
|
pd->object_list = NULL;
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
pd->children_list = NULL;
|
||||||
|
pd->bus = NULL;
|
||||||
|
pd->path = NULL;
|
||||||
|
pd->unique_name = NULL;
|
||||||
|
pd->pending_list = NULL;
|
||||||
|
pd->introspection = NULL;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_connection_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
Eldbus_Connection *connection)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(connection);
|
||||||
|
|
||||||
|
pd->connection = eldbus_connection_ref(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Connection*
|
||||||
|
_eldbus_model_object_connection_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_connection_model_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
Eldbus_Model_Connection *connection)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(connection);
|
||||||
|
|
||||||
|
Eldbus_Model_Connection_Data* connection_data
|
||||||
|
= eo_data_scope_get(connection, ELDBUS_MODEL_CONNECTION_CLASS);
|
||||||
|
eo_do(connection, fprintf(stderr, "%d\n", eldbus_model_connection_type_get()));
|
||||||
|
fflush(stderr);
|
||||||
|
pd->connection = eldbus_connection_ref(connection_data->connection);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(NULL != pd->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_eo_base_destructor(Eo *obj, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
eina_stringshare_del(pd->bus);
|
||||||
|
eina_stringshare_del(pd->path);
|
||||||
|
|
||||||
|
_eldbus_model_object_clear(pd);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
Eina_Array * const* properties_array)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
if (NULL == pd->properties_array)
|
||||||
|
{
|
||||||
|
pd->properties_array = eina_array_new(1);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->properties_array, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(pd->properties_array, UNIQUE_NAME_PROPERTY);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(Eina_Array**)properties_array = pd->properties_array;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_object_connect(pd);
|
||||||
|
|
||||||
|
pd->unique_name = eina_value_new(EINA_VALUE_TYPE_STRING);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd->unique_name);
|
||||||
|
|
||||||
|
const char *unique_name = eldbus_connection_unique_name_get(pd->connection);
|
||||||
|
Eina_Bool ret = eina_value_set(pd->unique_name, unique_name);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_property_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd EINA_UNUSED,
|
||||||
|
const char *property EINA_UNUSED,
|
||||||
|
Eina_Value const* value EINA_UNUSED)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_property_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const**value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
if (strcmp(property, UNIQUE_NAME_PROPERTY) != 0)
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
*value = pd->unique_name;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_object_connect(pd);
|
||||||
|
|
||||||
|
_eldbus_model_object_efl_model_base_properties_load(obj, pd);
|
||||||
|
_eldbus_model_object_efl_model_base_children_load(obj, pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_object_clear(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
_eldbus_model_object_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_child_del(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd EINA_UNUSED,
|
||||||
|
Eo *child EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
unsigned start,
|
||||||
|
unsigned count,
|
||||||
|
Eina_Accessor **children_accessor)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
|
||||||
|
{
|
||||||
|
WRN("(%p): Children not loaded", obj);
|
||||||
|
*children_accessor = NULL;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
WRN("(%p): Children already loaded", obj);
|
||||||
|
|
||||||
|
fprintf(stderr, "%p\n", pd->children_list);
|
||||||
|
|
||||||
|
*children_accessor = efl_model_list_slice(pd->children_list, start, count);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_object_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Object_Data *pd,
|
||||||
|
unsigned *children_count)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_count = eina_list_count(pd->children_list);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_efl_model_base_children_load(Eo *obj, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!pd->connection)
|
||||||
|
_eldbus_model_object_connect(pd);
|
||||||
|
|
||||||
|
if (!_eldbus_model_object_introspect(pd, pd->bus, pd->path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_model_object_bus_get(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->bus;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_bus_set(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd, const char *value)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(pd->bus);
|
||||||
|
pd->bus = eina_stringshare_add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_model_object_path_get(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_path_set(Eo *obj EINA_UNUSED, Eldbus_Model_Object_Data *pd, const char *value)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(pd->path);
|
||||||
|
pd->path = eina_stringshare_add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_connect(Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
|
||||||
|
/* if (ELDBUS_CONNECTION_TYPE_ADDRESS == pd->type) */
|
||||||
|
/* { */
|
||||||
|
/* if (pd->private) */
|
||||||
|
/* pd->connection = eldbus_address_connection_get(pd->address); */
|
||||||
|
/* else */
|
||||||
|
/* pd->connection = eldbus_private_address_connection_get(pd->address); */
|
||||||
|
/* } */
|
||||||
|
/* else */
|
||||||
|
/* { */
|
||||||
|
/* if (pd->private) */
|
||||||
|
/* pd->connection = eldbus_private_connection_get(pd->type); */
|
||||||
|
/* else */
|
||||||
|
/* pd->connection = eldbus_connection_get(pd->type); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
// TODO: Register for disconnection event
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(NULL != pd->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_disconnect(Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
eldbus_connection_unref(pd->connection);
|
||||||
|
pd->connection = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_clear(Eldbus_Model_Object_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
if (!pd->connection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eina_value_free(pd->unique_name);
|
||||||
|
pd->unique_name = NULL;
|
||||||
|
|
||||||
|
Eo *child;
|
||||||
|
EINA_LIST_FREE(pd->children_list, child)
|
||||||
|
eo_unref(child);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending;
|
||||||
|
EINA_LIST_FREE(pd->pending_list, pending)
|
||||||
|
eldbus_pending_cancel(pending);
|
||||||
|
|
||||||
|
if (pd->properties_array)
|
||||||
|
{
|
||||||
|
eina_array_free(pd->properties_array);
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Object *object;
|
||||||
|
EINA_LIST_FREE(pd->object_list, object)
|
||||||
|
eldbus_object_unref(object);
|
||||||
|
|
||||||
|
if (pd->introspection)
|
||||||
|
{
|
||||||
|
eldbus_introspection_node_free(pd->introspection);
|
||||||
|
pd->introspection = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_eldbus_model_object_disconnect(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_object_introspect(Eldbus_Model_Object_Data *pd,
|
||||||
|
const char *bus,
|
||||||
|
const char *path)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(bus, false);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
|
||||||
|
|
||||||
|
DBG("(%p) Introspecting: bus = %s, path = %s", pd->obj, bus, path);
|
||||||
|
|
||||||
|
Eldbus_Object *object = eldbus_object_get(pd->connection, bus, path);
|
||||||
|
if (!object)
|
||||||
|
{
|
||||||
|
ERR("(%p): Cannot get object: bus=%s, path=%s", pd->obj, bus, path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pd->object_list = eina_list_append(pd->object_list, object);
|
||||||
|
|
||||||
|
// TODO: Register for interface added/removed event
|
||||||
|
|
||||||
|
Eldbus_Pending *pending = eldbus_object_introspect(object, &_eldbus_model_object_introspect_cb, pd);
|
||||||
|
eldbus_pending_data_set(pending, "object", object);
|
||||||
|
pd->pending_list = eina_list_append(pd->pending_list, pending);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_introspect_cb(void *data,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Object_Data *pd = (Eldbus_Model_Object_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
pd->pending_list = eina_list_remove(pd->pending_list, pending);
|
||||||
|
Eldbus_Object *object = eldbus_pending_data_get(pending, "object");
|
||||||
|
|
||||||
|
const char *error_name, *error_text;
|
||||||
|
if (eldbus_message_error_get(msg, &error_name, &error_text))
|
||||||
|
{
|
||||||
|
ERR("%s: %s", error_name, error_text);
|
||||||
|
efl_model_error_notify(pd->obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *xml = NULL;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "s", &xml))
|
||||||
|
{
|
||||||
|
ERR("Error getting arguments.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(xml);
|
||||||
|
|
||||||
|
const char *current_path = eldbus_object_path_get(object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(current_path);
|
||||||
|
|
||||||
|
DBG("(%p): introspect of bus = %s, path = %s =>\n%s", pd->obj, pd->bus, current_path, xml);
|
||||||
|
|
||||||
|
pd->introspection = eldbus_introspection_parse(xml);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd->introspection);
|
||||||
|
|
||||||
|
_eldbus_model_object_introspect_nodes(pd, current_path, pd->introspection->nodes);
|
||||||
|
_eldbus_model_object_create_children(pd, object, pd->introspection->interfaces);
|
||||||
|
|
||||||
|
if (eina_list_count(pd->pending_list) == 0)
|
||||||
|
{
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
unsigned int count = eina_list_count(pd->children_list);
|
||||||
|
if (count)
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_introspect_nodes(Eldbus_Model_Object_Data *pd, const char *current_path, Eina_List *nodes)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(current_path);
|
||||||
|
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Node *node;
|
||||||
|
EINA_LIST_FOREACH(nodes, it, node)
|
||||||
|
{
|
||||||
|
const char *relative_path = node->name;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(relative_path);
|
||||||
|
|
||||||
|
char *absolute_path = _eldbus_model_object_concatenate_path(current_path, relative_path);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(absolute_path);
|
||||||
|
|
||||||
|
_eldbus_model_object_introspect(pd, pd->bus, absolute_path);
|
||||||
|
|
||||||
|
free(absolute_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_eldbus_model_object_concatenate_path(const char *root_path, const char *relative_path)
|
||||||
|
{
|
||||||
|
Eina_Strbuf *buffer = eina_strbuf_new();
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(buffer, NULL);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_strbuf_append(buffer, root_path);
|
||||||
|
if (strcmp(root_path, "/") != 0)
|
||||||
|
ret = ret && eina_strbuf_append_char(buffer, '/');
|
||||||
|
ret = ret && eina_strbuf_append(buffer, relative_path);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, free_buffer);
|
||||||
|
|
||||||
|
char *absolute_path = eina_strbuf_string_steal(buffer);
|
||||||
|
|
||||||
|
eina_strbuf_free(buffer);
|
||||||
|
|
||||||
|
return absolute_path;
|
||||||
|
|
||||||
|
free_buffer:
|
||||||
|
eina_strbuf_free(buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_object_create_children(Eldbus_Model_Object_Data *pd, Eldbus_Object *object, Eina_List *interfaces)
|
||||||
|
{
|
||||||
|
const char *current_path = eldbus_object_path_get(object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(current_path);
|
||||||
|
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Interface *interface;
|
||||||
|
EINA_LIST_FOREACH(interfaces, it, interface)
|
||||||
|
{
|
||||||
|
WRN("(%p) Creating child: bus = %s, path = %s, interface = %s", pd->obj, pd->bus, current_path, interface->name);
|
||||||
|
|
||||||
|
// TODO: increment reference to keep 'interface' in memory
|
||||||
|
Eo *child = eo_add_ref(ELDBUS_MODEL_PROXY_CLASS, NULL,
|
||||||
|
eldbus_model_proxy_object_set(object),
|
||||||
|
eldbus_model_proxy_interface_set(interface));
|
||||||
|
|
||||||
|
pd->children_list = eina_list_append(pd->children_list, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_object.eo.c"
|
|
@ -0,0 +1,55 @@
|
||||||
|
class Eldbus.Model_Object (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
data: Eldbus_Model_Object_Data;
|
||||||
|
methods {
|
||||||
|
@property bus {
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
value: const(char)*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property path {
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
value: const(char)*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property connection_model {
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
value: Eldbus.Model_Connection*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property connection {
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
value: Eldbus_Connection*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.connection @optional;
|
||||||
|
.connection_model @optional;
|
||||||
|
.bus;
|
||||||
|
.path;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_OBJECT_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_OBJECT_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Object_Data Eldbus_Model_Object_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_object
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Object_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eldbus_Connection *connection;
|
||||||
|
Eina_List *object_list;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_List *children_list;
|
||||||
|
// Eldbus_Connection_Type type;
|
||||||
|
// Eina_Stringshare *address;
|
||||||
|
// bool private;
|
||||||
|
Eina_Stringshare *bus;
|
||||||
|
Eina_Stringshare *path;
|
||||||
|
Eina_Value *unique_name;
|
||||||
|
Eina_List *pending_list;
|
||||||
|
Eldbus_Introspection_Node *introspection;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_PRIVATE_H
|
||||||
|
|
||||||
|
#include "eldbus_private.h"
|
||||||
|
|
||||||
|
#include <Eo.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
|
||||||
|
/* logging support */
|
||||||
|
extern int eldbus_model_log_dom;
|
||||||
|
|
||||||
|
#ifdef CRI
|
||||||
|
# undef CRI
|
||||||
|
#endif
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(eldbus_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef ERR
|
||||||
|
# undef ERR
|
||||||
|
#endif
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(eldbus_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef WRN
|
||||||
|
# undef WRN
|
||||||
|
#endif
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(eldbus_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef INF
|
||||||
|
# undef INF
|
||||||
|
#endif
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(eldbus_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
# undef DBG
|
||||||
|
#endif
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(eldbus_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,713 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_proxy_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_PROXY_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Proxy"
|
||||||
|
|
||||||
|
static void _eldbus_model_proxy_efl_model_base_properties_load(Eo *, Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_efl_model_base_children_load(Eo *, Eldbus_Model_Proxy_Data *);
|
||||||
|
static bool _eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_unload(Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_property_get_all_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
static void _eldbus_model_proxy_property_set_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
static void _eldbus_model_proxy_start_monitor(Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_stop_monitor(Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_property_changed_cb(void *, Eldbus_Proxy *, void *);
|
||||||
|
static void _eldbus_model_proxy_property_invalidated_cb(void *, Eldbus_Proxy *, void *);
|
||||||
|
static bool _eldbus_model_proxy_is_property_writeable(Eldbus_Model_Proxy_Data *, const char *);
|
||||||
|
static bool _eldbus_model_proxy_is_property_readable(Eldbus_Model_Proxy_Data *, const char *);
|
||||||
|
static const char *_eldbus_model_proxy_property_type_get(Eldbus_Model_Proxy_Data *, const char *);
|
||||||
|
static void _eldbus_model_proxy_create_methods_children(Eldbus_Model_Proxy_Data *);
|
||||||
|
static void _eldbus_model_proxy_create_signals_children(Eldbus_Model_Proxy_Data *);
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Proxy_Property_Set_Data Eldbus_Model_Proxy_Property_Set_Data;
|
||||||
|
|
||||||
|
struct _Eldbus_Model_Proxy_Property_Set_Data
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Data *pd;
|
||||||
|
Eina_Stringshare *property;
|
||||||
|
Eina_Value value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Eldbus_Model_Proxy_Property_Set_Data * _eldbus_model_proxy_property_set_data_new(Eldbus_Model_Proxy_Data *, const char *, const Eina_Value *);
|
||||||
|
static void _eldbus_model_proxy_property_set_data_free(Eldbus_Model_Proxy_Property_Set_Data *);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_hash_free(Eina_Value *value)
|
||||||
|
{
|
||||||
|
eina_value_free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_proxy_eo_base_constructor(Eo *obj, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
|
||||||
|
pd->object = NULL;
|
||||||
|
pd->proxy = NULL;
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
pd->properties_hash = eina_hash_string_superfast_new(EINA_FREE_CB(_eldbus_model_proxy_hash_free));
|
||||||
|
pd->children_list = NULL;
|
||||||
|
pd->name = NULL;
|
||||||
|
pd->pending_list = NULL;
|
||||||
|
pd->monitoring = false;
|
||||||
|
pd->interface = NULL;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_object_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
Eldbus_Object *object)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(object);
|
||||||
|
|
||||||
|
pd->object = eldbus_object_ref(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_interface_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
const Eldbus_Introspection_Interface *interface)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(interface);
|
||||||
|
|
||||||
|
pd->name = eina_stringshare_add(interface->name);
|
||||||
|
pd->interface = interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Object*
|
||||||
|
_eldbus_model_proxy_object_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->object;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Eldbus_Introspection_Interface*
|
||||||
|
_eldbus_model_proxy_interface_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_eo_base_destructor(Eo *obj, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_proxy_unload(pd);
|
||||||
|
|
||||||
|
eina_hash_free(pd->properties_hash);
|
||||||
|
|
||||||
|
eina_stringshare_del(pd->name);
|
||||||
|
eldbus_object_unref(pd->object);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
Eina_Array * const* properties_array)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
{
|
||||||
|
WRN("%s", "Properties not loaded.");
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(Eina_Array**)properties_array = pd->properties_array;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_eldbus_model_proxy_load(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const unsigned int properties_count = eina_list_count(pd->interface->properties);
|
||||||
|
|
||||||
|
pd->properties_array = eina_array_new(properties_count);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd->properties_array);
|
||||||
|
|
||||||
|
if (0 == properties_count)
|
||||||
|
{
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Property *property;
|
||||||
|
EINA_LIST_FOREACH(pd->interface->properties, it, property)
|
||||||
|
{
|
||||||
|
Eina_Stringshare *name = eina_stringshare_add(property->name);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(name);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(pd->properties_array, name);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Pending *pending = eldbus_proxy_property_get_all(pd->proxy, _eldbus_model_proxy_property_get_all_cb, pd);
|
||||||
|
pd->pending_list = eina_list_append(pd->pending_list, pending);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_property_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const* value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
DBG("(%p): property=%s", obj, property);
|
||||||
|
|
||||||
|
if (!_eldbus_model_proxy_is_property_writeable(pd, property))
|
||||||
|
{
|
||||||
|
WRN("Property is read-only: %s", property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Model_Proxy_Property_Set_Data *data =
|
||||||
|
_eldbus_model_proxy_property_set_data_new(pd, property, value);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
const char *signature = _eldbus_model_proxy_property_type_get(pd, property);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending = eldbus_proxy_property_value_set
|
||||||
|
(pd->proxy, property, signature, (Eina_Value*)value, _eldbus_model_proxy_property_set_cb, data);
|
||||||
|
pd->pending_list = eina_list_append(pd->pending_list, pending);
|
||||||
|
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_property_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
Eina_Value const **value)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(property, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
|
||||||
|
if (!_eldbus_model_proxy_is_property_readable(pd, property))
|
||||||
|
{
|
||||||
|
WRN("Property is write-only: %s", property);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = eina_hash_find(pd->properties_hash, property);
|
||||||
|
|
||||||
|
if(!*value)
|
||||||
|
{
|
||||||
|
*value = &pd->tmp_value;
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_efl_model_base_load(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
if (!_eldbus_model_proxy_load(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_eldbus_model_proxy_efl_model_base_properties_load(obj, pd);
|
||||||
|
_eldbus_model_proxy_efl_model_base_children_load(obj, pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_load_status_get(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_proxy_unload(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
_eldbus_model_proxy_efl_model_base_child_add(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_child_del(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd EINA_UNUSED,
|
||||||
|
Eo *child EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
unsigned start,
|
||||||
|
unsigned count,
|
||||||
|
Eina_Accessor **children_accessor)
|
||||||
|
{
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
|
||||||
|
{
|
||||||
|
WRN("(%p): Children not loaded", obj);
|
||||||
|
*children_accessor = NULL;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*children_accessor = efl_model_list_slice(pd->children_list, start, count);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_eldbus_model_proxy_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Proxy_Data *pd,
|
||||||
|
unsigned *children_count)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_count = eina_list_count(pd->children_list);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_efl_model_base_children_load(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_eldbus_model_proxy_load(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_eldbus_model_proxy_create_methods_children(pd);
|
||||||
|
_eldbus_model_proxy_create_signals_children(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
unsigned int count = eina_list_count(pd->children_list);
|
||||||
|
if (count)
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_create_methods_children(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Method *method;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(pd->interface->methods, it, method)
|
||||||
|
{
|
||||||
|
const char *bus = eldbus_object_bus_name_get(pd->object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(bus);
|
||||||
|
|
||||||
|
const char *path = eldbus_object_path_get(pd->object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(path);
|
||||||
|
|
||||||
|
const char *interface_name = pd->interface->name;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(interface_name);
|
||||||
|
|
||||||
|
const char *method_name = method->name;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(method_name);
|
||||||
|
|
||||||
|
INF("(%p) Creating method child: bus = %s, path = %s, method = %s::%s", pd->obj, bus, path, interface_name, method_name);
|
||||||
|
|
||||||
|
Eo *child = eo_add(ELDBUS_MODEL_METHOD_CLASS, NULL,
|
||||||
|
eldbus_model_arguments_proxy_set(pd->proxy),
|
||||||
|
eldbus_model_method_set(method));
|
||||||
|
|
||||||
|
pd->children_list = eina_list_append(pd->children_list, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_create_signals_children(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Signal *signal;
|
||||||
|
EINA_LIST_FOREACH(pd->interface->signals, it, signal)
|
||||||
|
{
|
||||||
|
const char *bus = eldbus_object_bus_name_get(pd->object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(bus);
|
||||||
|
|
||||||
|
const char *path = eldbus_object_path_get(pd->object);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(path);
|
||||||
|
|
||||||
|
const char *interface_name = pd->interface->name;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(interface_name);
|
||||||
|
|
||||||
|
const char *signal_name = signal->name;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(signal_name);
|
||||||
|
|
||||||
|
DBG("(%p) Creating signal child: bus = %s, path = %s, signal = %s::%s", pd->obj, bus, path, interface_name, signal_name);
|
||||||
|
|
||||||
|
Eo *child = eo_add(ELDBUS_MODEL_SIGNAL_CLASS, NULL,
|
||||||
|
eldbus_model_arguments_proxy_set(pd->proxy),
|
||||||
|
eldbus_model_signal_set(signal));
|
||||||
|
|
||||||
|
pd->children_list = eina_list_append(pd->children_list, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_model_proxy_name_get(Eo *obj EINA_UNUSED, Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_proxy_load(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
|
||||||
|
if (pd->proxy)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pd->proxy = eldbus_proxy_get(pd->object, pd->name);
|
||||||
|
if (!pd->proxy)
|
||||||
|
{
|
||||||
|
ERR("Cannot get proxy for interface: %s", pd->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_unload(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
|
||||||
|
Eo *child;
|
||||||
|
EINA_LIST_FREE(pd->children_list, child)
|
||||||
|
eo_unref(child);
|
||||||
|
|
||||||
|
Eldbus_Pending *pending;
|
||||||
|
EINA_LIST_FREE(pd->pending_list, pending)
|
||||||
|
eldbus_pending_cancel(pending);
|
||||||
|
|
||||||
|
if (pd->properties_array)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
Eina_Stringshare *property;
|
||||||
|
Eina_Array_Iterator it;
|
||||||
|
EINA_ARRAY_ITER_NEXT(pd->properties_array, i, property, it)
|
||||||
|
eina_stringshare_del(property);
|
||||||
|
eina_array_free(pd->properties_array);
|
||||||
|
pd->properties_array = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
eina_hash_free_buckets(pd->properties_hash);
|
||||||
|
|
||||||
|
_eldbus_model_proxy_stop_monitor(pd);
|
||||||
|
|
||||||
|
if (pd->proxy)
|
||||||
|
{
|
||||||
|
eldbus_proxy_unref(pd->proxy);
|
||||||
|
pd->proxy = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_start_monitor(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->monitoring)
|
||||||
|
return;
|
||||||
|
pd->monitoring = true;
|
||||||
|
|
||||||
|
eldbus_proxy_event_callback_add(pd->proxy,
|
||||||
|
ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
|
||||||
|
_eldbus_model_proxy_property_changed_cb,
|
||||||
|
pd);
|
||||||
|
|
||||||
|
eldbus_proxy_event_callback_add(pd->proxy,
|
||||||
|
ELDBUS_PROXY_EVENT_PROPERTY_REMOVED,
|
||||||
|
_eldbus_model_proxy_property_invalidated_cb,
|
||||||
|
pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_stop_monitor(Eldbus_Model_Proxy_Data *pd)
|
||||||
|
{
|
||||||
|
if (!pd->monitoring)
|
||||||
|
return;
|
||||||
|
pd->monitoring = false;
|
||||||
|
|
||||||
|
eldbus_proxy_event_callback_del(pd->proxy,
|
||||||
|
ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
|
||||||
|
_eldbus_model_proxy_property_changed_cb,
|
||||||
|
pd);
|
||||||
|
|
||||||
|
eldbus_proxy_event_callback_del(pd->proxy,
|
||||||
|
ELDBUS_PROXY_EVENT_PROPERTY_REMOVED,
|
||||||
|
_eldbus_model_proxy_property_invalidated_cb,
|
||||||
|
pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_property_changed_cb(void *data,
|
||||||
|
Eldbus_Proxy *proxy EINA_UNUSED,
|
||||||
|
void *event_info)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
Eldbus_Object_Event_Property_Changed *event = (Eldbus_Object_Event_Property_Changed*)event_info;
|
||||||
|
|
||||||
|
Eina_Value *prop_value = eina_hash_find(pd->properties_hash, event->name);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(prop_value);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_value_copy(event->value, prop_value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
|
||||||
|
efl_model_property_changed_notify(pd->obj, event->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_property_invalidated_cb(void *data,
|
||||||
|
Eldbus_Proxy *proxy EINA_UNUSED,
|
||||||
|
void *event_info)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
Eldbus_Proxy_Event_Property_Changed *event = (Eldbus_Proxy_Event_Property_Changed*)event_info;
|
||||||
|
|
||||||
|
// TODO: eldbus_proxy_property_get(event->name) ?
|
||||||
|
|
||||||
|
Efl_Model_Property_Event evt = {0};
|
||||||
|
evt.invalidated_properties = eina_array_new(1);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(evt.invalidated_properties);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_array_push(evt.invalidated_properties, event->name);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_array_free(evt.invalidated_properties);
|
||||||
|
efl_model_property_invalidated_notify(pd->obj, event->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_property_get_all_cb(void *data,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data;
|
||||||
|
|
||||||
|
pd->pending_list = eina_list_remove(pd->pending_list, pending);
|
||||||
|
|
||||||
|
const char *error_name, *error_text;
|
||||||
|
if (eldbus_message_error_get(msg, &error_name, &error_text))
|
||||||
|
{
|
||||||
|
ERR("%s: %s", error_name, error_text);
|
||||||
|
efl_model_error_notify(pd->obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Message_Iter *values = NULL;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "a{sv}", &values))
|
||||||
|
{
|
||||||
|
ERR("%s", "Error getting arguments.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_List *it;
|
||||||
|
Eldbus_Introspection_Property *prop;
|
||||||
|
EINA_LIST_FOREACH(pd->interface->properties, it, prop)
|
||||||
|
{
|
||||||
|
const Eina_Value_Type *type = _dbus_type_to_eina_value_type(prop->type[0]);
|
||||||
|
Eina_Value *value = eina_value_new(type);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(value);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_hash_add(pd->properties_hash, prop->name, value);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Array *changed_properties = eina_array_new(1);
|
||||||
|
Eldbus_Message_Iter *entry;
|
||||||
|
while (eldbus_message_iter_get_and_next(values, 'e', &entry))
|
||||||
|
{
|
||||||
|
const char *property;
|
||||||
|
Eldbus_Message_Iter *variant;
|
||||||
|
if (!eldbus_message_iter_arguments_get(entry, "sv", &property, &variant))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Eina_Value *struct_value = eldbus_message_iter_struct_like_to_eina_value(variant);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(struct_value, on_error);
|
||||||
|
|
||||||
|
Eina_Value arg0;
|
||||||
|
Eina_Bool ret = eina_value_struct_value_get(struct_value, "arg0", &arg0);
|
||||||
|
eina_value_free(struct_value);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
Eina_Value *prop_value = eina_hash_find(pd->properties_hash, property);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(prop_value, on_error);
|
||||||
|
|
||||||
|
ret = eina_value_copy(&arg0, prop_value);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
eina_value_flush(&arg0);
|
||||||
|
|
||||||
|
ret = eina_array_push(changed_properties, property);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
_eldbus_model_proxy_start_monitor(pd);
|
||||||
|
|
||||||
|
if (eina_array_count(changed_properties))
|
||||||
|
{
|
||||||
|
Efl_Model_Property_Event evt = {.changed_properties = changed_properties};
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt));
|
||||||
|
}
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_array_free(changed_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_property_set_cb(void *data,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Property_Set_Data *property_set_data = (Eldbus_Model_Proxy_Property_Set_Data *)data;
|
||||||
|
Eldbus_Model_Proxy_Data *pd = property_set_data->pd;
|
||||||
|
|
||||||
|
pd->pending_list = eina_list_remove(pd->pending_list, pending);
|
||||||
|
|
||||||
|
const char *error_name, *error_text;
|
||||||
|
if (eldbus_message_error_get(msg, &error_name, &error_text))
|
||||||
|
{
|
||||||
|
ERR("%s: %s", error_name, error_text);
|
||||||
|
efl_model_error_notify(pd->obj);
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Value *prop_value = eina_hash_find(pd->properties_hash,
|
||||||
|
property_set_data->property);
|
||||||
|
EINA_SAFETY_ON_NULL_GOTO(prop_value, on_error);
|
||||||
|
|
||||||
|
Eina_Bool ret = eina_value_copy(&property_set_data->value, prop_value);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
|
||||||
|
|
||||||
|
Efl_Model_Property_Event evt = {.changed_properties = pd->properties_array};
|
||||||
|
eo_do(pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, &evt));
|
||||||
|
efl_model_property_changed_notify(pd->obj, property_set_data->property);
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
_eldbus_model_proxy_property_set_data_free(property_set_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_proxy_is_property_writeable(Eldbus_Model_Proxy_Data *pd, const char *property)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Property *property_introspection =
|
||||||
|
eldbus_introspection_property_find(pd->interface->properties, property);
|
||||||
|
if (NULL == property_introspection)
|
||||||
|
{
|
||||||
|
WRN("Property not found: %s", property);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ELDBUS_INTROSPECTION_PROPERTY_ACCESS_WRITE == property_introspection->access
|
||||||
|
|| ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READWRITE == property_introspection->access;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_eldbus_model_proxy_is_property_readable(Eldbus_Model_Proxy_Data *pd, const char *property)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Property *property_introspection =
|
||||||
|
eldbus_introspection_property_find(pd->interface->properties, property);
|
||||||
|
if (NULL == property_introspection)
|
||||||
|
{
|
||||||
|
WRN("Property not found: %s", property);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READ == property_introspection->access
|
||||||
|
|| ELDBUS_INTROSPECTION_PROPERTY_ACCESS_READWRITE == property_introspection->access;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_eldbus_model_proxy_property_type_get(Eldbus_Model_Proxy_Data *pd, const char *property)
|
||||||
|
{
|
||||||
|
Eldbus_Introspection_Property *property_introspection =
|
||||||
|
eldbus_introspection_property_find(pd->interface->properties, property);
|
||||||
|
if (NULL == property_introspection)
|
||||||
|
{
|
||||||
|
WRN("Property not found: %s", property);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return property_introspection->type;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Model_Proxy_Property_Set_Data *
|
||||||
|
_eldbus_model_proxy_property_set_data_new(Eldbus_Model_Proxy_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
const Eina_Value *value)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Proxy_Property_Set_Data *data = calloc(1, sizeof(Eldbus_Model_Proxy_Property_Set_Data));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
|
||||||
|
|
||||||
|
data->pd = pd;
|
||||||
|
data->property = eina_stringshare_add(property);
|
||||||
|
Eina_Bool ret = eina_value_copy(value, &data->value);
|
||||||
|
EINA_SAFETY_ON_FALSE_GOTO(ret, error);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
|
||||||
|
error:
|
||||||
|
eina_stringshare_del(data->property);
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_proxy_property_set_data_free(Eldbus_Model_Proxy_Property_Set_Data *data)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(data);
|
||||||
|
eina_stringshare_del(data->property);
|
||||||
|
eina_value_flush(&data->value);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_proxy.eo.c"
|
|
@ -0,0 +1,48 @@
|
||||||
|
class Eldbus.Model_Proxy (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property object {
|
||||||
|
[[Custom Eldbus_Model_Proxy constructor.
|
||||||
|
|
||||||
|
@since 1.16]]
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
object: Eldbus_Object *; [[Eldbus object]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property name {
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
value: const(char)*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property interface {
|
||||||
|
get {}
|
||||||
|
set {}
|
||||||
|
values {
|
||||||
|
interface_: const(Eldbus_Introspection_Interface)*; [[The introspected interface]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.object;
|
||||||
|
.interface;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_PROXY_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_PROXY_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Proxy_Data Eldbus_Model_Proxy_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_proxy
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Proxy_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eldbus_Object *object;
|
||||||
|
Eldbus_Proxy *proxy;
|
||||||
|
Eina_Array *properties_array;
|
||||||
|
Eina_Hash *properties_hash;
|
||||||
|
Eina_List *children_list;
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_List *pending_list;
|
||||||
|
bool monitoring;
|
||||||
|
const Eldbus_Introspection_Interface *interface;
|
||||||
|
Eina_Value tmp_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_model_arguments_private.h"
|
||||||
|
#include "eldbus_model_signal_private.h"
|
||||||
|
#include "eldbus_model_private.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ELDBUS_MODEL_SIGNAL_CLASS
|
||||||
|
#define MY_CLASS_NAME "Eldbus_Model_Signal"
|
||||||
|
|
||||||
|
static void _eldbus_model_signal_handler_cb(void *, const Eldbus_Message *);
|
||||||
|
static void _eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *);
|
||||||
|
static void _eldbus_model_signal_callback_del(Eldbus_Model_Signal_Data *);
|
||||||
|
|
||||||
|
static Eo_Base*
|
||||||
|
_eldbus_model_signal_eo_base_constructor(Eo *obj, Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_constructor());
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->handler = NULL;
|
||||||
|
pd->signal = NULL;
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_proxy_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Signal_Data *pd EINA_UNUSED,
|
||||||
|
Eldbus_Proxy *proxy)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(proxy);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eldbus_model_arguments_proxy_set(proxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Proxy*
|
||||||
|
_eldbus_model_signal_proxy_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Signal_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
Eldbus_Proxy* p = NULL;
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, p = eldbus_model_arguments_proxy_get());
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_signal_set(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Signal_Data *pd,
|
||||||
|
const Eldbus_Introspection_Signal *signal)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(signal);
|
||||||
|
|
||||||
|
pd->signal = signal;
|
||||||
|
eo_do(obj,
|
||||||
|
eldbus_model_arguments_name_set(signal->name),
|
||||||
|
eldbus_model_arguments_set(signal->arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Eldbus_Introspection_Signal*
|
||||||
|
_eldbus_model_signal_signal_get(Eo *obj EINA_UNUSED,
|
||||||
|
Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->signal;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_eo_base_destructor(Eo *obj, Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_eldbus_model_signal_callback_del(pd);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(args_data);
|
||||||
|
|
||||||
|
if (args_data->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_eldbus_model_signal_callback_add(pd);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, efl_model_properties_load());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
_eldbus_model_signal_callback_del(pd);
|
||||||
|
eo_do_super(obj, MY_CLASS, efl_model_unload());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(NULL == pd->handler);
|
||||||
|
|
||||||
|
Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(args_data);
|
||||||
|
|
||||||
|
pd->handler = eldbus_proxy_signal_handler_add(args_data->proxy, pd->signal->name, _eldbus_model_signal_handler_cb, pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_callback_del(Eldbus_Model_Signal_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
if (pd->handler)
|
||||||
|
{
|
||||||
|
eldbus_signal_handler_unref(pd->handler);
|
||||||
|
pd->handler = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eldbus_model_signal_handler_cb(void *data, const Eldbus_Message *msg)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Signal_Data *pd = (Eldbus_Model_Signal_Data*)data;
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(args_data);
|
||||||
|
|
||||||
|
eldbus_model_arguments_process_arguments(args_data, msg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "eldbus_model_signal.eo.c"
|
|
@ -0,0 +1,22 @@
|
||||||
|
class Eldbus.Model_Signal (Eldbus.Model_Arguments) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property signal {
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
signal: const(Eldbus_Introspection_Signal)*; [[The introspected method]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
Eldbus.Model_Arguments.proxy;
|
||||||
|
.signal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef _ELDBUS_MODEL_SIGNAL_PRIVATE_H
|
||||||
|
#define _ELDBUS_MODEL_SIGNAL_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Eldbus_Model.h"
|
||||||
|
|
||||||
|
typedef struct _Eldbus_Model_Signal_Data Eldbus_Model_Signal_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eldbus_model_signal
|
||||||
|
*/
|
||||||
|
struct _Eldbus_Model_Signal_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Eldbus_Signal_Handler *handler;
|
||||||
|
const Eldbus_Introspection_Signal *signal;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -76,10 +76,15 @@ Eldbus_Pending *_eldbus_connection_send(Eldbus_Connection *conn, Eldbus_
|
||||||
Eldbus_Message *_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg, double timeout);
|
Eldbus_Message *_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg, double timeout);
|
||||||
|
|
||||||
Eldbus_Message_Iter *eldbus_message_iter_sub_iter_get(Eldbus_Message_Iter *iter);
|
Eldbus_Message_Iter *eldbus_message_iter_sub_iter_get(Eldbus_Message_Iter *iter);
|
||||||
Eina_Value *_message_iter_struct_to_eina_value(Eldbus_Message_Iter *iter);
|
Eina_Value *_message_iter_struct_to_eina_value(Eldbus_Message_Iter *iter);
|
||||||
Eina_Bool _message_iter_from_eina_value_struct(const char *signature, Eldbus_Message_Iter *iter, const Eina_Value *value);
|
Eina_Bool _message_iter_from_eina_value(const char *signature, Eldbus_Message_Iter *iter, const Eina_Value *value);
|
||||||
|
Eina_Bool _message_iter_from_eina_value_struct(const char *signature, Eldbus_Message_Iter *iter, const Eina_Value *value);
|
||||||
|
|
||||||
void eldbus_connection_name_ref(Eldbus_Connection_Name *cn);
|
void eldbus_connection_name_ref(Eldbus_Connection_Name *cn);
|
||||||
void eldbus_connection_name_unref(Eldbus_Connection *conn, Eldbus_Connection_Name *cn);
|
void eldbus_connection_name_unref(Eldbus_Connection *conn, Eldbus_Connection_Name *cn);
|
||||||
Eldbus_Signal_Handler *_eldbus_signal_handler_add(Eldbus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, Eldbus_Signal_Cb cb, const void *cb_data);
|
Eldbus_Signal_Handler *_eldbus_signal_handler_add(Eldbus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, Eldbus_Signal_Cb cb, const void *cb_data);
|
||||||
|
Eldbus_Message *eldbus_message_signal_new(const char *path, const char *interface, const char *name) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
const Eina_Value_Type *_dbus_type_to_eina_value_type(char type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -727,6 +727,42 @@ eldbus_proxy_property_set(Eldbus_Proxy *proxy, const char *name, const char *sig
|
||||||
return eldbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);
|
return eldbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eldbus_Pending *
|
||||||
|
eldbus_proxy_property_value_set(Eldbus_Proxy *proxy, const char *name, const char *sig, const Eina_Value *value, Eldbus_Message_Cb cb, const void *data)
|
||||||
|
{
|
||||||
|
Eldbus_Message *msg;
|
||||||
|
Eldbus_Message_Iter *iter, *variant;
|
||||||
|
|
||||||
|
ELDBUS_PROXY_CHECK_RETVAL(proxy, NULL);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sig, NULL);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(dbus_signature_validate_single(sig, NULL), NULL);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL((_type_is_number(sig[0]) || value), NULL);
|
||||||
|
|
||||||
|
msg = eldbus_proxy_method_call_new(proxy->obj->properties, "Set");
|
||||||
|
iter = eldbus_message_iter_get(msg);
|
||||||
|
eldbus_message_iter_basic_append(iter, 's', proxy->interface);
|
||||||
|
eldbus_message_iter_basic_append(iter, 's', name);
|
||||||
|
variant = eldbus_message_iter_container_new(iter, 'v', sig);
|
||||||
|
if (dbus_type_is_basic(sig[0]))
|
||||||
|
{
|
||||||
|
if (!_message_iter_from_eina_value(sig, variant, value))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!_message_iter_from_eina_value_struct(sig, variant, value))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
eldbus_message_iter_container_close(iter, variant);
|
||||||
|
|
||||||
|
return eldbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);
|
||||||
|
|
||||||
|
error:
|
||||||
|
eldbus_message_unref(msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eldbus_Pending *
|
EAPI Eldbus_Pending *
|
||||||
eldbus_proxy_property_get_all(Eldbus_Proxy *proxy, Eldbus_Message_Cb cb, const void *data)
|
eldbus_proxy_property_get_all(Eldbus_Proxy *proxy, Eldbus_Message_Cb cb, const void *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#ifndef ESOAP_MODEL_H
|
||||||
|
#define ESOAP_MODEL_H
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Efl_Config.h>
|
||||||
|
|
||||||
|
#ifdef EAPI
|
||||||
|
# undef EAPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifdef EFL_ESOAP_MODEL_BUILD
|
||||||
|
# ifdef DLL_EXPORT
|
||||||
|
# define EAPI __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif /* ! DLL_EXPORT */
|
||||||
|
# else
|
||||||
|
# define EAPI __declspec(dllimport)
|
||||||
|
# endif /* ! EFL_ESOAP_MODEL_BUILD */
|
||||||
|
#else
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# if __GNUC__ >= 4
|
||||||
|
# define EAPI __attribute__ ((visibility("default")))
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define EAPI
|
||||||
|
# endif
|
||||||
|
#endif /* ! _WIN32 */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize esoap_model.
|
||||||
|
*
|
||||||
|
* @return 1 or greater on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
EAPI int esoap_model_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Shutdown esoap_model.
|
||||||
|
*
|
||||||
|
* @return 0 if esoap_model shuts down, greater than 0 otherwise.
|
||||||
|
*/
|
||||||
|
EAPI int esoap_model_shutdown(void);
|
||||||
|
|
||||||
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
|
# include <esoap_model.eo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EAPI
|
||||||
|
#define EAPI
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,498 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "esoap_model_private.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define MY_CLASS ESOAP_MODEL_CLASS
|
||||||
|
#define MY_CLASS_NAME "Esoap_Model"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Esoap_Model_Data *pd;
|
||||||
|
Eina_Strbuf *response;
|
||||||
|
struct curl_slist *header;
|
||||||
|
char *soap_action;
|
||||||
|
CURL *curl;
|
||||||
|
Ecore_Thread *thread;
|
||||||
|
} Esoap_Model_Perform_Data;
|
||||||
|
|
||||||
|
static void _properties_load(Esoap_Model_Data *);
|
||||||
|
static void _children_load(Esoap_Model_Data *);
|
||||||
|
static bool _init(Esoap_Model_Data *);
|
||||||
|
static void _clear(Esoap_Model_Data *);
|
||||||
|
static void _perform(Esoap_Model_Data *, const char *);
|
||||||
|
static void _perform_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
|
||||||
|
static void _perform_end_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
|
||||||
|
static void _perform_cancel_cb(Esoap_Model_Perform_Data *, Ecore_Thread *);
|
||||||
|
static Eina_Bool _properties_changed_cb(void *, Eo *, const Eo_Event_Description *, void *);
|
||||||
|
static size_t _write_data_cb(void *, size_t, size_t, void *);
|
||||||
|
static void _perform_data_free(Esoap_Model_Perform_Data *data);
|
||||||
|
|
||||||
|
static int _esoap_model_init_count = 0;
|
||||||
|
int _esoap_model_log_dom = -1;
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
esoap_model_init(void)
|
||||||
|
{
|
||||||
|
if (_esoap_model_init_count++ > 0)
|
||||||
|
return _esoap_model_init_count;
|
||||||
|
|
||||||
|
if (!eina_init())
|
||||||
|
{
|
||||||
|
fputs("Esoap_Model: Unable to initialize eina\n", stderr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_esoap_model_log_dom = eina_log_domain_register("Esoap_Model", EINA_COLOR_CYAN);
|
||||||
|
if (_esoap_model_log_dom < 0)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("Unable to create an 'Esoap_Model' log domain");
|
||||||
|
_esoap_model_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ecore_init())
|
||||||
|
{
|
||||||
|
ERR("Unable to initialize ecore");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!eflat_xml_model_init())
|
||||||
|
{
|
||||||
|
ERR("Unable to initialize eflat_xml_model");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
if (CURLE_OK != code)
|
||||||
|
{
|
||||||
|
ERR("Unable to initialize curl");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _esoap_model_init_count;
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
eina_log_domain_unregister(_esoap_model_log_dom);
|
||||||
|
_esoap_model_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
esoap_model_shutdown(void)
|
||||||
|
{
|
||||||
|
if (_esoap_model_init_count <= 0)
|
||||||
|
{
|
||||||
|
ERR("Init count not greater than 0 in shutdown.");
|
||||||
|
_esoap_model_init_count = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--_esoap_model_init_count)
|
||||||
|
return _esoap_model_init_count;
|
||||||
|
|
||||||
|
curl_global_cleanup();
|
||||||
|
eflat_xml_model_shutdown();
|
||||||
|
ecore_shutdown();
|
||||||
|
eina_log_domain_unregister(_esoap_model_log_dom);
|
||||||
|
_esoap_model_log_dom = -1;
|
||||||
|
eina_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eo_Base *
|
||||||
|
_esoap_model_eo_base_constructor(Eo *obj, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
pd->obj = obj;
|
||||||
|
pd->load.status = EFL_MODEL_LOAD_STATUS_UNLOADED;
|
||||||
|
pd->children_list = NULL;
|
||||||
|
pd->xml = NULL;
|
||||||
|
pd->url = NULL;
|
||||||
|
pd->action = NULL;
|
||||||
|
|
||||||
|
return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_url_set(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd EINA_UNUSED,
|
||||||
|
const char *url)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(url);
|
||||||
|
|
||||||
|
pd->url = strdup(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
_esoap_model_url_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_action_set(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd EINA_UNUSED,
|
||||||
|
const char *action)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(action);
|
||||||
|
|
||||||
|
pd->action = strdup(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
_esoap_model_action_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
return pd->action;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_eo_base_destructor(Eo *obj, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_clear(pd);
|
||||||
|
free(pd->url);
|
||||||
|
free(pd->action);
|
||||||
|
|
||||||
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_properties_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd,
|
||||||
|
Eina_Array * const* properties_array)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->obj, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
|
||||||
|
eo_do(pd->xml, efl_model_properties_get(properties_array));
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_efl_model_base_properties_load(Eo *obj, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_init(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_properties_load(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_properties_load(Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
efl_model_load_set(pd->obj,
|
||||||
|
&pd->load,
|
||||||
|
EFL_MODEL_LOAD_STATUS_LOADING_PROPERTIES);
|
||||||
|
eo_do(pd->xml, efl_model_properties_load());
|
||||||
|
efl_model_load_set(pd->obj,
|
||||||
|
&pd->load,
|
||||||
|
EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_property_set(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
const Eina_Value *value)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pd->xml, status = efl_model_property_set(property, value));
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_property_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd,
|
||||||
|
const char *property,
|
||||||
|
const Eina_Value **value)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pd->xml, status = efl_model_property_get(property, value));
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(status != EFL_MODEL_LOAD_STATUS_ERROR, EFL_MODEL_LOAD_STATUS_ERROR);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_efl_model_base_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if ((pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED) == EFL_MODEL_LOAD_STATUS_LOADED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_init(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES))
|
||||||
|
_properties_load(pd);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
|
||||||
|
_children_load(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_load_status_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_efl_model_base_unload(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
_clear(pd);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
_esoap_model_efl_model_base_child_add(Eo *obj, Esoap_Model_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_child_del(Eo *obj,
|
||||||
|
Esoap_Model_Data *pd EINA_UNUSED,
|
||||||
|
Eo *child EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
return EFL_MODEL_LOAD_STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_children_slice_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd,
|
||||||
|
unsigned start EINA_UNUSED,
|
||||||
|
unsigned count EINA_UNUSED,
|
||||||
|
Eina_Accessor **children_accessor)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (!(pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN))
|
||||||
|
{
|
||||||
|
WRN("(%p): Children not loaded", obj);
|
||||||
|
*children_accessor = NULL;
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*children_accessor = efl_model_list_slice(pd->children_list, start, count);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_esoap_model_efl_model_base_children_count_get(Eo *obj EINA_UNUSED,
|
||||||
|
Esoap_Model_Data *pd,
|
||||||
|
unsigned *children_count)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
*children_count = eina_list_count(pd->children_list);
|
||||||
|
return pd->load.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_esoap_model_efl_model_base_children_load(Eo *obj EINA_UNUSED, Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", obj);
|
||||||
|
|
||||||
|
if (pd->load.status & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_init(pd))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_children_load(pd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_children_load(Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
|
||||||
|
efl_model_load_set(pd->obj, &pd->load, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
|
||||||
|
|
||||||
|
const Eina_Value *xml_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pd->xml, status = efl_model_property_get("/", &xml_value));
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
|
||||||
|
|
||||||
|
const char *xml = NULL;
|
||||||
|
eina_value_get(xml_value, &xml);
|
||||||
|
_perform(pd, xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_properties_changed_cb(void *data,
|
||||||
|
Eo *child EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info)
|
||||||
|
{
|
||||||
|
eo_do(data, eo_event_callback_call(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED, event_info));
|
||||||
|
return EO_CALLBACK_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_init(Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->xml)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pd->xml = eo_add(EFLAT_XML_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
eflat_xml_model_constructor(NULL));
|
||||||
|
|
||||||
|
eo_do(pd->xml, eo_event_callback_add(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED,
|
||||||
|
_properties_changed_cb,
|
||||||
|
pd->obj));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_clear(Esoap_Model_Data *pd)
|
||||||
|
{
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(pd);
|
||||||
|
|
||||||
|
if (pd->xml)
|
||||||
|
{
|
||||||
|
eo_unref(pd->xml);
|
||||||
|
pd->xml = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *child;
|
||||||
|
EINA_LIST_FREE(pd->children_list, child)
|
||||||
|
eo_del(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
_write_data_cb(void *ptr, size_t size, size_t nmeb, void *data)
|
||||||
|
{
|
||||||
|
Eina_Strbuf *buf = (Eina_Strbuf *)data;
|
||||||
|
Eina_Bool ret = eina_strbuf_append_length(buf, ptr, size * nmeb);
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, 0);
|
||||||
|
return size * nmeb;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_perform(Esoap_Model_Data *pd, const char *xml)
|
||||||
|
{
|
||||||
|
DBG("(%p)", pd->obj);
|
||||||
|
Esoap_Model_Perform_Data *data = calloc(1, sizeof(Esoap_Model_Perform_Data));
|
||||||
|
data->pd = pd;
|
||||||
|
data->response = eina_strbuf_new();
|
||||||
|
|
||||||
|
const char *SOAP_ACTION = "SOAPAction:";
|
||||||
|
const size_t soap_action_lenght = strlen(SOAP_ACTION) + strlen(pd->action) + 1;
|
||||||
|
data->soap_action = malloc(soap_action_lenght);
|
||||||
|
snprintf(data->soap_action, soap_action_lenght, "%s%s", SOAP_ACTION, pd->action);
|
||||||
|
|
||||||
|
data->header = curl_slist_append(data->header, "Content-Type:application/soap+xml");
|
||||||
|
data->header = curl_slist_append(data->header, data->soap_action);
|
||||||
|
data->header = curl_slist_append(data->header, "Transfer-Encoding: chunked");
|
||||||
|
data->header = curl_slist_append(data->header, "Expect:");
|
||||||
|
|
||||||
|
data->curl = curl_easy_init();
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(data->curl);
|
||||||
|
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_URL, pd->url);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_POST, 1L);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_WRITEFUNCTION, _write_data_cb);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_WRITEDATA, data->response);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_HTTPHEADER, data->header);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_COPYPOSTFIELDS, xml);
|
||||||
|
curl_easy_setopt(data->curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
|
||||||
|
data->thread = ecore_thread_run((Ecore_Thread_Cb)_perform_cb,
|
||||||
|
(Ecore_Thread_Cb)_perform_end_cb,
|
||||||
|
(Ecore_Thread_Cb)_perform_cancel_cb, data);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(data->thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_perform_cb(Esoap_Model_Perform_Data *data, Ecore_Thread *thread)
|
||||||
|
{
|
||||||
|
DBG("(%p)", data->pd->obj);
|
||||||
|
CURLcode res = curl_easy_perform(data->curl);
|
||||||
|
if (CURLE_OK != res)
|
||||||
|
{
|
||||||
|
ERR("Could not perform: %d", res);
|
||||||
|
ecore_thread_cancel(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_perform_end_cb(Esoap_Model_Perform_Data *data,
|
||||||
|
Ecore_Thread *thread EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", data->pd->obj);
|
||||||
|
const char *response = eina_strbuf_string_get(data->response);
|
||||||
|
|
||||||
|
DBG("(%p) response: %s", data->pd->obj, response);
|
||||||
|
|
||||||
|
Eo *child = eo_add(EFLAT_XML_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
eflat_xml_model_constructor(response));
|
||||||
|
data->pd->children_list = eina_list_append(data->pd->children_list, child);
|
||||||
|
|
||||||
|
unsigned int count = eina_list_count(data->pd->children_list);
|
||||||
|
Efl_Model_Children_Event evt = {.child = child, .index = count};
|
||||||
|
eo_do(data->pd->obj, eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILD_ADDED, &evt),
|
||||||
|
eo_event_callback_call(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED, &count));
|
||||||
|
|
||||||
|
efl_model_load_set(data->pd->obj, &data->pd->load, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_perform_data_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_perform_cancel_cb(Esoap_Model_Perform_Data *data,
|
||||||
|
Ecore_Thread *thread EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("(%p)", data->pd->obj);
|
||||||
|
efl_model_error_notify(data->pd->obj);
|
||||||
|
_perform_data_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_perform_data_free(Esoap_Model_Perform_Data *data)
|
||||||
|
{
|
||||||
|
DBG("(%p)", data->pd->obj);
|
||||||
|
curl_easy_cleanup(data->curl);
|
||||||
|
eina_strbuf_free(data->response);
|
||||||
|
curl_slist_free_all(data->header);
|
||||||
|
free(data->soap_action);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "esoap_model.eo.c"
|
|
@ -0,0 +1,48 @@
|
||||||
|
class Esoap.Model (Eo.Base, Efl.Model.Base) {
|
||||||
|
legacy_prefix: null;
|
||||||
|
methods {
|
||||||
|
@property url {
|
||||||
|
[[
|
||||||
|
Custom Soap_Model constructor.
|
||||||
|
|
||||||
|
@since 1.16
|
||||||
|
]]
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
url: const(char)*; [[The webservice URL]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property action {
|
||||||
|
[[
|
||||||
|
Custom Soap_Model constructor.
|
||||||
|
|
||||||
|
@since 1.16
|
||||||
|
]]
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
action: const(char)*; [[The soap action]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Efl.Model.Base.properties.get;
|
||||||
|
Efl.Model.Base.properties_load;
|
||||||
|
Efl.Model.Base.property.set;
|
||||||
|
Efl.Model.Base.property.get;
|
||||||
|
Efl.Model.Base.load;
|
||||||
|
Efl.Model.Base.load_status.get;
|
||||||
|
Efl.Model.Base.unload;
|
||||||
|
Efl.Model.Base.child_add;
|
||||||
|
Efl.Model.Base.child_del;
|
||||||
|
Efl.Model.Base.children_slice.get;
|
||||||
|
Efl.Model.Base.children_count.get;
|
||||||
|
Efl.Model.Base.children_load;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.url;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef _ESOAP_MODEL_PRIVATE_H
|
||||||
|
#define _ESOAP_MODEL_PRIVATE_H
|
||||||
|
|
||||||
|
#include "Esoap_Model.h"
|
||||||
|
|
||||||
|
#include <Eflat_Xml_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* logging support */
|
||||||
|
extern int _esoap_model_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
typedef struct _Esoap_Model_Data Esoap_Model_Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* esoap_model
|
||||||
|
*/
|
||||||
|
struct _Esoap_Model_Data
|
||||||
|
{
|
||||||
|
Eo *obj;
|
||||||
|
Efl_Model_Load load;
|
||||||
|
Eina_List *children_list;
|
||||||
|
Eflat_Xml_Model *xml;
|
||||||
|
char *url;
|
||||||
|
char *action;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eflat_xml_model_suite.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int _test_eflat_xml_model_log_dom = -1;
|
||||||
|
|
||||||
|
typedef struct _Eflat_Xml_Test_Case Eflat_Xml_Test_Case;
|
||||||
|
|
||||||
|
struct _Eflat_Xml_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eflat_Xml_Test_Case etc[] = {
|
||||||
|
{ "Eflat_Xml_Model", eflat_xml_test_eflat_xml_model },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Eflat_Xml_Test_Case *it = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; it->test_case; it++)
|
||||||
|
fprintf(stderr, "\t%s\n", it->test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
_eflat_xml_suite_build(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create("Eflat_Xml");
|
||||||
|
|
||||||
|
for (int i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||||
|
TCase *tc = tcase_create(etc[i].test_case);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
//tcase_set_timeout(tc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_init_logging(void)
|
||||||
|
{
|
||||||
|
_test_eflat_xml_model_log_dom = eina_log_domain_register("test_eflat_xml_model", EINA_COLOR_LIGHTBLUE);
|
||||||
|
if (_test_eflat_xml_model_log_dom < 0)
|
||||||
|
ck_abort_msg("Could not register log domain: test_eflat_xml_model");
|
||||||
|
|
||||||
|
//eina_log_domain_level_set("esskyuehl", EINA_LOG_LEVEL_DBG);
|
||||||
|
//eina_log_domain_level_set("eflat_xml_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
eina_log_domain_level_set("test_eflat_xml_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_shutdown_logging(void)
|
||||||
|
{
|
||||||
|
eina_log_domain_unregister(_test_eflat_xml_model_log_dom);
|
||||||
|
_test_eflat_xml_model_log_dom = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_init_logging();
|
||||||
|
|
||||||
|
Suite *s = _eflat_xml_suite_build(argc - 1, (const char **)argv + 1);
|
||||||
|
SRunner *sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
int failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
_shutdown_logging();
|
||||||
|
|
||||||
|
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _EFLAT_XML_SUITE_H
|
||||||
|
#define _EFLAT_XML_SUITE_H
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
extern int _test_eflat_xml_model_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_test_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_test_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_test_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_test_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_test_eflat_xml_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
void eflat_xml_test_eflat_xml_model(TCase *tc);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,503 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eflat_xml_model_test_eflat_xml_model.h"
|
||||||
|
#include "eflat_xml_model_suite.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eflat_Xml_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
int ret = eflat_xml_model_init();
|
||||||
|
ck_assert_int_ge(ret, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
int ret = eflat_xml_model_shutdown();
|
||||||
|
ck_assert_int_eq(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eo_event_load_status_cb(void *data,
|
||||||
|
Eo *obj EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status expected_status = *((Efl_Model_Load_Status*)data);
|
||||||
|
Efl_Model_Load load = *((Efl_Model_Load*)event_info);
|
||||||
|
if ((load.status & expected_status) != expected_status)
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_wait_until_load_status(Efl_Model_Base *emodel,
|
||||||
|
Efl_Model_Load_Status expected_status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status actual_status;
|
||||||
|
eo_do(emodel, actual_status = efl_model_load_status_get());
|
||||||
|
if (expected_status == actual_status) return;
|
||||||
|
|
||||||
|
eo_do(emodel, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
|
||||||
|
_eo_event_load_status_cb,
|
||||||
|
&expected_status));
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
eo_do(emodel, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
|
||||||
|
_eo_event_load_status_cb,
|
||||||
|
&expected_status));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_efl_model_property_str_eq(Efl_Model_Base *emodel,
|
||||||
|
const char *property,
|
||||||
|
const char *expected_value)
|
||||||
|
{
|
||||||
|
const Eina_Value *value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(emodel, status = efl_model_property_get(property, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, value);
|
||||||
|
|
||||||
|
const Eina_Value_Type *property_type = eina_value_type_get(value);
|
||||||
|
fail_if(EINA_VALUE_TYPE_STRING != property_type &&
|
||||||
|
EINA_VALUE_TYPE_STRINGSHARE != property_type);
|
||||||
|
|
||||||
|
const char *actual_value = NULL;
|
||||||
|
eina_value_get(value, &actual_value);
|
||||||
|
ck_assert_str_eq(expected_value, actual_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_efl_model_load(Efl_Model_Base *model)
|
||||||
|
{
|
||||||
|
eo_do(model, efl_model_load());
|
||||||
|
_wait_until_load_status(model, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_efl_model_properties(Efl_Model_Base *model,
|
||||||
|
const char *expected_properties[])
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
|
||||||
|
unsigned int expected_properties_count = 0;
|
||||||
|
const char *expected_property = NULL;
|
||||||
|
while ((expected_property = *expected_properties++))
|
||||||
|
{
|
||||||
|
const char *actual_property = eina_array_data_get(properties,
|
||||||
|
expected_properties_count);
|
||||||
|
ck_assert_str_eq(expected_property, actual_property);
|
||||||
|
++expected_properties_count;
|
||||||
|
ck_assert_int_le(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eflat_Xml_Model *
|
||||||
|
_create_flat_xml_model(void)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = eo_add(EFLAT_XML_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
eflat_xml_model_constructor(NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, xml_model);
|
||||||
|
return xml_model;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(smoke)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_string_property_set(Efl_Model_Base *model,
|
||||||
|
const char *property,
|
||||||
|
const char *v)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&value, v);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(property, &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_xml_string(Efl_Model_Base *model, const char *expected_xml_string)
|
||||||
|
{
|
||||||
|
_check_efl_model_property_str_eq(model, "/", expected_xml_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *SAMPLE_XML =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
|
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
|
||||||
|
" <soap:Header>\n"
|
||||||
|
" <m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 1234\n"
|
||||||
|
" </m:Trans>\n"
|
||||||
|
" </soap:Header>\n"
|
||||||
|
" <soap:Body>\n"
|
||||||
|
" <m:MethodName xmlns:m=\"http://my.namespece/body\">\n"
|
||||||
|
" <m:Item>\n"
|
||||||
|
" Value\n"
|
||||||
|
" </m:Item>\n"
|
||||||
|
" </m:MethodName>\n"
|
||||||
|
" </soap:Body>\n"
|
||||||
|
"</soap:Envelope>\n";
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_sample_xml_properties_names(Efl_Model_Base *xml_model)
|
||||||
|
{
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName/m:Item",
|
||||||
|
NULL});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_sample_xml_properties_values(Efl_Model_Base *xml_model)
|
||||||
|
{
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "?xml", "version=\"1.0\" encoding=\"UTF-8\"");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope@xmlns:soap", "http://www.w3.org/2001/12/soap-envelope");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope@soap:encodingStyle", "http://www.w3.org/2001/12/soap-encoding");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Header/m:Trans@xmlns:m", "http://my.namespace/header");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand", "1");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Header/m:Trans", "1234");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Body/m:MethodName@xmlns:m", "http://my.namespece/body");
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Body/m:MethodName/m:Item", "Value");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_property_set(Efl_Model_Base *xml_model)
|
||||||
|
{
|
||||||
|
_check_string_property_set(xml_model, "?xml", "version=\"1.0\" encoding=\"UTF-8\"");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope@xmlns:soap", "http://www.w3.org/2001/12/soap-envelope");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope@soap:encodingStyle", "http://www.w3.org/2001/12/soap-encoding");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Header/m:Trans@xmlns:m", "http://my.namespace/header");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand", "1");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Header/m:Trans", "1234");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Body/m:MethodName@xmlns:m", "http://my.namespece/body");
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Body/m:MethodName/m:Item", "Value");
|
||||||
|
|
||||||
|
_check_xml_string(xml_model, SAMPLE_XML);
|
||||||
|
|
||||||
|
_check_sample_xml_properties_names(xml_model);
|
||||||
|
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "?xml", "version=\"1.0\" encoding=\"UTF-8\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(property_set_basic)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
|
||||||
|
_check_property_set(xml_model);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_property_not_exists(Efl_Model_Base *model, const char *property)
|
||||||
|
{
|
||||||
|
const Eina_Value *value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_get(property, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
eo_do(model, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
|
char *item;
|
||||||
|
Eina_Array_Iterator it;
|
||||||
|
EINA_ARRAY_ITER_NEXT(properties, i, item, it)
|
||||||
|
ck_assert_str_ne(property, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(property_set_existing)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
|
||||||
|
_check_property_set(xml_model);
|
||||||
|
|
||||||
|
// replaces an attribute
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Header/m:Trans@xmlns:m", "http://other.namespace/header");
|
||||||
|
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName/m:Item",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
// replaces a value
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Header/m:Trans", "4321");
|
||||||
|
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName/m:Item",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
// clears a value
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Body/m:MethodName/m:Item", "");
|
||||||
|
|
||||||
|
_check_xml_string(xml_model,
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
|
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
|
||||||
|
" <soap:Header>\n"
|
||||||
|
" <m:Trans xmlns:m=\"http://other.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 4321\n"
|
||||||
|
" </m:Trans>\n"
|
||||||
|
" </soap:Header>\n"
|
||||||
|
" <soap:Body>\n"
|
||||||
|
" <m:MethodName xmlns:m=\"http://my.namespece/body\">\n"
|
||||||
|
" <m:Item/>\n"
|
||||||
|
" </m:MethodName>\n"
|
||||||
|
" </soap:Body>\n"
|
||||||
|
"</soap:Envelope>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
"soap:Envelope/soap:Body/m:MethodName/m:Item",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
// clearing a value clears its children too
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Body", "");
|
||||||
|
|
||||||
|
_check_property_not_exists(xml_model, "soap:Envelope/soap:Body/m:MethodName/m:Item");
|
||||||
|
_check_property_not_exists(xml_model, "soap:Envelope/soap:Body/m:MethodName@xmlns:m");
|
||||||
|
|
||||||
|
_check_xml_string(xml_model,
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
|
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
|
||||||
|
" <soap:Header>\n"
|
||||||
|
" <m:Trans xmlns:m=\"http://other.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 4321\n"
|
||||||
|
" </m:Trans>\n"
|
||||||
|
" </soap:Header>\n"
|
||||||
|
" <soap:Body/>\n"
|
||||||
|
"</soap:Envelope>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
"soap:Envelope/soap:Body",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set_stream)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
|
||||||
|
// root level
|
||||||
|
_check_string_property_set(xml_model, "/", SAMPLE_XML);
|
||||||
|
_check_sample_xml_properties_names(xml_model);
|
||||||
|
_check_sample_xml_properties_values(xml_model);
|
||||||
|
|
||||||
|
_check_string_property_set(xml_model, "soap:Envelope/soap:Body/",
|
||||||
|
" <m:OtherMethod xmlns:m=\"http://my.namespece/body\">\n"
|
||||||
|
" <m:OtherItem>\n"
|
||||||
|
" OtherValue\n"
|
||||||
|
" </m:OtherItem>\n"
|
||||||
|
" </m:OtherMethod>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
_check_efl_model_properties(xml_model, (const char*[]){
|
||||||
|
"?xml",
|
||||||
|
"soap:Envelope@xmlns:soap",
|
||||||
|
"soap:Envelope@soap:encodingStyle",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans@soap:mustUnderstand",
|
||||||
|
"soap:Envelope/soap:Header/m:Trans",
|
||||||
|
"soap:Envelope/soap:Body/m:OtherMethod@xmlns:m",
|
||||||
|
"soap:Envelope/soap:Body/m:OtherMethod/m:OtherItem",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
|
||||||
|
_check_xml_string(xml_model,
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
|
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">\n"
|
||||||
|
" <soap:Header>\n"
|
||||||
|
" <m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 1234\n"
|
||||||
|
" </m:Trans>\n"
|
||||||
|
" </soap:Header>\n"
|
||||||
|
" <soap:Body>\n"
|
||||||
|
" <m:OtherMethod xmlns:m=\"http://my.namespece/body\">\n"
|
||||||
|
" <m:OtherItem>\n"
|
||||||
|
" OtherValue\n"
|
||||||
|
" </m:OtherItem>\n"
|
||||||
|
" </m:OtherMethod>\n"
|
||||||
|
" </soap:Body>\n"
|
||||||
|
"</soap:Envelope>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get_stream)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
|
||||||
|
_check_property_set(xml_model);
|
||||||
|
|
||||||
|
// sublevel
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/",
|
||||||
|
"<soap:Header>\n"
|
||||||
|
" <m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 1234\n"
|
||||||
|
" </m:Trans>\n"
|
||||||
|
"</soap:Header>\n"
|
||||||
|
"<soap:Body>\n"
|
||||||
|
" <m:MethodName xmlns:m=\"http://my.namespece/body\">\n"
|
||||||
|
" <m:Item>\n"
|
||||||
|
" Value\n"
|
||||||
|
" </m:Item>\n"
|
||||||
|
" </m:MethodName>\n"
|
||||||
|
"</soap:Body>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// sublevel
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Header/",
|
||||||
|
"<m:Trans xmlns:m=\"http://my.namespace/header\" soap:mustUnderstand=\"1\">\n"
|
||||||
|
" 1234\n"
|
||||||
|
"</m:Trans>\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// sublevel data
|
||||||
|
_check_efl_model_property_str_eq(xml_model, "soap:Envelope/soap:Header/m:Trans/",
|
||||||
|
"1234\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(xml_model, status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
|
||||||
|
eo_do(xml_model, status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = _create_flat_xml_model();
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
_check_property_set(xml_model);
|
||||||
|
|
||||||
|
eo_do(xml_model, efl_model_unload());
|
||||||
|
|
||||||
|
// status must be unloaded now
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(xml_model, status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
|
||||||
|
// reload and manipulate content
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
_check_property_set(xml_model);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(xml_load)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *xml_model = eo_add(EFLAT_XML_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
eflat_xml_model_constructor(SAMPLE_XML));
|
||||||
|
ck_assert_ptr_ne(NULL, xml_model);
|
||||||
|
|
||||||
|
_check_efl_model_load(xml_model);
|
||||||
|
_check_sample_xml_properties_names(xml_model);
|
||||||
|
_check_sample_xml_properties_values(xml_model);
|
||||||
|
|
||||||
|
eo_unref(xml_model);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
eflat_xml_test_eflat_xml_model(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, smoke);
|
||||||
|
tcase_add_test(tc, property_set_basic);
|
||||||
|
tcase_add_test(tc, property_set_existing);
|
||||||
|
tcase_add_test(tc, property_set_stream);
|
||||||
|
tcase_add_test(tc, property_get_stream);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, xml_load);
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _EFLAT_XML_MODEL_TEST_EFLAT_XML_MODEL_H
|
||||||
|
#define _EFLAT_XML_MODEL_TEST_EFLAT_XML_MODEL_H
|
||||||
|
|
||||||
|
#include <Eflat_Xml_Model.h>
|
||||||
|
|
||||||
|
#endif
|
|
@ -2731,6 +2731,147 @@ START_TEST(eina_value_test_array_of_struct)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eina_value_test_optional_int)
|
||||||
|
{
|
||||||
|
eina_init();
|
||||||
|
|
||||||
|
/* Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_OPTIONAL); */
|
||||||
|
/* Eina_Bool is_empty; */
|
||||||
|
/* ck_assert(eina_value_optional_empty_is(value, &is_empty)); */
|
||||||
|
/* ck_assert(is_empty); */
|
||||||
|
|
||||||
|
/* // sets expectation */
|
||||||
|
/* int expected_value = -12345; */
|
||||||
|
/* ck_assert(eina_value_optional_pset(value, EINA_VALUE_TYPE_INT, &expected_value)); */
|
||||||
|
/* ck_assert(eina_value_optional_empty_is(value, &is_empty)); */
|
||||||
|
/* ck_assert(!is_empty); */
|
||||||
|
|
||||||
|
/* // gets the actual value */
|
||||||
|
/* int actual_value; */
|
||||||
|
/* ck_assert(eina_value_optional_pget(value, &actual_value)); */
|
||||||
|
/* ck_assert_int_eq(expected_value, actual_value); */
|
||||||
|
|
||||||
|
/* // resets the optional */
|
||||||
|
/* ck_assert(eina_value_optional_reset(value)); */
|
||||||
|
/* ck_assert(eina_value_optional_empty_is(value, &is_empty)); */
|
||||||
|
/* ck_assert(is_empty); */
|
||||||
|
|
||||||
|
/* // Sets expectation again after reset */
|
||||||
|
/* expected_value = -54321; */
|
||||||
|
/* ck_assert(eina_value_optional_pset(value, EINA_VALUE_TYPE_INT, &expected_value)); */
|
||||||
|
/* ck_assert(eina_value_optional_empty_is(value, &is_empty)); */
|
||||||
|
/* ck_assert(!is_empty); */
|
||||||
|
|
||||||
|
/* // gets the actual value */
|
||||||
|
/* ck_assert(eina_value_optional_pget(value, &actual_value)); */
|
||||||
|
/* ck_assert_int_eq(expected_value, actual_value); */
|
||||||
|
|
||||||
|
/* eina_value_free(value); */
|
||||||
|
eina_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eina_value_test_optional_string)
|
||||||
|
{
|
||||||
|
eina_init();
|
||||||
|
|
||||||
|
Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_OPTIONAL);
|
||||||
|
Eina_Bool is_empty;
|
||||||
|
ck_assert(eina_value_optional_empty_is(value, &is_empty));
|
||||||
|
ck_assert(is_empty);
|
||||||
|
ck_assert(EINA_VALUE_TYPE_OPTIONAL);
|
||||||
|
|
||||||
|
// sets expectation
|
||||||
|
const char *expected_value = "Hello world!";
|
||||||
|
ck_assert(eina_value_optional_pset(value, EINA_VALUE_TYPE_STRING, &expected_value));
|
||||||
|
ck_assert(eina_value_optional_empty_is(value, &is_empty));
|
||||||
|
ck_assert(!is_empty);
|
||||||
|
|
||||||
|
// gets the actual value
|
||||||
|
const char *actual_value;
|
||||||
|
ck_assert(eina_value_optional_pget(value, &actual_value));
|
||||||
|
ck_assert_str_eq(expected_value, actual_value);
|
||||||
|
|
||||||
|
// resets the optional
|
||||||
|
ck_assert(eina_value_optional_reset(value));
|
||||||
|
ck_assert(eina_value_optional_empty_is(value, &is_empty));
|
||||||
|
ck_assert(is_empty);
|
||||||
|
|
||||||
|
// Sets expectation again after reset
|
||||||
|
expected_value = "!dlrow olleH";
|
||||||
|
ck_assert(eina_value_optional_pset(value, EINA_VALUE_TYPE_STRING, &expected_value));
|
||||||
|
ck_assert(eina_value_optional_empty_is(value, &is_empty));
|
||||||
|
ck_assert(!is_empty);
|
||||||
|
|
||||||
|
// gets the actual value
|
||||||
|
ck_assert(eina_value_optional_pget(value, &actual_value));
|
||||||
|
ck_assert_str_eq(expected_value, actual_value);
|
||||||
|
|
||||||
|
eina_value_free(value);
|
||||||
|
eina_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eina_value_test_optional_struct_members)
|
||||||
|
{
|
||||||
|
eina_init();
|
||||||
|
|
||||||
|
struct s {
|
||||||
|
int64_t a;
|
||||||
|
Eina_Value_Optional text;
|
||||||
|
int64_t b;
|
||||||
|
};
|
||||||
|
const Eina_Value_Struct_Member members[] = {
|
||||||
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT64, struct s, a),
|
||||||
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_OPTIONAL, struct s, text),
|
||||||
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT64, struct s, b),
|
||||||
|
EINA_VALUE_STRUCT_MEMBER_SENTINEL
|
||||||
|
};
|
||||||
|
const Eina_Value_Struct_Desc desc = {
|
||||||
|
EINA_VALUE_STRUCT_DESC_VERSION,
|
||||||
|
NULL, members, 3, sizeof(struct s)
|
||||||
|
};
|
||||||
|
|
||||||
|
Eina_Value *value = eina_value_struct_new(&desc);
|
||||||
|
ck_assert_ptr_ne(NULL, value);
|
||||||
|
|
||||||
|
int64_t expected_a = 0x1234567887654321ll;
|
||||||
|
fail_unless(eina_value_struct_set(value, "a", expected_a));
|
||||||
|
int64_t actual_a;
|
||||||
|
fail_unless(eina_value_struct_get(value, "a", &actual_a));
|
||||||
|
ck_assert_int_eq(expected_a, actual_a);
|
||||||
|
|
||||||
|
int64_t expected_b = 0xEEDCBA9889ABCDEFll;
|
||||||
|
fail_unless(eina_value_struct_set(value, "b", expected_b));
|
||||||
|
int64_t actual_b;
|
||||||
|
fail_unless(eina_value_struct_get(value, "b", &actual_b));
|
||||||
|
ck_assert_int_eq(expected_b, actual_b);
|
||||||
|
|
||||||
|
Eina_Value expected_value;
|
||||||
|
fail_unless(eina_value_setup(&expected_value, EINA_VALUE_TYPE_OPTIONAL));
|
||||||
|
const char* str = "Hello world!";
|
||||||
|
fail_unless(eina_value_optional_pset(&expected_value, EINA_VALUE_TYPE_STRING, &str));
|
||||||
|
fail_unless(eina_value_struct_value_set(value, "text", &expected_value));
|
||||||
|
|
||||||
|
Eina_Value actual_value;
|
||||||
|
fail_unless(eina_value_struct_value_get(value, "text", &actual_value));
|
||||||
|
fail_unless(eina_value_compare(&expected_value, &actual_value) == 0);
|
||||||
|
|
||||||
|
// tests if the value have been overriden
|
||||||
|
fail_unless(eina_value_struct_get(value, "a", &actual_a));
|
||||||
|
ck_assert_int_eq(expected_a, actual_a);
|
||||||
|
fail_unless(eina_value_struct_get(value, "b", &actual_b));
|
||||||
|
ck_assert_int_eq(expected_b, actual_b);
|
||||||
|
|
||||||
|
eina_value_flush(&actual_value);
|
||||||
|
eina_value_flush(&expected_value);
|
||||||
|
|
||||||
|
eina_value_free(value);
|
||||||
|
|
||||||
|
eina_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
START_TEST(eina_value_test_model)
|
START_TEST(eina_value_test_model)
|
||||||
{
|
{
|
||||||
|
@ -2801,6 +2942,9 @@ eina_test_value(TCase *tc)
|
||||||
tcase_add_test(tc, eina_value_test_blob);
|
tcase_add_test(tc, eina_value_test_blob);
|
||||||
tcase_add_test(tc, eina_value_test_struct);
|
tcase_add_test(tc, eina_value_test_struct);
|
||||||
tcase_add_test(tc, eina_value_test_array_of_struct);
|
tcase_add_test(tc, eina_value_test_array_of_struct);
|
||||||
|
tcase_add_test(tc, eina_value_test_optional_int);
|
||||||
|
tcase_add_test(tc, eina_value_test_optional_string);
|
||||||
|
tcase_add_test(tc, eina_value_test_optional_struct_members);
|
||||||
#if 0
|
#if 0
|
||||||
tcase_add_test(tc, eina_value_test_model);
|
tcase_add_test(tc, eina_value_test_model);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
check_PROGRAMS = \
|
||||||
|
src/tests/ejson_suite
|
||||||
|
TESTS = src/tests/ejson_suite
|
||||||
|
|
||||||
|
src_tests_ejson_suite_SOURCES = \
|
||||||
|
src/tests/ejson_suite.c \
|
||||||
|
src/tests/ejson_test_ejson_model.c
|
||||||
|
src_tests_ejson_suite_CFLAGS = $(MOD_CFLAGS) \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests\"
|
||||||
|
src_tests_ejson_suite_LDADD = $(MOD_LIBS) $(CHECK_LIBS)
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ejson_suite.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int _test_ejson_model_log_dom = -1;
|
||||||
|
|
||||||
|
typedef struct _Ejson_Test_Case Ejson_Test_Case;
|
||||||
|
|
||||||
|
struct _Ejson_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Ejson_Test_Case etc[] = {
|
||||||
|
{ "Ejson_Model", ejson_test_ejson_model },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Ejson_Test_Case *it = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; it->test_case; it++)
|
||||||
|
fprintf(stderr, "\t%s\n", it->test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
_ejson_suite_build(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create("Ejson");
|
||||||
|
|
||||||
|
for (int i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||||
|
TCase *tc = tcase_create(etc[i].test_case);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
//tcase_set_timeout(tc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_init_logging(void)
|
||||||
|
{
|
||||||
|
_test_ejson_model_log_dom = eina_log_domain_register("test_ejson_model", EINA_COLOR_LIGHTBLUE);
|
||||||
|
if (_test_ejson_model_log_dom < 0)
|
||||||
|
ck_abort_msg("Could not register log domain: test_ejson_model");
|
||||||
|
|
||||||
|
//eina_log_domain_level_set("esskyuehl", EINA_LOG_LEVEL_DBG);
|
||||||
|
//eina_log_domain_level_set("ejson_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
eina_log_domain_level_set("test_ejson_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_shutdown_logging(void)
|
||||||
|
{
|
||||||
|
eina_log_domain_unregister(_test_ejson_model_log_dom);
|
||||||
|
_test_ejson_model_log_dom = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_init_logging();
|
||||||
|
|
||||||
|
Suite *s = _ejson_suite_build(argc - 1, (const char **)argv + 1);
|
||||||
|
SRunner *sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
int failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
_shutdown_logging();
|
||||||
|
|
||||||
|
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _EJSON_SUITE_H
|
||||||
|
#define _EJSON_SUITE_H
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
extern int _test_ejson_model_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_test_ejson_model_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_test_ejson_model_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_test_ejson_model_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_test_ejson_model_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_test_ejson_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
void ejson_test_ejson_model(TCase *tc);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,782 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ejson_test_ejson_model.h"
|
||||||
|
#include "ejson_suite.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Ejson.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
int ret = ejson_init();
|
||||||
|
ck_assert_int_ge(ret, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
int ret = ejson_shutdown();
|
||||||
|
ck_assert_int_eq(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eo_event_load_status_cb(void *data,
|
||||||
|
Eo *obj EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status expected_status = *((Efl_Model_Load_Status*)data);
|
||||||
|
Efl_Model_Load load = *((Efl_Model_Load*)event_info);
|
||||||
|
if ((load.status & expected_status) != expected_status)
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_wait_until_load_status(Efl_Model_Base *emodel,
|
||||||
|
Efl_Model_Load_Status expected_status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status actual_status;
|
||||||
|
eo_do(emodel, actual_status = efl_model_load_status_get());
|
||||||
|
if (expected_status == actual_status) return;
|
||||||
|
|
||||||
|
eo_do(emodel, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
eo_do(emodel, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_json_string(Efl_Model_Base *model, const char *expected_json_string)
|
||||||
|
{
|
||||||
|
const Eina_Value *json_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_get(EJSON_MODEL_JSON_PROPERTY, &json_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES, status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
ck_assert_ptr_ne(NULL, json_value);
|
||||||
|
|
||||||
|
const char *actual_json_string;
|
||||||
|
fail_unless(eina_value_get(json_value, &actual_json_string));
|
||||||
|
|
||||||
|
ck_assert_str_eq(expected_json_string, actual_json_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_value_type_cannot_have_children(Efl_Model_Base *model)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *child = eo_do_ret(model, child, efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Load_Status
|
||||||
|
_json_property_set(Efl_Model_Base *model, const char *v)
|
||||||
|
{
|
||||||
|
Eina_Value json;
|
||||||
|
eina_value_setup(&json, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&json, v);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(EJSON_MODEL_JSON_PROPERTY, &json));
|
||||||
|
eina_value_flush(&json);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_name_property_set(Efl_Model_Base *model, const char *v)
|
||||||
|
{
|
||||||
|
Eina_Value name;
|
||||||
|
eina_value_setup(&name, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&name, v);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(EJSON_MODEL_NAME_PROPERTY, &name));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
eina_value_flush(&name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_int_value_property_set(Efl_Model_Base *model, int64_t v)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT64);
|
||||||
|
eina_value_set(&value, v);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
char buf[64];
|
||||||
|
snprintf(buf, sizeof(buf), "%lld", (long long)v);
|
||||||
|
|
||||||
|
_check_json_string(model, buf);
|
||||||
|
|
||||||
|
eina_value_flush(&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_bool_value_property_set(Efl_Model_Base *model, bool v)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&value, (int)v);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
_check_json_string(model, v ? "true" : "false");
|
||||||
|
|
||||||
|
eina_value_flush(&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_string_value_property_set(Efl_Model_Base *model, const char *v)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&value, v);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(EJSON_MODEL_VALUE_PROPERTY, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
size_t len = 1 + strlen(v) + 1 + 1;
|
||||||
|
char buf[len];
|
||||||
|
snprintf(buf, len, "\"%s\"", v);
|
||||||
|
|
||||||
|
_check_json_string(model, buf);
|
||||||
|
|
||||||
|
eina_value_flush(&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_emodel_children_count_eq(Efl_Model_Base *model,
|
||||||
|
unsigned int expected_children_count)
|
||||||
|
{
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(model, efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_emodel_property_int_eq(Efl_Model_Base *emodel,
|
||||||
|
const char *property,
|
||||||
|
int64_t expected_value)
|
||||||
|
{
|
||||||
|
const Eina_Value *value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(emodel, status = efl_model_property_get(property, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, value);
|
||||||
|
|
||||||
|
const Eina_Value_Type *property_type = eina_value_type_get(value);
|
||||||
|
ck_assert_ptr_eq(EINA_VALUE_TYPE_INT64, property_type);
|
||||||
|
|
||||||
|
int64_t actual_value = 0;
|
||||||
|
eina_value_get(value, &actual_value);
|
||||||
|
ck_assert_int_eq(expected_value, actual_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_emodel_property_str_eq(Efl_Model_Base *emodel,
|
||||||
|
const char *property,
|
||||||
|
const char *expected_value)
|
||||||
|
{
|
||||||
|
const Eina_Value *value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(emodel, status = efl_model_property_get(property, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, value);
|
||||||
|
|
||||||
|
const Eina_Value_Type *property_type = eina_value_type_get(value);
|
||||||
|
fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
|
||||||
|
|
||||||
|
const char *actual_value = NULL;
|
||||||
|
eina_value_get(value, &actual_value);
|
||||||
|
ck_assert_str_eq(expected_value, actual_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Base *
|
||||||
|
_emodel_nth_child_get(Efl_Model_Base *emodel, unsigned int n)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(emodel, status = efl_model_children_slice_get(n, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
Efl_Model_Base *child = NULL;
|
||||||
|
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_ejson_type(Efl_Model_Base *model, Ejson_Model_Type expected_type)
|
||||||
|
{
|
||||||
|
Ejson_Model_Type actual_type;
|
||||||
|
eo_do(model, actual_type = ejson_model_type_get());
|
||||||
|
ck_assert_int_eq(expected_type, actual_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_emodel_load(Efl_Model_Base *model)
|
||||||
|
{
|
||||||
|
eo_do(model, efl_model_load());
|
||||||
|
_wait_until_load_status(model, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_emodel_properties(Efl_Model_Base *model,
|
||||||
|
const char *expected_properties[])
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
|
||||||
|
unsigned int expected_properties_count = 0;
|
||||||
|
const char *expected_property = NULL;
|
||||||
|
while ((expected_property = *expected_properties++))
|
||||||
|
{
|
||||||
|
const char *actual_property = eina_array_data_get(properties,
|
||||||
|
expected_properties_count);
|
||||||
|
ck_assert_str_eq(expected_property, actual_property);
|
||||||
|
++expected_properties_count;
|
||||||
|
ck_assert_int_le(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_properties_count_eq(Efl_Model_Base *model,
|
||||||
|
unsigned int expected_properties_count)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_ne(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
if (!expected_properties_count && !properties)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(smoke)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(load_object)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_OBJECT));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(object_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_OBJECT));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "{ }");
|
||||||
|
|
||||||
|
Efl_Model_Base *child = eo_do_ret(json, child, efl_model_child_add());
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
|
||||||
|
_check_json_string(json, "{ }");
|
||||||
|
|
||||||
|
Ejson_Model_Type type = eo_do_ret(child, type, ejson_model_type_get());
|
||||||
|
ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type);
|
||||||
|
eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT));
|
||||||
|
eo_do(child, type = ejson_model_type_get());
|
||||||
|
ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type);
|
||||||
|
|
||||||
|
_check_emodel_load(child);
|
||||||
|
|
||||||
|
_check_json_string(child, "null");
|
||||||
|
_check_json_string(json, "{ }");
|
||||||
|
|
||||||
|
// set member name
|
||||||
|
_check_name_property_set(child, "a");
|
||||||
|
_check_json_string(child, "null");
|
||||||
|
_check_json_string(json, "{ \"a\": null }");
|
||||||
|
|
||||||
|
// set member value
|
||||||
|
_check_int_value_property_set(child, 1234);
|
||||||
|
_check_json_string(json, "{ \"a\": 1234 }");
|
||||||
|
|
||||||
|
// change member name
|
||||||
|
_check_name_property_set(child, "b");
|
||||||
|
_check_json_string(json, "{ \"b\": 1234 }");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(array_object_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_ARRAY));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "[ ]");
|
||||||
|
|
||||||
|
Efl_Model_Base *child = eo_do_ret(json, child, efl_model_child_add());
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
|
||||||
|
_check_json_string(json, "[ ]");
|
||||||
|
|
||||||
|
Ejson_Model_Type type = eo_do_ret(child, type, ejson_model_type_get());
|
||||||
|
ck_assert_int_eq(EJSON_MODEL_TYPE_NULL, type);
|
||||||
|
eo_do(child, ejson_model_type_set(EJSON_MODEL_TYPE_INT));
|
||||||
|
eo_do(child, type = ejson_model_type_get());
|
||||||
|
ck_assert_int_eq(EJSON_MODEL_TYPE_INT, type);
|
||||||
|
|
||||||
|
_check_emodel_load(child);
|
||||||
|
|
||||||
|
_check_json_string(child, "null");
|
||||||
|
_check_json_string(json, "[ ]");
|
||||||
|
|
||||||
|
_check_int_value_property_set(child, 1234);
|
||||||
|
|
||||||
|
_check_json_string(json, "[ 1234 ]");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(int_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_INT));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "null");
|
||||||
|
|
||||||
|
_check_int_value_property_set(json, 1234);
|
||||||
|
|
||||||
|
_check_value_type_cannot_have_children(json);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(boolean_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_BOOLEAN));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "null");
|
||||||
|
|
||||||
|
_check_bool_value_property_set(json, true);
|
||||||
|
_check_bool_value_property_set(json, false);
|
||||||
|
|
||||||
|
_check_value_type_cannot_have_children(json);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(string_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_STRING));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "null");
|
||||||
|
|
||||||
|
_check_string_value_property_set(json, "Hello world!");
|
||||||
|
|
||||||
|
_check_value_type_cannot_have_children(json);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(json_object_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_json_property_set(json, "{ \"a\": 1, \"b\": \"Hello\" }");
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "{ \"a\": 1, \"b\": \"Hello\" }");
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 2);
|
||||||
|
|
||||||
|
Efl_Model_Base *child1 = _emodel_nth_child_get(json, 1);
|
||||||
|
Efl_Model_Base *child2 = _emodel_nth_child_get(json, 2);
|
||||||
|
|
||||||
|
_check_ejson_type(child1, EJSON_MODEL_TYPE_INT);
|
||||||
|
_check_ejson_type(child2, EJSON_MODEL_TYPE_STRING);
|
||||||
|
|
||||||
|
_check_emodel_load(child1);
|
||||||
|
|
||||||
|
_check_emodel_property_int_eq(child1, EJSON_MODEL_VALUE_PROPERTY, 1);
|
||||||
|
_check_emodel_property_str_eq(child1, EJSON_MODEL_NAME_PROPERTY, "a");
|
||||||
|
|
||||||
|
_check_emodel_load(child2);
|
||||||
|
|
||||||
|
_check_emodel_property_str_eq(child2, EJSON_MODEL_VALUE_PROPERTY, "Hello");
|
||||||
|
_check_emodel_property_str_eq(child2, EJSON_MODEL_NAME_PROPERTY, "b");
|
||||||
|
|
||||||
|
_json_property_set(child2, "{ \"c\": 2, \"d\": \"World\" }");
|
||||||
|
|
||||||
|
_check_json_string(json, "{ \"a\": 1, \"b\": { \"c\": 2, \"d\": \"World\" } }");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(json_array_property_set)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_json_property_set(json, "[ 1, \"Hello\" ]");
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_check_json_string(json, "[ 1, \"Hello\" ]");
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 2);
|
||||||
|
|
||||||
|
Efl_Model_Base *child1 = _emodel_nth_child_get(json, 1);
|
||||||
|
Efl_Model_Base *child2 = _emodel_nth_child_get(json, 2);
|
||||||
|
|
||||||
|
_check_ejson_type(child1, EJSON_MODEL_TYPE_INT);
|
||||||
|
_check_ejson_type(child2, EJSON_MODEL_TYPE_STRING);
|
||||||
|
|
||||||
|
_check_emodel_load(child1);
|
||||||
|
|
||||||
|
_check_emodel_property_int_eq(child1, EJSON_MODEL_VALUE_PROPERTY, 1);
|
||||||
|
|
||||||
|
_check_emodel_load(child2);
|
||||||
|
|
||||||
|
_check_emodel_property_str_eq(child2, EJSON_MODEL_VALUE_PROPERTY, "Hello");
|
||||||
|
|
||||||
|
_json_property_set(child2, "[ 2, \"World\" ]");
|
||||||
|
|
||||||
|
_check_json_string(json, "[ 1, [ 2, \"World\" ] ]");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(json, status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
eo_do(json, status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static const char *_all_json_types_object_string =
|
||||||
|
"{ \"i\": 1, "
|
||||||
|
"\"s\": \"Hello World!\", "
|
||||||
|
"\"b\": true, "
|
||||||
|
"\"d\": 1.234, "
|
||||||
|
"\"n\": null, "
|
||||||
|
"\"o\": { }, "
|
||||||
|
"\"a\": [ ] "
|
||||||
|
"}";
|
||||||
|
|
||||||
|
static Efl_Model_Base *
|
||||||
|
_create_model_with_all_json_types()
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_json_property_set(json, _all_json_types_object_string);
|
||||||
|
_check_json_string(json, _all_json_types_object_string);
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 7);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = _create_model_with_all_json_types();
|
||||||
|
|
||||||
|
_check_emodel_properties(json, (const char*[]){"json", NULL});
|
||||||
|
|
||||||
|
Efl_Model_Base *child_i = _emodel_nth_child_get(json, 1);
|
||||||
|
Efl_Model_Base *child_s = _emodel_nth_child_get(json, 2);
|
||||||
|
Efl_Model_Base *child_b = _emodel_nth_child_get(json, 3);
|
||||||
|
Efl_Model_Base *child_d = _emodel_nth_child_get(json, 4);
|
||||||
|
Efl_Model_Base *child_n = _emodel_nth_child_get(json, 5);
|
||||||
|
Efl_Model_Base *child_o = _emodel_nth_child_get(json, 6);
|
||||||
|
Efl_Model_Base *child_a = _emodel_nth_child_get(json, 7);
|
||||||
|
|
||||||
|
_check_emodel_load(child_i);
|
||||||
|
_check_emodel_load(child_s);
|
||||||
|
_check_emodel_load(child_b);
|
||||||
|
_check_emodel_load(child_d);
|
||||||
|
_check_emodel_load(child_n);
|
||||||
|
_check_emodel_load(child_o);
|
||||||
|
_check_emodel_load(child_a);
|
||||||
|
|
||||||
|
_check_ejson_type(child_i, EJSON_MODEL_TYPE_INT);
|
||||||
|
_check_ejson_type(child_s, EJSON_MODEL_TYPE_STRING);
|
||||||
|
_check_ejson_type(child_b, EJSON_MODEL_TYPE_BOOLEAN);
|
||||||
|
_check_ejson_type(child_d, EJSON_MODEL_TYPE_DOUBLE);
|
||||||
|
_check_ejson_type(child_n, EJSON_MODEL_TYPE_NULL);
|
||||||
|
_check_ejson_type(child_o, EJSON_MODEL_TYPE_OBJECT);
|
||||||
|
_check_ejson_type(child_a, EJSON_MODEL_TYPE_ARRAY);
|
||||||
|
|
||||||
|
_check_emodel_properties(child_i, (const char*[]){"json", "value", "name", NULL});
|
||||||
|
_check_emodel_properties(child_s, (const char*[]){"json", "value", "name", NULL});
|
||||||
|
_check_emodel_properties(child_b, (const char*[]){"json", "value", "name", NULL});
|
||||||
|
_check_emodel_properties(child_d, (const char*[]){"json", "value", "name", NULL});
|
||||||
|
_check_emodel_properties(child_n, (const char*[]){"json", "name", NULL});
|
||||||
|
_check_emodel_properties(child_o, (const char*[]){"json", "name", NULL});
|
||||||
|
_check_emodel_properties(child_a, (const char*[]){"json", "name", NULL});
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = _create_model_with_all_json_types();
|
||||||
|
|
||||||
|
eo_do(json, efl_model_unload());
|
||||||
|
_wait_until_load_status(json, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
// reload
|
||||||
|
_check_emodel_load(json);
|
||||||
|
_check_json_string(json, "{ }");
|
||||||
|
|
||||||
|
_json_property_set(json, _all_json_types_object_string);
|
||||||
|
_check_json_string(json, _all_json_types_object_string);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_json_property_set(json, _all_json_types_object_string);
|
||||||
|
|
||||||
|
eo_do(json, efl_model_properties_load());
|
||||||
|
_wait_until_load_status(json, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 0);
|
||||||
|
|
||||||
|
_check_json_string(json, _all_json_types_object_string);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS,
|
||||||
|
NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_json_property_set(json, _all_json_types_object_string);
|
||||||
|
|
||||||
|
eo_do(json, efl_model_children_load());
|
||||||
|
_wait_until_load_status(json, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 7);
|
||||||
|
|
||||||
|
_check_properties_count_eq(json, 0);
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST(object_child_del)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *json = _create_model_with_all_json_types();
|
||||||
|
|
||||||
|
Efl_Model_Base *child_i = _emodel_nth_child_get(json, 1);
|
||||||
|
Efl_Model_Base *child_s = _emodel_nth_child_get(json, 2);
|
||||||
|
Efl_Model_Base *child_b = _emodel_nth_child_get(json, 3);
|
||||||
|
Efl_Model_Base *child_d = _emodel_nth_child_get(json, 4);
|
||||||
|
Efl_Model_Base *child_n = _emodel_nth_child_get(json, 5);
|
||||||
|
Efl_Model_Base *child_o = _emodel_nth_child_get(json, 6);
|
||||||
|
Efl_Model_Base *child_a = _emodel_nth_child_get(json, 7);
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_s));
|
||||||
|
_check_emodel_children_count_eq(json, 6);
|
||||||
|
_check_json_string(json, "{ \"i\": 1, \"b\": true, \"d\": 1.234, \"n\": null, \"o\": { }, \"a\": [ ] }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_i));
|
||||||
|
_check_emodel_children_count_eq(json, 5);
|
||||||
|
_check_json_string(json, "{ \"b\": true, \"d\": 1.234, \"n\": null, \"o\": { }, \"a\": [ ] }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_a));
|
||||||
|
_check_emodel_children_count_eq(json, 4);
|
||||||
|
_check_json_string(json, "{ \"b\": true, \"d\": 1.234, \"n\": null, \"o\": { } }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_d));
|
||||||
|
_check_emodel_children_count_eq(json, 3);
|
||||||
|
_check_json_string(json, "{ \"b\": true, \"n\": null, \"o\": { } }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_b));
|
||||||
|
_check_emodel_children_count_eq(json, 2);
|
||||||
|
_check_json_string(json, "{ \"n\": null, \"o\": { } }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_o));
|
||||||
|
_check_emodel_children_count_eq(json, 1);
|
||||||
|
_check_json_string(json, "{ \"n\": null }");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_n));
|
||||||
|
_check_emodel_children_count_eq(json, 0);
|
||||||
|
_check_json_string(json, "{ }");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(array_child_del)
|
||||||
|
{
|
||||||
|
const char *_all_json_types_array_string =
|
||||||
|
"[ 1, \"Hello World!\", true, 1.234, null, { }, [ ] ]";
|
||||||
|
|
||||||
|
Efl_Model_Base *json = eo_add(EJSON_MODEL_CLASS, NULL,
|
||||||
|
ejson_model_constructor(EJSON_MODEL_TYPE_NULL));
|
||||||
|
ck_assert_ptr_ne(NULL, json);
|
||||||
|
|
||||||
|
_check_emodel_load(json);
|
||||||
|
|
||||||
|
_json_property_set(json, _all_json_types_array_string);
|
||||||
|
_check_json_string(json, _all_json_types_array_string);
|
||||||
|
|
||||||
|
_check_emodel_children_count_eq(json, 7);
|
||||||
|
|
||||||
|
Efl_Model_Base *child_i = _emodel_nth_child_get(json, 1);
|
||||||
|
Efl_Model_Base *child_s = _emodel_nth_child_get(json, 2);
|
||||||
|
Efl_Model_Base *child_b = _emodel_nth_child_get(json, 3);
|
||||||
|
Efl_Model_Base *child_d = _emodel_nth_child_get(json, 4);
|
||||||
|
Efl_Model_Base *child_n = _emodel_nth_child_get(json, 5);
|
||||||
|
Efl_Model_Base *child_o = _emodel_nth_child_get(json, 6);
|
||||||
|
Efl_Model_Base *child_a = _emodel_nth_child_get(json, 7);
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_s));
|
||||||
|
_check_emodel_children_count_eq(json, 6);
|
||||||
|
_check_json_string(json, "[ 1, true, 1.234, null, { }, [ ] ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_i));
|
||||||
|
_check_emodel_children_count_eq(json, 5);
|
||||||
|
_check_json_string(json, "[ true, 1.234, null, { }, [ ] ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_a));
|
||||||
|
_check_emodel_children_count_eq(json, 4);
|
||||||
|
_check_json_string(json, "[ true, 1.234, null, { } ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_d));
|
||||||
|
_check_emodel_children_count_eq(json, 3);
|
||||||
|
_check_json_string(json, "[ true, null, { } ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_b));
|
||||||
|
_check_emodel_children_count_eq(json, 2);
|
||||||
|
_check_json_string(json, "[ null, { } ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_o));
|
||||||
|
_check_emodel_children_count_eq(json, 1);
|
||||||
|
_check_json_string(json, "[ null ]");
|
||||||
|
|
||||||
|
eo_do(json, efl_model_child_del(child_n));
|
||||||
|
_check_emodel_children_count_eq(json, 0);
|
||||||
|
_check_json_string(json, "[ ]");
|
||||||
|
|
||||||
|
eo_unref(json);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
ejson_test_ejson_model(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, smoke);
|
||||||
|
tcase_add_test(tc, load_object);
|
||||||
|
tcase_add_test(tc, object_property_set);
|
||||||
|
tcase_add_test(tc, array_object_property_set);
|
||||||
|
tcase_add_test(tc, int_property_set);
|
||||||
|
tcase_add_test(tc, boolean_property_set);
|
||||||
|
tcase_add_test(tc, string_property_set);
|
||||||
|
tcase_add_test(tc, json_object_property_set);
|
||||||
|
tcase_add_test(tc, json_array_property_set);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, object_child_del);
|
||||||
|
tcase_add_test(tc, array_child_del);
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _EJSON_TEST_EJSON_MODEL_H
|
||||||
|
#define _EJSON_TEST_EJSON_MODEL_H
|
||||||
|
|
||||||
|
#include <Ejson.h>
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,182 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_fake_server.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
#define FAKE_SERVER_DATA_KEY "data"
|
||||||
|
|
||||||
|
static void _fake_server_name_request_cb(void *, const Eldbus_Message *, Eldbus_Pending *);
|
||||||
|
static Eina_Bool _fakse_server_property_get(const Eldbus_Service_Interface *, const char *, Eldbus_Message_Iter *, const Eldbus_Message *, Eldbus_Message **);
|
||||||
|
static Eldbus_Message *_fake_server_property_set(const Eldbus_Service_Interface *, const char *, Eldbus_Message_Iter *, const Eldbus_Message *);
|
||||||
|
static Eldbus_Message *_fake_server_sum(const Eldbus_Service_Interface *, const Eldbus_Message *);
|
||||||
|
static Eldbus_Message *_fake_server_ping(const Eldbus_Service_Interface *, const Eldbus_Message *);
|
||||||
|
static Eina_Bool _fake_server_send_pong_signal(void *);
|
||||||
|
|
||||||
|
static Eldbus_Connection *conn;
|
||||||
|
|
||||||
|
static const Eldbus_Method methods[] = {
|
||||||
|
{
|
||||||
|
FAKE_SERVER_SUM_METHOD_NAME, ELDBUS_ARGS({"i", "a"}, {"i", "b"}), ELDBUS_ARGS({"i", "result"}),
|
||||||
|
_fake_server_sum
|
||||||
|
},
|
||||||
|
{
|
||||||
|
FAKE_SERVER_PING_METHOD_NAME, ELDBUS_ARGS({"i", "a"}), NULL,
|
||||||
|
_fake_server_ping
|
||||||
|
},
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
FAKE_SERVER_PONG_SIGNAL = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eldbus_Signal signals[] = {
|
||||||
|
[FAKE_SERVER_PONG_SIGNAL] = {FAKE_SERVER_PONG_SIGNAL_NAME, ELDBUS_ARGS({ "i", NULL }), 0},
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eldbus_Property properties[] = {
|
||||||
|
{ FAKE_SERVER_READONLY_PROPERTY, "i", _fakse_server_property_get, NULL, 0 },
|
||||||
|
{ FAKE_SERVER_WRITEONLY_PROPERTY, "i", NULL, _fake_server_property_set, 0 },
|
||||||
|
{ FAKE_SERVER_READWRITE_PROPERTY, "i", _fakse_server_property_get, _fake_server_property_set, 0 },
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eldbus_Service_Interface_Desc test_interface_desc = {
|
||||||
|
FAKE_SERVER_INTERFACE, methods, signals, properties, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Eldbus_Service_Interface *
|
||||||
|
fake_server_start(Fake_Server_Data *data)
|
||||||
|
{
|
||||||
|
ck_assert_ptr_ne(NULL, data);
|
||||||
|
|
||||||
|
conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
|
||||||
|
|
||||||
|
Eldbus_Service_Interface *interface = eldbus_service_interface_register(conn, FAKE_SERVER_PATH, &test_interface_desc);
|
||||||
|
eldbus_service_object_data_set(interface, FAKE_SERVER_DATA_KEY, data);
|
||||||
|
|
||||||
|
eldbus_name_request(conn, FAKE_SERVER_BUS, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE,
|
||||||
|
_fake_server_name_request_cb, interface);
|
||||||
|
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
return interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fake_server_stop(Eldbus_Service_Interface *interface)
|
||||||
|
{
|
||||||
|
eldbus_service_object_unregister(interface);
|
||||||
|
eldbus_connection_unref(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Message *
|
||||||
|
_fake_server_sum(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "ii", &a, &b))
|
||||||
|
return eldbus_message_error_new(msg, "Invalid arguments", "Error getting arguments..");
|
||||||
|
|
||||||
|
int sum = a + b;
|
||||||
|
|
||||||
|
Eldbus_Message *reply = eldbus_message_method_return_new(msg);
|
||||||
|
eldbus_message_arguments_append(reply, "i", sum);
|
||||||
|
return reply;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Message *
|
||||||
|
_fake_server_ping(const Eldbus_Service_Interface *iface , const Eldbus_Message *msg)
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "i", &a))
|
||||||
|
return eldbus_message_error_new(msg, "Invalid arguments", "Error getting arguments..");
|
||||||
|
|
||||||
|
Fake_Server_Data *pd = eldbus_service_object_data_get(iface, FAKE_SERVER_DATA_KEY);
|
||||||
|
ck_assert_ptr_ne(NULL, pd);
|
||||||
|
|
||||||
|
pd->pong_response = a + 1;
|
||||||
|
Ecore_Timer *timer = ecore_timer_add(0.1, _fake_server_send_pong_signal, iface);
|
||||||
|
ck_assert_ptr_ne(NULL, timer);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_fake_server_send_pong_signal(void *data)
|
||||||
|
{
|
||||||
|
Eldbus_Service_Interface *iface = (Eldbus_Service_Interface*)data;
|
||||||
|
|
||||||
|
Fake_Server_Data *pd = eldbus_service_object_data_get(iface, FAKE_SERVER_DATA_KEY);
|
||||||
|
ck_assert_ptr_ne(NULL, pd);
|
||||||
|
|
||||||
|
eldbus_service_signal_emit(iface, FAKE_SERVER_PONG_SIGNAL, pd->pong_response);
|
||||||
|
return ECORE_CALLBACK_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_fakse_server_property_get(const Eldbus_Service_Interface *iface,
|
||||||
|
const char *propname,
|
||||||
|
Eldbus_Message_Iter *iter,
|
||||||
|
const Eldbus_Message *request_msg EINA_UNUSED,
|
||||||
|
Eldbus_Message **error EINA_UNUSED)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s:%d _fake_server_property_get %s\n", __FILE__, __LINE__, propname); fflush(stderr);
|
||||||
|
Fake_Server_Data *data = eldbus_service_object_data_get(iface, FAKE_SERVER_DATA_KEY);
|
||||||
|
ck_assert_ptr_ne(NULL, data);
|
||||||
|
|
||||||
|
if (strcmp(propname, FAKE_SERVER_READONLY_PROPERTY) == 0)
|
||||||
|
eldbus_message_iter_arguments_append(iter, "i", data->readonly_property);
|
||||||
|
else
|
||||||
|
if (strcmp(propname, FAKE_SERVER_READWRITE_PROPERTY) == 0)
|
||||||
|
eldbus_message_iter_arguments_append(iter, "i", data->readwrite_property);
|
||||||
|
else
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Message *
|
||||||
|
_fake_server_property_set(const Eldbus_Service_Interface *iface,
|
||||||
|
const char *propname,
|
||||||
|
Eldbus_Message_Iter *iter,
|
||||||
|
const Eldbus_Message *msg)
|
||||||
|
{
|
||||||
|
Fake_Server_Data *data = eldbus_service_object_data_get(iface, FAKE_SERVER_DATA_KEY);
|
||||||
|
ck_assert_ptr_ne(NULL, data);
|
||||||
|
|
||||||
|
if (strcmp(propname, FAKE_SERVER_WRITEONLY_PROPERTY) == 0)
|
||||||
|
eldbus_message_iter_arguments_get(iter, "i", &data->writeonly_property);
|
||||||
|
else
|
||||||
|
if (strcmp(propname, FAKE_SERVER_READWRITE_PROPERTY) == 0)
|
||||||
|
eldbus_message_iter_arguments_get(iter, "i", &data->readwrite_property);
|
||||||
|
else
|
||||||
|
return eldbus_message_error_new(msg, "Invalid property", "Invalid property.");
|
||||||
|
|
||||||
|
return eldbus_message_method_return_new(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_fake_server_name_request_cb(void *data EINA_UNUSED,
|
||||||
|
const Eldbus_Message *msg,
|
||||||
|
Eldbus_Pending *pending EINA_UNUSED)
|
||||||
|
{
|
||||||
|
if (eldbus_message_error_get(msg, NULL, NULL))
|
||||||
|
ck_abort_msg("error on _fake_server_name_request_cb");
|
||||||
|
|
||||||
|
unsigned int reply;
|
||||||
|
if (!eldbus_message_arguments_get(msg, "u", &reply))
|
||||||
|
ck_abort_msg("error geting arguments on _fake_server_name_request_cb");
|
||||||
|
|
||||||
|
if (ELDBUS_NAME_REQUEST_REPLY_PRIMARY_OWNER != reply)
|
||||||
|
ck_abort_msg("error name already in use");
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef _ELDBUS_FAKE_SERVER_H
|
||||||
|
#define _ELDBUS_FAKE_SERVER_H
|
||||||
|
|
||||||
|
#include <Eldbus.h>
|
||||||
|
|
||||||
|
#define FAKE_SERVER_BUS "org.Enlightenment"
|
||||||
|
#define FAKE_SERVER_PATH "/org/enlightenment"
|
||||||
|
#define FAKE_SERVER_INTERFACE "org.enlightenment.FakeServer"
|
||||||
|
#define FAKE_SERVER_READONLY_PROPERTY "r"
|
||||||
|
#define FAKE_SERVER_WRITEONLY_PROPERTY "w"
|
||||||
|
#define FAKE_SERVER_READWRITE_PROPERTY "rw"
|
||||||
|
#define FAKE_SERVER_SUM_METHOD_NAME "Sum"
|
||||||
|
#define FAKE_SERVER_PING_METHOD_NAME "Ping"
|
||||||
|
#define FAKE_SERVER_PONG_SIGNAL_NAME "Pong"
|
||||||
|
|
||||||
|
typedef struct _Fake_Server_Data Fake_Server_Data;
|
||||||
|
|
||||||
|
struct _Fake_Server_Data
|
||||||
|
{
|
||||||
|
int readonly_property;
|
||||||
|
int writeonly_property;
|
||||||
|
int readwrite_property;
|
||||||
|
int pong_response;
|
||||||
|
};
|
||||||
|
|
||||||
|
Eldbus_Service_Interface *fake_server_start(Fake_Server_Data *data);
|
||||||
|
void fake_server_stop(Eldbus_Service_Interface *interface);
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,7 +19,14 @@ struct _Eldbus_Test_Case
|
||||||
|
|
||||||
static const Eldbus_Test_Case etc[] = {
|
static const Eldbus_Test_Case etc[] = {
|
||||||
{ "eldbus_init", eldbus_test_eldbus_init },
|
{ "eldbus_init", eldbus_test_eldbus_init },
|
||||||
{ }
|
{ "eldbus_model", eldbus_test_eldbus_model },
|
||||||
|
{ "eldbus_model_connection", eldbus_test_eldbus_model_connection },
|
||||||
|
{ "eldbus_model_object", eldbus_test_eldbus_model_object },
|
||||||
|
{ "eldbus_model_proxy", eldbus_test_eldbus_model_proxy },
|
||||||
|
{ "eldbus_test_fake_server_eldbus_model_proxy", eldbus_test_fake_server_eldbus_model_proxy },
|
||||||
|
{ "eldbus_model_method", eldbus_test_eldbus_model_method },
|
||||||
|
{ "eldbus_model_signal", eldbus_test_eldbus_model_signal },
|
||||||
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -4,5 +4,12 @@
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
|
|
||||||
void eldbus_test_eldbus_init(TCase *tc);
|
void eldbus_test_eldbus_init(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model_connection(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model_object(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model_proxy(TCase *tc);
|
||||||
|
void eldbus_test_fake_server_eldbus_model_proxy(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model_method(TCase *tc);
|
||||||
|
void eldbus_test_eldbus_model_signal(TCase *tc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,418 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eo_event_quit_cb(void *data EINA_UNUSED,
|
||||||
|
Eo *obj EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_wait_for_event(Eo *obj, const Eo_Event_Description* event)
|
||||||
|
{
|
||||||
|
eo_do(obj, eo_event_callback_add(event, _eo_event_quit_cb, NULL));
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
eo_do(obj, eo_event_callback_del(event, _eo_event_quit_cb, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_event_load_status_quit_cb(void *data, Eo *obj EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
printf("_event_load_status_quit_cb\n");
|
||||||
|
Efl_Model_Load_Status expected_status = (Efl_Model_Load_Status)data;
|
||||||
|
Efl_Model_Load *actual_load = (Efl_Model_Load*)event_info;
|
||||||
|
|
||||||
|
if (expected_status == actual_load->status)
|
||||||
|
{
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_wait_for_load_status(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status actual_status;
|
||||||
|
eo_do(efl_model, actual_status = efl_model_load_status_get());
|
||||||
|
if (expected_status == actual_status)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eo_do(efl_model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status));
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
eo_do(efl_model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status));
|
||||||
|
}
|
||||||
|
|
||||||
|
Efl_Model_Base *
|
||||||
|
efl_model_nth_child_get(Efl_Model_Base *efl_model, unsigned int n)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(efl_model, status = efl_model_children_slice_get(n, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
Eo *child = NULL;
|
||||||
|
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
Efl_Model_Base *
|
||||||
|
efl_model_first_child_get(Efl_Model_Base *efl_model)
|
||||||
|
{
|
||||||
|
return efl_model_nth_child_get(efl_model, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
efl_model_load_and_wait_for_load_status(Eo *obj, Efl_Model_Load_Status expected_status)
|
||||||
|
{
|
||||||
|
eo_do(obj, efl_model_load());
|
||||||
|
efl_model_wait_for_load_status(obj, expected_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_init(void)
|
||||||
|
{
|
||||||
|
int ret = eldbus_init();
|
||||||
|
ck_assert_int_ge(ret, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_shutdown(void)
|
||||||
|
{
|
||||||
|
int ret = eldbus_shutdown();
|
||||||
|
ck_assert_int_eq(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_property(Eo *object, const char *property_name, const char *expected_value)
|
||||||
|
{
|
||||||
|
Eina_Value const* property_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_property_get(property_name, &property_value));
|
||||||
|
ck_assert_msg(EFL_MODEL_LOAD_STATUS_ERROR != status, "Nonexistent property: %s", property_name);
|
||||||
|
ck_assert_ptr_ne(NULL, property_value);
|
||||||
|
char *actual_value = eina_value_to_string(property_value);
|
||||||
|
if (!actual_value)
|
||||||
|
ck_assert_ptr_eq(expected_value, actual_value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool is_property_equal = strcmp(expected_value, actual_value) == 0;
|
||||||
|
ck_assert_msg(is_property_equal, "'%s' != '%s'", expected_value, actual_value);
|
||||||
|
free(actual_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
create_connection(void)
|
||||||
|
{
|
||||||
|
Eo *connection = eo_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, NULL,
|
||||||
|
eldbus_model_connection_type_set(ELDBUS_CONNECTION_TYPE_SESSION),
|
||||||
|
eldbus_model_connection_address_set(NULL),
|
||||||
|
eldbus_model_connection_private_set(EINA_FALSE));
|
||||||
|
ck_assert_ptr_ne(NULL, connection);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
create_and_load_connection(void)
|
||||||
|
{
|
||||||
|
Eo *connection = create_connection();
|
||||||
|
efl_model_load_and_wait_for_load_status(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
create_object(void)
|
||||||
|
{
|
||||||
|
Eo *connection = eo_add(ELDBUS_MODEL_CONNECTION_CLASS, NULL,
|
||||||
|
eldbus_model_connection_type_set(ELDBUS_CONNECTION_TYPE_SESSION),
|
||||||
|
eldbus_model_connection_address_set(NULL),
|
||||||
|
eldbus_model_connection_private_set(EINA_FALSE));
|
||||||
|
ck_assert_ptr_ne(NULL, connection);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
Eo *object = eo_add_ref(ELDBUS_MODEL_OBJECT_CLASS, NULL,
|
||||||
|
eldbus_model_object_connection_model_set(connection),
|
||||||
|
eldbus_model_object_bus_set(ELDBUS_FDO_BUS),
|
||||||
|
eldbus_model_object_path_set(ELDBUS_FDO_PATH));
|
||||||
|
ck_assert_ptr_ne(NULL, object);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo *
|
||||||
|
create_and_load_object(void)
|
||||||
|
{
|
||||||
|
Eo *object = create_object();
|
||||||
|
efl_model_load_and_wait_for_load_status(object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_load_status_get(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_load_status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status actual_load_status;
|
||||||
|
eo_do(efl_model, actual_load_status = efl_model_load_status_get());
|
||||||
|
ck_assert_int_eq(expected_load_status, actual_load_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_children_count_eq(Efl_Model_Base *efl_model, unsigned int expected_children_count)
|
||||||
|
{
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(efl_model, efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_children_count_ge(Efl_Model_Base *efl_model, unsigned int minimum_children_count)
|
||||||
|
{
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(efl_model, status = efl_model_children_count_get(&actual_children_count));
|
||||||
|
// A minimum count only exists if model have EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN
|
||||||
|
ck_assert((EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN & status) == EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
ck_assert_int_ge(actual_children_count, minimum_children_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_children_slice_get(Efl_Model_Base *efl_model)
|
||||||
|
{
|
||||||
|
unsigned int count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(efl_model, status = efl_model_children_count_get(&count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_msg(count, "There must be at least 1 child to test");
|
||||||
|
|
||||||
|
// Test slice all
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
eo_do(efl_model, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
// Get first child
|
||||||
|
Eo *first_child = NULL;
|
||||||
|
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&first_child);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, first_child);
|
||||||
|
// get last child
|
||||||
|
Eo *last_child = NULL;
|
||||||
|
ret = eina_accessor_data_get(accessor, count - 1, (void**)&last_child);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, last_child);
|
||||||
|
// Test nonexistent child
|
||||||
|
Eo *nonexistent_child = NULL;
|
||||||
|
ret = eina_accessor_data_get(accessor, count, (void**)&nonexistent_child);
|
||||||
|
ck_assert(!ret);
|
||||||
|
ck_assert_ptr_eq(NULL, nonexistent_child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
|
||||||
|
// Test slice first child
|
||||||
|
Eo *child = NULL;
|
||||||
|
eo_do(efl_model, status = efl_model_children_slice_get(1, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
ret = eina_accessor_data_get(accessor, 1, (void**)&child);
|
||||||
|
ck_assert(!ret);
|
||||||
|
ck_assert_ptr_eq(first_child, child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
|
||||||
|
// Test slice last child
|
||||||
|
eo_do(efl_model, status = efl_model_children_slice_get(count, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
ret = eina_accessor_data_get(accessor, 1, (void**)&child);
|
||||||
|
ck_assert(!ret);
|
||||||
|
ck_assert_ptr_eq(last_child, child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
|
||||||
|
// Test slice nonexistent element
|
||||||
|
eo_do(efl_model, status = efl_model_children_slice_get(count + 1, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(smoke)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
Eo *connection = create_and_load_connection();
|
||||||
|
eo_unref(connection);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(object)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
Eo *root = create_object();
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(root, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
eo_unref(root);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(proxy)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
Eo *root = create_object();
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(root, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
Eina_Accessor *accessor = NULL;
|
||||||
|
eo_do(root, efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
|
Eo *proxy;
|
||||||
|
EINA_ACCESSOR_FOREACH(accessor, i, proxy)
|
||||||
|
{
|
||||||
|
efl_model_load_and_wait_for_load_status(proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
|
||||||
|
eo_unref(root);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
eldbus_test_eldbus_model(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, smoke);
|
||||||
|
tcase_add_test(tc, object);
|
||||||
|
tcase_add_test(tc, proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Model_Proxy *
|
||||||
|
eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
|
||||||
|
Eo *proxy = NULL;
|
||||||
|
unsigned int i;
|
||||||
|
EINA_ACCESSOR_FOREACH(accessor, i, proxy)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
eo_do(proxy, name = eldbus_model_proxy_name_get());
|
||||||
|
ck_assert_ptr_ne(NULL, name);
|
||||||
|
if (strcmp(name, interface_name) == 0)
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
proxy = NULL;
|
||||||
|
|
||||||
|
end:
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eldbus_Model_Arguments *
|
||||||
|
_eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name, const Eo_Class *klass)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(proxy, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
|
||||||
|
Eo *child = NULL;
|
||||||
|
unsigned int i;
|
||||||
|
EINA_ACCESSOR_FOREACH(accessor, i, child)
|
||||||
|
{
|
||||||
|
if (!eo_isa(child, klass))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char *name;
|
||||||
|
eo_do(child, name = eldbus_model_arguments_name_get());
|
||||||
|
ck_assert_ptr_ne(NULL, name);
|
||||||
|
if (strcmp(name, method_name) == 0)
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
child = NULL;
|
||||||
|
|
||||||
|
end:
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Model_Method *
|
||||||
|
eldbus_model_method_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name)
|
||||||
|
{
|
||||||
|
return _eldbus_model_arguments_from_proxy_get(proxy, method_name, ELDBUS_MODEL_METHOD_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eldbus_Model_Signal *
|
||||||
|
eldbus_model_signal_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *signal_name)
|
||||||
|
{
|
||||||
|
return _eldbus_model_arguments_from_proxy_get(proxy, signal_name, ELDBUS_MODEL_SIGNAL_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_property_int_eq(Efl_Model_Base *efl_model, const char *property, int expected_value)
|
||||||
|
{
|
||||||
|
Eina_Value const* property_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(efl_model, status = efl_model_property_get(property, &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, property_value);
|
||||||
|
|
||||||
|
const Eina_Value_Type *property_type = eina_value_type_get(property_value);
|
||||||
|
ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type);
|
||||||
|
|
||||||
|
int actual_value = 0;
|
||||||
|
eina_value_get(property_value, &actual_value);
|
||||||
|
ck_assert_int_eq(expected_value, actual_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_efl_model_property_int_set(Efl_Model_Base *efl_model, const char *property, int value)
|
||||||
|
{
|
||||||
|
Eina_Value eina_value;
|
||||||
|
eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&eina_value, value);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(efl_model, status = efl_model_property_set(property, &eina_value));
|
||||||
|
eina_value_flush(&eina_value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef _ELDBUS_TEST_ELDBUS_MODEL_H
|
||||||
|
#define _ELDBUS_TEST_ELDBUS_MODEL_H
|
||||||
|
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
void check_init(void);
|
||||||
|
void check_shutdown(void);
|
||||||
|
Eo *create_connection(void);
|
||||||
|
Eo *create_and_load_connection(void);
|
||||||
|
Eo *create_object(void);
|
||||||
|
Eo *create_and_load_object(void);
|
||||||
|
|
||||||
|
void efl_model_wait_for_event(Eo *obj, const Eo_Event_Description *event);
|
||||||
|
void efl_model_wait_for_load_status(Eo *obj, Efl_Model_Load_Status expected_status);
|
||||||
|
void efl_model_load_and_wait_for_load_status(Eo *obj, Efl_Model_Load_Status expected_status);
|
||||||
|
Efl_Model_Base *efl_model_nth_child_get(Efl_Model_Base *obj, unsigned int n);
|
||||||
|
Efl_Model_Base *efl_model_first_child_get(Efl_Model_Base *efl_model);
|
||||||
|
|
||||||
|
void check_efl_model_load_status_get(Efl_Model_Base *obj, Efl_Model_Load_Status expected_load_status);
|
||||||
|
void check_efl_model_children_count_eq(Efl_Model_Base *obj, unsigned int expected_children_count);
|
||||||
|
void check_efl_model_children_count_ge(Efl_Model_Base *obj, unsigned int minimum_children_count);
|
||||||
|
void check_efl_model_children_slice_get(Efl_Model_Base *efl_model);
|
||||||
|
void check_efl_model_property_int_eq(Efl_Model_Base *obj, const char *property, int expected_value);
|
||||||
|
void check_efl_model_property_int_set(Efl_Model_Base *obj, const char *property, int value);
|
||||||
|
|
||||||
|
Eldbus_Model_Proxy *eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name);
|
||||||
|
Eldbus_Model_Method *eldbus_model_method_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name);
|
||||||
|
Eldbus_Model_Signal *eldbus_model_signal_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *signal_name);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,201 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static Eo *connection = NULL;
|
||||||
|
static Eo *unloaded_connection = NULL;
|
||||||
|
|
||||||
|
#define UNIQUE_NAME_PROPERTY "unique_name"
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
connection = create_and_load_connection();
|
||||||
|
unloaded_connection = create_connection();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(unloaded_connection);
|
||||||
|
eo_unref(connection);
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
check_efl_model_load_status_get(unloaded_connection, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(connection, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
const unsigned int expected_properties_count = 1;
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
|
||||||
|
// Unloaded connection populates its properties
|
||||||
|
eo_do(unloaded_connection, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
Eina_Value const* property_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(connection, status = efl_model_property_get(UNIQUE_NAME_PROPERTY, &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, property_value);
|
||||||
|
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
eo_do(connection, status = efl_model_property_get("nonexistent", &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&value, 1);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(connection, status = efl_model_property_set("nonexistent", &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
// UNIQUE_NAME_PROPERTY is read-only
|
||||||
|
eo_do(connection, status = efl_model_property_set(UNIQUE_NAME_PROPERTY, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
// The model must be loaded to be able to set its properties
|
||||||
|
const char *expected_value = "unloaded";
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&value, expected_value);
|
||||||
|
eo_do(unloaded_connection, status = efl_model_property_set(UNIQUE_NAME_PROPERTY, &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
// At least this connection <unique_name> and 'org.freedesktop.DBus' must exist
|
||||||
|
check_efl_model_children_count_ge(efl_model, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_children_count(connection);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
check_efl_model_children_slice_get(connection);
|
||||||
|
|
||||||
|
// Unloaded connection must return EFL_MODEL_LOAD_STATUS_UNLOADED
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(unloaded_connection, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(connection, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(connection, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(connection, 0);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_connection, efl_model_properties_load());
|
||||||
|
check_efl_model_load_status_get(unloaded_connection, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_connection, efl_model_children_load());
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(unloaded_connection, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
|
||||||
|
|
||||||
|
efl_model_wait_for_load_status(unloaded_connection, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(unloaded_connection, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_children_count(unloaded_connection);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child;
|
||||||
|
eo_do(connection, child = efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
unsigned int expected_children_count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(connection, status = efl_model_children_count_get(&expected_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
Eo *child = efl_model_first_child_get(connection);
|
||||||
|
eo_do(connection, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(connection, status = efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_eldbus_model_connection(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
}
|
|
@ -0,0 +1,226 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_fake_server.h"
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define ARGUMENT_A "arg0"
|
||||||
|
#define ARGUMENT_B "arg1"
|
||||||
|
#define ARGUMENT_RESULT "arg2"
|
||||||
|
|
||||||
|
static Eo *fake_server_object = NULL;
|
||||||
|
static Eo *fake_server_proxy = NULL;
|
||||||
|
static Eldbus_Service_Interface *fake_server = NULL;
|
||||||
|
static Fake_Server_Data fake_server_data = {0};
|
||||||
|
static Eo *method = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
fake_server = fake_server_start(&fake_server_data);
|
||||||
|
|
||||||
|
Eldbus_Model_Connection* connection
|
||||||
|
= eo_add(ELDBUS_MODEL_CONNECTION_CLASS, NULL,
|
||||||
|
eldbus_model_connection_type_set(ELDBUS_CONNECTION_TYPE_SESSION),
|
||||||
|
eldbus_model_connection_address_set(NULL),
|
||||||
|
eldbus_model_connection_private_set(EINA_FALSE));
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_object = eo_add(ELDBUS_MODEL_OBJECT_CLASS, NULL,
|
||||||
|
eldbus_model_object_connection_model_set(connection),
|
||||||
|
eldbus_model_object_bus_set(FAKE_SERVER_BUS),
|
||||||
|
eldbus_model_object_path_set(FAKE_SERVER_PATH));
|
||||||
|
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||||
|
ck_assert_ptr_ne(NULL, fake_server_proxy);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
method = eldbus_model_method_from_proxy_get(fake_server_proxy, FAKE_SERVER_SUM_METHOD_NAME);
|
||||||
|
ck_assert_ptr_ne(NULL, method);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(method, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(fake_server_object);
|
||||||
|
|
||||||
|
fake_server_stop(fake_server);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(method, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
const unsigned int expected_properties_count = 3; // a, b and result arguments of 'sum' method
|
||||||
|
const unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
// Input only property returns error
|
||||||
|
Eina_Value const* dummy;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = efl_model_property_get(ARGUMENT_A, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
eo_do(method, status = efl_model_property_get(ARGUMENT_RESULT, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
// Nonexistent property returns error
|
||||||
|
eo_do(method, status = efl_model_property_get("nonexistent", &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
// Output argument returns error
|
||||||
|
Eina_Value dummy = {0};
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = efl_model_property_set(ARGUMENT_RESULT, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_method_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
check_efl_model_children_count_eq(efl_model, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_method_children_count(method);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = efl_model_children_slice_get(1, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_unload(void)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(method, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(method, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(method, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(method, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(method, efl_model_properties_load());
|
||||||
|
efl_model_wait_for_load_status(method, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(method, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(method, efl_model_children_load());
|
||||||
|
efl_model_wait_for_load_status(method, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(method, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_method_children_count(method);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child;
|
||||||
|
eo_do(method, child = efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
// efl_model_child_del always returns ERROR
|
||||||
|
Eo *child = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(call)
|
||||||
|
{
|
||||||
|
check_efl_model_property_int_set(method, ARGUMENT_A, 12345678);
|
||||||
|
check_efl_model_property_int_set(method, ARGUMENT_B, 87654321);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(method, status = eldbus_model_method_call());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
efl_model_wait_for_event(method, ELDBUS_MODEL_METHOD_EVENT_SUCCESSFUL_CALL);
|
||||||
|
|
||||||
|
check_efl_model_property_int_eq(method, ARGUMENT_RESULT, 99999999);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_eldbus_model_method(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
tcase_add_test(tc, call);
|
||||||
|
}
|
|
@ -0,0 +1,200 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static Eo *object = NULL;
|
||||||
|
static Eo *unloaded_object = NULL;
|
||||||
|
|
||||||
|
#define UNIQUE_NAME_PROPERTY "unique_name"
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
object = create_and_load_object();
|
||||||
|
unloaded_object = create_object();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(unloaded_object);
|
||||||
|
eo_unref(object);
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
check_efl_model_load_status_get(unloaded_object, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
const unsigned int expected_properties_count = 1;
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
|
||||||
|
// Unloaded object populates its properties
|
||||||
|
eo_do(unloaded_object, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
const Eina_Value* property_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_property_get(UNIQUE_NAME_PROPERTY, &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
eo_do(object, status = efl_model_property_get("nonexistent", &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&value, 1);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_property_set("nonexistent", &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
// UNIQUE_NAME_PROPERTY is read-only
|
||||||
|
eo_do(object, status = efl_model_property_set(UNIQUE_NAME_PROPERTY, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
// The model must be loaded to be able to set its properties
|
||||||
|
const char *expected_value = "unloaded";
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&value, expected_value);
|
||||||
|
eo_do(unloaded_object, status = efl_model_property_set(UNIQUE_NAME_PROPERTY, &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
// 'org.freedesktop.DBus' and 'org.freedesktop.DBus.Introspectable'
|
||||||
|
check_efl_model_children_count_ge(efl_model, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_children_count(object);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
check_efl_model_children_slice_get(object);
|
||||||
|
|
||||||
|
// Unloaded object must return EFL_MODEL_LOAD_STATUS_UNLOADED
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(unloaded_object, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(object, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(object, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(object, 0);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_object, efl_model_properties_load());
|
||||||
|
check_efl_model_load_status_get(unloaded_object, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_object, efl_model_children_load());
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(unloaded_object, EFL_MODEL_LOAD_STATUS_LOADING_CHILDREN);
|
||||||
|
|
||||||
|
efl_model_wait_for_load_status(unloaded_object, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(unloaded_object, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_children_count(unloaded_object);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child;
|
||||||
|
eo_do(object, child = efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
unsigned int expected_children_count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(object, status = efl_model_children_count_get(&expected_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
Eo *child = efl_model_first_child_get(object);
|
||||||
|
eo_do(object, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(object, status = efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_eldbus_model_object(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static Eo *dbus_object1 = NULL;
|
||||||
|
static Eo *dbus_object2 = NULL;
|
||||||
|
static Eo *dbus_proxy = NULL;
|
||||||
|
static Eo *unloaded_dbus_proxy = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
dbus_object1 = create_and_load_object();
|
||||||
|
dbus_object2 = create_and_load_object();
|
||||||
|
|
||||||
|
dbus_proxy = eldbus_model_proxy_from_object_get(dbus_object1, ELDBUS_FDO_INTERFACE);
|
||||||
|
ck_assert_ptr_ne(NULL, dbus_proxy);
|
||||||
|
efl_model_load_and_wait_for_load_status(dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
unloaded_dbus_proxy = eldbus_model_proxy_from_object_get(dbus_object2, ELDBUS_FDO_INTERFACE);
|
||||||
|
ck_assert_ptr_ne(NULL, dbus_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(dbus_object2);
|
||||||
|
eo_unref(dbus_object1);
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
check_efl_model_load_status_get(unloaded_dbus_proxy, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
// ELDBUS_FDO_INTERFACE have no properties
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(dbus_proxy, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
ck_assert_int_eq(0, eina_array_count(properties));
|
||||||
|
|
||||||
|
// Must be loaded to get the properties
|
||||||
|
eo_do(unloaded_dbus_proxy, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
const Eina_Value* property_value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(dbus_proxy, status = efl_model_property_get("nonexistent", &property_value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&value, 1);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(dbus_proxy, status = efl_model_property_set("nonexistent", &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_dbus_proxy_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
// 'org.freedesktop.DBus::AddMatch' and 'org.freedesktop.DBus::ListNames' at least
|
||||||
|
check_efl_model_children_count_ge(efl_model, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_dbus_proxy_children_count(dbus_proxy);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
check_efl_model_children_slice_get(dbus_proxy);
|
||||||
|
|
||||||
|
// Unloaded dbus_proxy must return EFL_MODEL_LOAD_STATUS_UNLOADED
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(unloaded_dbus_proxy, status = efl_model_children_slice_get(0, 0, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_UNLOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(dbus_proxy, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(dbus_proxy, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(dbus_proxy, 0);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_dbus_proxy, efl_model_properties_load());
|
||||||
|
check_efl_model_load_status_get(unloaded_dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
eo_do(unloaded_dbus_proxy, efl_model_children_load());
|
||||||
|
|
||||||
|
efl_model_wait_for_load_status(unloaded_dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(unloaded_dbus_proxy, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_dbus_proxy_children_count(unloaded_dbus_proxy);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child;
|
||||||
|
eo_do(dbus_proxy, child = efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
unsigned int expected_children_count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(dbus_proxy, status = efl_model_children_count_get(&expected_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
Eo *child = efl_model_first_child_get(dbus_proxy);
|
||||||
|
eo_do(dbus_proxy, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(dbus_proxy, status = efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_eldbus_model_proxy(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
}
|
|
@ -0,0 +1,226 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_fake_server.h"
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define ARGUMENT_A "arg0"
|
||||||
|
|
||||||
|
static Eo *fake_server_object = NULL;
|
||||||
|
static Eo *fake_server_proxy = NULL;
|
||||||
|
static Eldbus_Service_Interface *fake_server = NULL;
|
||||||
|
static Fake_Server_Data fake_server_data = {0};
|
||||||
|
static Eo *pong_signal = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
fake_server = fake_server_start(&fake_server_data);
|
||||||
|
|
||||||
|
Eldbus_Model_Connection* connection
|
||||||
|
= eo_add(ELDBUS_MODEL_CONNECTION_CLASS, NULL,
|
||||||
|
eldbus_model_connection_type_set(ELDBUS_CONNECTION_TYPE_SESSION),
|
||||||
|
eldbus_model_connection_address_set(NULL),
|
||||||
|
eldbus_model_connection_private_set(EINA_FALSE));
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_object = eo_add(ELDBUS_MODEL_OBJECT_CLASS, NULL,
|
||||||
|
eldbus_model_object_connection_model_set(connection),
|
||||||
|
eldbus_model_object_bus_set(FAKE_SERVER_BUS),
|
||||||
|
eldbus_model_object_path_set(FAKE_SERVER_PATH));
|
||||||
|
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||||
|
ck_assert_ptr_ne(NULL, fake_server_proxy);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
pong_signal = eldbus_model_signal_from_proxy_get(fake_server_proxy, FAKE_SERVER_PONG_SIGNAL_NAME);
|
||||||
|
ck_assert_ptr_ne(NULL, pong_signal);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(fake_server_object);
|
||||||
|
|
||||||
|
fake_server_stop(fake_server);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pong_signal, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
const unsigned int expected_properties_count = 1; // 'response' only
|
||||||
|
const unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
// Signal properties always have output direction
|
||||||
|
Eina_Value const* dummy;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pong_signal, status = efl_model_property_get(ARGUMENT_A, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, dummy);
|
||||||
|
|
||||||
|
// Nonexistent property must return EFL_MODEL_LOAD_STATUS_ERROR
|
||||||
|
eo_do(pong_signal, status = efl_model_property_get("nonexistent", &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
// Signals have output arguments only. All returns error
|
||||||
|
Eina_Value dummy = {0};
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pong_signal, status = efl_model_property_set(ARGUMENT_A, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_signal_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
check_efl_model_children_count_eq(efl_model, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_signal_children_count(pong_signal);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pong_signal, status = efl_model_children_slice_get(1, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_eq(NULL, accessor);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_unload(void)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(pong_signal, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(pong_signal, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(pong_signal, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(pong_signal, efl_model_properties_load());
|
||||||
|
efl_model_wait_for_load_status(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(pong_signal, efl_model_children_load());
|
||||||
|
efl_model_wait_for_load_status(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(pong_signal, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_signal_children_count(pong_signal);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child;
|
||||||
|
eo_do(pong_signal, child = efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
// efl_model_child_del always returns ERROR
|
||||||
|
Eo *child = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(pong_signal, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(signals)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Method *ping_method = eldbus_model_method_from_proxy_get(fake_server_proxy, FAKE_SERVER_PING_METHOD_NAME);
|
||||||
|
ck_assert_ptr_ne(NULL, ping_method);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(ping_method, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
check_efl_model_property_int_set(ping_method, ARGUMENT_A, 99);
|
||||||
|
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(ping_method, status = eldbus_model_method_call());
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
efl_model_wait_for_event(pong_signal, EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED);
|
||||||
|
|
||||||
|
check_efl_model_property_int_eq(pong_signal, ARGUMENT_A, 100);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_eldbus_model_signal(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
tcase_add_test(tc, signals);
|
||||||
|
}
|
|
@ -0,0 +1,270 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eldbus_fake_server.h"
|
||||||
|
#include "eldbus_suite.h"
|
||||||
|
#include "eldbus_test_eldbus_model.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eldbus_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static Eo *fake_server_object = NULL;
|
||||||
|
static Eo *fake_server_proxy = NULL;
|
||||||
|
static Eldbus_Service_Interface *fake_server = NULL;
|
||||||
|
static Fake_Server_Data fake_server_data = {0};
|
||||||
|
|
||||||
|
#define FAKE_SERVER_READONLY_PROPERTY_VALUE 1111
|
||||||
|
#define FAKE_SERVER_WRITEONLY_PROPERTY_VALUE 2222
|
||||||
|
#define FAKE_SERVER_READWRITE_PROPERTY_VALUE 3333
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
check_init();
|
||||||
|
|
||||||
|
fake_server_data = (Fake_Server_Data){
|
||||||
|
.readonly_property = FAKE_SERVER_READONLY_PROPERTY_VALUE,
|
||||||
|
.writeonly_property = FAKE_SERVER_WRITEONLY_PROPERTY_VALUE,
|
||||||
|
.readwrite_property = FAKE_SERVER_READWRITE_PROPERTY_VALUE
|
||||||
|
};
|
||||||
|
fake_server = fake_server_start(&fake_server_data);
|
||||||
|
|
||||||
|
Eldbus_Model_Connection* connection
|
||||||
|
= eo_add(ELDBUS_MODEL_CONNECTION_CLASS, NULL,
|
||||||
|
eldbus_model_connection_type_set(ELDBUS_CONNECTION_TYPE_SESSION),
|
||||||
|
eldbus_model_connection_address_set(NULL),
|
||||||
|
eldbus_model_connection_private_set(EINA_FALSE));
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(connection, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_object = eo_add(ELDBUS_MODEL_OBJECT_CLASS, NULL,
|
||||||
|
eldbus_model_object_connection_model_set(connection),
|
||||||
|
eldbus_model_object_bus_set(FAKE_SERVER_BUS),
|
||||||
|
eldbus_model_object_path_set(FAKE_SERVER_PATH));
|
||||||
|
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_object, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||||
|
|
||||||
|
efl_model_load_and_wait_for_load_status(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
eo_unref(fake_server_object);
|
||||||
|
|
||||||
|
fake_server_stop(fake_server);
|
||||||
|
|
||||||
|
check_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_status_get)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_get)
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
const unsigned int expected_properties_count = 3; // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
|
||||||
|
const unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(property_get)
|
||||||
|
{
|
||||||
|
check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE);
|
||||||
|
check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE);
|
||||||
|
|
||||||
|
// Write-only property returns error
|
||||||
|
const Eina_Value *dummy;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_property_get(FAKE_SERVER_WRITEONLY_PROPERTY, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_property_set(const char *property_name, int expected_property_value, int *actual_property_value)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||||
|
eina_value_set(&value, expected_property_value);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_property_set(property_name, &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
efl_model_wait_for_event(fake_server_proxy, EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED);
|
||||||
|
|
||||||
|
ck_assert_int_eq(expected_property_value, *actual_property_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(property_set)
|
||||||
|
{
|
||||||
|
_check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property);
|
||||||
|
_check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property);
|
||||||
|
|
||||||
|
// Read-only property returns error
|
||||||
|
Eina_Value dummy = {0};
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_property_set(FAKE_SERVER_READONLY_PROPERTY, &dummy));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_test_fake_server_proxy_children_count(Eo *efl_model)
|
||||||
|
{
|
||||||
|
// 'Sum' and 'Ping' methods and 'Pong' signal
|
||||||
|
check_efl_model_children_count_eq(efl_model, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(children_count)
|
||||||
|
{
|
||||||
|
_test_fake_server_proxy_children_count(fake_server_proxy);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_slice_get)
|
||||||
|
{
|
||||||
|
Eldbus_Model_Arguments *method1 = efl_model_nth_child_get(fake_server_proxy, 1);
|
||||||
|
Eldbus_Model_Arguments *method2 = efl_model_nth_child_get(fake_server_proxy, 2);
|
||||||
|
Eldbus_Model_Arguments *signal1 = efl_model_nth_child_get(fake_server_proxy, 3);
|
||||||
|
|
||||||
|
const char *actual_method1_name = eo_do_ret(method1, actual_method1_name, eldbus_model_arguments_name_get());
|
||||||
|
const char *actual_method2_name = eo_do_ret(method2, actual_method2_name, eldbus_model_arguments_name_get());
|
||||||
|
const char *actual_signal1_name = eo_do_ret(signal1, actual_signal1_name, eldbus_model_arguments_name_get());
|
||||||
|
|
||||||
|
ck_assert_ptr_ne(NULL, actual_method1_name);
|
||||||
|
ck_assert_ptr_ne(NULL, actual_method2_name);
|
||||||
|
ck_assert_ptr_ne(NULL, actual_signal1_name);
|
||||||
|
|
||||||
|
// Eldbus doesn't have order for method names. Methods order are determined by Eina_Hash
|
||||||
|
if (strcmp(FAKE_SERVER_SUM_METHOD_NAME, actual_method1_name) == 0)
|
||||||
|
ck_assert(strcmp(FAKE_SERVER_PING_METHOD_NAME, actual_method2_name) == 0);
|
||||||
|
else
|
||||||
|
ck_assert(strcmp(FAKE_SERVER_SUM_METHOD_NAME, actual_method2_name) == 0);
|
||||||
|
|
||||||
|
ck_assert(strcmp(FAKE_SERVER_PONG_SIGNAL_NAME, actual_signal1_name) == 0);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_unload(void)
|
||||||
|
{
|
||||||
|
check_efl_model_load_status_get(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
eo_do(fake_server_proxy, efl_model_unload());
|
||||||
|
check_efl_model_load_status_get(fake_server_proxy, EFL_MODEL_LOAD_STATUS_UNLOADED);
|
||||||
|
|
||||||
|
check_efl_model_children_count_eq(fake_server_proxy, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(unload)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(properties_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(fake_server_proxy, efl_model_properties_load());
|
||||||
|
efl_model_wait_for_load_status(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(children_load)
|
||||||
|
{
|
||||||
|
_check_unload();
|
||||||
|
|
||||||
|
eo_do(fake_server_proxy, efl_model_children_load());
|
||||||
|
efl_model_wait_for_load_status(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
check_efl_model_load_status_get(fake_server_proxy, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_test_fake_server_proxy_children_count(fake_server_proxy);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_add)
|
||||||
|
{
|
||||||
|
Eo *child = eo_do_ret(fake_server_proxy, child, efl_model_child_add());
|
||||||
|
ck_assert_ptr_eq(NULL, child);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(child_del)
|
||||||
|
{
|
||||||
|
// Tests that it is not possible to delete children
|
||||||
|
unsigned int expected_children_count = 0;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_children_count_get(&expected_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
// efl_model_child_del always returns ERROR
|
||||||
|
Eo *child = efl_model_first_child_get(fake_server_proxy);
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_child_del(child));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||||
|
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(fake_server_proxy, status = efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
|
||||||
|
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||||
|
|
||||||
|
_teardown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eldbus_test_fake_server_eldbus_model_proxy(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, NULL);
|
||||||
|
tcase_add_test(tc, load_status_get);
|
||||||
|
tcase_add_test(tc, properties_get);
|
||||||
|
tcase_add_test(tc, property_get);
|
||||||
|
tcase_add_test(tc, property_set);
|
||||||
|
tcase_add_test(tc, children_count);
|
||||||
|
tcase_add_test(tc, children_slice_get);
|
||||||
|
tcase_add_test(tc, unload);
|
||||||
|
tcase_add_test(tc, properties_load);
|
||||||
|
tcase_add_test(tc, children_load);
|
||||||
|
tcase_add_test(tc, child_add);
|
||||||
|
tcase_add_test(tc, child_del);
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "esoap_model_suite.h"
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int _test_esoap_model_log_dom = -1;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
} Esoap_Model_Test_Case;
|
||||||
|
|
||||||
|
static const Esoap_Model_Test_Case etc[] = {
|
||||||
|
{ "Esoap_Model", esoap_model_test_esoap_model },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Esoap_Model_Test_Case *it = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; it->test_case; it++)
|
||||||
|
fprintf(stderr, "\t%s\n", it->test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
_esoap_suite_build(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create("Esoap");
|
||||||
|
|
||||||
|
for (int i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||||
|
TCase *tc = tcase_create(etc[i].test_case);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
//tcase_set_timeout(tc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_init_logging(void)
|
||||||
|
{
|
||||||
|
_test_esoap_model_log_dom = eina_log_domain_register("test_esoap_model", EINA_COLOR_LIGHTBLUE);
|
||||||
|
if (_test_esoap_model_log_dom < 0)
|
||||||
|
ck_abort_msg("Could not register log domain: test_esoap_model");
|
||||||
|
|
||||||
|
//eina_log_domain_level_set("esskyuehl", EINA_LOG_LEVEL_DBG);
|
||||||
|
//eina_log_domain_level_set("esoap_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
eina_log_domain_level_set("test_esoap_model", EINA_LOG_LEVEL_DBG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_shutdown_logging(void)
|
||||||
|
{
|
||||||
|
eina_log_domain_unregister(_test_esoap_model_log_dom);
|
||||||
|
_test_esoap_model_log_dom = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_init_logging();
|
||||||
|
|
||||||
|
Suite *s = _esoap_suite_build(argc - 1, (const char **)argv + 1);
|
||||||
|
SRunner *sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
int failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
_shutdown_logging();
|
||||||
|
|
||||||
|
return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _ESOAP_MODEL_SUITE_H
|
||||||
|
#define _ESOAP_MODEL_SUITE_H
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
extern int _test_esoap_model_log_dom;
|
||||||
|
|
||||||
|
#define CRI(...) EINA_LOG_DOM_CRIT(_test_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define ERR(...) EINA_LOG_DOM_ERR(_test_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define WRN(...) EINA_LOG_DOM_WARN(_test_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define INF(...) EINA_LOG_DOM_INFO(_test_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
#define DBG(...) EINA_LOG_DOM_DBG(_test_esoap_model_log_dom, __VA_ARGS__)
|
||||||
|
|
||||||
|
void esoap_model_test_esoap_model(TCase *tc);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,270 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "esoap_model_test_esoap_model.h"
|
||||||
|
#include "esoap_model_suite.h"
|
||||||
|
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Ecore_Con.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Esoap_Model.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
server_data_callback(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
||||||
|
{
|
||||||
|
Ecore_Con_Event_Client_Data* client_event = event;
|
||||||
|
|
||||||
|
const char check_data[] =
|
||||||
|
"POST /axis2/services/echo HTTP/1.1\r\n"
|
||||||
|
"Host: 127.0.0.1:9090\r\n"
|
||||||
|
"Accept: */*\r\n"
|
||||||
|
"Content-Type:application/soap+xml\r\n"
|
||||||
|
"SOAPAction:http://ws.apache.org/axis2/c/samples/echoString\r\n"
|
||||||
|
"Transfer-Encoding: chunked\r\n"
|
||||||
|
"\r\n"
|
||||||
|
"150\r\n"
|
||||||
|
"<esoap:Envelope xmlns:esoap=\"http://www.w3.org/2003/05/esoap-envelope\" esoap:encodingStyle=\"http://www.w3.org/2001/12/esoap-encoding\">\n"
|
||||||
|
" <esoap:Body>\n"
|
||||||
|
" <ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/services/echo\">\n"
|
||||||
|
" <ns1:text>\n"
|
||||||
|
" Hello World!\n"
|
||||||
|
" </ns1:text>\n"
|
||||||
|
" </ns1:echoString>\n"
|
||||||
|
" </esoap:Body>\n"
|
||||||
|
"</esoap:Envelope>\n"
|
||||||
|
"\r\n"
|
||||||
|
"0\r\n"
|
||||||
|
"\r\n";
|
||||||
|
|
||||||
|
// static check that check_data is at least 545 bytes
|
||||||
|
char a[545-sizeof(check_data)]; (void)a;
|
||||||
|
// static check that check_data is at most 545 bytes
|
||||||
|
char b[sizeof(check_data) - 545]; (void)b;
|
||||||
|
|
||||||
|
ck_assert(client_event->size == 544);
|
||||||
|
ck_assert(!memcmp(check_data, client_event->data, sizeof(check_data)-1));
|
||||||
|
|
||||||
|
const char data_to_send[] =
|
||||||
|
"HTTP/1.1 200\r\n"
|
||||||
|
"Host: 127.0.0.1:9090\r\n"
|
||||||
|
"Content-Type:application/soap+xml\r\n"
|
||||||
|
"Content-Length: 276\r\n"
|
||||||
|
"\r\n"
|
||||||
|
"<esoapenv:Envelope xmlns:esoapenv=\"http://www.w3.org/2003/05/esoap-envelope\">\n"
|
||||||
|
" <esoapenv:Body>\n"
|
||||||
|
" <ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/c/samples\">\n"
|
||||||
|
" <text>\n"
|
||||||
|
" Hello World!\n"
|
||||||
|
" </text>\n"
|
||||||
|
" </ns1:echoString>\n"
|
||||||
|
" </esoapenv:Body>\n"
|
||||||
|
"</esoapenv:Envelope>\n";
|
||||||
|
|
||||||
|
ecore_con_client_send(client_event->client, data_to_send, sizeof(data_to_send)-1);
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ecore_Con_Server* server;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_setup(void)
|
||||||
|
{
|
||||||
|
int ret = esoap_model_init();
|
||||||
|
ck_assert_int_ge(ret, 1);
|
||||||
|
ecore_con_init();
|
||||||
|
|
||||||
|
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
|
||||||
|
server_data_callback,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
server = ecore_con_server_add
|
||||||
|
(ECORE_CON_REMOTE_TCP, "0.0.0.0", 9090, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_teardown(void)
|
||||||
|
{
|
||||||
|
int ret = esoap_model_shutdown();
|
||||||
|
ck_assert_int_eq(ret, 0);
|
||||||
|
|
||||||
|
ecore_con_server_del(server);
|
||||||
|
|
||||||
|
ecore_con_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eo_event_load_status_cb(void *data,
|
||||||
|
Eo *obj EINA_UNUSED,
|
||||||
|
const Eo_Event_Description *desc EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status expected_status = *((Efl_Model_Load_Status*)data);
|
||||||
|
Efl_Model_Load load = *((Efl_Model_Load*)event_info);
|
||||||
|
if ((load.status & expected_status) != expected_status)
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_wait_until_load_status(Efl_Model_Base *model, Efl_Model_Load_Status expected_status)
|
||||||
|
{
|
||||||
|
Efl_Model_Load_Status actual_status;
|
||||||
|
eo_do(model, actual_status = efl_model_load_status_get());
|
||||||
|
if ((expected_status & actual_status) == expected_status) return;
|
||||||
|
|
||||||
|
eo_do(model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
eo_do(model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _eo_event_load_status_cb, &expected_status));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_model_children_count_eq(Efl_Model_Base *model, unsigned int expected_children_count)
|
||||||
|
{
|
||||||
|
unsigned int actual_children_count = 0;
|
||||||
|
eo_do(model, efl_model_children_count_get(&actual_children_count));
|
||||||
|
ck_assert_int_eq(expected_children_count, actual_children_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_model_property_str_eq(Efl_Model_Base *model, const char *property, const char *expected_value)
|
||||||
|
{
|
||||||
|
const Eina_Value *value;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_get(property, &value));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, value);
|
||||||
|
|
||||||
|
const Eina_Value_Type *property_type = eina_value_type_get(value);
|
||||||
|
fail_if(EINA_VALUE_TYPE_STRING != property_type && EINA_VALUE_TYPE_STRINGSHARE != property_type);
|
||||||
|
|
||||||
|
const char *actual_value = NULL;
|
||||||
|
eina_value_get(value, &actual_value);
|
||||||
|
ck_assert_str_eq(expected_value, actual_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Efl_Model_Base *
|
||||||
|
_efl_model_nth_child_get(Efl_Model_Base *model, unsigned int n)
|
||||||
|
{
|
||||||
|
Eina_Accessor *accessor;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_children_slice_get(n, 1, &accessor));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, accessor);
|
||||||
|
Efl_Model_Base *child = NULL;
|
||||||
|
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||||
|
eina_accessor_free(accessor);
|
||||||
|
ck_assert(ret);
|
||||||
|
ck_assert_ptr_ne(NULL, child);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_model_load(Efl_Model_Base *model)
|
||||||
|
{
|
||||||
|
eo_do(model, efl_model_load());
|
||||||
|
_wait_until_load_status(model, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_model_properties(Efl_Model_Base *model, const char *expected_properties[])
|
||||||
|
{
|
||||||
|
Eina_Array *properties = NULL;
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_properties_get(&properties));
|
||||||
|
ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
|
||||||
|
ck_assert_ptr_ne(NULL, properties);
|
||||||
|
|
||||||
|
unsigned int actual_properties_count = eina_array_count(properties);
|
||||||
|
|
||||||
|
unsigned int expected_properties_count = 0;
|
||||||
|
const char *expected_property = NULL;
|
||||||
|
while ((expected_property = *expected_properties++))
|
||||||
|
{
|
||||||
|
const char *actual_property = eina_array_data_get(properties,
|
||||||
|
expected_properties_count);
|
||||||
|
ck_assert_str_eq(expected_property, actual_property);
|
||||||
|
++expected_properties_count;
|
||||||
|
ck_assert_int_le(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Esoap_Model *
|
||||||
|
_create_esoap_model()
|
||||||
|
{
|
||||||
|
Efl_Model_Base *esoap = eo_add(ESOAP_MODEL_CLASS, NULL,
|
||||||
|
esoap_model_url_set("http://127.0.0.1:9090/axis2/services/echo"),
|
||||||
|
esoap_model_action_set("http://ws.apache.org/axis2/c/samples/echoString"));
|
||||||
|
ck_assert_ptr_ne(NULL, esoap);
|
||||||
|
return esoap;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(smoke)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *esoap = _create_esoap_model();
|
||||||
|
eo_unref(esoap);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_string_property_set(Efl_Model_Base *model, const char *property, const char *v)
|
||||||
|
{
|
||||||
|
Eina_Value value;
|
||||||
|
eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
|
||||||
|
eina_value_set(&value, v);
|
||||||
|
Efl_Model_Load_Status status;
|
||||||
|
eo_do(model, status = efl_model_property_set(property, &value));
|
||||||
|
eina_value_flush(&value);
|
||||||
|
ck_assert(EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES & status);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(load_children)
|
||||||
|
{
|
||||||
|
Efl_Model_Base *esoap = _create_esoap_model();
|
||||||
|
|
||||||
|
eo_do(esoap, efl_model_properties_load());
|
||||||
|
_wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES);
|
||||||
|
|
||||||
|
_check_string_property_set(esoap, "esoap:Envelope@xmlns:esoap", "http://www.w3.org/2003/05/esoap-envelope");
|
||||||
|
_check_string_property_set(esoap, "esoap:Envelope@esoap:encodingStyle", "http://www.w3.org/2001/12/esoap-encoding");
|
||||||
|
_check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/services/echo");
|
||||||
|
_check_string_property_set(esoap, "esoap:Envelope/esoap:Body/ns1:echoString/ns1:text", "Hello World!");
|
||||||
|
|
||||||
|
// make the call loading the children
|
||||||
|
eo_do(esoap, efl_model_children_load());
|
||||||
|
_wait_until_load_status(esoap, EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
|
||||||
|
|
||||||
|
_check_model_children_count_eq(esoap, 1);
|
||||||
|
|
||||||
|
Efl_Model_Base *child = _efl_model_nth_child_get(esoap, 1);
|
||||||
|
_check_model_load(child);
|
||||||
|
|
||||||
|
_check_model_properties(child, (const char*[]){
|
||||||
|
"esoapenv:Envelope@xmlns:esoapenv",
|
||||||
|
"esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1",
|
||||||
|
"esoapenv:Envelope/esoapenv:Body/ns1:echoString/text",
|
||||||
|
NULL});
|
||||||
|
|
||||||
|
_check_model_property_str_eq(child, "esoapenv:Envelope@xmlns:esoapenv", "http://www.w3.org/2003/05/esoap-envelope");
|
||||||
|
_check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString@xmlns:ns1", "http://ws.apache.org/axis2/c/samples");
|
||||||
|
_check_model_property_str_eq(child, "esoapenv:Envelope/esoapenv:Body/ns1:echoString/text", "Hello World!");
|
||||||
|
|
||||||
|
eo_unref(esoap);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
esoap_model_test_esoap_model(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_checked_fixture(tc, _setup, _teardown);
|
||||||
|
tcase_add_test(tc, smoke);
|
||||||
|
tcase_add_test(tc, load_children);
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef _ESOAP_MODEL_TEST_ESOAP_MODEL_H
|
||||||
|
#define _ESOAP_MODEL_TEST_ESOAP_MODEL_H
|
||||||
|
|
||||||
|
#include <Esoap_Model.h>
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue