aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-11-05 16:00:40 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-11-05 16:00:40 -0200
commitf60f3595144090a6b5615db52ac5712692bafabb (patch)
tree743b043676b5611b4bfa918453a804c9e6815d59
parentecordova: Fixed contacts dlsym (diff)
downloadefl-devs/felipealmeida/ecordova.tar.gz
ecordova: dlsym for sensordevs/felipealmeida/ecordova
-rw-r--r--src/modules/ecordova/tizen/ecordova_contacts_service.h34
-rw-r--r--src/modules/ecordova/tizen/ecordova_device.c5
-rw-r--r--src/modules/ecordova/tizen/ecordova_devicemotion.c3
-rw-r--r--src/modules/ecordova/tizen/ecordova_devicemotion_private.h3
-rw-r--r--src/modules/ecordova/tizen/ecordova_deviceorientation.c2
-rw-r--r--src/modules/ecordova/tizen/ecordova_deviceorientation_private.h3
-rw-r--r--src/modules/ecordova/tizen/ecordova_sensor.c57
-rw-r--r--src/modules/ecordova/tizen/ecordova_sensor.h69
-rw-r--r--src/modules/ecordova/tizen/ecordova_tizen.c34
-rw-r--r--src/modules/ecordova/tizen/ecordova_tizen.h55
-rw-r--r--src/tests/ecordova/ecordova_devicemotion_test.c7
-rw-r--r--src/tests/ecordova/ecordova_deviceorientation_test.c2
12 files changed, 217 insertions, 57 deletions
diff --git a/src/modules/ecordova/tizen/ecordova_contacts_service.h b/src/modules/ecordova/tizen/ecordova_contacts_service.h
index 524615836e..e4274698b0 100644
--- a/src/modules/ecordova/tizen/ecordova_contacts_service.h
+++ b/src/modules/ecordova/tizen/ecordova_contacts_service.h
@@ -5,7 +5,7 @@
#include <errno.h>
#include <stdlib.h>
-#define CONTACTS_API
+#include "ecordova_tizen.h"
struct __contacts_record_h;
typedef struct __contacts_record_h* contacts_record_h;
@@ -42,7 +42,7 @@ typedef struct __contacts_query_h* contacts_query_h;
#define _CONTACTS_PROPERTY_PROJECTION_LLI(property_id_name) unsigned int property_id_name;
#define _CONTACTS_END_VIEW(name) \
} name##_property_ids; \
- extern CONTACTS_API const name##_property_ids* name;
+ extern const name##_property_ids* name;
#define _CONTACTS_END_READ_ONLY_VIEW(name) _CONTACTS_END_VIEW(name)
_CONTACTS_BEGIN_VIEW()
@@ -339,36 +339,6 @@ extern int (*contacts_query_destroy)(contacts_query_h query);
typedef struct _Ecordova_Contact_Data Ecordova_Contact_Data;
-/* Check if slp error or not */
-#define TIZEN_ERROR_MIN_PLATFORM_ERROR (-1073741824LL) /* = -2147483648 / 2 */
-/* Tizen Contacts Error */
-#define TIZEN_ERROR_CONTACTS -0x02010000
-
-/**
- * @brief Enumeration for tizen errors.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- *
-*/
-typedef enum
-{
- TIZEN_ERROR_NONE = 0, /**< Successful */
- TIZEN_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of memory */
- TIZEN_ERROR_INVALID_PARAMETER = -EINVAL, /**< Invalid function parameter */
- TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE = -ENOSPC, /**< No space left on device */
- TIZEN_ERROR_PERMISSION_DENIED = -EACCES, /**< Permission denied */
- TIZEN_ERROR_NO_DATA = -ENODATA, /**< No data available */
-
- TIZEN_ERROR_UNKNOWN = TIZEN_ERROR_MIN_PLATFORM_ERROR, /**< Unknown error */
-
- /* This is a place to add new errors here.
- * Do not assign integer values explicitly. Values are auto-assigned.
- */
- TIZEN_ERROR_TIMED_OUT, /**< Time out */
- TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
- TIZEN_ERROR_USER_NOT_CONSENTED, /**< Not Consented */
- TIZEN_ERROR_END_OF_COLLECTION,
-} tizen_error_e;
-
typedef enum
{
/* GENERAL */
diff --git a/src/modules/ecordova/tizen/ecordova_device.c b/src/modules/ecordova/tizen/ecordova_device.c
index f60a9aa5ac..90a2f5ec16 100644
--- a/src/modules/ecordova/tizen/ecordova_device.c
+++ b/src/modules/ecordova/tizen/ecordova_device.c
@@ -3,9 +3,7 @@
#endif
#include "ecordova_device_private.h"
-
-#ifdef HAVE_TIZEN_INFO
-#include <system/system_info.h>
+#include "ecordova_tizen.h"
#define MY_CLASS ECORDOVA_DEVICE_CLASS
#define MY_CLASS_NAME "Ecordova_Device"
@@ -99,4 +97,3 @@ _ecordova_device_version_get(Eo *obj EINA_UNUSED, Ecordova_Device_Data *pd)
}
#include "ecordova_device.eo.c"
-#endif
diff --git a/src/modules/ecordova/tizen/ecordova_devicemotion.c b/src/modules/ecordova/tizen/ecordova_devicemotion.c
index a5344c04b6..99e4afa461 100644
--- a/src/modules/ecordova/tizen/ecordova_devicemotion.c
+++ b/src/modules/ecordova/tizen/ecordova_devicemotion.c
@@ -2,7 +2,6 @@
# include <config.h>
#endif
-#ifdef HAVE_TIZEN_SENSOR
#include "ecordova_devicemotion_private.h"
#define MY_CLASS ECORDOVA_DEVICEMOTION_CLASS
@@ -168,4 +167,4 @@ _hash_data_free(sensor_listener_h listener)
}
#include "ecordova_devicemotion.eo.c"
-#endif
+
diff --git a/src/modules/ecordova/tizen/ecordova_devicemotion_private.h b/src/modules/ecordova/tizen/ecordova_devicemotion_private.h
index fb75f4d810..36d4574191 100644
--- a/src/modules/ecordova/tizen/ecordova_devicemotion_private.h
+++ b/src/modules/ecordova/tizen/ecordova_devicemotion_private.h
@@ -2,8 +2,7 @@
#define _ECORDOVA_DEVICEMOTION_PRIVATE_H
#include "ecordova_private.h"
-
-#include <sensor.h>
+#include "ecordova_sensor.h"
typedef struct _Ecordova_DeviceMotion_Data Ecordova_DeviceMotion_Data;
diff --git a/src/modules/ecordova/tizen/ecordova_deviceorientation.c b/src/modules/ecordova/tizen/ecordova_deviceorientation.c
index b3592f2589..8ba7f51acd 100644
--- a/src/modules/ecordova/tizen/ecordova_deviceorientation.c
+++ b/src/modules/ecordova/tizen/ecordova_deviceorientation.c
@@ -2,7 +2,6 @@
# include <config.h>
#endif
-#ifdef HAVE_TIZEN_SENSOR
#include "ecordova_deviceorientation_private.h"
#define MY_CLASS ECORDOVA_DEVICEORIENTATION_CLASS
@@ -172,4 +171,3 @@ _hash_data_free(sensor_listener_h listener)
}
#include "ecordova_deviceorientation.eo.c"
-#endif
diff --git a/src/modules/ecordova/tizen/ecordova_deviceorientation_private.h b/src/modules/ecordova/tizen/ecordova_deviceorientation_private.h
index a2f1c6dfea..055f538459 100644
--- a/src/modules/ecordova/tizen/ecordova_deviceorientation_private.h
+++ b/src/modules/ecordova/tizen/ecordova_deviceorientation_private.h
@@ -2,8 +2,7 @@
#define _ECORDOVA_DEVICEORIENTATION_PRIVATE_H
#include "ecordova_private.h"
-
-#include <sensor.h>
+#include "ecordova_sensor.h"
typedef struct _Ecordova_DeviceOrientation_Data Ecordova_DeviceOrientation_Data;
diff --git a/src/modules/ecordova/tizen/ecordova_sensor.c b/src/modules/ecordova/tizen/ecordova_sensor.c
new file mode 100644
index 0000000000..acc38f65f6
--- /dev/null
+++ b/src/modules/ecordova/tizen/ecordova_sensor.c
@@ -0,0 +1,57 @@
+
+#include "ecordova_sensor.h"
+
+int (*sensor_listener_start)(sensor_listener_h listener) = 0;
+int (*sensor_listener_read_data)(sensor_listener_h listener, sensor_event_s *event) = 0;
+int (*sensor_destroy_listener)(sensor_listener_h listener) = 0;
+int (*sensor_listener_set_event_cb)(sensor_listener_h listener, unsigned int interval_ms, sensor_event_cb callback, void *data) = 0;
+int (*sensor_get_default_sensor)(sensor_type_e type, sensor_h *sensor) = 0;
+int (*sensor_create_listener)(sensor_h sensor, sensor_listener_h *listener) = 0;
+
+static void* system_sensor_lib = 0;
+
+void ecordova_sensor_shutdown()
+{
+ if(sensor_lib)
+ dlclose(sensor_lib);
+ sensor_listener_start = NULL;
+ sensor_listener_read_data = NULL;
+ sensor_destroy_listener = NULL;
+ sensor_listener_set_event_cb = NULL;
+ sensor_get_default_sensor = NULL;
+ sensor_create_listener = NULL;
+}
+
+void ecordova_sensor_init()
+{
+ if(!sensor_lib)
+ {
+ sensor_lib = dlopen("capi-system-sensor.so", RTLD_NOW);
+ if(!sensor_lib)
+ goto on_error;
+ sensor_listener_start = dlsym(sensor_lib, "sensor_listener_start");
+ if(!sensor_listener_start)
+ goto on_error;
+ sensor_listener_read_data = dlsym(sensor_lib, "sensor_listener_read_data");
+ if(!sensor_listener_read_data)
+ goto on_error;
+ sensor_destroy_listener = dlsym(sensor_lib, "sensor_destroy_listener");
+ if(!sensor_destroy_listener)
+ goto on_error;
+ sensor_listener_set_event_cb = dlsym(sensor_lib, "sensor_listener_set_event_cb");
+ if(!sensor_listener_set_event_cb)
+ goto on_error;
+ sensor_get_default_sensor = dlsym(sensor_lib, "sensor_get_default_sensor");
+ if(!sensor_get_default_sensor)
+ goto on_error;
+ sensor_create_listener = dlsym(sensor_lib, "sensor_create_listener");
+ if(!sensor_create_listener)
+ goto on_error;
+ }
+
+ return;
+on_error:
+ ecordova_sensor_shutdown();
+}
+
+
diff --git a/src/modules/ecordova/tizen/ecordova_sensor.h b/src/modules/ecordova/tizen/ecordova_sensor.h
new file mode 100644
index 0000000000..1d39a05c37
--- /dev/null
+++ b/src/modules/ecordova/tizen/ecordova_sensor.h
@@ -0,0 +1,69 @@
+#ifndef ECORDOVA_SENSOR_H
+#define ECORDOVA_SENSOR_H
+
+#include "ecordova_tizen.h"
+
+#define MAX_VALUE_SIZE 16
+
+typedef void* sensor_h;
+typedef void* sensor_listener_h;
+
+typedef struct
+{
+ int accuracy; /**< Accuracy */
+ unsigned long long timestamp; /**< Timestamp */
+ int value_count; /**< Count of values */
+ float values[MAX_VALUE_SIZE]; /**< Sensor values */
+} sensor_event_s;
+
+typedef enum
+{
+ SENSOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ SENSOR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ SENSOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ SENSOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported sensor in the current device */
+ SENSOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ SENSOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ SENSOR_ERROR_NOT_NEED_CALIBRATION = TIZEN_ERROR_SENSOR | 0x03, /**< Sensor doesn't need calibration */
+ SENSOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_SENSOR | 0x06, /**< Operation failed */
+} sensor_error_e;
+
+typedef enum
+{
+ SENSOR_ALL = -1, /**< All sensors */
+ SENSOR_ACCELEROMETER, /**< Accelerometer */
+ SENSOR_GRAVITY, /**< Gravity sensor */
+ SENSOR_LINEAR_ACCELERATION, /**< Linear acceleration sensor */
+ SENSOR_MAGNETIC, /**< Magnetic sensor */
+ SENSOR_ROTATION_VECTOR, /**< Rotation Vector sensor */
+ SENSOR_ORIENTATION, /**< Orientation sensor */
+ SENSOR_GYROSCOPE, /**< Gyroscope sensor */
+ SENSOR_LIGHT, /**< Light sensor */
+ SENSOR_PROXIMITY, /**< Proximity sensor */
+ SENSOR_PRESSURE, /**< Pressure sensor */
+ SENSOR_ULTRAVIOLET, /**< Ultraviolet sensor */
+ SENSOR_TEMPERATURE, /**< Temperature sensor */
+ SENSOR_HUMIDITY, /**< Humidity sensor */
+ SENSOR_HRM, /**< Heart Rate Monitor sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_GREEN, /**< HRM (LED Green) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_IR, /**< HRM (LED IR) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_RED, /**< HRM (LED RED) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_GYROSCOPE_UNCALIBRATED, /**< Uncalibrated Gyroscope sensor (Since Tizen 2.4) */
+ SENSOR_GEOMAGNETIC_UNCALIBRATED, /**< Uncalibrated Geomagnetic sensor (Since Tizen 2.4) */
+ SENSOR_GYROSCOPE_ROTATION_VECTOR, /**< Gyroscope-based rotation vector sensor (Since Tizen 2.4) */
+ SENSOR_GEOMAGNETIC_ROTATION_VECTOR, /**< Geomagnetic-based rotation vector sensor (Since Tizen 2.4) */
+ SENSOR_LAST, /**< End of sensor enum values */
+ SENSOR_CUSTOM = 10000 /**< Custom sensor */
+} sensor_type_e;
+
+typedef void (*sensor_event_cb)(sensor_h sensor, sensor_event_s *event, void *data);
+
+extern int (*sensor_listener_start)(sensor_listener_h listener);
+extern int (*sensor_listener_read_data)(sensor_listener_h listener, sensor_event_s *event);
+extern int (*sensor_destroy_listener)(sensor_listener_h listener);
+extern int (*sensor_listener_set_event_cb)(sensor_listener_h listener, unsigned int interval_ms, sensor_event_cb callback, void *data);
+extern int (*sensor_get_default_sensor)(sensor_type_e type, sensor_h *sensor);
+extern int (*sensor_create_listener)(sensor_h sensor, sensor_listener_h *listener);
+
+
+#endif
diff --git a/src/modules/ecordova/tizen/ecordova_tizen.c b/src/modules/ecordova/tizen/ecordova_tizen.c
index f496580119..e3de602f2a 100644
--- a/src/modules/ecordova/tizen/ecordova_tizen.c
+++ b/src/modules/ecordova/tizen/ecordova_tizen.c
@@ -3,17 +3,17 @@
#endif
#include <Ecore.h>
+#include <dlfcn.h>
int _ecordova_log_dom;
-#define CRI(...) EINA_LOG_DOM_CRIT(_ecordova_log_dom, __VA_ARGS__)
-#define ERR(...) EINA_LOG_DOM_ERR(_ecordova_log_dom, __VA_ARGS__)
-#define WRN(...) EINA_LOG_DOM_WARN(_ecordova_log_dom, __VA_ARGS__)
-#define INF(...) EINA_LOG_DOM_INFO(_ecordova_log_dom, __VA_ARGS__)
-#define DBG(...) EINA_LOG_DOM_DBG(_ecordova_log_dom, __VA_ARGS__)
+int (*system_info_get_platform_string)(const char *key, char **value);
+static void* system_info_lib = 0;
void ecordova_contacts_service_init();
void ecordova_contacts_service_shutdown();
+void ecordova_sensor_init();
+void ecordova_sensor_shutdown();
static Eina_Bool
_ecordova_tizen_init(void)
@@ -26,6 +26,19 @@ _ecordova_tizen_init(void)
}
ecordova_contacts_service_init();
+
+ if(!system_info_lib)
+ {
+ system_info_lib = dlopen("capi-system-info", RTLD_NOW);
+ if(system_info_lib)
+ {
+ system_info_get_platform_string = dlsym(system_info_lib, "system_info_get_platform_string");
+ if(!system_info_get_platform_string)
+ dlclose(system_info_lib);
+ }
+ }
+
+ ecordova_sensor_init();
return EINA_TRUE;
}
@@ -33,9 +46,16 @@ _ecordova_tizen_init(void)
static void
_ecordova_tizen_shutdown(void)
{
- ecordova_contacts_service_shutdown();
+ ecordova_sensor_shutdown();
+
+ if(system_info_lib)
+ dlclose(system_info_lib);
+
+ system_info_get_platform_string = 0;
+
+ ecordova_contacts_service_shutdown();
- eina_log_domain_unregister(_ecordova_log_dom);
+ eina_log_domain_unregister(_ecordova_log_dom);
_ecordova_log_dom = -1;
}
diff --git a/src/modules/ecordova/tizen/ecordova_tizen.h b/src/modules/ecordova/tizen/ecordova_tizen.h
new file mode 100644
index 0000000000..f2fa676a77
--- /dev/null
+++ b/src/modules/ecordova/tizen/ecordova_tizen.h
@@ -0,0 +1,55 @@
+#ifndef ECORDOVA_TIZEN_H
+#define ECORDOVA_TIZEN_H
+
+extern int _ecordova_log_dom;
+
+#define CRI(...) EINA_LOG_DOM_CRIT(_ecordova_log_dom, __VA_ARGS__)
+#define ERR(...) EINA_LOG_DOM_ERR(_ecordova_log_dom, __VA_ARGS__)
+#define WRN(...) EINA_LOG_DOM_WARN(_ecordova_log_dom, __VA_ARGS__)
+#define INF(...) EINA_LOG_DOM_INFO(_ecordova_log_dom, __VA_ARGS__)
+#define DBG(...) EINA_LOG_DOM_DBG(_ecordova_log_dom, __VA_ARGS__)
+
+extern int (*system_info_get_platform_string)(const char *key, char **value);
+
+/* Check if slp error or not */
+#define TIZEN_ERROR_MIN_PLATFORM_ERROR (-1073741824LL) /* = -2147483648 / 2 */
+/* Tizen Contacts Error */
+#define TIZEN_ERROR_CONTACTS -0x02010000
+/* Tizen Sensor Error */
+#define TIZEN_ERROR_SENSOR -0x02440000
+
+/**
+ * @brief Enumeration for tizen errors.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+*/
+typedef enum
+{
+ TIZEN_ERROR_NONE = 0, /**< Successful */
+ TIZEN_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of memory */
+ TIZEN_ERROR_INVALID_PARAMETER = -EINVAL, /**< Invalid function parameter */
+ TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE = -ENOSPC, /**< No space left on device */
+ TIZEN_ERROR_PERMISSION_DENIED = -EACCES, /**< Permission denied */
+ TIZEN_ERROR_NO_DATA = -ENODATA, /**< No data available */
+ TIZEN_ERROR_IO_ERROR = -EIO, /**< I/O error */
+
+ TIZEN_ERROR_UNKNOWN = TIZEN_ERROR_MIN_PLATFORM_ERROR, /**< Unknown error */
+
+ /* This is a place to add new errors here.
+ * Do not assign integer values explicitly. Values are auto-assigned.
+ */
+ TIZEN_ERROR_TIMED_OUT, /**< Time out */
+ TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ TIZEN_ERROR_USER_NOT_CONSENTED, /**< Not Consented */
+ TIZEN_ERROR_END_OF_COLLECTION,
+} tizen_error_e;
+
+typedef enum {
+ SYSTEM_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ SYSTEM_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ SYSTEM_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ SYSTEM_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when reading value from system */
+ SYSTEM_INFO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the API */
+} system_info_error_e;
+
+#endif
diff --git a/src/tests/ecordova/ecordova_devicemotion_test.c b/src/tests/ecordova/ecordova_devicemotion_test.c
index c0a2179480..a63ab12848 100644
--- a/src/tests/ecordova/ecordova_devicemotion_test.c
+++ b/src/tests/ecordova/ecordova_devicemotion_test.c
@@ -8,7 +8,6 @@
#include <check.h>
-#ifdef HAVE_TIZEN_CONFIGURATION_MANAGER
static void
_setup(void)
{
@@ -23,6 +22,7 @@ _teardown(void)
ck_assert_int_eq(ret, 0);
}
+#ifdef HAVE_TIZEN_SENSOR
static Ecordova_Device *
_devicemotion_new(void)
{
@@ -92,20 +92,17 @@ ecordova_devicemotion_test(TCase *tc)
#else
START_TEST(devicemotion_fail_load)
{
- ecordova_init();
-
Ecordova_Device *devicemotion
= eo_add(ECORDOVA_DEVICEMOTION_CLASS, NULL);
ck_assert_ptr_eq(devicemotion, NULL);
-
- ecordova_shutdown();
}
END_TEST
void
ecordova_devicemotion_test(TCase *tc)
{
+ tcase_add_checked_fixture(tc, _setup, _teardown);
tcase_add_test(tc, devicemotion_fail_load);
}
#endif
diff --git a/src/tests/ecordova/ecordova_deviceorientation_test.c b/src/tests/ecordova/ecordova_deviceorientation_test.c
index 4e3d4059e0..1c41b708ce 100644
--- a/src/tests/ecordova/ecordova_deviceorientation_test.c
+++ b/src/tests/ecordova/ecordova_deviceorientation_test.c
@@ -22,7 +22,7 @@ _teardown(void)
ck_assert_int_eq(ret, 0);
}
-#ifdef HAVE_TIZEN_CONFIGURATION_MANAGER
+#ifdef HAVE_TIZEN_SENSOR
static Ecordova_Device *
_deviceorientation_new(void)
{