summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-07-02 16:50:57 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-10-22 16:23:59 -0200
commitb030e01b2f03b5ef3218dcbf9ecea3d958ac56ea (patch)
tree5d83c37df5b2618bb1ca479655549886cacf7d01
parentb1600b2daa0d5de62b5f738d7845fd512aa6bfba (diff)
Ecordova eolification and tizen implementation
-rw-r--r--cmakeconfig/EcordovaConfig.cmake.in32
-rw-r--r--cmakeconfig/EcordovaCxxConfig.cmake.in30
-rw-r--r--configure.ac96
-rw-r--r--pc/ecordova-cxx.pc.in12
-rw-r--r--pc/ecordova.pc.in12
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile_Ecordova.am189
-rw-r--r--src/Makefile_Ecordova_Cxx.am22
-rw-r--r--src/lib/ecordova/Ecordova.h50
-rw-r--r--src/lib/ecordova/Ecordova_Common.h13
-rw-r--r--src/lib/ecordova/Ecordova_Eo.h34
-rw-r--r--src/lib/ecordova/ecordova_batterystatus.c196
-rw-r--r--src/lib/ecordova/ecordova_batterystatus.eo51
-rw-r--r--src/lib/ecordova/ecordova_batterystatus_private.h19
-rw-r--r--src/lib/ecordova/ecordova_capture.c60
-rw-r--r--src/lib/ecordova/ecordova_capture.eo178
-rw-r--r--src/lib/ecordova/ecordova_capture_private.h16
-rw-r--r--src/lib/ecordova/ecordova_console.c175
-rw-r--r--src/lib/ecordova/ecordova_console.eo106
-rw-r--r--src/lib/ecordova/ecordova_console_private.h20
-rw-r--r--src/lib/ecordova/ecordova_contact.c1117
-rw-r--r--src/lib/ecordova/ecordova_contact.eo98
-rw-r--r--src/lib/ecordova/ecordova_contact_private.h38
-rw-r--r--src/lib/ecordova/ecordova_contactaddress.c312
-rw-r--r--src/lib/ecordova/ecordova_contactaddress.eo93
-rw-r--r--src/lib/ecordova/ecordova_contactaddress_private.h25
-rw-r--r--src/lib/ecordova/ecordova_contactfield.c415
-rw-r--r--src/lib/ecordova/ecordova_contactfield.eo57
-rw-r--r--src/lib/ecordova/ecordova_contactfield_private.h58
-rw-r--r--src/lib/ecordova/ecordova_contactname.c257
-rw-r--r--src/lib/ecordova/ecordova_contactname.eo58
-rw-r--r--src/lib/ecordova/ecordova_contactname_private.h25
-rw-r--r--src/lib/ecordova/ecordova_contactorganization.c232
-rw-r--r--src/lib/ecordova/ecordova_contactorganization.eo72
-rw-r--r--src/lib/ecordova/ecordova_contactorganization_private.h25
-rw-r--r--src/lib/ecordova/ecordova_contacts.c519
-rw-r--r--src/lib/ecordova/ecordova_contacts.eo76
-rw-r--r--src/lib/ecordova/ecordova_contacts_private.h16
-rw-r--r--src/lib/ecordova/ecordova_contacts_record_utils.c121
-rw-r--r--src/lib/ecordova/ecordova_contacts_record_utils.h20
-rw-r--r--src/lib/ecordova/ecordova_device.c107
-rw-r--r--src/lib/ecordova/ecordova_device.eo60
-rw-r--r--src/lib/ecordova/ecordova_device_private.h20
-rw-r--r--src/lib/ecordova/ecordova_devicemotion.c176
-rw-r--r--src/lib/ecordova/ecordova_devicemotion.eo70
-rw-r--r--src/lib/ecordova/ecordova_devicemotion_private.h20
-rw-r--r--src/lib/ecordova/ecordova_deviceorientation.c180
-rw-r--r--src/lib/ecordova/ecordova_deviceorientation.eo87
-rw-r--r--src/lib/ecordova/ecordova_deviceorientation_private.h20
-rw-r--r--src/lib/ecordova/ecordova_dialogs.c75
-rw-r--r--src/lib/ecordova/ecordova_dialogs.eo87
-rw-r--r--src/lib/ecordova/ecordova_dialogs_private.h16
-rw-r--r--src/lib/ecordova/ecordova_directoryentry.c324
-rw-r--r--src/lib/ecordova/ecordova_directoryentry.eo75
-rw-r--r--src/lib/ecordova/ecordova_directoryentry_private.h18
-rw-r--r--src/lib/ecordova/ecordova_directoryreader.c161
-rw-r--r--src/lib/ecordova/ecordova_directoryreader.eo32
-rw-r--r--src/lib/ecordova/ecordova_directoryreader_private.h18
-rw-r--r--src/lib/ecordova/ecordova_entry.c506
-rw-r--r--src/lib/ecordova/ecordova_entry.eo114
-rw-r--r--src/lib/ecordova/ecordova_entry_private.h53
-rw-r--r--src/lib/ecordova/ecordova_file.c128
-rw-r--r--src/lib/ecordova/ecordova_file.eo61
-rw-r--r--src/lib/ecordova/ecordova_file_private.h23
-rw-r--r--src/lib/ecordova/ecordova_fileentry.c109
-rw-r--r--src/lib/ecordova/ecordova_fileentry.eo48
-rw-r--r--src/lib/ecordova/ecordova_fileentry_private.h16
-rw-r--r--src/lib/ecordova/ecordova_filereader.c272
-rw-r--r--src/lib/ecordova/ecordova_filereader.eo92
-rw-r--r--src/lib/ecordova/ecordova_filereader_private.h26
-rw-r--r--src/lib/ecordova/ecordova_filesystem.c38
-rw-r--r--src/lib/ecordova/ecordova_filesystem.eo25
-rw-r--r--src/lib/ecordova/ecordova_filesystem_private.h16
-rw-r--r--src/lib/ecordova/ecordova_filetransfer.c613
-rw-r--r--src/lib/ecordova/ecordova_filetransfer.eo155
-rw-r--r--src/lib/ecordova/ecordova_filetransfer_private.h21
-rw-r--r--src/lib/ecordova/ecordova_filewriter.c357
-rw-r--r--src/lib/ecordova/ecordova_filewriter.eo112
-rw-r--r--src/lib/ecordova/ecordova_filewriter_private.h26
-rw-r--r--src/lib/ecordova/ecordova_geolocation.c282
-rw-r--r--src/lib/ecordova/ecordova_geolocation.eo152
-rw-r--r--src/lib/ecordova/ecordova_geolocation_private.h19
-rw-r--r--src/lib/ecordova/ecordova_globalization.c1122
-rw-r--r--src/lib/ecordova/ecordova_globalization.eo390
-rw-r--r--src/lib/ecordova/ecordova_globalization_private.h16
-rw-r--r--src/lib/ecordova/ecordova_inappbrowser.c78
-rw-r--r--src/lib/ecordova/ecordova_inappbrowser.eo89
-rw-r--r--src/lib/ecordova/ecordova_inappbrowser_private.h16
-rw-r--r--src/lib/ecordova/ecordova_main.c98
-rw-r--r--src/lib/ecordova/ecordova_media.c531
-rw-r--r--src/lib/ecordova/ecordova_media.eo108
-rw-r--r--src/lib/ecordova/ecordova_media_private.h26
-rw-r--r--src/lib/ecordova/ecordova_mediafile.c187
-rw-r--r--src/lib/ecordova/ecordova_mediafile.eo62
-rw-r--r--src/lib/ecordova/ecordova_mediafile_private.h21
-rw-r--r--src/lib/ecordova/ecordova_networkinformation.c98
-rw-r--r--src/lib/ecordova/ecordova_networkinformation.eo61
-rw-r--r--src/lib/ecordova/ecordova_networkinformation_private.h19
-rw-r--r--src/lib/ecordova/ecordova_private.h54
-rw-r--r--src/lib/ecordova/ecordova_splashscreen.c51
-rw-r--r--src/lib/ecordova/ecordova_splashscreen.eo29
-rw-r--r--src/lib/ecordova/ecordova_splashscreen_private.h16
-rw-r--r--src/lib/ecordova/ecordova_systeminfo.c139
-rw-r--r--src/lib/ecordova/ecordova_systeminfo.eo27
-rw-r--r--src/lib/ecordova/ecordova_systeminfo_private.h19
-rw-r--r--src/lib/ecordova/ecordova_vibration.c66
-rw-r--r--src/lib/ecordova/ecordova_vibration.eo30
-rw-r--r--src/lib/ecordova/ecordova_vibration_private.h16
-rw-r--r--src/tests/ecordova/44khz32kbps.mp3bin0 -> 220891 bytes
-rw-r--r--src/tests/ecordova/ecordova_batterystatus_test.c44
-rw-r--r--src/tests/ecordova/ecordova_batterystatus_test.h9
-rw-r--r--src/tests/ecordova/ecordova_console_test.c140
-rw-r--r--src/tests/ecordova/ecordova_console_test.h9
-rw-r--r--src/tests/ecordova/ecordova_contacts_test.c255
-rw-r--r--src/tests/ecordova/ecordova_contacts_test.h9
-rw-r--r--src/tests/ecordova/ecordova_device_test.c100
-rw-r--r--src/tests/ecordova/ecordova_device_test.h9
-rw-r--r--src/tests/ecordova/ecordova_devicemotion_test.c89
-rw-r--r--src/tests/ecordova/ecordova_devicemotion_test.h9
-rw-r--r--src/tests/ecordova/ecordova_deviceorientation_test.c89
-rw-r--r--src/tests/ecordova/ecordova_deviceorientation_test.h9
-rw-r--r--src/tests/ecordova/ecordova_directoryentry_test.c434
-rw-r--r--src/tests/ecordova/ecordova_directoryentry_test.h24
-rw-r--r--src/tests/ecordova/ecordova_directoryreader_test.c132
-rw-r--r--src/tests/ecordova/ecordova_directoryreader_test.h9
-rw-r--r--src/tests/ecordova/ecordova_entry_test.c748
-rw-r--r--src/tests/ecordova/ecordova_entry_test.h14
-rw-r--r--src/tests/ecordova/ecordova_file_test.c140
-rw-r--r--src/tests/ecordova/ecordova_file_test.h9
-rw-r--r--src/tests/ecordova/ecordova_fileentry_test.c211
-rw-r--r--src/tests/ecordova/ecordova_fileentry_test.h17
-rw-r--r--src/tests/ecordova/ecordova_filereader_test.c294
-rw-r--r--src/tests/ecordova/ecordova_filereader_test.h13
-rw-r--r--src/tests/ecordova/ecordova_filetransfer_test.c227
-rw-r--r--src/tests/ecordova/ecordova_filetransfer_test.h9
-rw-r--r--src/tests/ecordova/ecordova_filewriter_test.c218
-rw-r--r--src/tests/ecordova/ecordova_filewriter_test.h9
-rw-r--r--src/tests/ecordova/ecordova_geolocation_test.c93
-rw-r--r--src/tests/ecordova/ecordova_geolocation_test.h9
-rw-r--r--src/tests/ecordova/ecordova_globalization_test.c594
-rw-r--r--src/tests/ecordova/ecordova_globalization_test.h9
-rw-r--r--src/tests/ecordova/ecordova_media_test.c44
-rw-r--r--src/tests/ecordova/ecordova_media_test.h9
-rw-r--r--src/tests/ecordova/ecordova_mediafile_test.c142
-rw-r--r--src/tests/ecordova/ecordova_mediafile_test.h12
-rw-r--r--src/tests/ecordova/ecordova_networkinformation_test.c44
-rw-r--r--src/tests/ecordova/ecordova_networkinformation_test.h9
-rw-r--r--src/tests/ecordova/ecordova_suite.c163
-rw-r--r--src/tests/ecordova/ecordova_suite.h14
-rw-r--r--src/tests/ecordova/ecordova_vibration_test.c44
-rw-r--r--src/tests/ecordova/ecordova_vibration_test.h9
-rw-r--r--src/tests/evas/evas_test_textblock.c8
152 files changed, 17607 insertions, 1 deletions
diff --git a/cmakeconfig/EcordovaConfig.cmake.in b/cmakeconfig/EcordovaConfig.cmake.in
new file mode 100644
index 0000000000..9ca947c004
--- /dev/null
+++ b/cmakeconfig/EcordovaConfig.cmake.in
@@ -0,0 +1,32 @@
1# - Try to find ecordova
2# Once done this will define
3# ECORDOVA_FOUND - System has ecordova
4# ECORDOVA_INCLUDE_DIRS - The ecordova include directories
5# ECORDOVA_LIBRARIES - The libraries needed to use ecordova
6# ECORDOVA_DEFINITIONS - Compiler switches required for using ecordova
7
8set(MY_PKG ecordova)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBECORDOVA ${_QUIET} ${MY_PKG})
16
17find_library(ECORDOVA_LIBRARY
18 NAMES ${PC_LIBECORDOVA_LIBRARIES}
19 HINTS ${PC_LIBECORDOVA_LIBDIR} ${PC_LIBECORDOVA_LIBRARY_DIRS} )
20
21set(ECORDOVA_DEFINITIONS ${PC_LIBECORDOVA_CFLAGS_OTHER})
22set(ECORDOVA_LIBRARIES ${ECORDOVA_LIBRARY})
23set(ECORDOVA_INCLUDE_DIRS ${PC_LIBECORDOVA_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set ECORDOVA_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 ECORDOVA_LIBRARIES ECORDOVA_INCLUDE_DIRS)
30
31mark_as_advanced(ECORDOVA_INCLUDE_DIRS ECORDOVA_LIBRARY ECORDOVA_LIBRARIES ECORDOVA_DEFINITIONS)
32
diff --git a/cmakeconfig/EcordovaCxxConfig.cmake.in b/cmakeconfig/EcordovaCxxConfig.cmake.in
new file mode 100644
index 0000000000..ebd8414fb4
--- /dev/null
+++ b/cmakeconfig/EcordovaCxxConfig.cmake.in
@@ -0,0 +1,30 @@
1# - Try to find ecordova
2# Once done this will define
3# ECORDOVA_CXX_FOUND - System has ecordova
4# ECORDOVA_CXX_INCLUDE_DIRS - The ecordova include directories
5# ECORDOVA_CXX_LIBRARIES - The libraries needed to use ecordova
6# ECORDOVA_CXX_DEFINITIONS - Compiler switches required for using ecordova
7
8set(MY_PKG ecordova_cxx)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_ECORDOVA_CXX ${_QUIET} ${MY_PKG})
16find_library(ECORDOVA_CXX_LIBRARY
17 NAMES ${PC_ECORDOVA_CXX_LIBRARIES}
18 HINTS ${PC_ECORDOVA_CXX_LIBDIR} ${PC_ECORDOVA_CXX_LIBRARY_DIRS} )
19
20set(ECORDOVA_CXX_DEFINITIONS ${PC_ECORDOVA_CXX_CFLAGS_OTHER})
21set(ECORDOVA_CXX_LIBRARIES ${ECORDOVA_CXX_LIBRARY})
22set(ECORDOVA_CXX_INCLUDE_DIRS ${PC_ECORDOVA_CXX_INCLUDE_DIRS})
23
24include(FindPackageHandleStandardArgs)
25# handle the QUIETLY and REQUIRED arguments and set ECORDOVA_CXX_FOUND to TRUE
26# if all listed variables are TRUE
27find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
28 ECORDOVA_CXX_LIBRARIES ECORDOVA_CXX_INCLUDE_DIRS)
29
30mark_as_advanced(ECORDOVA_CXX_INCLUDE_DIRS ECORDOVA_CXX_LIBRARY ECORDOVA_CXX_LIBRARIES ECORDOVA_CXX_DEFINITIONS)
diff --git a/configure.ac b/configure.ac
index 929a088783..c6f0fbaabd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3911,7 +3911,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [emile])
3911ECORE_EVAS_MODULE([extn], [${want_ecore_evas_extn}]) 3911ECORE_EVAS_MODULE([extn], [${want_ecore_evas_extn}])
3912ECORE_EVAS_MODULE([ews], [yes]) 3912ECORE_EVAS_MODULE([ews], [yes])
3913ECORE_EVAS_MODULE([fb], [${want_fb}]) 3913ECORE_EVAS_MODULE([fb], [${want_fb}])
3914ECORE_EVAS_MODULE([drm], [${want_drm}], 3914ECORE_EVAS_MODULE([drm], [${want_drm}],
3915 [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_drm}], [ecore-drm])]) 3915 [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_drm}], [ecore-drm])])
3916ECORE_EVAS_MODULE([gl-drm], [${want_gl_drm}], 3916ECORE_EVAS_MODULE([gl-drm], [${want_gl_drm}],
3917 [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_gl_drm}], [ecore-drm])]) 3917 [EFL_OPTIONAL_INTERNAL_DEPEND_PKG([ECORE_EVAS], [${want_gl_drm}], [ecore-drm])])
@@ -4581,6 +4581,93 @@ EFL_ADD_LIBS([ELOCATION], [-lm])
4581EFL_LIB_END([Elocation]) 4581EFL_LIB_END([Elocation])
4582#### End of Elocation 4582#### End of Elocation
4583 4583
4584
4585
4586#### Ecordova
4587AC_ARG_WITH([ecordova],
4588 [AS_HELP_STRING([--with-ecordova=tizen|none],[ecordova implementation: tizen or none. @<:@default=none@:>@])],
4589 [build_ecordova=${withval}],
4590 [build_ecordova="none"])
4591
4592want_ecordova_tizen="no"
4593want_ecordova_none="no"
4594want_ecordova="no"
4595case "${build_ecordova}" in
4596 tizen)
4597 want_ecordova_tizen="yes"
4598 want_ecordova="yes"
4599 ;;
4600 none)
4601 want_ecordova_none="yes"
4602 ;;
4603 *)
4604 AC_MSG_ERROR([Unknown build ecordova --with-ecordova=${build_ecordova}])
4605 ;;
4606esac
4607
4608AM_CONDITIONAL([HAVE_ECORDOVA], [test "x${want_ecordova}" = "xyes"])
4609
4610EFL_LIB_START_OPTIONAL([Ecordova], [test "x${want_ecordova}" = "xyes"])
4611
4612### Additional options to configure
4613
4614### Default values
4615
4616### Checks for programs
4617
4618### Checks for libraries
4619
4620EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [eina])
4621EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [eo])
4622EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [efl])
4623EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [ecore])
4624EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [ecore-evas])
4625EFL_INTERNAL_DEPEND_PKG([ECORDOVA], [ecore-file])
4626
4627EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_VCONF], [vconf])
4628EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_CONTACTS_SERVICE], [contacts-service2])
4629EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_INFO], [capi-system-info])
4630EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_SENSOR], [capi-system-sensor])
4631EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_LOCATION_MANAGER], [capi-location-manager])
4632EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_HAPTIC], [capi-system-haptic])
4633EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_NETWORK_CONNECTION], [capi-network-connection])
4634EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_MEDIA_METADATA_EXTRACTOR], [capi-media-metadata-extractor])
4635EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_MEDIA_PLAYER], [capi-media-player])
4636EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_MEDIA_RECORDER], [capi-media-recorder])
4637EFL_OPTIONAL_DEPEND_PKG([ECORDOVA], [${want_ecordova_tizen}], [TIZEN_BASE_UTILS_I18N], [capi-base-utils-i18n])
4638
4639EFL_ADD_LIBS([ECORDOVA], [-lm])
4640
4641EFL_EVAL_PKGS([ECORDOVA])
4642
4643### Checks for header files
4644
4645### Checks for types
4646
4647### Checks for structures
4648
4649### Checks for compiler characteristics
4650
4651### Checks for linker characteristics
4652
4653### Checks for library functions
4654
4655EFL_LIB_END_OPTIONAL([Ecordova])
4656
4657#### End of Ecordova
4658
4659
4660#### Ecordova CXX
4661EFL_LIB_START_OPTIONAL([Ecordova_Cxx], [test "x${want_ecordova}" = "xyes"])
4662
4663EFL_EVAL_PKGS([ECORDOVA_CXX])
4664
4665EFL_LIB_END_OPTIONAL([Ecordova_Cxx])
4666#### End of Ecordova CXX
4667
4668
4669
4670
4584### Add Wayland server library if test is enabled 4671### Add Wayland server library if test is enabled
4585if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then 4672if test "x${want_tests}" = "xyes" -a "x${want_wayland}" = "xyes"; then
4586 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0]) 4673 EFL_DEPEND_PKG([ECORE_WAYLAND_SRV], [WAYLAND], [wayland-server >= 1.8.0])
@@ -4769,6 +4856,8 @@ pc/ethumb.pc
4769pc/ethumb_client.pc 4856pc/ethumb_client.pc
4770pc/elocation.pc 4857pc/elocation.pc
4771pc/elua.pc 4858pc/elua.pc
4859pc/ecordova.pc
4860pc/ecordova-cxx.pc
4772dbus-services/org.enlightenment.Ethumb.service 4861dbus-services/org.enlightenment.Ethumb.service
4773systemd-services/ethumb.service 4862systemd-services/ethumb.service
4774$po_makefile_in 4863$po_makefile_in
@@ -4818,6 +4907,10 @@ cmakeconfig/EluaConfig.cmake
4818cmakeconfig/EluaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4907cmakeconfig/EluaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4819cmakeconfig/EmileConfig.cmake 4908cmakeconfig/EmileConfig.cmake
4820cmakeconfig/EmileConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in 4909cmakeconfig/EmileConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4910cmakeconfig/EcordovaConfig.cmake
4911cmakeconfig/EcordovaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4912cmakeconfig/EcordovaCxxConfig.cmake
4913cmakeconfig/EcordovaCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
4821]) 4914])
4822 4915
4823AC_OUTPUT 4916AC_OUTPUT
@@ -4932,6 +5025,7 @@ echo "Emotion.........: yes (${features_emotion})"
4932echo "Ethumb..........: yes" 5025echo "Ethumb..........: yes"
4933echo "Ethumb_Client...: yes" 5026echo "Ethumb_Client...: yes"
4934echo "Elua............: $have_elua" 5027echo "Elua............: $have_elua"
5028echo "Ecordova........: ${efl_lib_optional_ecordova} (${COLOR_OTHER}${build_ecordova}${COLOR_RESET})"
4935if test "${build_tests}" = "none"; then 5029if test "${build_tests}" = "none"; then
4936echo "Tests...........: no" 5030echo "Tests...........: no"
4937elif test "${build_tests}" = "auto"; then 5031elif test "${build_tests}" = "auto"; then
diff --git a/pc/ecordova-cxx.pc.in b/pc/ecordova-cxx.pc.in
new file mode 100644
index 0000000000..8cfae25b2d
--- /dev/null
+++ b/pc/ecordova-cxx.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: Ecordova C++
7Description: A C++ binding for the Ecordova library
8Requires.private: @requirements_pc_ecordova@ @requirements_pc_eo@
9Version: @VERSION@
10Libs: -L${libdir} -lecordova @requirements_public_libs_ecordova@ @requirements_public_libs_eo@
11Libs.private: @requirements_libs_ecordova@ @requirements_libs_eo@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/ecordova-@VMAJ@ -I${includedir}/ecordova-cxx-@VMAJ@
diff --git a/pc/ecordova.pc.in b/pc/ecordova.pc.in
new file mode 100644
index 0000000000..87c091c404
--- /dev/null
+++ b/pc/ecordova.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: Ecordova
7Description: Cordova API eolification
8Requires.private: @requirements_pc_ecordova@
9Version: @VERSION@
10Libs: -L${libdir} -lecordova @requirements_public_libs_ecordova@
11Libs.private: @requirements_libs_ecordova@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/ecordova-@VMAJ@
diff --git a/src/Makefile.am b/src/Makefile.am
index dccc538af2..28e8e83fbb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,6 +74,8 @@ include Makefile_Eio_Cxx.am
74 74
75include Makefile_Elua.am 75include Makefile_Elua.am
76include Makefile_Elocation.am 76include Makefile_Elocation.am
77include Makefile_Ecordova.am
78include Makefile_Ecordova_Cxx.am
77 79
78.PHONY: benchmark examples 80.PHONY: benchmark examples
79 81
diff --git a/src/Makefile_Ecordova.am b/src/Makefile_Ecordova.am
new file mode 100644
index 0000000000..1315925e53
--- /dev/null
+++ b/src/Makefile_Ecordova.am
@@ -0,0 +1,189 @@
1if HAVE_ECORDOVA
2### Library
3
4ecordova_eolian_files = \
5lib/ecordova/ecordova_systeminfo.eo \
6lib/ecordova/ecordova_batterystatus.eo \
7lib/ecordova/ecordova_console.eo \
8lib/ecordova/ecordova_contacts.eo \
9lib/ecordova/ecordova_contact.eo \
10lib/ecordova/ecordova_contactaddress.eo \
11lib/ecordova/ecordova_contactfield.eo \
12lib/ecordova/ecordova_contactname.eo \
13lib/ecordova/ecordova_contactorganization.eo \
14lib/ecordova/ecordova_device.eo \
15lib/ecordova/ecordova_devicemotion.eo \
16lib/ecordova/ecordova_deviceorientation.eo \
17lib/ecordova/ecordova_dialogs.eo \
18lib/ecordova/ecordova_geolocation.eo \
19lib/ecordova/ecordova_globalization.eo \
20lib/ecordova/ecordova_inappbrowser.eo \
21lib/ecordova/ecordova_media.eo \
22lib/ecordova/ecordova_networkinformation.eo \
23lib/ecordova/ecordova_splashscreen.eo \
24lib/ecordova/ecordova_vibration.eo \
25lib/ecordova/ecordova_file.eo \
26lib/ecordova/ecordova_filewriter.eo \
27lib/ecordova/ecordova_filereader.eo \
28lib/ecordova/ecordova_filesystem.eo \
29lib/ecordova/ecordova_entry.eo \
30lib/ecordova/ecordova_directoryentry.eo \
31lib/ecordova/ecordova_directoryreader.eo \
32lib/ecordova/ecordova_fileentry.eo \
33lib/ecordova/ecordova_mediafile.eo \
34lib/ecordova/ecordova_filetransfer.eo \
35lib/ecordova/ecordova_capture.eo
36
37ecordova_eolian_c = $(ecordova_eolian_files:%.eo=%.eo.c)
38ecordova_eolian_h = $(ecordova_eolian_files:%.eo=%.eo.h)
39
40BUILT_SOURCES += \
41 $(ecordova_eolian_c) \
42 $(ecordova_eolian_h)
43
44CLEANFILES += \
45 $(ecordova_eolian_c) \
46 $(ecordova_eolian_h)
47
48ecordovaeolianfilesdir = $(datadir)/eolian/include/ecordova-@VMAJ@
49ecordovaeolianfiles_DATA = \
50 $(ecordova_eolian_files)
51
52EXTRA_DIST += \
53 ${ecordovaeolianfiles_DATA}
54
55lib_LTLIBRARIES += lib/ecordova/libecordova.la
56
57installed_ecordovamainheadersdir = $(includedir)/ecordova-@VMAJ@
58dist_installed_ecordovamainheaders_DATA = \
59lib/ecordova/Ecordova.h \
60lib/ecordova/Ecordova_Common.h \
61lib/ecordova/Ecordova_Eo.h
62
63nodist_installed_ecordovamainheaders_DATA = \
64 $(ecordova_eolian_h)
65
66lib_ecordova_libecordova_la_SOURCES = \
67lib/ecordova/ecordova_main.c \
68lib/ecordova/ecordova_private.h \
69lib/ecordova/ecordova_systeminfo.c \
70lib/ecordova/ecordova_batterystatus.c \
71lib/ecordova/ecordova_console.c \
72lib/ecordova/ecordova_contacts.c \
73lib/ecordova/ecordova_contact.c \
74lib/ecordova/ecordova_contactaddress.c \
75lib/ecordova/ecordova_contactfield.c \
76lib/ecordova/ecordova_contactname.c \
77lib/ecordova/ecordova_contactorganization.c \
78lib/ecordova/ecordova_contacts_record_utils.c \
79lib/ecordova/ecordova_device.c \
80lib/ecordova/ecordova_devicemotion.c \
81lib/ecordova/ecordova_deviceorientation.c \
82lib/ecordova/ecordova_dialogs.c \
83lib/ecordova/ecordova_geolocation.c \
84lib/ecordova/ecordova_globalization.c \
85lib/ecordova/ecordova_inappbrowser.c \
86lib/ecordova/ecordova_media.c \
87lib/ecordova/ecordova_networkinformation.c \
88lib/ecordova/ecordova_splashscreen.c \
89lib/ecordova/ecordova_vibration.c \
90lib/ecordova/ecordova_file.c \
91lib/ecordova/ecordova_filewriter.c \
92lib/ecordova/ecordova_filereader.c \
93lib/ecordova/ecordova_filesystem.c \
94lib/ecordova/ecordova_entry.c \
95lib/ecordova/ecordova_directoryentry.c \
96lib/ecordova/ecordova_directoryreader.c \
97lib/ecordova/ecordova_fileentry.c \
98lib/ecordova/ecordova_mediafile.c \
99lib/ecordova/ecordova_filetransfer.c \
100lib/ecordova/ecordova_capture.c
101
102lib_ecordova_libecordova_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORDOVA_CFLAGS@ @EFL_CFLAGS@
103lib_ecordova_libecordova_la_LIBADD = @ECORDOVA_LIBS@ @EFL_LIBS@
104lib_ecordova_libecordova_la_DEPENDENCIES = @ECORDOVA_INTERNAL_LIBS@ @EFL_INTERNAL_LIBS@
105lib_ecordova_libecordova_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
106
107### Unit tests
108
109if EFL_ENABLE_TESTS
110
111check_PROGRAMS += tests/ecordova/ecordova_suite
112TESTS += tests/ecordova/ecordova_suite
113
114tests_ecordova_ecordova_suite_SOURCES = \
115tests/ecordova/ecordova_suite.c \
116tests/ecordova/ecordova_suite.h \
117tests/ecordova/ecordova_contacts_test.c \
118tests/ecordova/ecordova_contacts_test.h \
119tests/ecordova/ecordova_device_test.c \
120tests/ecordova/ecordova_device_test.h \
121tests/ecordova/ecordova_devicemotion_test.c \
122tests/ecordova/ecordova_devicemotion_test.h \
123tests/ecordova/ecordova_deviceorientation_test.c \
124tests/ecordova/ecordova_deviceorientation_test.h \
125tests/ecordova/ecordova_geolocation_test.c \
126tests/ecordova/ecordova_geolocation_test.h \
127tests/ecordova/ecordova_batterystatus_test.c \
128tests/ecordova/ecordova_batterystatus_test.h \
129tests/ecordova/ecordova_console_test.c \
130tests/ecordova/ecordova_console_test.h \
131tests/ecordova/ecordova_filetransfer_test.c \
132tests/ecordova/ecordova_filetransfer_test.h \
133tests/ecordova/ecordova_media_test.c \
134tests/ecordova/ecordova_media_test.h \
135tests/ecordova/ecordova_networkinformation_test.c \
136tests/ecordova/ecordova_networkinformation_test.h \
137tests/ecordova/ecordova_vibration_test.c \
138tests/ecordova/ecordova_vibration_test.h \
139tests/ecordova/ecordova_directoryreader_test.c \
140tests/ecordova/ecordova_directoryreader_test.h \
141tests/ecordova/ecordova_directoryentry_test.c \
142tests/ecordova/ecordova_directoryentry_test.h \
143tests/ecordova/ecordova_entry_test.c \
144tests/ecordova/ecordova_entry_test.h \
145tests/ecordova/ecordova_file_test.c \
146tests/ecordova/ecordova_file_test.h \
147tests/ecordova/ecordova_fileentry_test.c \
148tests/ecordova/ecordova_fileentry_test.h \
149tests/ecordova/ecordova_filereader_test.c \
150tests/ecordova/ecordova_filereader_test.h \
151tests/ecordova/ecordova_filewriter_test.c \
152tests/ecordova/ecordova_filewriter_test.h \
153tests/ecordova/ecordova_mediafile_test.c \
154tests/ecordova/ecordova_mediafile_test.h \
155tests/ecordova/ecordova_globalization_test.c \
156tests/ecordova/ecordova_globalization_test.h
157
158tests_ecordova_ecordova_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
159-DTESTS_SRC_DIR=\"$(abs_top_srcdir)/src/tests/ecordova\" \
160-DTESTS_BUILD_DIR=\"$(abs_top_builddir)/src/tests/ecordova\" \
161@CHECK_CFLAGS@ \
162@ECORDOVA_CFLAGS@ @EFL_CFLAGS@
163
164tests_ecordova_ecordova_suite_LDADD = \
165@CHECK_LIBS@ \
166@USE_ECORDOVA_LIBS@ \
167@USE_EFL_LIBS@
168
169tests_ecordova_ecordova_suite_DEPENDENCIES = \
170@USE_ECORDOVA_INTERNAL_LIBS@
171
172endif
173
174EXTRA_DIST += $(ECORDOVA_DATA_FILES)
175
176if HAVE_ELUA
177
178ecordova_eolian_lua = $(ecordova_eolian_files:%.eo=%.eo.lua)
179
180generated_ecordova_lua_all = $(ecordova_eolian_lua)
181
182CLEANFILES += $(generated_ecordova_lua_all)
183
184installed_ecordovaluadir = $(datadir)/elua/modules/ecordova
185nodist_installed_ecordovalua_DATA = $(generated_ecordova_lua_all)
186
187endif
188
189endif
diff --git a/src/Makefile_Ecordova_Cxx.am b/src/Makefile_Ecordova_Cxx.am
new file mode 100644
index 0000000000..764a55f5fa
--- /dev/null
+++ b/src/Makefile_Ecordova_Cxx.am
@@ -0,0 +1,22 @@
1if HAVE_CXX11
2
3### Generated headers
4
5generated_ecordova_cxx_bindings = $(ecordova_eolian_files:%.eo=%.eo.hh)
6
7lib/ecordova/Ecordova.hh: $(generated_ecordova_cxx_bindings)
8 @echo @ECHO_E@ "#ifndef EFL_CXX_ECORDOVA_HH\n#define EFL_CXX_ECORDOVA_HH\n" > $(top_builddir)/src/lib/ecordova/Ecordova.hh
9 @echo @ECHO_E@ "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/ecordova/Ecordova.hh
10 @for i in $(generated_ecordova_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/ecordova/Ecordova.hh; done
11 @echo @ECHO_E@ "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/ecordova/Ecordova.hh
12
13generated_ecordova_cxx_all = \
14 $(generated_ecordova_cxx_bindings) \
15 lib/ecordova/Ecordova.hh
16
17CLEANFILES += $(generated_ecordova_cxx_all)
18
19installed_ecordovacxxmainheadersdir = $(includedir)/ecordova-cxx-@VMAJ@/
20nodist_installed_ecordovacxxmainheaders_DATA = $(generated_ecordova_cxx_all)
21
22endif
diff --git a/src/lib/ecordova/Ecordova.h b/src/lib/ecordova/Ecordova.h
new file mode 100644
index 0000000000..46396e02af
--- /dev/null
+++ b/src/lib/ecordova/Ecordova.h
@@ -0,0 +1,50 @@
1#ifndef _ECORDOVA_H
2#define _ECORDOVA_H
3
4#include <Ecore.h>
5#include <Efl.h>
6#include <Efl_Config.h>
7
8#ifdef EAPI
9# undef EAPI
10#endif
11
12#ifdef _WIN32
13# ifdef EFL_ECORDOVA_BUILD
14# ifdef DLL_EXPORT
15# define EAPI __declspec(dllexport)
16# else
17# define EAPI
18# endif /* ! DLL_EXPORT */
19# else
20# define EAPI __declspec(dllimport)
21# endif /* ! EFL_ECORDOVA_BUILD */
22#else
23# ifdef __GNUC__
24# if __GNUC__ >= 4
25# define EAPI __attribute__ ((visibility("default")))
26# else
27# define EAPI
28# endif
29# else
30# define EAPI
31# endif
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include "Ecordova_Common.h"
39#ifdef EFL_EO_API_SUPPORT
40#include "Ecordova_Eo.h"
41#endif
42
43#ifdef __cplusplus
44}
45#endif
46
47#undef EAPI
48#define EAPI
49
50#endif
diff --git a/src/lib/ecordova/Ecordova_Common.h b/src/lib/ecordova/Ecordova_Common.h
new file mode 100644
index 0000000000..b1e45cf1a9
--- /dev/null
+++ b/src/lib/ecordova/Ecordova_Common.h
@@ -0,0 +1,13 @@
1/**
2 * @brief Initialize ecordova.
3 *
4 * @return 1 or greater on success, 0 otherwise
5 */
6EAPI int ecordova_init(void);
7
8/**
9 * @brief Shutdown ecordova.
10 *
11 * @return 0 if ecordova shuts down, greater than 0 otherwise.
12 */
13EAPI int ecordova_shutdown(void);
diff --git a/src/lib/ecordova/Ecordova_Eo.h b/src/lib/ecordova/Ecordova_Eo.h
new file mode 100644
index 0000000000..d1da074fd3
--- /dev/null
+++ b/src/lib/ecordova/Ecordova_Eo.h
@@ -0,0 +1,34 @@
1#include <Efl.h>
2
3typedef Eo Ecordova_DirectoryReader;
4
5#include <ecordova_batterystatus.eo.h>
6#include <ecordova_console.eo.h>
7#include <ecordova_contactaddress.eo.h>
8#include <ecordova_contactfield.eo.h>
9#include <ecordova_contactname.eo.h>
10#include <ecordova_contactorganization.eo.h>
11#include <ecordova_contact.eo.h>
12#include <ecordova_contacts.eo.h>
13#include <ecordova_device.eo.h>
14#include <ecordova_devicemotion.eo.h>
15#include <ecordova_deviceorientation.eo.h>
16#include <ecordova_dialogs.eo.h>
17#include <ecordova_geolocation.eo.h>
18#include <ecordova_globalization.eo.h>
19#include <ecordova_inappbrowser.eo.h>
20#include <ecordova_media.eo.h>
21#include <ecordova_networkinformation.eo.h>
22#include <ecordova_splashscreen.eo.h>
23#include <ecordova_vibration.eo.h>
24#include <ecordova_file.eo.h>
25#include <ecordova_filewriter.eo.h>
26#include <ecordova_filereader.eo.h>
27#include <ecordova_filesystem.eo.h>
28#include <ecordova_entry.eo.h>
29#include <ecordova_directoryentry.eo.h>
30#include <ecordova_directoryreader.eo.h>
31#include <ecordova_fileentry.eo.h>
32#include <ecordova_mediafile.eo.h>
33#include <ecordova_filetransfer.eo.h>
34#include <ecordova_capture.eo.h>
diff --git a/src/lib/ecordova/ecordova_batterystatus.c b/src/lib/ecordova/ecordova_batterystatus.c
new file mode 100644
index 0000000000..a864e733df
--- /dev/null
+++ b/src/lib/ecordova/ecordova_batterystatus.c
@@ -0,0 +1,196 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_batterystatus_private.h"
6#include "ecordova_systeminfo.eo.h"
7
8#include <vconf.h>
9
10#include <stdbool.h>
11#include <stdint.h>
12#include <stdlib.h>
13
14#define MY_CLASS ECORDOVA_BATTERYSTATUS_CLASS
15#define MY_CLASS_NAME "Ecordova_BatteryStatus"
16
17#define STATUS_CRITICAL 5
18#define STATUS_LOW 20
19
20static Eina_Bool _add_cb(void *, Eo *, const Eo_Event_Description *, void *);
21static Eina_Bool _del_cb(void *, Eo *, const Eo_Event_Description *, void *);
22static void _start(Ecordova_BatteryStatus_Data *);
23static void _stop(Ecordova_BatteryStatus_Data *);
24static Eina_Bool _on_battery_changed(void *, Eo *, const Eo_Event_Description *, void *);
25static bool _fetch_level(int *);
26static bool _fetch_charging_is(Eina_Bool *);
27
28static Eo_Base *
29_ecordova_batterystatus_eo_base_constructor(Eo *obj,
30 Ecordova_BatteryStatus_Data *pd)
31{
32 DBG("(%p)", obj);
33
34 pd->obj = obj;
35
36 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
37}
38
39static void
40_ecordova_batterystatus_constructor(Eo *obj,
41 Ecordova_BatteryStatus_Data *pd)
42{
43 DBG("(%p)", obj);
44
45 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _add_cb, pd));
46 eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _del_cb, pd));
47}
48
49static void
50_ecordova_batterystatus_eo_base_destructor(Eo *obj,
51 Ecordova_BatteryStatus_Data *pd)
52{
53 DBG("(%p)", obj);
54
55 if (pd->callback_ref_count)
56 _stop(pd);
57
58 eo_do(obj, eo_event_callback_del(EO_EV_CALLBACK_ADD, _add_cb, pd));
59 eo_do(obj, eo_event_callback_del(EO_EV_CALLBACK_DEL, _del_cb, pd));
60
61 eo_do_super(obj, MY_CLASS, eo_destructor());
62}
63
64static Eina_Bool
65_add_cb(void *data,
66 Eo *obj EINA_UNUSED,
67 const Eo_Event_Description *desc,
68 void *event_info)
69{
70 Ecordova_BatteryStatus_Data *pd = (Ecordova_BatteryStatus_Data*)data;
71 const Eo_Callback_Array_Item *array = (const Eo_Callback_Array_Item*)event_info;
72
73 for (size_t i = 0; (desc = array[i].desc); ++i)
74 {
75 if (ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_STATUS == desc ||
76 ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_CRITICAL == desc ||
77 ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_LOW == desc)
78 {
79 ++pd->callback_ref_count;
80 if (1 == pd->callback_ref_count)
81 _start(pd);
82 }
83 }
84
85 return EO_CALLBACK_CONTINUE;
86}
87
88static Eina_Bool
89_del_cb(void *data,
90 Eo *obj EINA_UNUSED,
91 const Eo_Event_Description *desc,
92 void *event_info)
93{
94 Ecordova_BatteryStatus_Data *pd = (Ecordova_BatteryStatus_Data*)data;
95 const Eo_Callback_Array_Item *array = (const Eo_Callback_Array_Item*)event_info;
96
97 for (size_t i = 0; (desc = array[i].desc); ++i)
98 {
99 if (ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_STATUS == desc ||
100 ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_CRITICAL == desc ||
101 ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_LOW == desc)
102 --pd->callback_ref_count;
103 }
104
105 if (0 == pd->callback_ref_count)
106 _stop(pd);
107
108 return EO_CALLBACK_CONTINUE;
109}
110
111static void
112_start(Ecordova_BatteryStatus_Data *pd)
113{
114 eo_do(_ecordova_systeminfo,
115 eo_event_callback_add(ECORDOVA_SYSTEMINFO_EVENT_BATTERY_CHANGED,
116 _on_battery_changed,
117 pd));
118}
119
120static void
121_stop(Ecordova_BatteryStatus_Data *pd)
122{
123 free(pd->info);
124 pd->info = NULL;
125
126 eo_do(_ecordova_systeminfo,
127 eo_event_callback_del(ECORDOVA_SYSTEMINFO_EVENT_BATTERY_CHANGED,
128 _on_battery_changed,
129 pd));
130}
131
132static bool
133_fetch_level(int *level)
134{
135 int value = 0;
136 bool ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &value) == 0;
137 if (ret)
138 ERR("%s", "Failed to get battery capacity");
139
140 *level = value;
141 return ret;
142}
143
144static bool
145_fetch_charging_is(Eina_Bool *charging_is)
146{
147 int value = 0;
148 int ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value) == 0;
149 if (!ret)
150 ERR("%s", "Failed to get battery change");
151
152 *charging_is = (0 != value) ? EINA_TRUE : EINA_FALSE;
153 return ret;
154}
155
156static Eina_Bool
157_on_battery_changed(void *data,
158 Eo *obj EINA_UNUSED,
159 const Eo_Event_Description *desc EINA_UNUSED,
160 void *event_info EINA_UNUSED)
161{
162 Ecordova_BatteryStatus_Data *pd = (Ecordova_BatteryStatus_Data*)data;
163
164 Ecordova_BatteryStatus_EventInfo info;
165 if (!_fetch_level(&info.level) ||
166 !_fetch_charging_is(&info.plugged_is))
167 return EO_CALLBACK_CONTINUE;
168
169 if (!pd->info ||
170 pd->info->level != info.level ||
171 pd->info->plugged_is != info.plugged_is)
172 {
173 eo_do(pd->obj, eo_event_callback_call
174 (ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_STATUS, &info));
175
176 if (!info.plugged_is)
177 {
178 if ((!pd->info || pd->info->level > STATUS_CRITICAL) &&
179 info.level <= STATUS_CRITICAL)
180 eo_do(pd->obj, eo_event_callback_call
181 (ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_CRITICAL, &info));
182 else
183 if ((!pd->info || pd->info->level > STATUS_LOW) &&
184 info.level <= STATUS_LOW)
185 eo_do(pd->obj, eo_event_callback_call
186 (ECORDOVA_BATTERYSTATUS_EVENT_BATTERY_LOW, &info));
187 }
188
189 if (!pd->info)
190 pd->info = malloc(sizeof(Ecordova_BatteryStatus_EventInfo));
191 *pd->info = info;
192 }
193 return EO_CALLBACK_CONTINUE;
194}
195
196#include "ecordova_batterystatus.eo.c"
diff --git a/src/lib/ecordova/ecordova_batterystatus.eo b/src/lib/ecordova/ecordova_batterystatus.eo
new file mode 100644
index 0000000000..2dcb511c73
--- /dev/null
+++ b/src/lib/ecordova/ecordova_batterystatus.eo
@@ -0,0 +1,51 @@
1struct Ecordova.BatteryStatus.EventInfo {
2 [[The battery status event info is passed an object that contains two
3 properties.
4 ]]
5
6 level: int;
7 [[The percentage of battery charge (0-100).]]
8
9 plugged_is: bool;
10 [[A boolean that indicates whether the device is plugged in.]]
11}
12
13class Ecordova.BatteryStatus (Eo.Base) {
14 [[Ecordova Battery Plugin
15 Plugin ID: org.apache.cordova.battery-status
16 http://plugins.cordova.io/#/package/org.apache.cordova.battery-status
17 ]]
18 legacy_prefix: null;
19 methods {
20 constructor {
21 [[Custom Ecordova_BatteryStatus constructor.
22 @.constructor
23
24 @since 2.3
25 ]]
26 }
27 }
28 implements {
29 Eo.Base.constructor;
30 Eo.Base.destructor;
31 }
32 constructors {
33 .constructor;
34 }
35 events {
36 battery,status: const(Ecordova.BatteryStatus.EventInfo)*;
37 [[This event fires when the percentage of battery charge changes by at
38 least 1 percent, or if the device is plugged in or unplugged.
39 ]]
40
41 battery,critical: const(Ecordova.BatteryStatus.EventInfo)*;
42 [[This event fires when the percentage of battery charge has reached
43 the critical battery threshold. The value is device-specific.
44 ]]
45
46 battery,low: const(Ecordova.BatteryStatus.EventInfo)*;
47 [[This event fires when the percentage of battery charge has reached
48 the low battery threshold, device-specific value.
49 ]]
50 }
51}
diff --git a/src/lib/ecordova/ecordova_batterystatus_private.h b/src/lib/ecordova/ecordova_batterystatus_private.h
new file mode 100644
index 0000000000..f9ced32f04
--- /dev/null
+++ b/src/lib/ecordova/ecordova_batterystatus_private.h
@@ -0,0 +1,19 @@
1#ifndef _ECORDOVA_BATTERYSTATUS_PRIVATE_H
2#define _ECORDOVA_BATTERYSTATUS_PRIVATE_H
3
4#include "ecordova_private.h"
5#include "ecordova_batterystatus.eo.h"
6
7typedef struct _Ecordova_BatteryStatus_Data Ecordova_BatteryStatus_Data;
8
9/**
10 * Ecordova.BatteryStatus private data
11 */
12struct _Ecordova_BatteryStatus_Data
13{
14 Eo *obj;
15 int callback_ref_count;
16 Ecordova_BatteryStatus_EventInfo *info;
17};
18
19#endif
diff --git a/src/lib/ecordova/ecordova_capture.c b/src/lib/ecordova/ecordova_capture.c
new file mode 100644
index 0000000000..c17b1dad12
--- /dev/null
+++ b/src/lib/ecordova/ecordova_capture.c
@@ -0,0 +1,60 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_capture_private.h"
6
7#define MY_CLASS ECORDOVA_CAPTURE_CLASS
8#define MY_CLASS_NAME "Ecordova_Capture"
9
10static Eo_Base *
11_ecordova_capture_eo_base_constructor(Eo *obj, Ecordova_Capture_Data *pd)
12{
13 DBG("(%p)", obj);
14
15 pd->obj = obj;
16
17 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
18}
19
20static void
21_ecordova_capture_constructor(Eo *obj EINA_UNUSED,
22 Ecordova_Capture_Data *pd EINA_UNUSED)
23{
24 DBG("(%p)", obj);
25}
26
27static void
28_ecordova_capture_eo_base_destructor(Eo *obj,
29 Ecordova_Capture_Data *pd EINA_UNUSED)
30{
31 DBG("(%p)", obj);
32
33 eo_do_super(obj, MY_CLASS, eo_destructor());
34}
35
36static void
37_ecordova_capture_audio_capture(Eo *obj EINA_UNUSED,
38 Ecordova_Capture_Data *pd EINA_UNUSED,
39 const Ecordova_Capture_AudioOptions *options EINA_UNUSED)
40{
41 ERR("Not implemented.");
42}
43
44static void
45_ecordova_capture_image_capture(Eo *obj EINA_UNUSED,
46 Ecordova_Capture_Data *pd EINA_UNUSED,
47 const Ecordova_Capture_ImageOptions *options EINA_UNUSED)
48{
49 ERR("Not implemented.");
50}
51
52static void
53_ecordova_capture_video_capture(Eo *obj EINA_UNUSED,
54 Ecordova_Capture_Data *pd EINA_UNUSED,
55 const Ecordova_Capture_VideoOptions *options EINA_UNUSED)
56{
57 ERR("Not implemented.");
58}
59
60#include "ecordova_capture.eo.c"
diff --git a/src/lib/ecordova/ecordova_capture.eo b/src/lib/ecordova/ecordova_capture.eo
new file mode 100644
index 0000000000..cef42940f0
--- /dev/null
+++ b/src/lib/ecordova/ecordova_capture.eo
@@ -0,0 +1,178 @@
1enum Ecordova.Capture.ErrorCode {
2 CAPTURE_INTERNAL_ERR,
3 [[The camera or microphone failed to capture image or sound.]]
4
5 CAPTURE_APPLICATION_BUSY,
6 [[The camera or audio capture application is currently serving another capture request.]]
7
8 CAPTURE_INVALID_ARGUMENT,
9 [[Invalid use of the API (e.g., the value of limit is less than one).]]
10
11 CAPTURE_NO_MEDIA_FILES,
12 [[The user exits the camera or audio capture application before capturing anything.]]
13
14 CAPTURE_NOT_SUPPORTED
15 [[The requested capture operation is not supported.]]
16
17}
18
19struct Ecordova.Capture.Error {
20 code: Ecordova.Capture.ErrorCode; [[One of the pre-defined error codes]]
21}
22
23struct Ecordova.Capture.AudioOptions {
24 [[Encapsulates audio capture configuration options.]]
25
26 limit: int;
27 [[The maximum number of audio clips the device user can record in a single
28 capture operation. The value must be greater than or equal to 1 (defaults to 1).]]
29
30 duration: int;
31 [[The maximum duration of an audio sound clip, in seconds.]]
32}
33
34struct Ecordova.Capture.ImageOptions {
35 [[Encapsulates image capture configuration options.]]
36
37 limit: int;
38 [[The maximum number of images the user can capture in a single capture
39 operation. The value must be greater than or equal to 1 (defaults to 1).]]
40}
41
42struct Ecordova.Capture.VideoOptions {
43 [[Encapsulates video capture configuration options.]]
44
45 limit: int;
46 [[The maximum number of video clips the device's user can capture in a
47 single capture operation. The value must be greater than or equal to 1 (defaults to 1).]]
48
49 duration: int;
50 [[The maximum duration of a video clip, in seconds.]]
51}
52
53class Ecordova.Capture (Eo.Base) {
54 [[Ecordova Media-Capture Plugin
55 Plugin ID: org.apache.cordova.media-capture
56 http://plugins.cordova.io/#/package/org.apache.cordova.media-capture
57 ]]
58 legacy_prefix: null;
59 methods {
60 constructor {
61 [[Custom Ecordova_Capture constructor.
62 @.constructor
63
64 @since 2.3
65 ]]
66 }
67 audio_capture {
68 [[Start the audio recorder application and return information
69 about captured audio clip files.
70
71 Starts an asynchronous operation to capture audio recordings
72 using the device's default audio recording application. The
73 operation allows the device user to capture multiple recordings
74 in a single session.
75
76 The capture operation ends when either the user exits the audio
77 recording application, or the maximum number of recordings
78 specified by CaptureAudioOptions.limit is reached. If no limit
79 parameter value is specified, it defaults to one (1), and the
80 capture operation terminates after the user records a single
81 audio clip.
82
83 When the capture operation finishes, the CaptureCallback
84 executes with an array of MediaFile objects describing each
85 captured audio clip file. If the user terminates the operation
86 before an audio clip is captured, the CaptureErrorCallback
87 executes with a CaptureError object, featuring the
88 CaptureError.CAPTURE_NO_MEDIA_FILES error code.
89 ]]
90 params {
91 options: const(Ecordova.Capture.AudioOptions)*;
92 }
93 }
94 image_capture {
95 [[Start the camera application and return information about
96 captured image files.
97
98 Starts an asynchronous operation to capture images using the
99 device's camera application. The operation allows users to
100 capture more than one image in a single session.
101
102 The capture operation ends either when the user closes the
103 camera application, or the maximum number of recordings
104 specified by CaptureAudioOptions.limit is reached. If no limit
105 value is specified, it defaults to one (1), and the capture
106 operation terminates after the user captures a single image.
107
108 When the capture operation finishes, it invokes the CaptureCB
109 callback with an array of MediaFile objects describing each
110 captured image file. If the user terminates the operation before
111 capturing an image, the CaptureErrorCB callback executes with a
112 CaptureError object featuring a
113 CaptureError.CAPTURE_NO_MEDIA_FILES error code.
114 ]]
115 params {
116 options: const(Ecordova.Capture.ImageOptions)*;
117 }
118 }
119 video_capture {
120 [[Start the video recorder application and return information
121 about captured video clip files.
122
123 Starts an asynchronous operation to capture video recordings
124 using the device's video recording application. The operation
125 allows the user to capture more than one recordings in a single
126 session.
127
128 The capture operation ends when either the user exits the video
129 recording application, or the maximum number of recordings
130 specified by CaptureVideoOptions.limit is reached. If no limit
131 parameter value is specified, it defaults to one (1), and the
132 capture operation terminates after the user records a single
133 video clip.
134
135 When the capture operation finishes, it the CaptureCB callback
136 executes with an array of MediaFile objects describing each
137 captured video clip file. If the user terminates the operation
138 before capturing a video clip, the CaptureErrorCB callback
139 executes with a CaptureError object featuring a
140 CaptureError.CAPTURE_NO_MEDIA_FILES error code.
141 ]]
142 params {
143 options: const(Ecordova.Capture.VideoOptions)*;
144 }
145 }
146 }
147 implements {
148 Eo.Base.constructor;
149 Eo.Base.destructor;
150 }
151 constructors {
152 .constructor;
153 }
154 events {
155 success: const(array<MediaFile*>)*;
156 [[Invoked upon a successful media capture operation.
157
158 This function executes after a successful capture operation
159 completes. At this point a media file has been captured, and either
160 the user has exited the media capture application, or the capture
161 limit has been reached.
162
163 Each MediaFile object describes a captured media file.
164 ]]
165
166 error: const(Ecordova.Capture.Error)*;
167 [[Invoked if an error occurs during a media capture operation.
168
169 This function executes if an error occurs when trying to launch a
170 media capture operation. Failure scenarios include when the capture
171 application is busy, a capture operation is already taking place, or
172 the user cancels the operation before any media files are captured.
173
174 This function executes with a CaptureError object containing an
175 appropriate error code.
176 ]]
177 }
178}
diff --git a/src/lib/ecordova/ecordova_capture_private.h b/src/lib/ecordova/ecordova_capture_private.h
new file mode 100644
index 0000000000..bea0c4207a
--- /dev/null
+++ b/src/lib/ecordova/ecordova_capture_private.h
@@ -0,0 +1,16 @@
1#ifndef _ECORDOVA_CAPTURE_PRIVATE_H
2#define _ECORDOVA_CAPTURE_PRIVATE_H
3
4#include "ecordova_private.h"
5
6typedef struct _Ecordova_Capture_Data Ecordova_Capture_Data;
7
8/**
9 * Ecordova.Capture private data
10 */
11struct _Ecordova_Capture_Data
12{
13 Eo *obj;
14};
15
16#endif
diff --git a/src/lib/ecordova/ecordova_console.c b/src/lib/ecordova/ecordova_console.c
new file mode 100644
index 0000000000..fd3c5ff408
--- /dev/null
+++ b/src/lib/ecordova/ecordova_console.c
@@ -0,0 +1,175 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_console_private.h"
6
7#include <stdbool.h>
8#include <stdint.h>
9#include <stdlib.h>
10
11#define MY_CLASS ECORDOVA_CONSOLE_CLASS
12#define MY_CLASS_NAME "Ecordova_Console"
13
14static void _ecordova_console_level_log(Ecordova_Console_Data *, Ecordova_Console_LoggerLevel, const char *);
15
16static Eo_Base *
17_ecordova_console_eo_base_constructor(Eo *obj, Ecordova_Console_Data *pd)
18{
19 DBG("(%p)", obj);
20
21 pd->obj = obj;
22 pd->logger_use = EINA_TRUE;
23
24 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
25}
26
27static void
28_ecordova_console_constructor(Eo *obj EINA_UNUSED,
29 Ecordova_Console_Data *pd EINA_UNUSED)
30{
31 DBG("(%p)", obj);
32}
33
34static void
35_ecordova_console_eo_base_destructor(Eo *obj,
36 Ecordova_Console_Data *pd EINA_UNUSED)
37{
38 DBG("(%p)", obj);
39
40 eo_do_super(obj, MY_CLASS, eo_destructor());
41}
42
43static Ecordova_Console_LoggerLevel
44_ecordova_console_level_get(Eo *obj EINA_UNUSED, Ecordova_Console_Data *pd)
45{
46 return pd->level;
47}
48
49static void
50_ecordova_console_level_set(Eo *obj EINA_UNUSED,
51 Ecordova_Console_Data *pd,
52 Ecordova_Console_LoggerLevel value)
53{
54 pd->level = value;
55}
56
57static Eina_Bool
58_ecordova_console_console_use_get(Eo *obj EINA_UNUSED, Ecordova_Console_Data *pd)
59{
60 return pd->console_use;
61}
62
63static void
64_ecordova_console_console_use_set(Eo *obj EINA_UNUSED,
65 Ecordova_Console_Data *pd,
66 Eina_Bool value)
67{
68 pd->console_use = value;
69}
70
71static Eina_Bool
72_ecordova_console_logger_use_get(Eo *obj EINA_UNUSED, Ecordova_Console_Data *pd)
73{
74 return pd->logger_use;
75}
76
77static void
78_ecordova_console_logger_use_set(Eo *obj EINA_UNUSED,
79 Ecordova_Console_Data *pd,
80 Eina_Bool value)
81{
82 pd->logger_use = value;
83}
84
85static void
86_ecordova_console_log(Eo *obj EINA_UNUSED,
87 Ecordova_Console_Data *pd,
88 const char *message)
89{
90 _ecordova_console_level_log(pd, ECORDOVA_CONSOLE_LOGGERLEVEL_LOG, message);
91}
92
93static void
94_ecordova_console_error(Eo *obj EINA_UNUSED,
95 Ecordova_Console_Data *pd,
96 const char *message)
97{
98 _ecordova_console_level_log(pd, ECORDOVA_CONSOLE_LOGGERLEVEL_ERROR, message);
99}
100
101static void
102_ecordova_console_warn(Eo *obj EINA_UNUSED,
103 Ecordova_Console_Data *pd,
104 const char *message)
105{
106 _ecordova_console_level_log(pd, ECORDOVA_CONSOLE_LOGGERLEVEL_WARN, message);
107}
108
109static void
110_ecordova_console_info(Eo *obj EINA_UNUSED,
111 Ecordova_Console_Data *pd,
112 const char *message)
113{
114 _ecordova_console_level_log(pd, ECORDOVA_CONSOLE_LOGGERLEVEL_INFO, message);
115}
116
117static void
118_ecordova_console_debug(Eo *obj EINA_UNUSED,
119 Ecordova_Console_Data *pd,
120 const char *message)
121{
122 _ecordova_console_level_log(pd, ECORDOVA_CONSOLE_LOGGERLEVEL_DEBUG, message);
123}
124
125static void
126_ecordova_console_level_log(Ecordova_Console_Data *pd,
127 Ecordova_Console_LoggerLevel level,
128 const char *message)
129{
130 EINA_SAFETY_ON_NULL_RETURN(message);
131
132 if (level < 0 || pd->level >= ECORDOVA_CONSOLE_LOGGERLEVEL_LAST)
133 {
134 ERR("Invalid logging level: %d", level);
135 return;
136 }
137
138 if (level > pd->level) return;
139
140 if (pd->logger_use)
141 {
142 switch (level)
143 {
144 case ECORDOVA_CONSOLE_LOGGERLEVEL_LOG:
145 CRI("%s", message);
146 break;
147 case ECORDOVA_CONSOLE_LOGGERLEVEL_ERROR:
148 ERR("%s", message);
149 break;
150 case ECORDOVA_CONSOLE_LOGGERLEVEL_WARN:
151 WRN("%s", message);
152 break;
153 case ECORDOVA_CONSOLE_LOGGERLEVEL_INFO:
154 INF("%s", message);
155 break;
156 case ECORDOVA_CONSOLE_LOGGERLEVEL_DEBUG:
157 DBG("%s", message);
158 break;
159 default: break; // removes warning
160 }
161 }
162
163 const char *level_str[ECORDOVA_CONSOLE_LOGGERLEVEL_LAST] = {
164 [ECORDOVA_CONSOLE_LOGGERLEVEL_LOG] = "",
165 [ECORDOVA_CONSOLE_LOGGERLEVEL_ERROR] = "ERROR: ",
166 [ECORDOVA_CONSOLE_LOGGERLEVEL_WARN] = "WARN: ",
167 [ECORDOVA_CONSOLE_LOGGERLEVEL_INFO] = "INFO: ",
168 [ECORDOVA_CONSOLE_LOGGERLEVEL_DEBUG] = "DEBUG: ",
169 };
170
171 if (pd->console_use)
172 printf("%s%s\n", level_str[level], message);
173}
174
175#include "ecordova_console.eo.c"
diff --git a/src/lib/ecordova/ecordova_console.eo b/src/lib/ecordova/ecordova_console.eo
new file mode 100644
index 0000000000..208f3f961c
--- /dev/null
+++ b/src/lib/ecordova/ecordova_console.eo
@@ -0,0 +1,106 @@
1enum Ecordova.Console.LoggerLevel {
2 [[Logging levels]]
3 LOG,
4 ERROR,
5 WARN,
6 INFO,
7 DEBUG,
8 LAST
9}
10
11class Ecordova.Console (Eo.Base) {
12 [[Ecordova Console Plugin
13 Plugin ID: org.apache.cordova.console
14 http://plugins.cordova.io/#/package/org.apache.cordova.console
15 ]]
16 legacy_prefix: null;
17 methods {
18 constructor {
19 [[Custom Ecordova_Console constructor.
20 @.constructor
21
22 @since 2.3
23 ]]
24 }
25 log {
26 [[Logs a message at the LOG level.]]
27 params {
28 message: const(char)*; [[The log message]]
29 }
30 }
31 error {
32 [[Logs a message at the ERROR level.]]
33 params {
34 message: const(char)*; [[The log message]]
35 }
36 }
37 warn {
38 [[Logs a message at the WARN level.]]
39 params {
40 message: const(char)*; [[The log message]]
41 }
42 }
43 info {
44 [[Logs a message at the INFO level.]]
45 params {
46 message: const(char)*; [[The log message]]
47 }
48 }
49 debug {
50 [[Logs a message at the DEBUG level.]]
51 params {
52 message: const(char)*; [[The log message]]
53 }
54 }
55 @property level {
56 [[Getter/Setter for the logging level
57
58 Returns the current logging level.
59
60 When a value is passed, sets the logging level to that value.
61 The values should be one of the following constants:
62 CONSOLE_LOGGER_LEVEL_LOG
63 CONSOLE_LOGGER_LEVEL_ERROR
64 CONSOLE_LOGGER_LEVEL_WARN
65 CONSOLE_LOGGER_LEVEL_INFO
66 CONSOLE_LOGGER_LEVEL_DEBUG
67
68 The value used determines which messages get printed. The logging
69 values above are in order, and only messages logged at the logging
70 level or above will actually be displayed to the user. E.g., the
71 default level is WARN, so only messages logged with LOG, ERROR, or
72 WARN will be displayed; INFO and DEBUG messages will be ignored.
73 ]]
74 values {
75 value: Ecordova.Console.LoggerLevel; [[A valid logger level]]
76 }
77 }
78 @property console_use {
79 [[Getter/Setter for the console_use functionality
80
81 When console_use is true, the logger will log via the
82 browser 'console' object.
83 ]]
84 values {
85 value: bool; [[$EINA_TRUE to enable console output]]
86 }
87 }
88 @property logger_use {
89 [[Getter/Setter for the logger_use functionality
90
91 When logger_use is true, the logger will log via the
92 native Logger plugin.
93 ]]
94 values {
95 value: bool; [[$EINA_TRUE to enable logger output]]
96 }
97 }
98 }
99 implements {
100 Eo.Base.constructor;
101 Eo.Base.destructor;
102 }
103 constructors {
104 .constructor;
105 }
106}
diff --git a/src/lib/ecordova/ecordova_console_private.h b/src/lib/ecordova/ecordova_console_private.h
new file mode 100644
index 0000000000..178e60b966
--- /dev/null
+++ b/src/lib/ecordova/ecordova_console_private.h
@@ -0,0 +1,20 @@
1#ifndef _ECORDOVA_CONSOLE_PRIVATE_H
2#define _ECORDOVA_CONSOLE_PRIVATE_H
3
4#include "ecordova_private.h"
5#include "ecordova_console.eo.h"
6
7typedef struct _Ecordova_Console_Data Ecordova_Console_Data;
8
9/**
10 * Ecordova.Console private data
11 */
12struct _Ecordova_Console_Data
13{
14 Eo *obj;
15 Ecordova_Console_LoggerLevel level;
16 Eina_Bool console_use;
17 Eina_Bool logger_use;
18};
19
20#endif
diff --git a/src/lib/ecordova/ecordova_contact.c b/src/lib/ecordova/ecordova_contact.c
new file mode 100644
index 0000000000..9b986c09e5
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contact.c
@@ -0,0 +1,1117 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_contact_private.h"
6
7#include "ecordova_contactname_private.h"
8#include "ecordova_contactfield_private.h"
9#include "ecordova_contacts_record_utils.h"
10#include "ecordova_contactaddress_private.h"
11#include "ecordova_contactorganization_private.h"
12
13#include <contacts.h>
14
15#include <assert.h>
16#include <stdbool.h>
17#include <stdint.h>
18#include <stdlib.h>
19
20#define MY_CLASS ECORDOVA_CONTACT_CLASS
21#define MY_CLASS_NAME "Ecordova_Contact"
22
23static Ecordova_ContactName *_contactname_copy(Ecordova_ContactName *);
24static Eina_Array *_contactfield_array_copy(Eina_Array *);
25static Eina_Array *_contactaddress_array_copy(Eina_Array *);
26static Eina_Array *_contactorganization_array_copy(Eina_Array *);
27static void _contactfield_array_free(Eina_Array *);
28static void _contactaddress_array_free(Eina_Array *);
29static void _contactorganization_array_free(Eina_Array *);
30static bool _ecordova_contactfields_import(Eina_Array *, contacts_record_h, const Ecordova_ContactField_Metadata);
31static bool _ecordova_contactfields_export(Eina_Array *, contacts_record_h, const Ecordova_ContactField_Metadata);
32static bool _ecordova_contactaddresses_import(Eina_Array *, contacts_record_h);
33static bool _ecordova_contactaddresses_export(Eina_Array *, contacts_record_h);
34static bool _ecordova_contactorganizations_import(Eina_Array *, contacts_record_h);
35static bool _ecordova_contactorganizations_export(Eina_Array *, contacts_record_h);
36static void _contactfield_array_clear_id(Eina_Array *);
37static void _contactaddress_array_clear_id(Eina_Array *);
38static void _contactorganization_array_clear_id(Eina_Array *);
39
40static Eo_Base *
41_ecordova_contact_eo_base_constructor(Eo *obj, Ecordova_Contact_Data *pd)
42{
43 DBG("(%p)", obj);
44
45 pd->obj = obj;
46 pd->record = NULL;
47 int ret = contacts_record_create(_contacts_contact._uri, &pd->record);
48 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
49 pd->name = eo_add(ECORDOVA_CONTACTNAME_CLASS, NULL);
50 pd->phone_numbers = eina_array_new(1);
51 pd->emails = eina_array_new(1);
52 pd->addresses = eina_array_new(1);
53 pd->ims = eina_array_new(1);
54 pd->organizations = eina_array_new(1);
55 pd->photos = eina_array_new(1);
56 pd->categories = eina_array_new(1);
57 pd->urls = eina_array_new(1);
58
59 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
60}
61
62static void
63_ecordova_contact_eo_base_destructor(Eo *obj, Ecordova_Contact_Data *pd)
64{
65 DBG("(%p)", obj);
66
67 eo_unref(pd->name);
68 _contactfield_array_free(pd->phone_numbers);
69 _contactfield_array_free(pd->emails);
70 _contactaddress_array_free(pd->addresses);
71 _contactfield_array_free(pd->ims);
72 _contactorganization_array_free(pd->organizations);
73 _contactfield_array_free(pd->photos);
74 _contactfield_array_free(pd->categories);
75 _contactfield_array_free(pd->urls);
76
77 int ret = contacts_record_destroy(pd->record, true);
78 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
79
80 eo_do_super(obj, MY_CLASS, eo_destructor());
81}
82
83static void
84_ecordova_contact_remove(Eo *obj, Ecordova_Contact_Data *pd)
85{
86 if (!pd->id)
87 {
88 ERR("%s", "No id");
89 goto on_error;
90 }
91
92 int ret = contacts_db_delete_record(_contacts_contact._uri, pd->id);
93 if (CONTACTS_ERROR_NONE != ret)
94 {
95 ERR("Error deleting record id: %d", pd->id);
96 goto on_error;
97 }
98
99 eo_do(obj, eo_event_callback_call(ECORDOVA_CONTACT_EVENT_REMOVE_SUCCESS, NULL));
100 return;
101
102on_error:
103 eo_do(obj, eo_event_callback_call(ECORDOVA_CONTACT_EVENT_ERROR, NULL));
104}
105
106static Ecordova_Contact *
107_ecordova_contact_clone(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
108{
109 Ecordova_Contact *cloned = eo_add(ECORDOVA_CONTACTNAME_CLASS, NULL);
110 EINA_SAFETY_ON_NULL_RETURN_VAL(cloned, NULL);
111
112 if (!ecordova_contact_export(obj, pd->record))
113 goto on_error;
114
115 if (!ecordova_contact_import(cloned, pd->record))
116 goto on_error;
117
118 Ecordova_Contact_Data *cloned_pd = eo_data_scope_get(cloned, ECORDOVA_CONTACT_CLASS);
119 EINA_SAFETY_ON_NULL_GOTO(cloned_pd, on_error);
120
121 cloned_pd->id = 0;
122 _contactfield_array_clear_id(pd->phone_numbers);
123 _contactfield_array_clear_id(pd->emails);
124 _contactaddress_array_clear_id(pd->addresses);
125 _contactfield_array_clear_id(pd->ims);
126 _contactorganization_array_clear_id(pd->organizations);
127 _contactfield_array_clear_id(pd->photos);
128 _contactfield_array_clear_id(pd->categories);
129 _contactfield_array_clear_id(pd->urls);
130
131 return cloned;
132
133on_error:
134 eo_unref(cloned);
135 return NULL;
136}
137
138static void
139_ecordova_contact_save(Eo *obj, Ecordova_Contact_Data *pd)
140{
141 int ret;
142
143 // TODO: export records in a background thread
144 if (!ecordova_contact_export(obj, pd->record))
145 {
146 ERR("%s", "Exporting record");
147 goto on_error;
148 }
149
150 if (pd->id)
151 {
152 ret = contacts_db_update_record(pd->record);
153
154 if (CONTACTS_ERROR_NONE != ret)
155 {
156 ERR("Error updating record: %d", ret);
157 goto on_error;
158 }
159 }
160 else
161 {
162 ret = contacts_db_insert_record(pd->record, &pd->id);
163 if (CONTACTS_ERROR_NONE != ret)
164 {
165 ERR("Error inserting record: %d", ret);
166 goto on_error;
167 }
168
169 // must get the inserted record so we can properly update it further
170 contacts_record_h contacts_record = NULL;
171 ret = contacts_db_get_record(_contacts_contact._uri, pd->id, &contacts_record);
172 if (CONTACTS_ERROR_NONE != ret)
173 {
174 ERR("Error getting record: %d", ret);
175 goto on_error;
176 }
177
178 ret = contacts_record_destroy(pd->record, true);
179 if (CONTACTS_ERROR_NONE != ret)
180 {
181 ERR("Error destroying record: %d", ret);
182 goto on_error;
183 }
184
185 pd->record = contacts_record;
186 }
187
188 // TODO: Check if it's necessary to update children records
189
190 eo_do(obj, eo_event_callback_call(ECORDOVA_CONTACT_EVENT_SAVE_SUCCESS, NULL));
191 return;
192
193on_error:
194 eo_do(obj, eo_event_callback_call(ECORDOVA_CONTACT_EVENT_ERROR, NULL));
195}
196
197static int
198_ecordova_contact_id_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
199{
200 return pd->id;
201}
202
203static const char *
204_ecordova_contact_display_name_get(Eo *obj EINA_UNUSED,
205 Ecordova_Contact_Data *pd)
206{
207 const char *value = NULL;
208 get_str_p(pd->record, _contacts_contact.display_name, &value);
209 return value;
210}
211
212static void
213_ecordova_contact_display_name_set(Eo *obj EINA_UNUSED,
214 Ecordova_Contact_Data *pd,
215 const char *value)
216{
217 set_str(pd->record, _contacts_contact.display_name, value);
218}
219
220static Ecordova_ContactName *
221_ecordova_contact_name_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
222{
223 return pd->name;
224}
225
226static void
227_ecordova_contact_name_set(Eo *obj EINA_UNUSED,
228 Ecordova_Contact_Data *pd,
229 Ecordova_ContactName *name)
230{
231 if (pd->name) eo_unref(pd->name);
232 pd->name = _contactname_copy(name);
233}
234
235static const char *
236_ecordova_contact_nickname_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
237{
238 int ret;
239 int count = 0;
240 ret = contacts_record_get_child_record_count(pd->record,
241 _contacts_contact.nickname,
242 &count);
243 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
244
245 if (0 == count) return NULL;
246
247 contacts_record_h child_record = NULL;
248 ret = contacts_record_get_child_record_at_p(pd->record,
249 _contacts_contact.nickname,
250 0,
251 &child_record);
252 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
253
254 const char *value = NULL;
255 get_str_p(child_record, _contacts_nickname.name, &value);
256 return value;
257}
258
259static void
260_ecordova_contact_nickname_set(Eo *obj EINA_UNUSED,
261 Ecordova_Contact_Data *pd,
262 const char *value)
263{
264 int ret;
265 contacts_record_h child_record = NULL;
266 ret = contacts_record_create(_contacts_nickname._uri, &child_record);
267 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
268
269 if (!set_str(child_record, _contacts_nickname.name, value))
270 goto on_error;
271
272 if (!clear_all_contact_record(pd->record, _contacts_contact.nickname))
273 goto on_error;
274
275 ret = contacts_record_add_child_record(pd->record,
276 _contacts_contact.nickname,
277 child_record);
278 EINA_SAFETY_ON_FALSE_GOTO(CONTACTS_ERROR_NONE == ret, on_error);
279 return;
280
281on_error:
282 ret = contacts_record_destroy(child_record, true);
283 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
284}
285
286static Eina_Array *
287_ecordova_contact_phone_numbers_get(Eo *obj EINA_UNUSED,
288 Ecordova_Contact_Data *pd)
289{
290 return pd->phone_numbers;
291}
292
293static void
294_ecordova_contact_phone_numbers_set(Eo *obj EINA_UNUSED,
295 Ecordova_Contact_Data *pd,
296 Eina_Array *phone_numbers)
297{
298 _contactfield_array_free(pd->phone_numbers);
299 pd->phone_numbers = _contactfield_array_copy(phone_numbers);
300}
301
302static Eina_Array *
303_ecordova_contact_emails_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
304{
305 return pd->emails;
306}
307
308static void
309_ecordova_contact_emails_set(Eo *obj EINA_UNUSED,
310 Ecordova_Contact_Data *pd,
311 Eina_Array *emails)
312{
313 _contactfield_array_free(pd->emails);
314 pd->emails = _contactfield_array_copy(emails);
315}
316
317static Eina_Array *
318_ecordova_contact_addresses_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
319{
320 return pd->addresses;
321}
322
323static void
324_ecordova_contact_addresses_set(Eo *obj EINA_UNUSED,
325 Ecordova_Contact_Data *pd,
326 Eina_Array *addresses)
327{
328 _contactaddress_array_free(pd->addresses);
329 pd->addresses = _contactaddress_array_copy(addresses);
330}
331
332static Eina_Array *
333_ecordova_contact_ims_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
334{
335 return pd->ims;
336}
337
338static void
339_ecordova_contact_ims_set(Eo *obj EINA_UNUSED,
340 Ecordova_Contact_Data *pd,
341 Eina_Array *ims)
342{
343 _contactfield_array_free(pd->ims);
344 pd->ims = _contactfield_array_copy(ims);
345}
346
347static Eina_Array *
348_ecordova_contact_organizations_get(Eo *obj EINA_UNUSED,
349 Ecordova_Contact_Data *pd)
350{
351 return pd->organizations;
352}
353
354static void
355_ecordova_contact_organizations_set(Eo *obj EINA_UNUSED,
356 Ecordova_Contact_Data *pd,
357 Eina_Array *organizations)
358{
359 _contactorganization_array_free(pd->organizations);
360 pd->organizations = _contactorganization_array_copy(organizations);
361}
362
363static time_t
364_ecordova_contact_birthday_get(Eo *obj EINA_UNUSED,
365 Ecordova_Contact_Data *pd EINA_UNUSED)
366{
367 // TODO: get birthday
368 return 0;
369}
370
371static void
372_ecordova_contact_birthday_set(Eo *obj EINA_UNUSED,
373 Ecordova_Contact_Data *pd EINA_UNUSED,
374 time_t birthday EINA_UNUSED)
375{
376 // TODO: set birthday
377}
378
379static const char *
380_ecordova_contact_note_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
381{
382 int ret;
383 int count = 0;
384 ret = contacts_record_get_child_record_count(pd->record,
385 _contacts_contact.note,
386 &count);
387 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
388
389 if (0 == count)
390 return NULL;
391
392 contacts_record_h child_record = NULL;
393 ret = contacts_record_get_child_record_at_p(pd->record,
394 _contacts_contact.note,
395 0,
396 &child_record);
397 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
398
399 const char *value = NULL;
400 get_str_p(child_record, _contacts_note.note, &value);
401 return value;
402}
403
404static void
405_ecordova_contact_note_set(Eo *obj EINA_UNUSED,
406 Ecordova_Contact_Data *pd,
407 const char *value)
408{
409 int ret;
410 contacts_record_h child_record = NULL;
411 ret = contacts_record_create(_contacts_note._uri, &child_record);
412 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
413
414 if (!set_str(child_record, _contacts_note.note, value))
415 goto on_error;
416
417 if (!clear_all_contact_record(pd->record, _contacts_contact.note))
418 goto on_error;
419
420 ret = contacts_record_add_child_record(pd->record,
421 _contacts_contact.note,
422 child_record);
423 EINA_SAFETY_ON_FALSE_GOTO(CONTACTS_ERROR_NONE == ret, on_error);
424 return;
425
426on_error:
427 ret = contacts_record_destroy(child_record, true);
428 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
429}
430
431static Eina_Array *
432_ecordova_contact_photos_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
433{
434 return pd->photos;
435}
436
437static void
438_ecordova_contact_photos_set(Eo *obj EINA_UNUSED,
439 Ecordova_Contact_Data *pd,
440 Eina_Array *photos)
441{
442 _contactfield_array_free(pd->photos);
443 pd->photos = _contactfield_array_copy(photos);
444}
445
446static Eina_Array *
447_ecordova_contact_categories_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
448{
449 return pd->categories;
450}
451
452static void
453_ecordova_contact_categories_set(Eo *obj EINA_UNUSED,
454 Ecordova_Contact_Data *pd,
455 Eina_Array *categories)
456{
457 _contactfield_array_free(pd->categories);
458 pd->categories = _contactfield_array_copy(categories);
459}
460
461static Eina_Array *
462_ecordova_contact_urls_get(Eo *obj EINA_UNUSED, Ecordova_Contact_Data *pd)
463{
464 return pd->urls;
465}
466
467static void
468_ecordova_contact_urls_set(Eo *obj EINA_UNUSED,
469 Ecordova_Contact_Data *pd,
470 Eina_Array *urls)
471{
472 _contactfield_array_free(pd->urls);
473 pd->urls = _contactfield_array_copy(urls);
474}
475
476static Ecordova_ContactName *
477_contactname_copy(Ecordova_ContactName *name)
478{
479 if (!name)
480 return eo_add(ECORDOVA_CONTACTNAME_CLASS, NULL);
481
482 return ecordova_contactname_clone(name);
483}
484
485static Ecordova_ContactAddress *
486_contactaddress_copy(Ecordova_ContactAddress *address)
487{
488 if (!address)
489 return NULL;
490
491 Eina_Bool pref = EINA_FALSE;
492 const char *type = NULL;
493 const char *formatted = NULL;
494 const char *street_address = NULL;
495 const char *locality = NULL;
496 const char *region = NULL;
497 const char *postal_code = NULL;
498 const char *country = NULL;
499 eo_do(address,
500 pref = ecordova_contactaddress_pref_get(),
501 type = ecordova_contactaddress_type_get(),
502 formatted = ecordova_contactaddress_formatted_get(),
503 street_address = ecordova_contactaddress_street_address_get(),
504 locality = ecordova_contactaddress_locality_get(),
505 region = ecordova_contactaddress_region_get(),
506 postal_code = ecordova_contactaddress_postal_code_get(),
507 country = ecordova_contactaddress_country_get());
508
509 return eo_add(ECORDOVA_CONTACTADDRESS_CLASS,
510 NULL,
511 ecordova_contactaddress_constructor(pref,
512 type,
513 formatted,
514 street_address,
515 locality,
516 region,
517 postal_code,
518 country));
519}
520
521static Ecordova_ContactField *
522_contactfield_copy(Ecordova_ContactField *field)
523{
524 if (!field)
525 return NULL;
526
527 const char *type = NULL;
528 const char *value = NULL;
529 Eina_Bool pref = EINA_FALSE;
530 eo_do(field,
531 type = ecordova_contactfield_type_get(),
532 value = ecordova_contactfield_value_get(),
533 pref = ecordova_contactfield_pref_get());
534
535 return eo_add(ECORDOVA_CONTACTFIELD_CLASS, NULL,
536 ecordova_contactfield_constructor(type, value, pref));
537}
538
539static Ecordova_ContactOrganization *
540_contactorganization_copy(Ecordova_ContactOrganization *organization)
541{
542 if (!organization)
543 return NULL;
544
545 Eina_Bool pref = EINA_FALSE;
546 const char *type = NULL;
547 const char *name = NULL;
548 const char *dept = NULL;
549 const char *title = NULL;
550 eo_do(organization,
551 pref = ecordova_contactorganization_pref_get(),
552 type = ecordova_contactorganization_type_get(),
553 name = ecordova_contactorganization_name_get(),
554 dept = ecordova_contactorganization_dept_get(),
555 title = ecordova_contactorganization_title_get());
556
557 return eo_add(ECORDOVA_CONTACTORGANIZATION_CLASS,
558 NULL,
559 ecordova_contactorganization_constructor(pref,
560 type,
561 name,
562 dept,
563 title));
564}
565
566static Eina_Array *
567_contactfield_array_copy(Eina_Array *fields)
568{
569 Eina_Array *result = eina_array_new(1);
570 if (!fields)
571 return result;
572
573 size_t i;
574 Ecordova_ContactField *field;
575 Eina_Array_Iterator it;
576 EINA_ARRAY_ITER_NEXT(fields, i, field, it)
577 eina_array_push(result, _contactfield_copy(field));
578 return result;
579}
580
581static Eina_Array *
582_contactaddress_array_copy(Eina_Array *addresses)
583{
584 Eina_Array *result = eina_array_new(1);
585 if (!addresses)
586 return result;
587
588 size_t i;
589 Ecordova_ContactAddress *address;
590 Eina_Array_Iterator it;
591 EINA_ARRAY_ITER_NEXT(addresses, i, address, it)
592 eina_array_push(result, _contactaddress_copy(address));
593 return result;
594}
595
596static Eina_Array *
597_contactorganization_array_copy(Eina_Array *organizations)
598{
599 Eina_Array *result = eina_array_new(1);
600 if (!organizations)
601 return result;
602
603 size_t i;
604 Ecordova_ContactOrganization *organization;
605 Eina_Array_Iterator it;
606 EINA_ARRAY_ITER_NEXT(organizations, i, organization, it)
607 eina_array_push(result, _contactorganization_copy(organization));
608 return result;
609}
610
611static void
612_contactfield_array_free(Eina_Array *fields)
613{
614 if (!fields)
615 return;
616
617 size_t i;
618 Ecordova_ContactField *field;
619 Eina_Array_Iterator it;
620 EINA_ARRAY_ITER_NEXT(fields, i, field, it)
621 eo_unref(field);
622 eina_array_free(fields);
623}
624
625static void
626_contactaddress_array_free(Eina_Array *addresses)
627{
628 if (!addresses)
629 return;
630
631 size_t i;
632 Ecordova_ContactAddress *address;
633 Eina_Array_Iterator it;
634 EINA_ARRAY_ITER_NEXT(addresses, i, address, it)
635 eo_unref(address);
636 eina_array_free(addresses);
637}
638
639static void
640_contactorganization_array_free(Eina_Array *organizations)
641{
642 if (!organizations)
643 return;
644
645 size_t i;
646 Ecordova_ContactOrganization *organization;
647 Eina_Array_Iterator it;
648 EINA_ARRAY_ITER_NEXT(organizations, i, organization, it)
649 eo_unref(organization);
650 eina_array_free(organizations);
651}
652
653static void
654_contactfield_array_clear_id(Eina_Array *fields)
655{
656 if (!fields)
657 return;
658
659 size_t i;
660 Ecordova_ContactField *field;
661 Eina_Array_Iterator it;
662 EINA_ARRAY_ITER_NEXT(fields, i, field, it)
663 {
664 Ecordova_ContactField_Data *pd =
665 eo_data_scope_get(field, ECORDOVA_CONTACTFIELD_CLASS);
666 EINA_SAFETY_ON_NULL_RETURN(pd);
667
668 pd->id = 0;
669 }
670}
671
672static void
673_contactaddress_array_clear_id(Eina_Array *addresses)
674{
675 if (!addresses)
676 return;
677
678 size_t i;
679 Ecordova_ContactAddress *address;
680 Eina_Array_Iterator it;
681 EINA_ARRAY_ITER_NEXT(addresses, i, address, it)
682 {
683 Ecordova_ContactAddress_Data *pd =
684 eo_data_scope_get(address, ECORDOVA_CONTACTADDRESS_CLASS);
685 EINA_SAFETY_ON_NULL_RETURN(pd);
686
687 pd->id = 0;
688 }
689}
690
691static void
692_contactorganization_array_clear_id(Eina_Array *organizations)
693{
694 if (!organizations)
695 return;
696
697 size_t i;
698 Ecordova_ContactOrganization *organization;
699 Eina_Array_Iterator it;
700 EINA_ARRAY_ITER_NEXT(organizations, i, organization, it)
701 {
702 Ecordova_ContactOrganization_Data *pd =
703 eo_data_scope_get(organization, ECORDOVA_CONTACTORGANIZATION_CLASS);
704 EINA_SAFETY_ON_NULL_RETURN(pd);
705
706 pd->id = 0;
707 }
708}
709
710static const Ecordova_ContactField_Metadata
711_contact_number_metadata = {
712 .uri = &_contacts_number._uri,
713 .ids = {
714 [ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID] = &_contacts_contact.number,
715 [ECORDOVA_CONTACTFIELD_PROPERTY_ID] = &_contacts_number.id,
716 [ECORDOVA_CONTACTFIELD_PROPERTY_TYPE] = &_contacts_number.type,
717 [ECORDOVA_CONTACTFIELD_PROPERTY_LABEL] = &_contacts_number.label,
718 [ECORDOVA_CONTACTFIELD_PROPERTY_VALUE] = &_contacts_number.number,
719 [ECORDOVA_CONTACTFIELD_PROPERTY_PREF] = &_contacts_number.is_default},
720 .type2label = ecordova_contactnumber_type2label,
721 .label2type = ecordova_contactnumber_label2type
722};
723
724static const Ecordova_ContactField_Metadata
725_contact_email_metadata = {
726 .uri = &_contacts_email._uri,
727 .ids = {
728 [ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID] = &_contacts_contact.email,
729 [ECORDOVA_CONTACTFIELD_PROPERTY_ID] = &_contacts_email.id,
730 [ECORDOVA_CONTACTFIELD_PROPERTY_TYPE] = &_contacts_email.type,
731 [ECORDOVA_CONTACTFIELD_PROPERTY_LABEL] = &_contacts_email.label,
732 [ECORDOVA_CONTACTFIELD_PROPERTY_VALUE] = &_contacts_email.email,
733 [ECORDOVA_CONTACTFIELD_PROPERTY_PREF] = &_contacts_email.is_default},
734 .type2label = ecordova_contactemail_type2label,
735 .label2type = ecordova_contactemail_label2type
736};
737
738static const Ecordova_ContactField_Metadata
739_contact_messenger_metadata = {
740 .uri = &_contacts_messenger._uri,
741 .ids = {
742 [ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID] = &_contacts_contact.messenger,
743 [ECORDOVA_CONTACTFIELD_PROPERTY_ID] = &_contacts_messenger.id,
744 [ECORDOVA_CONTACTFIELD_PROPERTY_TYPE] = &_contacts_messenger.type,
745 [ECORDOVA_CONTACTFIELD_PROPERTY_LABEL] = &_contacts_messenger.label,
746 [ECORDOVA_CONTACTFIELD_PROPERTY_VALUE] = &_contacts_messenger.im_id,
747 [ECORDOVA_CONTACTFIELD_PROPERTY_PREF] = NULL},
748 .type2label = ecordova_contactmessenger_type2label,
749 .label2type = ecordova_contactmessenger_label2type
750};
751
752static const Ecordova_ContactField_Metadata
753_contact_image_metadata = {
754 .uri = &_contacts_image._uri,
755 .ids = {
756 [ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID] = &_contacts_contact.image,
757 [ECORDOVA_CONTACTFIELD_PROPERTY_ID] = &_contacts_image.id,
758 [ECORDOVA_CONTACTFIELD_PROPERTY_TYPE] = &_contacts_image.type,
759 [ECORDOVA_CONTACTFIELD_PROPERTY_LABEL] = &_contacts_image.label,
760 [ECORDOVA_CONTACTFIELD_PROPERTY_VALUE] = &_contacts_image.path,
761 [ECORDOVA_CONTACTFIELD_PROPERTY_PREF] = &_contacts_image.is_default},
762 .type2label = ecordova_contactimage_type2label,
763 .label2type = ecordova_contactimage_label2type
764};
765
766static const Ecordova_ContactField_Metadata
767_contact_url_metadata = {
768 .uri = &_contacts_url._uri,
769 .ids = {
770 [ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID] = &_contacts_contact.url,
771 [ECORDOVA_CONTACTFIELD_PROPERTY_ID] = &_contacts_url.id,
772 [ECORDOVA_CONTACTFIELD_PROPERTY_TYPE] = &_contacts_url.type,
773 [ECORDOVA_CONTACTFIELD_PROPERTY_LABEL] = &_contacts_url.label,
774 [ECORDOVA_CONTACTFIELD_PROPERTY_VALUE] = &_contacts_url.url,
775 [ECORDOVA_CONTACTFIELD_PROPERTY_PREF] = NULL},
776 .type2label = ecordova_contacturl_type2label,
777 .label2type = ecordova_contacturl_label2type
778};
779
780bool
781ecordova_contact_import(Ecordova_Contact *obj,
782 contacts_record_h contacts_record)
783{
784 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
785 EINA_SAFETY_ON_NULL_RETURN_VAL(contacts_record, false);
786
787 Ecordova_Contact_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACT_CLASS);
788 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
789
790 int ret;
791
792 ret = contacts_record_destroy(pd->record, true);
793 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
794 ret = contacts_record_clone(contacts_record, &pd->record);
795 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
796
797 ret = contacts_record_get_int(pd->record, _contacts_contact.id, &pd->id);
798 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
799
800 // name
801 DBG("%s", "Importing name");
802 if (!ecordova_contactname_import(pd->name, pd->record))
803 return false;
804
805 // phone_numbers
806 DBG("%s", "Importing phone_numbers");
807 if (!_ecordova_contactfields_import(pd->phone_numbers,
808 pd->record,
809 _contact_number_metadata))
810 return false;
811
812 // emails
813 DBG("%s", "Importing emails");
814 if (!_ecordova_contactfields_import(pd->emails,
815 pd->record,
816 _contact_email_metadata))
817 return false;
818
819 // addresses
820 DBG("%s", "Importing addresses");
821 if (!_ecordova_contactaddresses_import(pd->addresses, pd->record))
822 return false;
823
824 // ims
825 DBG("%s", "Importing ims");
826 if (!_ecordova_contactfields_import(pd->ims,
827 pd->record,
828 _contact_messenger_metadata))
829 return false;
830
831 // organizations
832 DBG("%s", "Importing organizations");
833 if (!_ecordova_contactorganizations_import(pd->organizations, pd->record))
834 return false;
835
836 // photos
837 DBG("%s", "Importing photos");
838 if (!_ecordova_contactfields_import(pd->photos,
839 pd->record,
840 _contact_image_metadata))
841 return false;
842
843 // TODO: categories
844
845 // urls
846 DBG("%s", "Importing urls");
847 if (!_ecordova_contactfields_import(pd->urls,
848 pd->record,
849 _contact_url_metadata))
850 return false;
851
852 return true;
853}
854
855bool
856ecordova_contact_export(Ecordova_Contact *obj,
857 contacts_record_h contacts_record)
858{
859 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
860 EINA_SAFETY_ON_NULL_RETURN_VAL(contacts_record, false);
861
862 Ecordova_Contact_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACT_CLASS);
863 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
864
865 // name
866 if (!clear_all_contact_record(contacts_record, _contacts_contact.name) ||
867 !ecordova_contactname_export(pd->name, contacts_record))
868 return false;
869
870 // phone_numbers
871 if (!_ecordova_contactfields_export(pd->phone_numbers,
872 contacts_record,
873 _contact_number_metadata))
874 return false;
875
876 // emails
877 if (!_ecordova_contactfields_export(pd->emails,
878 contacts_record,
879 _contact_email_metadata))
880 return false;
881
882 // addresses
883 if (!_ecordova_contactaddresses_export(pd->addresses, contacts_record))
884 return false;
885
886 // ims
887 if (!_ecordova_contactfields_export(pd->ims,
888 contacts_record,
889 _contact_messenger_metadata))
890 return false;
891
892 // organizations
893 if (!_ecordova_contactorganizations_export(pd->organizations, contacts_record))
894 return false;
895
896 // photos
897 if (!_ecordova_contactfields_export(pd->photos,
898 contacts_record,
899 _contact_image_metadata))
900 return false;
901
902 // TODO: categories
903
904 // urls
905 if (!_ecordova_contactfields_export(pd->urls,
906 contacts_record,
907 _contact_url_metadata))
908 return false;
909
910 return true;
911}
912
913static bool
914_ecordova_contactfields_import(Eina_Array *fields,
915 contacts_record_h contacts_record,
916 const Ecordova_ContactField_Metadata metadata)
917{
918 int ret;
919 int count = 0;
920 ret = contacts_record_get_child_record_count(contacts_record,
921 *metadata.ids[ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID],
922 &count);
923 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
924
925 DBG("Importing %d children", count);
926 for (int index = 0; index < count; ++index)
927 {
928 contacts_record_h child_record = NULL;
929 ret = contacts_record_get_child_record_at_p(contacts_record,
930 *metadata.ids[ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID],
931 index,
932 &child_record);
933 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
934
935 Ecordova_ContactField *field = eo_add(ECORDOVA_CONTACTFIELD_CLASS, NULL);
936 if (!ecordova_contactfield_import(field, child_record, metadata))
937 {
938 eo_unref(field);
939 return false;
940 }
941
942 Eina_Bool ret = eina_array_push(fields, field);
943 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, false);
944 }
945
946 return true;
947}
948
949static bool
950_ecordova_contactfields_export(Eina_Array *fields,
951 contacts_record_h contacts_record,
952 const Ecordova_ContactField_Metadata metadata)
953{
954 if (!clear_all_contact_record(contacts_record,
955 *metadata.ids[ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID]))
956 return false;
957
958 Ecordova_ContactField *field;
959 Eina_Array_Iterator iterator;
960 unsigned int i;
961 EINA_ARRAY_ITER_NEXT(fields, i, field, iterator)
962 {
963 contacts_record_h record = NULL;
964 int ret = contacts_record_create(*metadata.uri, &record);
965 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
966
967 if (!ecordova_contactfield_export(field, record, metadata))
968 {
969 ret = contacts_record_destroy(record, true);
970 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
971 return false;
972 }
973
974 ret = contacts_record_add_child_record(contacts_record,
975 *metadata.ids[ECORDOVA_CONTACTFIELD_PARENT_PROPERTY_ID],
976 record);
977 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
978 }
979
980 return true;
981}
982
983static bool
984_ecordova_contactaddresses_import(Eina_Array *fields,
985 contacts_record_h contacts_record)
986{
987 int ret;
988 int count = 0;
989 ret = contacts_record_get_child_record_count(contacts_record,
990 _contacts_contact.address,
991 &count);
992 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
993
994 DBG("Importing %d addresses", count);
995 for (int index = 0; index < count; ++index)
996 {
997 contacts_record_h child_record = NULL;
998 ret = contacts_record_get_child_record_at_p(contacts_record,
999 _contacts_contact.address,
1000 index,
1001 &child_record);
1002 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1003
1004 Ecordova_ContactAddress *address = eo_add(ECORDOVA_CONTACTADDRESS_CLASS, NULL);
1005 if (!ecordova_contactaddress_import(address, child_record))
1006 {
1007 eo_unref(address);
1008 return false;
1009 }
1010
1011 Eina_Bool ret = eina_array_push(fields, address);
1012 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, false);
1013 }
1014
1015 return true;
1016}
1017
1018static bool
1019_ecordova_contactaddresses_export(Eina_Array *addresses,
1020 contacts_record_h contacts_record)
1021{
1022 if (!clear_all_contact_record(contacts_record, _contacts_contact.address))
1023 return false;
1024
1025 Ecordova_ContactAddress *address;
1026 Eina_Array_Iterator iterator;
1027 unsigned int i;
1028 EINA_ARRAY_ITER_NEXT(addresses, i, address, iterator)
1029 {
1030 contacts_record_h record = NULL;
1031 int ret = contacts_record_create(_contacts_address._uri, &record);
1032 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1033
1034 if (!ecordova_contactaddress_export(address, record))
1035 {
1036 ret = contacts_record_destroy(record, true);
1037 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1038 return false;
1039 }
1040
1041 ret = contacts_record_add_child_record(contacts_record,
1042 _contacts_contact.address,
1043 record);
1044 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1045 }
1046
1047 return true;
1048}
1049
1050static bool
1051_ecordova_contactorganizations_import(Eina_Array *organizations,
1052 contacts_record_h contacts_record)
1053{
1054 int ret;
1055 int count = 0;
1056 ret = contacts_record_get_child_record_count(contacts_record,
1057 _contacts_contact.company,
1058 &count);
1059 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1060
1061 DBG("Importing %d organizations", count);
1062 for (int index = 0; index < count; ++index)
1063 {
1064 contacts_record_h child_record = NULL;
1065 ret = contacts_record_get_child_record_at_p(contacts_record,
1066 _contacts_contact.company,
1067 index,
1068 &child_record);
1069 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1070
1071 Ecordova_ContactOrganization *organization = eo_add(ECORDOVA_CONTACTORGANIZATION_CLASS, NULL);
1072 if (!ecordova_contactorganization_import(organization, child_record))
1073 {
1074 eo_unref(organization);
1075 return false;
1076 }
1077
1078 Eina_Bool ret = eina_array_push(organizations, organization);
1079 EINA_SAFETY_ON_FALSE_RETURN_VAL(ret, false);
1080 }
1081
1082 return true;
1083}
1084
1085static bool
1086_ecordova_contactorganizations_export(Eina_Array *organizations,
1087 contacts_record_h contacts_record)
1088{
1089 if (!clear_all_contact_record(contacts_record, _contacts_contact.company))
1090 return false;
1091
1092 Ecordova_ContactOrganization *organization;
1093 Eina_Array_Iterator iterator;
1094 unsigned int i;
1095 EINA_ARRAY_ITER_NEXT(organizations, i, organization, iterator)
1096 {
1097 contacts_record_h record = NULL;
1098 int ret = contacts_record_create(_contacts_company._uri, &record);
1099 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1100
1101 if (!ecordova_contactaddress_export(organization, record))
1102 {
1103 ret = contacts_record_destroy(record, true);
1104 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1105 return false;
1106 }
1107
1108 ret = contacts_record_add_child_record(contacts_record,
1109 _contacts_contact.company,
1110 record);
1111 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
1112 }
1113
1114 return true;
1115}
1116
1117#include "ecordova_contact.eo.c"
diff --git a/src/lib/ecordova/ecordova_contact.eo b/src/lib/ecordova/ecordova_contact.eo
new file mode 100644
index 0000000000..88afe5fe34
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contact.eo
@@ -0,0 +1,98 @@
1class Ecordova.Contact (Eo.Base) {
2 [[Contains information about a single contact.]]
3 legacy_prefix: null;
4 methods {
5 remove {
6 [[Removes contact from device storage.]]
7 }
8 clone {
9 [[Creates a deep copy of this Contact. With the contact ID set to
10 null.
11 ]]
12 return: Ecordova.Contact*; [[copy of this Contact]]
13 }
14 save {
15 [[Persists contact to device storage.]]
16 }
17 @property id {
18 get {}
19 values {
20 id: int ;
21 }
22 }
23 @property display_name {
24 values {
25 display_name: const(char)*;
26 }
27 }
28 @property name {
29 values {
30 name: Ecordova.ContactName*;
31 }
32 }
33 @property nickname {
34 values {
35 nickname: const(char)*;
36 }
37 }
38 @property phone_numbers {
39 values {
40 phone_numbers: array<Ecordova.ContactField*>*;
41 }
42 }
43 @property emails {
44 values {
45 emails: array<Ecordova.ContactField*>*;
46 }
47 }
48 @property addresses {
49 values {
50 addresses: array<Ecordova.ContactAddress*>*;
51 }
52 }
53 @property ims {
54 values {
55 ims: array<Ecordova.ContactField*>*;
56 }
57 }
58 @property organizations {
59 values {
60 organizations: array<Ecordova.ContactOrganization*>*;
61 }
62 }
63 @property birthday {
64 values {
65 birthday: time ;
66 }
67 }
68 @property note {
69 values {
70 note: const(char)*;
71 }
72 }
73 @property photos {
74 values {
75 photos: array<Ecordova.ContactField*>*;
76 }
77 }
78 @property categories {
79 values {
80 categories: array<Ecordova.ContactField*>*;
81 }
82 }
83 @property urls {
84 values {
85 urls: array<Ecordova.ContactField*>*;
86 }
87 }
88 }
89 implements {
90 Eo.Base.constructor;
91 Eo.Base.destructor;
92 }
93 events {
94 save,success;
95 remove,success;
96 error;
97 }
98}
diff --git a/src/lib/ecordova/ecordova_contact_private.h b/src/lib/ecordova/ecordova_contact_private.h
new file mode 100644
index 0000000000..4a1ddc8deb
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contact_private.h
@@ -0,0 +1,38 @@
1#ifndef _ECORDOVA_CONTACT_PRIVATE_H
2#define _ECORDOVA_CONTACT_PRIVATE_H
3
4#include "ecordova_private.h"
5#include "ecordova_contactaddress.eo.h"
6#include "ecordova_contactfield.eo.h"
7#include "ecordova_contactname.eo.h"
8#include "ecordova_contactorganization.eo.h"
9#include "ecordova_contact.eo.h"
10
11#include <contacts.h>
12#include <stdbool.h>
13
14typedef struct _Ecordova_Contact_Data Ecordova_Contact_Data;
15
16/**
17 * Ecordova.Contact private data
18 */
19struct _Ecordova_Contact_Data
20{
21 Eo *obj;
22 contacts_record_h record;
23 int id;
24 Ecordova_ContactName *name;
25 Eina_Array *phone_numbers;
26 Eina_Array *emails;
27 Eina_Array *addresses;
28 Eina_Array *ims;
29 Eina_Array *organizations;
30 Eina_Array *photos;
31 Eina_Array *categories;
32 Eina_Array *urls;
33};
34
35bool ecordova_contact_import(Ecordova_Contact *, contacts_record_h);
36bool ecordova_contact_export(Ecordova_Contact *, contacts_record_h);
37
38#endif
diff --git a/src/lib/ecordova/ecordova_contactaddress.c b/src/lib/ecordova/ecordova_contactaddress.c
new file mode 100644
index 0000000000..23918f2432
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contactaddress.c
@@ -0,0 +1,312 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_contactaddress_private.h"
6#include "ecordova_contacts_record_utils.h"
7
8#include <stdbool.h>
9#include <stdint.h>
10#include <stdlib.h>
11
12#define MY_CLASS ECORDOVA_CONTACTADDRESS_CLASS
13#define MY_CLASS_NAME "Ecordova_ContactAddress"
14
15static Eo_Base *
16_ecordova_contactaddress_eo_base_constructor(Eo *obj,
17 Ecordova_ContactAddress_Data *pd)
18{
19 DBG("(%p)", obj);
20
21 pd->obj = obj;
22 pd->id = 0;
23 pd->record = NULL;
24 int ret = contacts_record_create(_contacts_address._uri, &pd->record);
25 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
26
27 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
28}
29
30static void
31_ecordova_contactaddress_constructor(Eo *obj,
32 Ecordova_ContactAddress_Data *pd EINA_UNUSED,
33 Eina_Bool pref,
34 const char *type,
35 const char *formatted,
36 const char *street_address,
37 const char *locality,
38 const char *region,
39 const char *postal_code,
40 const char *country)
41{
42 DBG("(%p)", obj);
43 eo_do(obj,
44 ecordova_contactaddress_pref_set(pref),
45 ecordova_contactaddress_type_set(type),
46 ecordova_contactaddress_formatted_set(formatted),
47 ecordova_contactaddress_street_address_set(street_address),
48 ecordova_contactaddress_locality_set(locality),
49 ecordova_contactaddress_region_set(region),
50 ecordova_contactaddress_postal_code_set(postal_code),
51 ecordova_contactaddress_country_set(country));
52}
53
54static void
55_ecordova_contactaddress_eo_base_destructor(Eo *obj,
56 Ecordova_ContactAddress_Data *pd)
57{
58 DBG("(%p)", obj);
59
60 int ret = contacts_record_destroy(pd->record, true);
61 EINA_SAFETY_ON_FALSE_RETURN(CONTACTS_ERROR_NONE == ret);
62
63 eo_do_super(obj, MY_CLASS, eo_destructor());
64}
65
66static int
67_ecordova_contactaddress_id_get(Eo *obj EINA_UNUSED,
68 Ecordova_ContactAddress_Data *pd)
69{
70 return pd->id;
71}
72
73static Eina_Bool
74_ecordova_contactaddress_pref_get(Eo *obj EINA_UNUSED,
75 Ecordova_ContactAddress_Data *pd)
76{
77 Eina_Bool value = EINA_FALSE;
78 get_bool(pd->record, _contacts_address.is_default, &value);
79 return value;
80}
81
82static void
83_ecordova_contactaddress_pref_set(Eo *obj EINA_UNUSED,
84 Ecordova_ContactAddress_Data *pd,
85 Eina_Bool value)
86{
87 set_bool(pd->record, _contacts_address.is_default, value);
88}
89
90static const char *
91_ecordova_contactaddress_type_get(Eo *obj EINA_UNUSED,
92 Ecordova_ContactAddress_Data *pd)
93{
94 int type;
95 if (!get_int(pd->record, _contacts_address.type, &type))
96 return NULL;
97
98 switch (type)
99 {
100 case CONTACTS_ADDRESS_TYPE_HOME:
101 return "Home";
102 case CONTACTS_ADDRESS_TYPE_WORK:
103 return "Work";
104 case CONTACTS_ADDRESS_TYPE_DOM:
105 return "Dom";
106 case CONTACTS_ADDRESS_TYPE_INTL:
107 return "Intl";
108 case CONTACTS_ADDRESS_TYPE_POSTAL:
109 return "Postal";
110 case CONTACTS_ADDRESS_TYPE_PARCEL:
111 return "Parcel";
112 case CONTACTS_ADDRESS_TYPE_OTHER:
113 case CONTACTS_ADDRESS_TYPE_CUSTOM:
114 default:
115 {
116 const char *custom = NULL;
117 get_str_p(pd->record, _contacts_address.label, &custom);
118 return custom;
119 }
120 }
121}
122
123static void
124_ecordova_contactaddress_type_set(Eo *obj EINA_UNUSED,
125 Ecordova_ContactAddress_Data *pd,
126 const char *value)
127{
128 int type = CONTACTS_ADDRESS_TYPE_OTHER;
129 if (!value || strlen(value) == 0)
130 type = CONTACTS_ADDRESS_TYPE_OTHER;
131 else
132 if (strcasecmp(value, "Home"))
133 type = CONTACTS_ADDRESS_TYPE_HOME;
134 else if (strcasecmp(value, "Work"))
135 type = CONTACTS_ADDRESS_TYPE_WORK;
136 else if (strcasecmp(value, "Dom"))
137 type = CONTACTS_ADDRESS_TYPE_DOM;
138 else if (strcasecmp(value, "Intl"))
139 type = CONTACTS_ADDRESS_TYPE_INTL;
140 else if (strcasecmp(value, "Postal"))
141 type = CONTACTS_ADDRESS_TYPE_POSTAL;
142 else if (strcasecmp(value, "Parcel"))
143 type = CONTACTS_ADDRESS_TYPE_PARCEL;
144 else
145 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
146
147 set_int(pd->record, _contacts_address.type, type);
148 if (strlen(value) != 0)
149 set_str(pd->record, _contacts_address.label, value);
150}
151
152static const char *
153_ecordova_contactaddress_formatted_get(Eo *obj EINA_UNUSED,
154 Ecordova_ContactAddress_Data *pd EINA_UNUSED)
155{
156 // TODO: mount the formatted address
157 ERR("%s", "Not implemented");
158 return NULL;
159}
160
161static void
162_ecordova_contactaddress_formatted_set(Eo *obj EINA_UNUSED,
163 Ecordova_ContactAddress_Data *pd EINA_UNUSED,
164 const char *formatted EINA_UNUSED)
165{
166 ERR("%s", "Not implemented");
167}
168
169static const char *
170_ecordova_contactaddress_street_address_get(Eo *obj EINA_UNUSED,
171 Ecordova_ContactAddress_Data *pd)
172{
173 const char *value = NULL;
174 get_str_p(pd->record, _contacts_address.street, &value);
175 return value;
176}
177
178static void
179_ecordova_contactaddress_street_address_set(Eo *obj EINA_UNUSED,
180 Ecordova_ContactAddress_Data *pd,
181 const char *value)
182{
183 set_str(pd->record, _contacts_address.street, value);
184}
185
186static const char *
187_ecordova_contactaddress_locality_get(Eo *obj EINA_UNUSED,
188 Ecordova_ContactAddress_Data *pd)
189{
190 const char *value = NULL;
191 get_str_p(pd->record, _contacts_address.locality, &value);
192 return value;
193}
194
195static void
196_ecordova_contactaddress_locality_set(Eo *obj EINA_UNUSED,
197 Ecordova_ContactAddress_Data *pd,
198 const char *value)
199{
200 set_str(pd->record, _contacts_address.locality, value);
201}
202
203static const char *
204_ecordova_contactaddress_region_get(Eo *obj EINA_UNUSED,
205 Ecordova_ContactAddress_Data *pd)
206{
207 const char *value = NULL;
208 get_str_p(pd->record, _contacts_address.region, &value);
209 return value;
210}
211
212static void
213_ecordova_contactaddress_region_set(Eo *obj EINA_UNUSED,
214 Ecordova_ContactAddress_Data *pd,
215 const char *value)
216{
217 set_str(pd->record, _contacts_address.region, value);
218}
219
220static const char *
221_ecordova_contactaddress_postal_code_get(Eo *obj EINA_UNUSED,
222 Ecordova_ContactAddress_Data *pd)
223{
224 const char *value = NULL;
225 get_str_p(pd->record, _contacts_address.postal_code, &value);
226 return value;
227}
228
229static void
230_ecordova_contactaddress_postal_code_set(Eo *obj EINA_UNUSED,
231 Ecordova_ContactAddress_Data *pd,
232 const char *value)
233{
234 set_str(pd->record, _contacts_address.postal_code, value);
235}
236
237static const char *
238_ecordova_contactaddress_country_get(Eo *obj EINA_UNUSED,
239 Ecordova_ContactAddress_Data *pd)
240{
241 const char *value = NULL;
242 get_str_p(pd->record, _contacts_address.country, &value);
243 return value;
244}
245
246static void
247_ecordova_contactaddress_country_set(Eo *obj EINA_UNUSED,
248 Ecordova_ContactAddress_Data *pd,
249 const char *value)
250{
251 set_str(pd->record, _contacts_address.country, value);
252}
253
254bool
255ecordova_contactaddress_import(Ecordova_ContactAddress *obj,
256 contacts_record_h child_record)
257{
258 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
259 EINA_SAFETY_ON_NULL_RETURN_VAL(child_record, false);
260
261 Ecordova_ContactAddress_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACTADDRESS_CLASS);
262 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
263
264 int ret = contacts_record_destroy(pd->record, true);
265 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
266 ret = contacts_record_clone(child_record, &pd->record);
267 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
268
269 return get_int(child_record, _contacts_address.id, &pd->id);
270}
271
272bool
273ecordova_contactaddress_export(Ecordova_ContactAddress *obj,
274 contacts_record_h contacts_record)
275{
276 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
277 EINA_SAFETY_ON_NULL_RETURN_VAL(contacts_record, false);
278
279 Ecordova_ContactAddress_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACTADDRESS_CLASS);
280 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
281
282 contacts_record_h child_record = NULL;
283 int ret = contacts_record_clone(pd->record, &child_record);
284 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
285
286 ret = contacts_record_add_child_record(contacts_record,
287 _contacts_contact.address,
288 child_record);
289 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, false);
290
291 return true;
292}
293
294Ecordova_ContactAddress *
295ecordova_contactaddress_clone(Ecordova_ContactAddress *other)
296{
297 Ecordova_ContactAddress *cloned = eo_add(ECORDOVA_CONTACTADDRESS_CLASS, NULL);
298
299 Ecordova_ContactAddress_Data *cloned_pd = eo_data_scope_get(cloned, ECORDOVA_CONTACTADDRESS_CLASS);
300 EINA_SAFETY_ON_NULL_RETURN_VAL(cloned_pd, NULL);
301 Ecordova_ContactAddress_Data *other_pd = eo_data_scope_get(other, ECORDOVA_CONTACTADDRESS_CLASS);
302 EINA_SAFETY_ON_NULL_RETURN_VAL(other_pd, NULL);
303
304 int ret = contacts_record_destroy(cloned_pd->record, true);
305 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
306 ret = contacts_record_clone(other_pd->record, &cloned_pd->record);
307 EINA_SAFETY_ON_FALSE_RETURN_VAL(CONTACTS_ERROR_NONE == ret, NULL);
308
309 return cloned;
310}
311
312#include "ecordova_contactaddress.eo.c"
diff --git a/src/lib/ecordova/ecordova_contactaddress.eo b/src/lib/ecordova/ecordova_contactaddress.eo
new file mode 100644
index 0000000000..ee5a9efef9
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contactaddress.eo
@@ -0,0 +1,93 @@
1class Ecordova.ContactAddress (Eo.Base) {
2 [[Contains information about a single contact.]]
3 legacy_prefix: null;
4 methods {
5 constructor {
6 [[Custom Ecordova_ContactAddress constructor.
7 @.constructor
8
9 @since 2.3
10 ]]
11 params {
12 pref: bool;
13 [[user's preferred value.]]
14
15 type: const(char)*;
16 [[A string indicating what type of field this is, home for
17 example.
18 ]]
19
20 formatted: const(char)*;
21 [[The full address formatted for display.]]
22
23 street_address: const(char)*;
24 [[The full street address.]]
25
26 locality: const(char)*;
27 [[The city or locality.]]
28
29 region: const(char)*;
30 [[The state or region.]]
31
32 postal_code: const(char)*;
33 [[The zip code or postal code.]]
34
35 country: const(char)*;
36 [[The country name.]]
37 }
38 }
39 @property id {
40 get {}
41 values {
42 id: int;
43 }
44 }
45 @property pref {
46 values {
47 preferred: bool;
48 }
49 }
50 @property type {
51 values {
52 type: const(char)*;
53 }
54 }
55 @property formatted {
56 values {
57 formatted: const(char)*;
58 }
59 }
60 @property street_address {
61 values {
62 street_address: const(char)*;
63 }
64 }
65 @property locality {
66 values {
67 locality: const(char)*;
68 }
69 }
70 @property region {
71 values {
72 region: const(char)*;
73 }
74 }
75 @property postal_code {
76 values {
77 postal_code: const(char)*;
78 }
79 }
80 @property country {
81 values {
82 country: const(char)*;
83 }
84 }
85 }
86 implements {
87 Eo.Base.constructor;
88 Eo.Base.destructor;
89 }
90 constructors {
91 .constructor;
92 }
93}
diff --git a/src/lib/ecordova/ecordova_contactaddress_private.h b/src/lib/ecordova/ecordova_contactaddress_private.h
new file mode 100644
index 0000000000..56715d34f1
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contactaddress_private.h
@@ -0,0 +1,25 @@
1#ifndef _ECORDOVA_CONTACTADDRESS_PRIVATE_H
2#define _ECORDOVA_CONTACTADDRESS_PRIVATE_H
3
4#include "ecordova_private.h"
5#include "ecordova_contactaddress.eo.h"
6
7#include <contacts.h>
8
9typedef struct _Ecordova_ContactAddress_Data Ecordova_ContactAddress_Data;
10
11/**
12 * Ecordova.ContactAddress private data
13 */
14struct _Ecordova_ContactAddress_Data
15{
16 Eo *obj;
17 int id;
18 contacts_record_h record;
19};
20
21bool ecordova_contactaddress_import(Ecordova_ContactAddress *, contacts_record_h);
22bool ecordova_contactaddress_export(Ecordova_ContactAddress *, contacts_record_h);
23Ecordova_ContactAddress *ecordova_contactaddress_clone(Ecordova_ContactAddress *);
24
25#endif
diff --git a/src/lib/ecordova/ecordova_contactfield.c b/src/lib/ecordova/ecordova_contactfield.c
new file mode 100644
index 0000000000..8397a1944d
--- /dev/null
+++ b/src/lib/ecordova/ecordova_contactfield.c
@@ -0,0 +1,415 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecordova_contactfield_private.h"
6#include "ecordova_contacts_record_utils.h"
7
8#include <stdbool.h>
9#include <stdint.h>
10#include <stdlib.h>
11
12#define MY_CLASS ECORDOVA_CONTACTFIELD_CLASS
13#define MY_CLASS_NAME "Ecordova_ContactField"
14
15static Eo_Base *
16_ecordova_contactfield_eo_base_constructor(Eo *obj,
17 Ecordova_ContactField_Data *pd)
18{
19 DBG("(%p)", obj);
20
21 pd->obj = obj;
22
23 return eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
24}
25
26static void
27_ecordova_contactfield_constructor(Eo *obj,
28 Ecordova_ContactField_Data *pd,
29 const char *type,
30 const char *value,
31 Eina_Bool pref)
32{
33 DBG("(%p)", obj);
34 pd->id = 0;
35 pd->type = type ? strdup(type) : NULL;
36 pd->value = value ? strdup(value) : NULL;
37 pd->pref = pref;
38}
39
40static void
41_ecordova_contactfield_eo_base_destructor(Eo *obj,
42 Ecordova_ContactField_Data *pd)
43{
44 DBG("(%p)", obj);
45
46 free(pd->type);
47 free(pd->value);
48
49 eo_do_super(obj, MY_CLASS, eo_destructor());
50}
51
52static int
53_ecordova_contactfield_id_get(Eo *obj EINA_UNUSED,
54 Ecordova_ContactField_Data *pd)
55{
56 return pd->id;
57}
58
59static const char *
60_ecordova_contactfield_type_get(Eo *obj EINA_UNUSED,
61 Ecordova_ContactField_Data *pd)
62{
63 return pd->type;
64}
65
66static void
67_ecordova_contactfield_type_set(Eo *obj EINA_UNUSED,
68 Ecordova_ContactField_Data *pd,
69 const char *type)
70{
71 free(pd->type);
72 pd->type = type ? strdup(type) : NULL;
73}
74
75static const char *
76_ecordova_contactfield_value_get(Eo *obj EINA_UNUSED,
77 Ecordova_ContactField_Data *pd)
78{
79 return pd->value;
80}
81
82static void
83_ecordova_contactfield_value_set(Eo *obj EINA_UNUSED,
84 Ecordova_ContactField_Data *pd,
85 const char *value)
86{
87 free(pd->value);
88 pd->value = value ? strdup(value) : NULL;
89}
90
91static Eina_Bool
92_ecordova_contactfield_pref_get(Eo *obj EINA_UNUSED,
93 Ecordova_ContactField_Data *pd)
94{
95 return pd->pref;
96}
97
98static void
99_ecordova_contactfield_pref_set(Eo *obj EINA_UNUSED,
100 Ecordova_ContactField_Data *pd,
101 Eina_Bool pref)
102{
103 pd->pref = pref;
104}
105
106bool
107ecordova_contactfield_import(Ecordova_ContactField *obj,
108 contacts_record_h record,
109 const Ecordova_ContactField_Metadata metadata)
110{
111 DBG("%p", obj);
112 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
113 EINA_SAFETY_ON_NULL_RETURN_VAL(record, false);
114
115 Ecordova_ContactField_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACTFIELD_CLASS);
116 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
117
118 int type = 0;
119 const char* label = NULL;
120 if (!get_int(record,
121 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_TYPE],
122 &type) ||
123 !get_str_p(record,
124 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_LABEL],
125 &label))
126 return false;
127
128 pd->type = metadata.type2label(type, label);
129
130 if (!get_int(record,
131 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_ID],
132 &pd->id) ||
133 !get_str(record,
134 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_VALUE],
135 &pd->value))
136 return false;
137
138 if (metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_PREF] &&
139 !get_bool(record,
140 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_PREF],
141 &pd->pref))
142 return false;
143
144 return true;
145}
146
147bool
148ecordova_contactfield_export(Ecordova_ContactField *obj,
149 contacts_record_h record,
150 const Ecordova_ContactField_Metadata metadata)
151{
152 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, false);
153 EINA_SAFETY_ON_NULL_RETURN_VAL(record, false);
154
155 Ecordova_ContactField_Data *pd = eo_data_scope_get(obj, ECORDOVA_CONTACTFIELD_CLASS);
156 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, false);
157
158 int type = metadata.label2type(pd->type);
159 if (!set_int(record,
160 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_TYPE],
161 type))
162 return false;
163
164 if (pd->type &&
165 !set_str(record,
166 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_LABEL],
167 pd->type))
168 return false;
169
170 if (!set_str(record,
171 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_VALUE],
172 pd->value))
173 return false;
174
175 if (metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_PREF] &&
176 !set_bool(record,
177 *metadata.ids[ECORDOVA_CONTACTFIELD_PROPERTY_PREF],
178 pd->pref))
179 return false;
180
181 return true;
182}
183
184char *
185ecordova_contactnumber_type2label(int type, const char *custom)
186{
187 switch (type)
188 {
189 case CONTACTS_NUMBER_TYPE_HOME:
190 return strdup("Home");
191 case CONTACTS_NUMBER_TYPE_WORK:
192 return strdup("Work");
193 case CONTACTS_NUMBER_TYPE_VOICE:
194 return strdup("Voice");
195 case CONTACTS_NUMBER_TYPE_FAX:
196 return strdup("Fax");
197 case CONTACTS_NUMBER_TYPE_MSG:
198 return strdup("Msg");
199 case CONTACTS_NUMBER_TYPE_CELL:
200 return strdup("Cell");
201 case CONTACTS_NUMBER_TYPE_PAGER:
202 return strdup("Pager");
203 case CONTACTS_NUMBER_TYPE_BBS:
204 return strdup("BBS");
205 case CONTACTS_NUMBER_TYPE_MODEM:
206 return strdup("Modem");
207 case CONTACTS_NUMBER_TYPE_CAR:
208 return strdup("Car");
209 case CONTACTS_NUMBER_TYPE_ISDN:
210 return strdup("ISDN");
211 case CONTACTS_NUMBER_TYPE_VIDEO:
212 return strdup("Video");
213 case CONTACTS_NUMBER_TYPE_PCS:
214 return strdup("Pcs");
215 case CONTACTS_NUMBER_TYPE_COMPANY_MAIN:
216 return strdup("Company_Main");
217 case CONTACTS_NUMBER_TYPE_RADIO:
218 return strdup("Radio");
219 case CONTACTS_NUMBER_TYPE_MAIN:
220 return strdup("Main");
221 case CONTACTS_NUMBER_TYPE_ASSISTANT:
222 return strdup("Assistant");
223 case CONTACTS_NUMBER_TYPE_OTHER:
224 case CONTACTS_NUMBER_TYPE_CUSTOM:
225 default:
226 if (custom)
227 return strdup(custom);
228 return NULL;
229 }
230}
231
232int
233ecordova_contactnumber_label2type(const char *label)
234{
235 if (!label)
236 return CONTACTS_NUMBER_TYPE_OTHER;
237 if (strcasecmp(label, "Home") == 0)
238 return CONTACTS_NUMBER_TYPE_HOME;
239 if (strcasecmp(label, "Work") == 0)
240 return CONTACTS_NUMBER_TYPE_WORK;
241 if (strcasecmp(label, "Voice") == 0)
242 return CONTACTS_NUMBER_TYPE_VOICE;
243 if (strcasecmp(label, "Fax") == 0)
244 return CONTACTS_NUMBER_TYPE_FAX;
245 if (strcasecmp(label, "Msg") == 0)
246 return CONTACTS_NUMBER_TYPE_MSG;
247 if (strcasecmp(label, "Cell") == 0)
248 return CONTACTS_NUMBER_TYPE_CELL;
249 if (strcasecmp(label, "Pager") == 0)
250 return CONTACTS_NUMBER_TYPE_PAGER;
251 if (strcasecmp(label, "BBS") == 0)
252 return CONTACTS_NUMBER_TYPE_BBS;
253 if (strcasecmp(label, "Modem") == 0)
254 return CONTACTS_NUMBER_TYPE_MODEM;
255 if (strcasecmp(label, "Car") == 0)
256 return CONTACTS_NUMBER_TYPE_CAR;
257 if (strcasecmp(label, "ISDN") == 0)
258 return CONTACTS_NUMBER_TYPE_ISDN;
259 if (strcasecmp(label, "Video") == 0)
260 return CONTACTS_NUMBER_TYPE_VIDEO;
261 if (strcasecmp(label, "Pcs") == 0)
262 return CONTACTS_NUMBER_TYPE_PCS;
263 if (strcasecmp(label, "Company_Main") == 0)
264 return CONTACTS_NUMBER_TYPE_COMPANY_MAIN;
265 if (strcasecmp(label, "Radio") == 0)
266 return CONTACTS_NUMBER_TYPE_RADIO;
267 if (strcasecmp(label, "Main") == 0)
268 return CONTACTS_NUMBER_TYPE_MAIN;
269 if (strcasecmp(label, "Assistant") == 0)
270 return CONTACTS_NUMBER_TYPE_ASSISTANT;
271
272 return CONTACTS_NUMBER_TYPE_CUSTOM;
273}
274
275char *
276ecordova_contactemail_type2label(int type, const char *custom)
277{
278 switch (type)
279 {
280 case CONTACTS_EMAIL_TYPE_HOME:
281 return strdup("Home");
282 case CONTACTS_EMAIL_TYPE_WORK:
283 return strdup("Work");
284 case CONTACTS_EMAIL_TYPE_MOBILE:
285 return strdup("Mobile");
286 case CONTACTS_EMAIL_TYPE_OTHER:
287 case CONTACTS_EMAIL_TYPE_CUSTOM:
288 default:
289 if (custom)
290 return strdup(custom);
291 return NULL;
292 }
293}
294
295int
296ecordova_contactemail_label2type(const char *label)
297{
298 if (!label)
299 return CONTACTS_EMAIL_TYPE_OTHER;
300 if (strcasecmp(label, "Home") == 0)
301 return CONTACTS_EMAIL_TYPE_HOME;
302 if (strcasecmp(label, "Work") == 0)
303 return CONTACTS_EMAIL_TYPE_WORK;
304 if (strcasecmp(label, "Mobile") == 0)
305 return CONTACTS_EMAIL_TYPE_MOBILE;
306
307 return CONTACTS_EMAIL_TYPE_CUSTOM;
308}
309
310char *
311ecordova_contactmessenger_type2label(int type, const char *custom)
312{
313 switch (type)
314 {
315 case CONTACTS_MESSENGER_TYPE_GOOGLE:
316 return strdup("Google");
317 case CONTACTS_MESSENGER_TYPE_WLM:
318 return strdup("Wlm");
319 case CONTACTS_MESSENGER_TYPE_YAHOO:
320 return strdup("Yahoo");
321 case CONTACTS_MESSENGER_TYPE_FACEBOOK:
322 return strdup("Facebook");
323 case CONTACTS_MESSENGER_TYPE_ICQ:
324 return strdup("Icq");
325 case CONTACTS_MESSENGER_TYPE_AIM:
326 return strdup("Aim");
327 case CONTACTS_MESSENGER_TYPE_QQ:
328 return strdup("Qq");
329 case CONTACTS_MESSENGER_TYPE_JABBER:
330 return strdup("Jabber");
331 case CONTACTS_MESSENGER_TYPE_SKYPE:
332 return strdup("Skype");
333 case CONTACTS_MESSENGER_TYPE_IRC:
334 return strdup("IRC");
335 case CONTACTS_MESSENGER_TYPE_OTHER:
336 case CONTACTS_MESSENGER_TYPE_CUSTOM:
337 default:
338 if (custom)
339 return strdup(custom);
340 return NULL;
341 }
342}
343
344int
345ecordova_contactmessenger_label2type(const char *label)
346{
347 if (!label)
348 return CONTACTS_MESSENGER_TYPE_OTHER;
349 if (strcasecmp(label, "Google") == 0)
350 return CONTACTS_MESSENGER_TYPE_GOOGLE;
351 if (strcasecmp(label, "Wlm") == 0)
352 return CONTACTS_MESSENGER_TYPE_WLM;
353 if (strcasecmp(label, "Yahoo") == 0)
354 return CONTACTS_MESSENGER_TYPE_YAHOO;
355 if (strcasecmp(label, "Facebook") == 0)
356 return CONTACTS_MESSENGER_TYPE_FACEBOOK;
357 if (strcasecmp(label, "Icq") == 0)
358 return CONTACTS_MESSENGER_TYPE_ICQ;
359 if (strcasecmp(label, "Aim") == 0)
360 return CONTACTS_MESSENGER_TYPE_AIM;
361 if (strcasecmp(label, "Qq") == 0)
362 return CONTACTS_MESSENGER_TYPE_QQ;
363 if (strcasecmp(label, "Jabber") == 0)
364 return CONTACTS_MESSENGER_TYPE_JABBER;
365 if (strcasecmp(label, "Skype") == 0)
366 return CONTACTS_MESSENGER_TYPE_SKYPE;
367 if (strcasecmp(label, "IRC") == 0)
368 return CONTACTS_MESSENGER_TYPE_IRC;
369
370 return CONTACTS_MESSENGER_TYPE_CUSTOM;
371}
372
373char *
374ecordova_contactimage_type2label(int type EINA_UNUSED, const char *custom)
375{
376 return custom ? strdup(custom) : NULL;
377}
378
379int
380ecordova_contactimage_label2type(const char *label EINA_UNUSED)
381{
382 return 0;