From: Tomasz Marciniak Date: Tue, 24 Feb 2015 10:22:06 +0000 (+0100) Subject: [Bluetooth] Removed ReportError/Success from bluetooth_util X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~363 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c292f9cb0ad05e09a80b0c3d8039fa7df7e4934b;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Bluetooth] Removed ReportError/Success from bluetooth_util [Verification] Code compiles without errors. Change-Id: I55cb11461d4582aa1abf32904e59a3b3da2d9570 Signed-off-by: Tomasz Marciniak --- diff --git a/src/bluetooth/bluetooth_adapter.cc b/src/bluetooth/bluetooth_adapter.cc index 9d73caf1..8b335597 100644 --- a/src/bluetooth/bluetooth_adapter.cc +++ b/src/bluetooth/bluetooth_adapter.cc @@ -25,7 +25,6 @@ #include "common/converter.h" #include "common/logger.h" -#include "common/platform_exception.h" #include "common/platform_result.h" #include "common/extension.h" #include "common/task-queue.h" @@ -270,7 +269,7 @@ void BluetoothAdapter::DiscoveryStateChangedCB( data_obj->insert(std::make_pair(kAction, picojson::value(kOnDiscoverStarted))); util::FireEvent(kAdapterDiscoverSuccessEvent, value); } else { - util::ReportError(UnknownException("Unknown error"), *data_obj); + ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error"), data_obj); util::FireEvent(kAdapterDiscoverErrorEvent, value); adapter->user_request_list_[DISCOVER_DEVICES] = false; } @@ -304,7 +303,7 @@ void BluetoothAdapter::DiscoveryStateChangedCB( std::shared_ptr response = std::shared_ptr(new picojson::value(picojson::object())); - util::ReportSuccess(response->get()); + ReportSuccess(response->get()); util::AsyncResponse( adapter->user_request_callback_[STOP_DISCOVERY], response); @@ -1207,7 +1206,7 @@ void BluetoothAdapter::GetBluetoothProfileHandler(const picojson::value& data, void BluetoothAdapter::GetName(const picojson::value& /* data */, picojson::object& out) { LoggerD("Entered"); - util::ReportSuccess(picojson::value(get_name()), out); + ReportSuccess(picojson::value(get_name()), out); } void BluetoothAdapter::GetAddress(const picojson::value& /* data */, picojson::object& out) { @@ -1228,19 +1227,19 @@ void BluetoothAdapter::GetAddress(const picojson::value& /* data */, picojson::o } } - util::ReportSuccess(picojson::value(str_address), out); + ReportSuccess(picojson::value(str_address), out); } void BluetoothAdapter::GetPowered(const picojson::value& /* data */, picojson::object& out) { LoggerD("Entered"); - util::ReportSuccess(picojson::value(is_powered_), out); + ReportSuccess(picojson::value(is_powered_), out); } void BluetoothAdapter::GetVisible(const picojson::value& /* data */, picojson::object& out) { LoggerD("Entered"); - util::ReportSuccess(picojson::value(get_visible()), out); + ReportSuccess(picojson::value(get_visible()), out); } void BluetoothAdapter::OnSocketConnected(int result, @@ -1323,11 +1322,11 @@ void BluetoothAdapter::OnSocketConnected(int result, object->connected_sockets_.push_back(connection->socket_fd); bt_socket_set_data_received_cb(OnSocketReceivedData, user_data); - util::ReportSuccess(BluetoothSocket::ToJson(connection), + ReportSuccess(BluetoothSocket::ToJson(connection), response->get()); } else { - util::ReportError(NotFoundException("Not found"), - response->get()); + ReportError(PlatformResult( + ErrorCode::NOT_FOUND_ERR, "Not found"), &response->get()); } util::AsyncResponse(request->second->callback_handle_, response); @@ -1511,7 +1510,7 @@ void BluetoothAdapter::IsServiceConnected(const picojson::value& data, picojson: return; } - util::ReportSuccess(picojson::value(iter->second.second), out); + ReportSuccess(picojson::value(iter->second.second), out); } } // namespace bluetooth diff --git a/src/bluetooth/bluetooth_device.cc b/src/bluetooth/bluetooth_device.cc index 77a39b5b..6c82be04 100644 --- a/src/bluetooth/bluetooth_device.cc +++ b/src/bluetooth/bluetooth_device.cc @@ -109,7 +109,7 @@ void BluetoothDevice::ConnectToServiceByUUID(const picojson::value& data, picojs FromJson(args, "uuid"), util::GetAsyncCallbackHandle(data)); - util::ReportSuccess(out); + ReportSuccess(out); } void BluetoothDevice::GetBoolValue(const picojson::value& data, picojson::object& out) diff --git a/src/bluetooth/bluetooth_health_application.cc b/src/bluetooth/bluetooth_health_application.cc index 811d3463..ee18379d 100644 --- a/src/bluetooth/bluetooth_health_application.cc +++ b/src/bluetooth/bluetooth_health_application.cc @@ -18,6 +18,7 @@ #include "common/converter.h" #include "common/logger.h" +#include "common/extension.h" #include "bluetooth_health_profile_handler.h" #include "bluetooth_privilege.h" @@ -45,7 +46,7 @@ void BluetoothHealthApplication::Unregister(const picojson::value& data, picojso FromJson(args, "id"), util::GetAsyncCallbackHandle(data)); - util::ReportSuccess(out); + tools::ReportSuccess(out); } void BluetoothHealthApplication::ToJson(short data_type, diff --git a/src/bluetooth/bluetooth_health_channel.cc b/src/bluetooth/bluetooth_health_channel.cc index ca248186..6841c615 100644 --- a/src/bluetooth/bluetooth_health_channel.cc +++ b/src/bluetooth/bluetooth_health_channel.cc @@ -55,7 +55,7 @@ void BluetoothHealthChannel::Close(const picojson::value& data , picojson::objec return; } - util::ReportSuccess(out); + ReportSuccess(out); } void BluetoothHealthChannel::SendData(const picojson::value& data, picojson::object& out) { @@ -81,7 +81,7 @@ void BluetoothHealthChannel::SendData(const picojson::value& data, picojson::obj return; } - util::ReportSuccess(picojson::value(static_cast(data_size)), out); + ReportSuccess(picojson::value(static_cast(data_size)), out); } void BluetoothHealthChannel::ToJson(unsigned int channel, diff --git a/src/bluetooth/bluetooth_health_profile_handler.cc b/src/bluetooth/bluetooth_health_profile_handler.cc index 5591d6d1..830ae9f7 100644 --- a/src/bluetooth/bluetooth_health_profile_handler.cc +++ b/src/bluetooth/bluetooth_health_profile_handler.cc @@ -125,7 +125,7 @@ void BluetoothHealthProfileHandler::OnConnected(int result, app_id, &result.get()); - util::ReportSuccess(result, response_obj); + ReportSuccess(result, response_obj); bt_adapter_free_device_info(device_info); util::FireEvent("BLUETOOTH_HEALTH_APPLICATION_CHANGED", response); @@ -153,11 +153,12 @@ void BluetoothHealthProfileHandler::OnConnected(int result, type, &result.get()); - util::ReportSuccess(result, response->get()); + ReportSuccess(result, response->get()); } else { LoggerE("Failed to establish a connection with health profile"); - util::ReportError(UnknownException("Failed to establish a connection with health profile"), - response->get()); + ReportError(PlatformResult( + ErrorCode::UNKNOWN_ERR, "Failed to establish a connection with health profile"), + &response->get()); } util::AsyncResponse(request->second, response); @@ -257,7 +258,7 @@ void BluetoothHealthProfileHandler::RegisterSinkApp(const picojson::value& data, name, app_id, &result.get()); - util::ReportSuccess(result, response->get()); + ReportSuccess(result, response->get()); return; } @@ -284,7 +285,7 @@ void BluetoothHealthProfileHandler::RegisterSinkApp(const picojson::value& data, register_app_response, std::shared_ptr(new picojson::value(picojson::object()))); - util::ReportSuccess(out); + ReportSuccess(out); } void BluetoothHealthProfileHandler::ConnectToSource(const picojson::value& data, picojson::object& out) { @@ -331,7 +332,7 @@ void BluetoothHealthProfileHandler::ConnectToSource(const picojson::value& data, util::AsyncResponse(callback_handle, result); } - util::ReportSuccess(out); + ReportSuccess(out); } void BluetoothHealthProfileHandler::UnregisterSinkAppAsync(const std::string& app_id, diff --git a/src/bluetooth/bluetooth_instance.cc b/src/bluetooth/bluetooth_instance.cc index 439c06d9..5c62117b 100644 --- a/src/bluetooth/bluetooth_instance.cc +++ b/src/bluetooth/bluetooth_instance.cc @@ -38,7 +38,7 @@ void CheckPrivilege(const picojson::value& data, picojson::object& out) const auto& privilege = FromJson(args, "privilege"); util::CheckAccess(privilege); - util::ReportSuccess(out); + tools::ReportSuccess(out); } } // namespace diff --git a/src/bluetooth/bluetooth_service_handler.cc b/src/bluetooth/bluetooth_service_handler.cc index 02deb1e0..1b376f60 100644 --- a/src/bluetooth/bluetooth_service_handler.cc +++ b/src/bluetooth/bluetooth_service_handler.cc @@ -18,6 +18,7 @@ #include "common/converter.h" #include "common/logger.h" +#include "common/extension.h" #include "bluetooth_adapter.h" #include "bluetooth_privilege.h" @@ -39,7 +40,7 @@ void BluetoothServiceHandler::Unregister(const picojson::value& data, picojson:: FromJson(args, "uuid"), util::GetAsyncCallbackHandle(data)); - util::ReportSuccess(out); + tools::ReportSuccess(out); } } // namespace bluetooth diff --git a/src/bluetooth/bluetooth_socket.cc b/src/bluetooth/bluetooth_socket.cc index ec0f219d..d8878c12 100644 --- a/src/bluetooth/bluetooth_socket.cc +++ b/src/bluetooth/bluetooth_socket.cc @@ -66,7 +66,7 @@ void BluetoothSocket::WriteData(const picojson::value& data, picojson::object& o return; } - util::ReportSuccess(picojson::value(static_cast(data_size)), out); + ReportSuccess(picojson::value(static_cast(data_size)), out); } void BluetoothSocket::ReadData(const picojson::value& data, picojson::object& out) { @@ -88,7 +88,7 @@ void BluetoothSocket::ReadData(const picojson::value& data, picojson::object& ou BluetoothAdapter::GetInstance().ClearSocketData(socket); - util::ReportSuccess(ret, out); + ReportSuccess(ret, out); } void BluetoothSocket::Close(const picojson::value& data, picojson::object& out) { @@ -106,7 +106,7 @@ void BluetoothSocket::Close(const picojson::value& data, picojson::object& out) return; } - util::ReportSuccess(out); + ReportSuccess(out); } picojson::value BluetoothSocket::ToJson(bt_socket_connection_s* connection) { diff --git a/src/bluetooth/bluetooth_util.cc b/src/bluetooth/bluetooth_util.cc index 4c0585b4..d9bc30b4 100644 --- a/src/bluetooth/bluetooth_util.cc +++ b/src/bluetooth/bluetooth_util.cc @@ -73,24 +73,6 @@ void FireEvent(const std::string& event, const std::shared_ptr& FireEvent(event, *value.get()); } -void ReportSuccess(picojson::object& out) { - out.insert(std::make_pair(JSON_STATUS, picojson::value(JSON_CALLBACK_SUCCCESS))); -} - -void ReportSuccess(const picojson::value& result, picojson::object& out) { - ReportSuccess(out); - out.insert(std::make_pair(JSON_RESULT, result)); -} - -void ReportError(picojson::object& out) { - out.insert(std::make_pair(JSON_STATUS, picojson::value(JSON_CALLBACK_ERROR))); -} - -void ReportError(const common::PlatformException& ex, picojson::object& out) { - ReportError(out); - out.insert(std::make_pair(JSON_CALLBACK_ERROR, ex.ToJSON())); -} - double GetAsyncCallbackHandle(const picojson::value& data) { return data.get(JSON_CALLBACK_ID).get(); } diff --git a/src/bluetooth/bluetooth_util.h b/src/bluetooth/bluetooth_util.h index 109d187a..5ef31f6f 100644 --- a/src/bluetooth/bluetooth_util.h +++ b/src/bluetooth/bluetooth_util.h @@ -9,7 +9,6 @@ #include #include "common/picojson.h" -#include "common/platform_exception.h" #include "common/platform_result.h" namespace extension { @@ -26,12 +25,6 @@ void FireEvent(const std::string& event, picojson::value& value); void FireEvent(const std::string& event, const picojson::value& value); void FireEvent(const std::string& event, const std::shared_ptr& value); -void ReportSuccess(picojson::object& out); -void ReportSuccess(const picojson::value& result, picojson::object& out); - -void ReportError(picojson::object& out); -void ReportError(const common::PlatformException& ex, picojson::object& out); - double GetAsyncCallbackHandle(const picojson::value& data); const picojson::object& GetArguments(const picojson::value& data);