Remove tv profile dependency for cynara
[platform/core/location/lbs-location.git] / location / manager / location.c
index caca551..c201883 100644 (file)
@@ -157,11 +157,9 @@ location_request_single_location(LocationObject *obj, int timeout)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+
        ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
        LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
 
@@ -173,11 +171,8 @@ location_cancel_single_location(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_cancel_single_location(LOCATION_IELEMENT(obj));
        if (ret != LOCATION_ERROR_NONE)
@@ -191,11 +186,8 @@ location_start(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_start(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
@@ -219,12 +211,9 @@ EXPORT_API int
 location_start_batch(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
-       int ret = LOCATION_ERROR_NONE;
 
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
@@ -300,13 +289,10 @@ location_is_enabled_method(LocationMethod method, int *is_enabled)
 EXPORT_API int
 location_enable_method(const LocationMethod method, const int enable)
 {
-       int ret = 0;
        char *_key = NULL;
 
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
                LOCATION_SECLOG("Location setting is denied by DPM");
@@ -402,12 +388,8 @@ location_get_position(LocationObject *obj, LocationPosition **position, Location
        g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
        LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
@@ -423,12 +405,8 @@ location_get_position_ext(LocationObject *obj, LocationPosition **position, Loca
        g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
@@ -443,12 +421,8 @@ location_get_last_position(LocationObject *obj, LocationPosition **position, Loc
        g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
@@ -464,12 +438,8 @@ location_get_last_position_ext(LocationObject *obj, LocationPosition **position,
        g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
@@ -497,12 +467,8 @@ location_get_satellite(LocationObject *obj, LocationSatellite **satellite)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
        LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
@@ -516,12 +482,8 @@ location_get_batch(LocationObject *obj, LocationBatch **batch)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
        LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
@@ -535,12 +497,8 @@ location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
@@ -555,12 +513,8 @@ location_get_velocity(LocationObject *obj, LocationVelocity **velocity, Location
        g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
@@ -575,12 +529,8 @@ location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, Loc
        g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
@@ -591,17 +541,13 @@ location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, Loc
 EXPORT_API int
 location_get_accessibility_state(LocationAccessState *state)
 {
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
 
-               if (ret == LOCATION_ERROR_NONE) {
-                       *state = LOCATION_ACCESS_ALLOWED;
-               } else {
-                       *state = LOCATION_ACCESS_DENIED;
-                       LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
-               }
-       } else {
+       if (ret == LOCATION_ERROR_NONE) {
                *state = LOCATION_ACCESS_ALLOWED;
+       } else {
+               *state = LOCATION_ACCESS_DENIED;
+               LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
        }
 
        return LOCATION_ERROR_NONE;
@@ -641,12 +587,9 @@ EXPORT_API int
 location_set_option(LocationObject *obj, const char *option)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
-       int ret = LOCATION_ERROR_NONE;
 
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
        LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
@@ -660,12 +603,8 @@ location_set_option(LocationObject *obj, const char *option)
 EXPORT_API int
 location_enable_mock(const int enable)
 {
-       int ret = LOCATION_ERROR_NONE;
-
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
 #if 0 /* Tizen platform didn't turn developer option on */
        gboolean developer_option = FALSE;
@@ -691,11 +630,8 @@ location_set_mock_location(LocationObject *obj, const LocationPosition *position
        g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
@@ -708,11 +644,8 @@ location_clear_mock_location(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
-       int ret = LOCATION_ERROR_NONE;
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
+       int ret = location_check_cynara(LOCATION_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
        ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
@@ -735,13 +668,10 @@ location_set_fused_mode(LocationObject *obj, LocationFusedMode mode)
 EXPORT_API int
 location_enable_restriction(const int enable)
 {
-       int ret = LOCATION_ERROR_NONE;
        int restriction = 0;
+       int ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 
-       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
-               ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
-               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-       }
        if (enable) {
                int value = 0;
                ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);