diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index 8c577b3503..a9d6538bb5 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -59,7 +59,7 @@ void PrepareClassRefs(JNIEnv * env) jni::GetMethodID(env, bookmarkManagerInstance, "onSynchronizationFinished", "(IILjava/lang/String;)V"); g_onRestoreRequestedMethod = - jni::GetMethodID(env, bookmarkManagerInstance, "onRestoreRequested", "(IJ)V"); + jni::GetMethodID(env, bookmarkManagerInstance, "onRestoreRequested", "(ILjava/lang/String;J)V"); g_onRestoredFilesPreparedMethod = jni::GetMethodID(env, bookmarkManagerInstance, "onRestoredFilesPrepared", "()V"); g_onImportStartedMethod = @@ -166,13 +166,14 @@ void OnSynchronizationFinished(JNIEnv * env, Cloud::SynchronizationType type, } void OnRestoreRequested(JNIEnv * env, Cloud::RestoringRequestResult result, - uint64_t backupTimestampInMs) + std::string const & deviceName, uint64_t backupTimestampInMs) { ASSERT(g_bookmarkManagerClass, ()); jobject bookmarkManagerInstance = env->GetStaticObjectField(g_bookmarkManagerClass, g_bookmarkManagerInstanceField); env->CallVoidMethod(bookmarkManagerInstance, g_onRestoreRequestedMethod, - static_cast(result), static_cast(backupTimestampInMs)); + static_cast(result), jni::ToJavaString(env, deviceName), + static_cast(backupTimestampInMs)); jni::HandleJavaException(env); } @@ -231,7 +232,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeLoadBookmarks(JNIE frm()->GetBookmarkManager().SetCloudHandlers( std::bind(&OnSynchronizationStarted, env, _1), std::bind(&OnSynchronizationFinished, env, _1, _2, _3), - std::bind(&OnRestoreRequested, env, _1, _2), + std::bind(&OnRestoreRequested, env, _1, _2, _3), std::bind(&OnRestoredFilesPrepared, env)); frm()->GetBookmarkManager().SetCatalogHandlers(nullptr, nullptr, diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java index a73f422144..d73ed398b8 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java @@ -314,10 +314,11 @@ public class BookmarkBackupController implements Authorizer.Callback, @Override public void onRestoreRequested(@BookmarkManager.RestoringRequestResult int result, - long backupTimestampInMs) + @NonNull String deviceName, long backupTimestampInMs) { - LOGGER.d(TAG, "onRestoreRequested, result: " + result + ", backupTimestampInMs = " - + backupTimestampInMs); + //TODO (@alexzatsepin): Output deviceName to the dialog. + LOGGER.d(TAG, "onRestoreRequested, result: " + result + ", deviceName = " + deviceName + + ", backupTimestampInMs = " + backupTimestampInMs); Statistics.INSTANCE.trackBmRestoringRequestResult(result); hideRestoringProgressDialog(); diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 2cb93f4d52..528e236201 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -218,11 +218,11 @@ public enum BookmarkManager // Called from JNI. @MainThread - public void onRestoreRequested(@RestoringRequestResult int result, + public void onRestoreRequested(@RestoringRequestResult int result, @NonNull String deviceName, long backupTimestampInMs) { for (BookmarksCloudListener listener : mCloudListeners) - listener.onRestoreRequested(result, backupTimestampInMs); + listener.onRestoreRequested(result, deviceName, backupTimestampInMs); } // Called from JNI. @@ -626,9 +626,11 @@ public enum BookmarkManager * The method is called after restoring request. * * @param result By result you can determine if the restoring is possible. + * @param deviceName The name of device which was the source of the backup. * @param backupTimestampInMs contains timestamp of the backup on the server (in milliseconds). */ - void onRestoreRequested(@RestoringRequestResult int result, long backupTimestampInMs); + void onRestoreRequested(@RestoringRequestResult int result, @NonNull String deviceName, + long backupTimestampInMs); /** * Restored bookmark files are prepared to substitute for the current ones. diff --git a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm index 9fe30d570f..9f3cd0b252 100644 --- a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm +++ b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm @@ -167,8 +167,10 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result) }]; }; - auto onRestoreRequested = [](Cloud::RestoringRequestResult result, uint64_t backupTimestampInMs) + auto onRestoreRequested = [](Cloud::RestoringRequestResult result, std::string const & deviceName, + uint64_t backupTimestampInMs) { + //TODO (@beloal): Output device name to the dialog. auto const res = static_cast(my::Key(result)); NSDate * date = nil; diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index a9e8a6b1b7..bdaca8611e 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -478,7 +478,7 @@ BookmarkManager::BookmarkManager(Callbacks && callbacks) m_bookmarkCloud.SetSynchronizationHandlers( std::bind(&BookmarkManager::OnSynchronizationStarted, this, _1), std::bind(&BookmarkManager::OnSynchronizationFinished, this, _1, _2, _3), - std::bind(&BookmarkManager::OnRestoreRequested, this, _1, _2), + std::bind(&BookmarkManager::OnRestoreRequested, this, _1, _2, _3), std::bind(&BookmarkManager::OnRestoredFilesPrepared, this)); } @@ -1941,16 +1941,17 @@ void BookmarkManager::OnSynchronizationFinished(Cloud::SynchronizationType type, } void BookmarkManager::OnRestoreRequested(Cloud::RestoringRequestResult result, + std::string const & deviceName, uint64_t backupTimestampInMs) { - GetPlatform().RunTask(Platform::Thread::Gui, [this, result, backupTimestampInMs]() + GetPlatform().RunTask(Platform::Thread::Gui, [this, result, deviceName, backupTimestampInMs]() { if (m_onRestoreRequested) - m_onRestoreRequested(result, backupTimestampInMs); + m_onRestoreRequested(result, deviceName, backupTimestampInMs); }); using namespace std::chrono; - LOG(LINFO, ("Cloud Restore Requested:", result, + LOG(LINFO, ("Cloud Restore Requested:", result, deviceName, time_point(milliseconds(backupTimestampInMs)))); } diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index 55df963123..14300b5f1e 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -466,7 +466,8 @@ private: void OnSynchronizationStarted(Cloud::SynchronizationType type); void OnSynchronizationFinished(Cloud::SynchronizationType type, Cloud::SynchronizationResult result, std::string const & errorStr); - void OnRestoreRequested(Cloud::RestoringRequestResult result, uint64_t backupTimestampInMs); + void OnRestoreRequested(Cloud::RestoringRequestResult result, std::string const & deviceName, + uint64_t backupTimestampInMs); void OnRestoredFilesPrepared(); bool CanConvert() const; diff --git a/map/cloud.cpp b/map/cloud.cpp index d99ff90787..8fbb3a08a0 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -1240,7 +1240,7 @@ void Cloud::ProcessSuccessfulSnapshot(SnapshotResult const & result) if (result.m_response.m_files.empty()) { ThreadSafeCallback([this]() { return m_onRestoreRequested; }, - RestoringRequestResult::NoBackup, + RestoringRequestResult::NoBackup, "", result.m_response.m_datetime); FinishRestoring(SynchronizationResult::Success, {}); return; @@ -1252,7 +1252,7 @@ void Cloud::ProcessSuccessfulSnapshot(SnapshotResult const & result) if (totalSize * kSizeScalar >= GetPlatform().GetWritableStorageSpace()) { ThreadSafeCallback([this]() { return m_onRestoreRequested; }, - RestoringRequestResult::NotEnoughDiskSpace, + RestoringRequestResult::NotEnoughDiskSpace, "", result.m_response.m_datetime); FinishRestoring(SynchronizationResult::DiskError, {}); return; @@ -1269,6 +1269,7 @@ void Cloud::ProcessSuccessfulSnapshot(SnapshotResult const & result) { ThreadSafeCallback([this]() { return m_onRestoreRequested; }, RestoringRequestResult::BackupExists, + result.m_response.m_deviceName, result.m_response.m_datetime); } } diff --git a/map/cloud.hpp b/map/cloud.hpp index c748559497..27864507ce 100644 --- a/map/cloud.hpp +++ b/map/cloud.hpp @@ -210,6 +210,7 @@ public: SynchronizationResult, std::string const & error)>; using RestoreRequestedHandler = std::function; using RestoredFilesPreparedHandler = std::function;