[DataSync] stopSync
authorRyszard Matuszyk <r.matuszyk@samsung.com>
Wed, 21 Jan 2015 13:41:54 +0000 (14:41 +0100)
committerRyszard Matuszyk <r.matuszyk@samsung.com>
Wed, 21 Jan 2015 14:07:44 +0000 (23:07 +0900)
Verification: not available. Platform function sync_agent_ds_init not working

Change-Id: I900cdbbc6945a615356f613539087cb4febd8158
Signed-off-by: Ryszard Matuszyk <r.matuszyk@samsung.com>
src/datasync/datasync_instance.cc
src/datasync/datasync_manager.cc
src/datasync/datasync_manager.h

index 50c8edf0ce069075dc6113db1ecffc0bb519659c..841f48113d69ba7d9ea1b438bff2735457d38da8 100644 (file)
@@ -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<std::string>());
 
-    picojson::value val{picojson::object{}};
-
-    ReportSuccess(val, out);
+  picojson::value val{picojson::object{}};
+  ReportSuccess(val, out);
 }
 
 }  // namespace datasync
index 54d4917e4e4482c5998ad3cd4244c9a8c0b3aabf..35af1795ed47e9f273023d70508fa3a2411c251e 100644 (file)
@@ -431,34 +431,23 @@ void DataSyncManager::StartSync(const picojson::object& args) {
   callbacks_[id] = listener_id;
 }
 
-ResultOrError<void> 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() {
index a69f1fd04d9a29d0cda9c0cecf3130e47f65d1d4..52541446333ad12755aa7208e3d8728613e64021 100644 (file)
@@ -41,7 +41,7 @@ class DataSyncManager {
   void GetLastSyncStatistics(const std::string& id, picojson::array &out);
 
   void StartSync(const picojson::object& args);
-  ResultOrError<void> 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<std::string, std::string> callbacks_;
+  std::map<std::string, std::string> callbacks_;
 
   static bool sync_agent_initialized_;