[Bluetooth] Removed ReportError/Success from bluetooth_util
authorTomasz Marciniak <t.marciniak@samsung.com>
Tue, 24 Feb 2015 10:22:06 +0000 (11:22 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 24 Feb 2015 15:05:53 +0000 (00:05 +0900)
[Verification] Code compiles without errors.

Change-Id: I55cb11461d4582aa1abf32904e59a3b3da2d9570
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/bluetooth/bluetooth_adapter.cc
src/bluetooth/bluetooth_device.cc
src/bluetooth/bluetooth_health_application.cc
src/bluetooth/bluetooth_health_channel.cc
src/bluetooth/bluetooth_health_profile_handler.cc
src/bluetooth/bluetooth_instance.cc
src/bluetooth/bluetooth_service_handler.cc
src/bluetooth/bluetooth_socket.cc
src/bluetooth/bluetooth_util.cc
src/bluetooth/bluetooth_util.h

index 9d73caf15d7cfcdeeaed62efe9200f7b9d4288dc..8b335597c7bc390c7bee08ff8d5b37970f352d1c 100644 (file)
@@ -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<picojson::value> response =
                             std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
 
-                    util::ReportSuccess(response->get<picojson::object>());
+                    ReportSuccess(response->get<picojson::object>());
                     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<picojson::object>());
             } else {
-                util::ReportError(NotFoundException("Not found"),
-                                          response->get<picojson::object>());
+                ReportError(PlatformResult(
+                    ErrorCode::NOT_FOUND_ERR, "Not found"), &response->get<picojson::object>());
             }
 
             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
index 77a39b5bcc10be6e5b8a60f2791e70c920f8a916..6c82be04c21b40739b7b80c24d3c4a2661b92987 100644 (file)
@@ -109,7 +109,7 @@ void BluetoothDevice::ConnectToServiceByUUID(const picojson::value& data, picojs
             FromJson<std::string>(args, "uuid"),
             util::GetAsyncCallbackHandle(data));
 
-    util::ReportSuccess(out);
+    ReportSuccess(out);
 }
 
 void BluetoothDevice::GetBoolValue(const picojson::value& data, picojson::object& out)
index 811d3463f81e41d2a3b8afee7567b86ed9a90520..ee18379ddc0dd6e0ef077b65ad12295fa9cb6f26 100644 (file)
@@ -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<std::string>(args, "id"),
             util::GetAsyncCallbackHandle(data));
 
-    util::ReportSuccess(out);
+    tools::ReportSuccess(out);
 }
 
 void BluetoothHealthApplication::ToJson(short data_type,
index ca248186a3d8b695de091f0141a4d229eafa4921..6841c615fc015a14ee8ac78e7dde83675d8d7f9b 100644 (file)
@@ -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<double>(data_size)), out);
+    ReportSuccess(picojson::value(static_cast<double>(data_size)), out);
 }
 
 void BluetoothHealthChannel::ToJson(unsigned int channel,
index 5591d6d17579ef85dbbb235686d7ab706ada346c..830ae9f7d2556028f717d0a7e5bb09f2179f93f2 100644 (file)
@@ -125,7 +125,7 @@ void BluetoothHealthProfileHandler::OnConnected(int result,
                                            app_id,
                                            &result.get<picojson::object>());
 
-            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<picojson::object>());
 
-            util::ReportSuccess(result, response->get<picojson::object>());
+            ReportSuccess(result, response->get<picojson::object>());
         } else {
             LoggerE("Failed to establish a connection with health profile");
-            util::ReportError(UnknownException("Failed to establish a connection with health profile"),
-                                      response->get<picojson::object>());
+            ReportError(PlatformResult(
+                    ErrorCode::UNKNOWN_ERR, "Failed to establish a connection with health profile"),
+                    &response->get<picojson::object>());
         }
 
         util::AsyncResponse(request->second, response);
@@ -257,7 +258,7 @@ void BluetoothHealthProfileHandler::RegisterSinkApp(const picojson::value& data,
                                                name,
                                                app_id,
                                                &result.get<picojson::object>());
-            util::ReportSuccess(result, response->get<picojson::object>());
+            ReportSuccess(result, response->get<picojson::object>());
             return;
         }
 
@@ -284,7 +285,7 @@ void BluetoothHealthProfileHandler::RegisterSinkApp(const picojson::value& data,
                                                 register_app_response,
                                                 std::shared_ptr<picojson::value>(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,
index 439c06d975c99f02ca6cbdb8ad80a6ad54c5e0eb..5c62117b247de24edfd1d2b2e1fc7b6e985208ce 100644 (file)
@@ -38,7 +38,7 @@ void CheckPrivilege(const picojson::value& data, picojson::object& out)
     const auto& privilege = FromJson<std::string>(args, "privilege");
     util::CheckAccess(privilege);
 
-    util::ReportSuccess(out);
+    tools::ReportSuccess(out);
 }
 
 } // namespace
index 02deb1e0908e5c674321c04f3f5e7bd1e8ef86e7..1b376f6002c8c6c1f8d3f9a44e85a00be8f508e2 100644 (file)
@@ -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<std::string>(args, "uuid"),
             util::GetAsyncCallbackHandle(data));
 
-    util::ReportSuccess(out);
+    tools::ReportSuccess(out);
 }
 
 } // namespace bluetooth
index ec0f219d4012035f0cd4b8deaf39c4e09a4b5f07..d8878c126338651112c3928d1595efa4ba1e49e2 100644 (file)
@@ -66,7 +66,7 @@ void BluetoothSocket::WriteData(const picojson::value& data, picojson::object& o
         return;
     }
 
-    util::ReportSuccess(picojson::value(static_cast<double>(data_size)), out);
+    ReportSuccess(picojson::value(static_cast<double>(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) {
index 4c0585b4e6bb55c2c61afffafa21502d3b2e9962..d9bc30b478980d85aed26a6a634c8e0a05cc7617 100644 (file)
@@ -73,24 +73,6 @@ void FireEvent(const std::string& event, const std::shared_ptr<picojson::value>&
     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<double>();
 }
index 109d187ab4ae96d059103e92b15b23eb4271f6d1..5ef31f6f59e54db32b78da0431525a876aa31496 100644 (file)
@@ -9,7 +9,6 @@
 #include <string>
 
 #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<picojson::value>& 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);