static LocationMethod __convert_method_from_key(const char *key)
{
LocationMethod _method = LOCATION_METHOD_NONE;
- if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0) {
+ if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0)
_method = LOCATION_METHOD_HYBRID;
- } else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0) {
+ else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0)
_method = LOCATION_METHOD_GPS;
- } else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0) {
+ else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
_method = LOCATION_METHOD_WPS;
- } else if (g_strcmp0(key, VCONFKEY_LOCATION_MOCK_ENABLED) == 0) {
+ else if (g_strcmp0(key, VCONFKEY_LOCATION_MOCK_ENABLED) == 0)
_method = LOCATION_METHOD_MOCK;
- }
return _method;
}
static void __location_setting_cb(keynode_t *key, gpointer data)
{
- if (key == NULL || data == NULL) {
+ if (key == NULL || data == NULL)
return;
- }
+
LocationSetting *_setting = (LocationSetting *)data;
LocationMethod _method = LOCATION_METHOD_NONE;
break;
}
- if (!self) LOCATION_LOGE("Fail to create location object. Method [%d]", method);
+ LOC_COND_LOG(!self, _E, "Fail to create location object. [method=%d]", method);
return self;
}
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to request single location. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
return ret;
}
int ret = LOCATION_ERROR_NONE;
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_start(LOCATION_IELEMENT(obj));
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to start. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
return ret;
}
location_stop(LocationObject *obj)
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
- int ret = LOCATION_ERROR_NONE;
+ int ret = LOCATION_ERROR_NONE;
ret = location_ielement_stop(LOCATION_IELEMENT(obj));
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to stop. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to stop [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to Batch start. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
return ret;
}
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to Batch stop. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%d]", err_msg(ret));
return ret;
}
int vconf_ret = VCONF_ERROR;
char *_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
vconf_ret = vconf_get_int(_key, &vconf_val);
if (vconf_ret != VCONF_OK) {
- LOCATION_SECLOG("failed [%s], error [%d]", _key, vconf_ret);
+ LOCATION_SECLOG("vconf_get failed [%s], error [%d]", _key, vconf_ret);
g_free(_key);
return LOCATION_ERROR_NOT_AVAILABLE;
} else {
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
/* for itself */
_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
+
ret = vconf_set_int(_key, enable);
if (ret != VCONF_OK) {
LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
/* for hybrid */
_key = __convert_setting_key(LOCATION_METHOD_HYBRID);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", LOCATION_METHOD_HYBRID);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", LOCATION_METHOD_HYBRID, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
if (enable) {
ret = vconf_set_int(_key, enable);
{
int ret = LOCATION_ERROR_NONE;
char *_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_PARAMETER;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
g_location_setting.callback = callback;
g_location_setting.user_data = user_data;
{
int ret = LOCATION_ERROR_NONE;
char *_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_PARAMETER;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
g_location_setting.callback = NULL;
g_location_setting.user_data = NULL;
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_position. Error [%d]", ret);
+ LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_position_ext. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_position. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_position_ext. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
return ret;
}
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_get_nmea(LOCATION_IELEMENT(obj), nmea);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Fail to get_nmea. Error [%d]", ret);
- }
+ LOC_IF_FAIL(ret, _E, "Fail to get_nmea [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Fail to get_satellite. Error [%d]", ret);
- }
+ LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_batch. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_satellite. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_velocity. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_velocity. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
return ret;
}
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
- if (ret != LOCATION_ERROR_NONE)
- LOCATION_LOGE("Fail to get_velocity. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
return ret;
}
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_get_status(LOCATION_IELEMENT(obj), state);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_position. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to get_position [%s]", err_msg(ret));
return ret;
}
int ret = 0;
char *_key = NULL;
- if (method != LOCATION_METHOD_MOCK) {
- return LOCATION_ERROR_PARAMETER;
- }
+ LOC_COND_RET(method != LOCATION_METHOD_MOCK, LOCATION_ERROR_PARAMETER, _E, "Method is not mock [%s]", err_msg(LOCATION_ERROR_PARAMETER));
#ifndef TIZEN_PROFILE_TV
ret = location_check_cynara(LOCATION_PRIVILEGE);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
#endif
#if 0 /* Tizen platform didn't turn developer option on */
gboolean developer_option = FALSE;
ret = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &developer_option);
- if (!developer_option) {
- LOCATION_LOGE("Cannot enable mock location because developer option is not turned on", ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
+ LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
#endif
_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
+
ret = vconf_set_int(_key, enable);
if (ret != VCONF_OK) {
LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
int vconf_val = 0;
_key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
ret = vconf_get_int(_key, &vconf_val);
if (ret != VCONF_OK) {
if (vconf_val) {
_key = __convert_mock_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
+ LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method[%d]", method);
ret = vconf_set_int(_key, enable);
if (ret != VCONF_OK) {
LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to location_ielement_set_mock_location. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
return ret;
}
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
- if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to location_ielement_set_mock_location. Error [%d]", ret);
+ LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
return ret;
-}
\ No newline at end of file
+}