From 4279e3e2ae97d7730e4f865d6ec27355571a91e6 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 10 May 2017 17:55:21 +0900 Subject: [PATCH] sensord: add privilege part to URI format - http:///sensor/// Change-Id: I10601f8f95fdb693dd02d047e2228c59e81e5dcd Signed-off-by: kibak.yoon --- src/client/sensor_provider.cpp | 4 + src/sensor/auto_rotation/auto_rotation_sensor.cpp | 4 +- src/sensor/gravity/gravity_comp_sensor.cpp | 6 +- src/sensor/gravity/gravity_lowpass_sensor.cpp | 4 +- src/sensor/linear_accel/linear_accel_sensor.cpp | 6 +- src/sensor/orientation/orientation_sensor.cpp | 4 +- src/sensor/rotation_vector/gyro_rv_sensor.cpp | 6 +- src/sensor/rotation_vector/magnetic_rv_sensor.cpp | 6 +- src/sensor/rotation_vector/rv_sensor.cpp | 8 +- src/server/sensor_handler.cpp | 3 + src/shared/sensor_types_private.h | 9 +- src/shared/sensor_utils.cpp | 193 ++++++++++++---------- src/shared/sensor_utils.h | 1 + 13 files changed, 147 insertions(+), 107 deletions(-) diff --git a/src/client/sensor_provider.cpp b/src/client/sensor_provider.cpp index 5d0b1c9..94036e0 100644 --- a/src/client/sensor_provider.cpp +++ b/src/client/sensor_provider.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,9 @@ bool sensor_provider::init(const char *uri) m_sensor.set_min_range(0); m_sensor.set_max_range(1); m_sensor.set_resolution(1); + /* TODO: temporary walkaround */ + const char *priv = sensor::utils::get_privilege(uri); + m_sensor.set_privilege(priv); return true; } diff --git a/src/sensor/auto_rotation/auto_rotation_sensor.cpp b/src/sensor/auto_rotation/auto_rotation_sensor.cpp index 33f1fda..e02cad3 100644 --- a/src/sensor/auto_rotation/auto_rotation_sensor.cpp +++ b/src/sensor/auto_rotation/auto_rotation_sensor.cpp @@ -24,11 +24,11 @@ #include "auto_rotation_alg_emul.h" -#define NAME_SENSOR "http://tizen.org/sensor/auto_rotation/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/auto_rotation/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" static sensor_info2_t sensor_info = { id: 0x1, diff --git a/src/sensor/gravity/gravity_comp_sensor.cpp b/src/sensor/gravity/gravity_comp_sensor.cpp index 9552e74..36b2171 100644 --- a/src/sensor/gravity/gravity_comp_sensor.cpp +++ b/src/sensor/gravity/gravity_comp_sensor.cpp @@ -24,14 +24,14 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/gravity/tizen_complementary" +#define NAME_SENSOR "http://tizen.org/sensor/general/gravity/tizen_complementary" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define SRC_ID_GYRO 0x2 -#define SRC_STR_GYRO "http://tizen.org/sensor/gyroscope" +#define SRC_STR_GYRO "http://tizen.org/sensor/general/gyroscope" #define GRAVITY 9.80665 diff --git a/src/sensor/gravity/gravity_lowpass_sensor.cpp b/src/sensor/gravity/gravity_lowpass_sensor.cpp index bc31ce2..5401934 100644 --- a/src/sensor/gravity/gravity_lowpass_sensor.cpp +++ b/src/sensor/gravity/gravity_lowpass_sensor.cpp @@ -24,11 +24,11 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/gravity/tizen_lowpass" +#define NAME_SENSOR "http://tizen.org/sensor/general/gravity/tizen_lowpass" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define GRAVITY 9.80665 #define US_PER_SEC 1000000 diff --git a/src/sensor/linear_accel/linear_accel_sensor.cpp b/src/sensor/linear_accel/linear_accel_sensor.cpp index 00e0bb7..2dac280 100644 --- a/src/sensor/linear_accel/linear_accel_sensor.cpp +++ b/src/sensor/linear_accel/linear_accel_sensor.cpp @@ -23,14 +23,14 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/linear_acceleration/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/linear_acceleration/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define SRC_ID_GRAVITY 0x2 -#define SRC_STR_GRAVITY "http://tizen.org/sensor/gravity" +#define SRC_STR_GRAVITY "http://tizen.org/sensor/general/gravity" #define GRAVITY 9.80665 diff --git a/src/sensor/orientation/orientation_sensor.cpp b/src/sensor/orientation/orientation_sensor.cpp index 551c73f..acdf12b 100644 --- a/src/sensor/orientation/orientation_sensor.cpp +++ b/src/sensor/orientation/orientation_sensor.cpp @@ -23,11 +23,11 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/orientation/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/orientation/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_RV 0x1 -#define SRC_STR_RV "http://tizen.org/sensor/rotation_vector" +#define SRC_STR_RV "http://tizen.org/sensor/general/rotation_vector" static sensor_info2_t sensor_info = { id: 0x1, diff --git a/src/sensor/rotation_vector/gyro_rv_sensor.cpp b/src/sensor/rotation_vector/gyro_rv_sensor.cpp index 74e0e27..478e2ee 100644 --- a/src/sensor/rotation_vector/gyro_rv_sensor.cpp +++ b/src/sensor/rotation_vector/gyro_rv_sensor.cpp @@ -23,14 +23,14 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/gyroscope_rotation_vector/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/gyroscope_rotation_vector/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define SRC_ID_GYRO 0x2 -#define SRC_STR_GYRO "http://tizen.org/sensor/gyroscope" +#define SRC_STR_GYRO "http://tizen.org/sensor/general/gyroscope" static sensor_info2_t sensor_info = { id: 0x1, diff --git a/src/sensor/rotation_vector/magnetic_rv_sensor.cpp b/src/sensor/rotation_vector/magnetic_rv_sensor.cpp index 2e4b255..ef438ad 100644 --- a/src/sensor/rotation_vector/magnetic_rv_sensor.cpp +++ b/src/sensor/rotation_vector/magnetic_rv_sensor.cpp @@ -23,14 +23,14 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/geomagnetic_rotation_vector/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/geomagnetic_rotation_vector/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define SRC_ID_MAG 0x3 -#define SRC_STR_MAG "http://tizen.org/sensor/magnetic" +#define SRC_STR_MAG "http://tizen.org/sensor/general/magnetic" static sensor_info2_t sensor_info = { id: 0x1, diff --git a/src/sensor/rotation_vector/rv_sensor.cpp b/src/sensor/rotation_vector/rv_sensor.cpp index e88a004..cb37f42 100644 --- a/src/sensor/rotation_vector/rv_sensor.cpp +++ b/src/sensor/rotation_vector/rv_sensor.cpp @@ -23,17 +23,17 @@ #include #include -#define NAME_SENSOR "http://tizen.org/sensor/rotation_vector/tizen_default" +#define NAME_SENSOR "http://tizen.org/sensor/general/rotation_vector/tizen_default" #define NAME_VENDOR "tizen.org" #define SRC_ID_ACC 0x1 -#define SRC_STR_ACC "http://tizen.org/sensor/accelerometer" +#define SRC_STR_ACC "http://tizen.org/sensor/general/accelerometer" #define SRC_ID_GYRO 0x2 -#define SRC_STR_GYRO "http://tizen.org/sensor/gyroscope" +#define SRC_STR_GYRO "http://tizen.org/sensor/general/gyroscope" #define SRC_ID_MAG 0x3 -#define SRC_STR_MAG "http://tizen.org/sensor/magnetic" +#define SRC_STR_MAG "http://tizen.org/sensor/general/magnetic" static sensor_info2_t sensor_info = { id: 0x1, diff --git a/src/server/sensor_handler.cpp b/src/server/sensor_handler.cpp index 95701cc..4f16244 100644 --- a/src/server/sensor_handler.cpp +++ b/src/server/sensor_handler.cpp @@ -21,12 +21,15 @@ #include #include +#include using namespace sensor; sensor_handler::sensor_handler(const sensor_info &info) : m_info(info) { + const char *priv = sensor::utils::get_privilege(m_info.get_uri()); + m_info.set_privilege(priv); } bool sensor_handler::has_observer(sensor_observer *ob) diff --git a/src/shared/sensor_types_private.h b/src/shared/sensor_types_private.h index 17fcd02..b1c49f3 100644 --- a/src/shared/sensor_types_private.h +++ b/src/shared/sensor_types_private.h @@ -20,9 +20,16 @@ #ifndef __SENSOR_TYPES_PRIVATE__ #define __SENSOR_TYPES_PRIVATE__ -#define URI_REGEX(CATEGORY) R"~(^http:\/\/[\w-]+(\.[\w-]+)*\/)~" CATEGORY R"~(\/[\w-]+(\.[\w-]+)*(\/[\w-]+(\.[\w-]+)*)$)~" +#define URI_REGEX(CATEGORY) R"~(^http:\/\/[\w-]+(\.[\w-]+)*\/)~" CATEGORY R"~(\/(general|healthinfo)\/[\w-]+(\.[\w-]+)*(\/[\w-]+(\.[\w-]+)*)$)~" #define SENSOR_URI_REGEX URI_REGEX("sensor") #define PREDEFINED_TYPE_URI "http://tizen.org/sensor/" +#define URI_DELIMITER "/" +#define PRIVILEGE_HEALTHINFO_STR "healthinfo" +#define PRIVILEGE_HEALTHINFO_URI "http://tizen.org/privilege/healthinfo" + +#define URI_PRIV_INDEX 4 +#define URI_SENSOR_TYPE_INDEX 5 + #endif /* __SENSOR_TYPES_PRIVATE__ */ diff --git a/src/shared/sensor_utils.cpp b/src/shared/sensor_utils.cpp index 8313c4d..1f09e4b 100644 --- a/src/shared/sensor_utils.cpp +++ b/src/shared/sensor_utils.cpp @@ -28,7 +28,9 @@ #include #include +#include #include +#include #ifndef PATH_MAX #define PATH_MAX 256 @@ -36,90 +38,90 @@ /* TODO: move and define string type to sensor_type.h */ static std::map types = { - {UNKNOWN_SENSOR, "http://tizen.org/sensor/unknown"}, - {ALL_SENSOR, "http://tizen.org/sensor/all"}, - {ACCELEROMETER_SENSOR, "http://tizen.org/sensor/accelerometer"}, - {GRAVITY_SENSOR, "http://tizen.org/sensor/gravity"}, - {LINEAR_ACCEL_SENSOR, "http://tizen.org/sensor/linear_acceleration"}, - {GEOMAGNETIC_SENSOR, "http://tizen.org/sensor/magnetic"}, - {ROTATION_VECTOR_SENSOR, "http://tizen.org/sensor/rotation_vector"}, - {ORIENTATION_SENSOR, "http://tizen.org/sensor/orientation"}, - {GYROSCOPE_SENSOR, "http://tizen.org/sensor/gyroscope"}, - {LIGHT_SENSOR, "http://tizen.org/sensor/light"}, - {PROXIMITY_SENSOR, "http://tizen.org/sensor/proximity"}, - {PRESSURE_SENSOR, "http://tizen.org/sensor/pressure"}, - {ULTRAVIOLET_SENSOR, "http://tizen.org/sensor/ultraviolet"}, - {TEMPERATURE_SENSOR, "http://tizen.org/sensor/temperature"}, - {HUMIDITY_SENSOR, "http://tizen.org/sensor/humidity"}, - {HRM_SENSOR, "http://tizen.org/sensor/heart_rate_monitor"}, - {HRM_LED_GREEN_SENSOR, "http://tizen.org/sensor/heart_rate_monitor.led_green"}, - {HRM_LED_IR_SENSOR, "http://tizen.org/sensor/heart_rate_monitor.led_ir"}, - {HRM_LED_RED_SENSOR, "http://tizen.org/sensor/heart_rate_monitor.led_red"}, - {GYROSCOPE_UNCAL_SENSOR, "http://tizen.org/sensor/gyroscope.uncalibrated"}, - {GEOMAGNETIC_UNCAL_SENSOR, "http://tizen.org/sensor/geomagnetic.uncalibrated"}, - {GYROSCOPE_RV_SENSOR, "http://tizen.org/sensor/gyroscope_rotation_vector"}, - {GEOMAGNETIC_RV_SENSOR, "http://tizen.org/sensor/geomagnetic_rotation_vector"}, - - {HUMAN_PEDOMETER_SENSOR, "http://tizen.org/sensor/human_pedometer"}, - {HUMAN_SLEEP_MONITOR_SENSOR, "http://tizen.org/sensor/human_sleep_monitor"}, - {HUMAN_SLEEP_DETECTOR_SENSOR, "http://tizen.org/sensor/human_sleep_detector"}, - {HUMAN_STRESS_MONITOR_SENSOR, "http://tizen.org/sensor/human_stress_monitor"}, - - {EXERCISE_WALKING_SENSOR, "http://tizen.org/sensor/exercise.walking"}, - {EXERCISE_RUNNING_SENSOR, "http://tizen.org/sensor/exercise.running"}, - {EXERCISE_HIKING_SENSOR, "http://tizen.org/sensor/exercise.hiking"}, - {EXERCISE_CYCLING_SENSOR, "http://tizen.org/sensor/exercise.cycling"}, - {EXERCISE_ELLIPTICAL_SENSOR, "http://tizen.org/sensor/exercise.elliptical"}, - {EXERCISE_INDOOR_CYCLING_SENSOR, "http://tizen.org/sensor/exercise.indoor_cycling"}, - {EXERCISE_ROWING_SENSOR, "http://tizen.org/sensor/exercise.rowing"}, - {EXERCISE_STEPPER_SENSOR, "http://tizen.org/sensor/exercise.stepper"}, - - {EXTERNAL_EXERCISE_SENSOR, "http://tizen.org/sensor/external_exercise"}, - - {FUSION_SENSOR, "http://tizen.org/sensor/fusion"}, - {AUTO_ROTATION_SENSOR, "http://tizen.org/sensor/auto_rotation"}, - {AUTO_BRIGHTNESS_SENSOR, "http://tizen.org/sensor/auto_brightness"}, - - {GESTURE_MOVEMENT_SENSOR, "http://tizen.org/sensor/gesture_movement"}, - {GESTURE_WRIST_UP_SENSOR, "http://tizen.org/sensor/gesture_wrist_up"}, - {GESTURE_WRIST_DOWN_SENSOR, "http://tizen.org/sensor/gesture_wrist_down"}, - {GESTURE_MOVEMENT_STATE_SENSOR, "http://tizen.org/sensor/gesture_movement_state"}, - {GESTURE_FACE_DOWN_SENSOR, "http://tizen.org/sensor/gesture_face_down"}, - - {ACTIVITY_TRACKER_SENSOR, "http://tizen.org/sensor/activity_tracker"}, - {ACTIVITY_LEVEL_MONITOR_SENSOR, "http://tizen.org/sensor/activity_level_monitor"}, - {GPS_BATCH_SENSOR, "http://tizen.org/sensor/gps_batch"}, - - {HRM_CTRL_SENSOR, "http://tizen.org/sensor/hrm_ctrl"}, - - {WEAR_STATUS_SENSOR, "http://tizen.org/sensor/wear_status"}, - {WEAR_ON_MONITOR_SENSOR, "http://tizen.org/sensor/wear_on_monitor"}, - {NO_MOVE_DETECTOR_SENSOR, "http://tizen.org/sensor/no_move_detector"}, - {RESTING_HR_SENSOR, "http://tizen.org/sensor/resting_hr"}, - {STEP_LEVEL_MONITOR_SENSOR, "http://tizen.org/sensor/step_level_monitor"}, - {EXERCISE_STANDALONE_SENSOR, "http://tizen.org/sensor/exercise_standalone"}, - {EXERCISE_HR_SENSOR, "http://tizen.org/sensor/exercise_hr"}, - {WORKOUT_SENSOR, "http://tizen.org/sensor/workout"}, - {CYCLE_MONITOR_SENSOR, "http://tizen.org/sensor/cycle_monitor"}, - {STAIR_TRACKER_SENSOR, "http://tizen.org/sensor/stair_tracker"}, - {PRESSURE_INDICATOR_SENSOR, "http://tizen.org/sensor/pressure_indicator"}, - {PRESSURE_ALERT_SENSOR, "http://tizen.org/sensor/pressure_alert"}, - {HR_CALORIE_SENSOR, "http://tizen.org/sensor/hr_calorie"}, - - {CONTEXT_SENSOR, "http://tizen.org/sensor/context"}, - {MOTION_SENSOR, "http://tizen.org/sensor/motion"}, - {PIR_SENSOR, "http://tizen.org/sensor/pir"}, - {PIR_LONG_SENSOR, "http://tizen.org/sensor/pir_long"}, - {DUST_SENSOR, "http://tizen.org/sensor/dust"}, - {THERMOMETER_SENSOR, "http://tizen.org/sensor/thermometer"}, - {PEDOMETER_SENSOR, "http://tizen.org/sensor/pedometer"}, - {FLAT_SENSOR, "http://tizen.org/sensor/flat"}, - {HRM_RAW_SENSOR, "http://tizen.org/sensor/hrm_raw"}, - {TILT_SENSOR, "http://tizen.org/sensor/tilt"}, - {RV_RAW_SENSOR, "http://tizen.org/sensor/rv_raw"}, - {GSR_SENSOR, "http://tizen.org/sensor/gsr"}, - {SIMSENSE_SENSOR, "http://tizen.org/sensor/simsense"}, - {PPG_SENSOR, "http://tizen.org/sensor/ppg"}, + {UNKNOWN_SENSOR, "http://tizen.org/sensor/general/unknown"}, + {ALL_SENSOR, "http://tizen.org/sensor/general/all"}, + {ACCELEROMETER_SENSOR, "http://tizen.org/sensor/general/accelerometer"}, + {GRAVITY_SENSOR, "http://tizen.org/sensor/general/gravity"}, + {LINEAR_ACCEL_SENSOR, "http://tizen.org/sensor/general/linear_acceleration"}, + {GEOMAGNETIC_SENSOR, "http://tizen.org/sensor/general/magnetic"}, + {ROTATION_VECTOR_SENSOR, "http://tizen.org/sensor/general/rotation_vector"}, + {ORIENTATION_SENSOR, "http://tizen.org/sensor/general/orientation"}, + {GYROSCOPE_SENSOR, "http://tizen.org/sensor/general/gyroscope"}, + {LIGHT_SENSOR, "http://tizen.org/sensor/general/light"}, + {PROXIMITY_SENSOR, "http://tizen.org/sensor/general/proximity"}, + {PRESSURE_SENSOR, "http://tizen.org/sensor/general/pressure"}, + {ULTRAVIOLET_SENSOR, "http://tizen.org/sensor/general/ultraviolet"}, + {TEMPERATURE_SENSOR, "http://tizen.org/sensor/general/temperature"}, + {HUMIDITY_SENSOR, "http://tizen.org/sensor/general/humidity"}, + {HRM_SENSOR, "http://tizen.org/sensor/healthinfo/heart_rate_monitor"}, + {HRM_LED_GREEN_SENSOR, "http://tizen.org/sensor/healthinfo/heart_rate_monitor.led_green"}, + {HRM_LED_IR_SENSOR, "http://tizen.org/sensor/healthinfo/heart_rate_monitor.led_ir"}, + {HRM_LED_RED_SENSOR, "http://tizen.org/sensor/healthinfo/heart_rate_monitor.led_red"}, + {GYROSCOPE_UNCAL_SENSOR, "http://tizen.org/sensor/general/gyroscope.uncalibrated"}, + {GEOMAGNETIC_UNCAL_SENSOR, "http://tizen.org/sensor/general/geomagnetic.uncalibrated"}, + {GYROSCOPE_RV_SENSOR, "http://tizen.org/sensor/general/gyroscope_rotation_vector"}, + {GEOMAGNETIC_RV_SENSOR, "http://tizen.org/sensor/general/geomagnetic_rotation_vector"}, + + {HUMAN_PEDOMETER_SENSOR, "http://tizen.org/sensor/healthinfo/human_pedometer"}, + {HUMAN_SLEEP_MONITOR_SENSOR, "http://tizen.org/sensor/healthinfo/human_sleep_monitor"}, + {HUMAN_SLEEP_DETECTOR_SENSOR, "http://tizen.org/sensor/healthinfo/human_sleep_detector"}, + {HUMAN_STRESS_MONITOR_SENSOR, "http://tizen.org/sensor/healthinfo/human_stress_monitor"}, + + {EXERCISE_WALKING_SENSOR, "http://tizen.org/sensor/general/exercise.walking"}, + {EXERCISE_RUNNING_SENSOR, "http://tizen.org/sensor/general/exercise.running"}, + {EXERCISE_HIKING_SENSOR, "http://tizen.org/sensor/general/exercise.hiking"}, + {EXERCISE_CYCLING_SENSOR, "http://tizen.org/sensor/general/exercise.cycling"}, + {EXERCISE_ELLIPTICAL_SENSOR, "http://tizen.org/sensor/general/exercise.elliptical"}, + {EXERCISE_INDOOR_CYCLING_SENSOR, "http://tizen.org/sensor/general/exercise.indoor_cycling"}, + {EXERCISE_ROWING_SENSOR, "http://tizen.org/sensor/general/exercise.rowing"}, + {EXERCISE_STEPPER_SENSOR, "http://tizen.org/sensor/general/exercise.stepper"}, + + {EXTERNAL_EXERCISE_SENSOR, "http://tizen.org/sensor/general/external_exercise"}, + + {FUSION_SENSOR, "http://tizen.org/sensor/general/fusion"}, + {AUTO_ROTATION_SENSOR, "http://tizen.org/sensor/general/auto_rotation"}, + {AUTO_BRIGHTNESS_SENSOR, "http://tizen.org/sensor/general/auto_brightness"}, + + {GESTURE_MOVEMENT_SENSOR, "http://tizen.org/sensor/general/gesture_movement"}, + {GESTURE_WRIST_UP_SENSOR, "http://tizen.org/sensor/general/gesture_wrist_up"}, + {GESTURE_WRIST_DOWN_SENSOR, "http://tizen.org/sensor/general/gesture_wrist_down"}, + {GESTURE_MOVEMENT_STATE_SENSOR, "http://tizen.org/sensor/general/gesture_movement_state"}, + {GESTURE_FACE_DOWN_SENSOR, "http://tizen.org/sensor/general/gesture_face_down"}, + + {ACTIVITY_TRACKER_SENSOR, "http://tizen.org/sensor/general/activity_tracker"}, + {ACTIVITY_LEVEL_MONITOR_SENSOR, "http://tizen.org/sensor/general/activity_level_monitor"}, + {GPS_BATCH_SENSOR, "http://tizen.org/sensor/general/gps_batch"}, + + {HRM_CTRL_SENSOR, "http://tizen.org/sensor/general/hrm_ctrl"}, + + {WEAR_STATUS_SENSOR, "http://tizen.org/sensor/general/wear_status"}, + {WEAR_ON_MONITOR_SENSOR, "http://tizen.org/sensor/general/wear_on_monitor"}, + {NO_MOVE_DETECTOR_SENSOR, "http://tizen.org/sensor/general/no_move_detector"}, + {RESTING_HR_SENSOR, "http://tizen.org/sensor/general/resting_hr"}, + {STEP_LEVEL_MONITOR_SENSOR, "http://tizen.org/sensor/general/step_level_monitor"}, + {EXERCISE_STANDALONE_SENSOR, "http://tizen.org/sensor/general/exercise_standalone"}, + {EXERCISE_HR_SENSOR, "http://tizen.org/sensor/healthinfo/general/exercise_hr"}, + {WORKOUT_SENSOR, "http://tizen.org/sensor/general/workout"}, + {CYCLE_MONITOR_SENSOR, "http://tizen.org/sensor/general/cycle_monitor"}, + {STAIR_TRACKER_SENSOR, "http://tizen.org/sensor/general/stair_tracker"}, + {PRESSURE_INDICATOR_SENSOR, "http://tizen.org/sensor/general/pressure_indicator"}, + {PRESSURE_ALERT_SENSOR, "http://tizen.org/sensor/general/pressure_alert"}, + {HR_CALORIE_SENSOR, "http://tizen.org/sensor/general/hr_calorie"}, + + {CONTEXT_SENSOR, "http://tizen.org/sensor/general/context"}, + {MOTION_SENSOR, "http://tizen.org/sensor/general/motion"}, + {PIR_SENSOR, "http://tizen.org/sensor/general/pir"}, + {PIR_LONG_SENSOR, "http://tizen.org/sensor/general/pir_long"}, + {DUST_SENSOR, "http://tizen.org/sensor/general/dust"}, + {THERMOMETER_SENSOR, "http://tizen.org/sensor/general/thermometer"}, + {PEDOMETER_SENSOR, "http://tizen.org/sensor/healthinfo/general/pedometer"}, + {FLAT_SENSOR, "http://tizen.org/sensor/general/flat"}, + {HRM_RAW_SENSOR, "http://tizen.org/sensor/healthinfo/general/hrm_raw"}, + {TILT_SENSOR, "http://tizen.org/sensor/general/tilt"}, + {RV_RAW_SENSOR, "http://tizen.org/sensor/general/rv_raw"}, + {GSR_SENSOR, "http://tizen.org/sensor/healthinfo/general/gsr"}, + {SIMSENSE_SENSOR, "http://tizen.org/sensor/general/simsense"}, + {PPG_SENSOR, "http://tizen.org/sensor/healthinfo/general/ppg"}, }; const char *sensor::utils::get_uri(sensor_type_t type) @@ -130,6 +132,29 @@ const char *sensor::utils::get_uri(sensor_type_t type) return it->second; } +const char *sensor::utils::get_privilege(std::string uri) +{ + std::size_t start = 0; + std::size_t end = uri.length(); + std::size_t size = uri.size(); + + for (int i = 0; i < URI_PRIV_INDEX; ++i) { + retv_if(start >= uri.length(), ""); + start = uri.find(URI_DELIMITER, start + 1); + retv_if(start == std::string::npos, ""); + } + + end = uri.find(URI_DELIMITER, start + 1); + retv_if(end == std::string::npos, ""); + + size = end - (start + 1); + + if (uri.substr(start + 1, size) == PRIVILEGE_HEALTHINFO_STR) + return PRIVILEGE_HEALTHINFO_URI; + + return ""; +} + unsigned long long sensor::utils::get_timestamp(void) { struct timespec t; diff --git a/src/shared/sensor_utils.h b/src/shared/sensor_utils.h index 7e31f6d..8e80f27 100644 --- a/src/shared/sensor_utils.h +++ b/src/shared/sensor_utils.h @@ -29,6 +29,7 @@ namespace sensor { namespace utils { const char *get_uri(sensor_type_t type); + const char *get_privilege(std::string uri); unsigned long long get_timestamp(void); unsigned long long get_timestamp(timeval *t); -- 2.7.4