From a34154e79c4c3dc43dfb0df7d3a21e05b52b2236 Mon Sep 17 00:00:00 2001 From: Ryszard Matuszyk Date: Wed, 21 Jan 2015 14:41:54 +0100 Subject: [PATCH] [DataSync] stopSync Verification: not available. Platform function sync_agent_ds_init not working Change-Id: I900cdbbc6945a615356f613539087cb4febd8158 Signed-off-by: Ryszard Matuszyk --- src/datasync/datasync_instance.cc | 7 +++---- src/datasync/datasync_manager.cc | 23 ++++++----------------- src/datasync/datasync_manager.h | 4 ++-- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/datasync/datasync_instance.cc b/src/datasync/datasync_instance.cc index 50c8edf0..841f4811 100644 --- a/src/datasync/datasync_instance.cc +++ b/src/datasync/datasync_instance.cc @@ -104,11 +104,10 @@ void DatasyncInstance::StartSync(const picojson::value &args, picojson::object & } void DatasyncInstance::StopSync(const picojson::value &args, picojson::object &out) { -// TODO: implementation + DataSyncManager::Instance().StopSync(args.get("profileId").get()); - picojson::value val{picojson::object{}}; - - ReportSuccess(val, out); + picojson::value val{picojson::object{}}; + ReportSuccess(val, out); } } // namespace datasync diff --git a/src/datasync/datasync_manager.cc b/src/datasync/datasync_manager.cc index 54d4917e..35af1795 100644 --- a/src/datasync/datasync_manager.cc +++ b/src/datasync/datasync_manager.cc @@ -431,34 +431,23 @@ void DataSyncManager::StartSync(const picojson::object& args) { callbacks_[id] = listener_id; } -ResultOrError DataSyncManager::StopSync( - const std::string& profile_id_str) { +void DataSyncManager::StopSync(const std::string& id) { ds_profile_h profile_h = nullptr; - auto exit = common::MakeScopeExit([&profile_h]() { - if (profile_h) { - sync_agent_ds_free_profile_info(profile_h); - } - }); - - sync_agent_ds_error_e ret = SYNC_AGENT_DS_FAIL; - - int profile_id = std::stoi(profile_id_str.c_str()); + int profile_id = std::stoi(id.c_str()); LoggerD("profileId: %d", profile_id); - ret = sync_agent_ds_get_profile(profile_id, &profile_h); + sync_agent_ds_error_e ret = sync_agent_ds_get_profile(profile_id, &profile_h); if (SYNC_AGENT_DS_SUCCESS != ret) { - return Error("Exception", - "Platform error while getting a profile"); + throw UnknownException("Platform error while getting a profile"); } ret = sync_agent_ds_stop_sync(profile_h); if (SYNC_AGENT_DS_SUCCESS != ret) { - return Error("Exception", - "Platform error while stopping a profile"); + throw UnknownException("Platform error while stopping a profile"); } - return {}; + callbacks_.erase(id); } DataSyncManager& DataSyncManager::Instance() { diff --git a/src/datasync/datasync_manager.h b/src/datasync/datasync_manager.h index a69f1fd0..52541446 100644 --- a/src/datasync/datasync_manager.h +++ b/src/datasync/datasync_manager.h @@ -41,7 +41,7 @@ class DataSyncManager { void GetLastSyncStatistics(const std::string& id, picojson::array &out); void StartSync(const picojson::object& args); - ResultOrError StopSync(const std::string& profile_id_str); + void StopSync(const std::string& id); static DataSyncManager& Instance(); @@ -62,7 +62,7 @@ class DataSyncManager { picojson::object& response_obj, picojson::value& answer, picojson::object& answer_obj); - static std::map callbacks_; + std::map callbacks_; static bool sync_agent_initialized_; -- 2.34.1