X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-api%2Fbt-adapter.c;h=418613f35392e71b827516b2d2c271885154fd9b;hb=1fa07edcd0e77a445700975773db3300f556caf5;hp=eed8f53f8148e3d2fdda40399daa0b767df4e6f2;hpb=39a6cbc0e0b202a9ec628daacc1cd4128912964d;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-api/bt-adapter.c b/bt-api/bt-adapter.c index eed8f53..418613f 100644 --- a/bt-api/bt-adapter.c +++ b/bt-api/bt-adapter.c @@ -28,7 +28,7 @@ static int __bt_fill_device_list(GArray *out_param2, GPtrArray **dev_list) { int i; guint size; - bluetooth_device_info_t info; + bluetooth_device_info_t *info; BT_CHECK_PARAMETER(out_param2, return); BT_CHECK_PARAMETER(dev_list, return); @@ -45,14 +45,13 @@ static int __bt_fill_device_list(GArray *out_param2, GPtrArray **dev_list) for (i = 0; i < size; i++) { bluetooth_device_info_t *dev_info = NULL; - info = g_array_index(out_param2, + info = &g_array_index(out_param2, bluetooth_device_info_t, i); - dev_info = g_memdup(&info, sizeof(bluetooth_device_info_t)); + dev_info = g_memdup(info, sizeof(bluetooth_device_info_t)); - if (dev_info) { + if (dev_info) g_ptr_array_add(*dev_list, (gpointer)dev_info); - } } return BLUETOOTH_ERROR_NONE; @@ -62,14 +61,13 @@ BT_EXPORT_API int bluetooth_check_adapter(void) { int value = VCONFKEY_BT_STATUS_OFF; -#ifndef EMUL +#ifndef TIZEN_TEST_EMUL int ret; - ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), NULL); + ret = _bt_get_adapter_path(_bt_get_system_private_conn(), NULL); - if (ret != BLUETOOTH_ERROR_NONE) { + if (ret != BLUETOOTH_ERROR_NONE) return BLUETOOTH_ADAPTER_DISABLED; - } #endif /* check VCONFKEY_BT_STATUS */ @@ -86,12 +84,13 @@ BT_EXPORT_API int bluetooth_enable_adapter(void) { int result; - BT_INFO(""); + BT_INFO_C("### Enable adapter"); + _bt_print_api_caller_name(); retv_if(bluetooth_check_adapter() == BLUETOOTH_ADAPTER_ENABLED, BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED); -#ifdef TIZEN_DPM_VCONF_ENABLE - retv_if(bluetooth_dpm_is_mode_allowed() == BLUETOOTH_DPM_RESULT_ACCESS_DENIED, +#ifdef TIZEN_FEATURE_BT_DPM + retv_if(bluetooth_dpm_is_mode_allowed() == BLUETOOTH_ERROR_PERMISSION_DEINED, BLUETOOTH_ERROR_PERMISSION_DEINED); #endif @@ -110,7 +109,8 @@ BT_EXPORT_API int bluetooth_disable_adapter(void) { int result; - BT_INFO(""); + BT_INFO_C("### Disable adapter"); + _bt_print_api_caller_name(); BT_CHECK_ENABLED(return); BT_INIT_PARAMS(); @@ -128,7 +128,7 @@ BT_EXPORT_API int bluetooth_recover_adapter(void) { int result; - BT_INFO(""); + BT_INFO_C("### Recover adapter"); BT_CHECK_ENABLED(return); BT_INIT_PARAMS(); @@ -194,9 +194,8 @@ BT_EXPORT_API int bluetooth_get_local_version(bluetooth_version_t *local_version result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_LOCAL_VERSION, in_param1, in_param2, in_param3, in_param4, &out_param); - if (result == BLUETOOTH_ERROR_NONE) { + if (result == BLUETOOTH_ERROR_NONE) *local_version = g_array_index(out_param, bluetooth_version_t, 0); - } BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -265,9 +264,8 @@ BT_EXPORT_API int bluetooth_is_service_used(const char *service_uuid, result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SERVICE_USED, in_param1, in_param2, in_param3, in_param4, &out_param); - if (result == BLUETOOTH_ERROR_NONE) { + if (result == BLUETOOTH_ERROR_NONE) *used = g_array_index(out_param, gboolean, 0); - } BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -281,26 +279,25 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t BT_CHECK_PARAMETER(discoverable_mode_ptr, return); -#ifndef TIZEN_WEARABLE - int timeout = 0; - /* Requirement in OSP */ - if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) { - if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) { - BT_ERR("Fail to get the timeout value"); - return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; - } + if (!TIZEN_PROFILE_WEARABLE) { + int timeout = 0; + /* Requirement in OSP */ + if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) { + if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) { + BT_ERR("Fail to get the timeout value"); + return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED; + } - if (timeout == -1) { - *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE; - } else { - *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; - } + if (timeout == -1) + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE; + else + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; - return BLUETOOTH_ERROR_NONE; + return BLUETOOTH_ERROR_NONE; + } + } else { + BT_CHECK_ENABLED(return); } -#else - BT_CHECK_ENABLED(return); -#endif BT_INIT_PARAMS(); BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -308,9 +305,8 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_DISCOVERABLE_MODE, in_param1, in_param2, in_param3, in_param4, &out_param); - if (result == BLUETOOTH_ERROR_NONE) { + if (result == BLUETOOTH_ERROR_NONE) *discoverable_mode_ptr = g_array_index(out_param, int, 0); - } BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -351,9 +347,8 @@ BT_EXPORT_API int bluetooth_get_timeout_value(int *timeout) result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_DISCOVERABLE_TIME, in_param1, in_param2, in_param3, in_param4, &out_param); - if (result == BLUETOOTH_ERROR_NONE) { + if (result == BLUETOOTH_ERROR_NONE) *timeout = g_array_index(out_param, int, 0); - } BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -371,6 +366,10 @@ BT_EXPORT_API int bluetooth_start_discovery(unsigned short max_response, BT_INIT_PARAMS(); BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + g_array_append_vals(in_param1, &max_response, sizeof(unsigned short)); + g_array_append_vals(in_param2, &discovery_duration, sizeof(unsigned short)); + g_array_append_vals(in_param3, &classOfDeviceMask, sizeof(unsigned int)); + result = _bt_send_request(BT_BLUEZ_SERVICE, BT_START_DISCOVERY, in_param1, in_param2, in_param3, in_param4, &out_param); @@ -459,11 +458,10 @@ BT_EXPORT_API int bluetooth_is_connectable(gboolean *is_connectable) result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_CONNECTABLE, in_param1, in_param2, in_param3, in_param4, &out_param); - if (result == BLUETOOTH_ERROR_NONE) { + if (result == BLUETOOTH_ERROR_NONE) *is_connectable = g_array_index(out_param, int, 0); - } else { + else BT_ERR("Fail to send request"); - } BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -552,9 +550,8 @@ BT_EXPORT_API int bluetooth_get_profile_connected_device_list( addr = g_memdup(ptr, sizeof(bluetooth_device_address_t)); - if (addr) { + if (addr) g_ptr_array_add(*addr_list, (gpointer)addr); - } } } }