diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index bba8499927..a84c8d0cd9 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -589,7 +589,7 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeAreNotificationsEn JNIEXPORT void JNICALL Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeImportFromCatalog( - JNIEnv * env, jobject thiz, jstring serverId, jstring filePath) + JNIEnv * env, jobject, jstring serverId, jstring filePath) { auto & bm = frm()->GetBookmarkManager(); bm.ImportDownloadedFromCatalog(ToNativeString(env, serverId), ToNativeString(env, filePath)); @@ -597,15 +597,31 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeImportFromCatalog( JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogDeeplink( - JNIEnv * env, jobject thiz, jlong catId) + JNIEnv * env, jobject, jlong catId) { auto & bm = frm()->GetBookmarkManager(); return ToJavaString(env, bm.GetCategoryCatalogDeeplink(static_cast(catId))); } +JNIEXPORT jstring JNICALL +Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogDownloadUrl( + JNIEnv * env, jobject, jstring serverId) +{ + auto & bm = frm()->GetBookmarkManager(); + return ToJavaString(env, bm.GetCatalogDownloadUrl(ToNativeString(env, serverId))); +} + +JNIEXPORT jstring JNICALL +Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogFrontendUrl( + JNIEnv * env, jobject) +{ + auto & bm = frm()->GetBookmarkManager(); + return ToJavaString(env, bm.GetCatalogFrontendUrl()); +} + JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeIsCategoryFromCatalog( - JNIEnv * env, jobject thiz, jlong catId) + JNIEnv *, jobject, jlong catId) { auto & bm = frm()->GetBookmarkManager(); return static_cast(bm.IsCategoryFromCatalog(static_cast(catId))); diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index b48efa5e78..4e1346dd82 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -445,6 +445,18 @@ public enum BookmarkManager return nativeGetCatalogDeeplink(catId); } + @NonNull + public String getCatalogDownloadUrl(@NonNull String serverId) + { + return nativeGetCatalogDownloadUrl(serverId); + } + + @NonNull + public String getCatalogFrontendUrl() + { + return nativeGetCatalogFrontendUrl(); + } + public boolean isCategoryFromCatalog(long catId) { return nativeIsCategoryFromCatalog(catId); @@ -553,6 +565,12 @@ public enum BookmarkManager @NonNull private static native String nativeGetCatalogDeeplink(long catId); + @NonNull + private static native String nativeGetCatalogDownloadUrl(@NonNull String serverId); + + @NonNull + private static native String nativeGetCatalogFrontendUrl(); + private static native boolean nativeIsCategoryFromCatalog(long catId); public interface BookmarksLoadingListener diff --git a/configure.sh b/configure.sh index 989de66a69..ef586ebd02 100755 --- a/configure.sh +++ b/configure.sh @@ -96,6 +96,8 @@ else #define CLOUD_URL "" #define MAXIM_CLIENT_ID "" #define MAXIM_SERVER_TOKEN "" +#define BOOKMARKS_CATALOG_FRONT_URL "" +#define BOOKMARKS_CATALOG_DOWNLOAD_URL "" ' > "$PRIVATE_HEADER" echo 'ext { diff --git a/map/bookmark_catalog.cpp b/map/bookmark_catalog.cpp index b2253fa4c1..944da58a96 100644 --- a/map/bookmark_catalog.cpp +++ b/map/bookmark_catalog.cpp @@ -6,14 +6,25 @@ #include "base/string_utils.hpp" +#include #include +#define STAGE_BOOKMARKS_CATALOG_SERVER +#include "private.h" + namespace { -std::string BuildCatalogUrl(std::string const & serverId) +std::string const kCatalogFrontendServer = BOOKMARKS_CATALOG_FRONT_URL; +std::string const kCatalogDownloadServer = BOOKMARKS_CATALOG_DOWNLOAD_URL; + +std::string BuildCatalogDownloadUrl(std::string const & serverId) { - //TODO: This code is temporary. - return "https://bookcat.demo.mapsme1.devmail.ru/static/" + serverId + "/" + serverId; + if (kCatalogDownloadServer.empty()) + return {}; + + std::ostringstream ss; + ss << kCatalogDownloadServer << "/static/" << serverId << "/" << serverId; + return ss.str(); } } // namespace @@ -69,7 +80,18 @@ void BookmarkCatalog::Download(std::string const & id, std::string const & name, static uint32_t counter = 0; auto const path = my::JoinPath(GetPlatform().TmpDir(), "file" + strings::to_string(++counter)); - platform::RemoteFile remoteFile(BuildCatalogUrl(id)); + auto const url = BuildCatalogDownloadUrl(id); + if (url.empty()) + { + if (finishHandler) + { + finishHandler(platform::RemoteFile::Result(url, platform::RemoteFile::Status::NetworkError, + "Empty server URL."), {}); + } + return; + } + + platform::RemoteFile remoteFile(url); remoteFile.DownloadAsync(path, [finishHandler = std::move(finishHandler)] (platform::RemoteFile::Result && result, std::string const & filePath) { @@ -77,3 +99,13 @@ void BookmarkCatalog::Download(std::string const & id, std::string const & name, finishHandler(std::move(result), filePath); }); } + +std::string BookmarkCatalog::GetCatalogDownloadUrl(std::string const & serverId) const +{ + return BuildCatalogDownloadUrl(serverId); +} + +std::string BookmarkCatalog::GetCatalogFrontendUrl() const +{ + return kCatalogFrontendServer; +} diff --git a/map/bookmark_catalog.hpp b/map/bookmark_catalog.hpp index 2c6b3b22c5..081b76b13e 100644 --- a/map/bookmark_catalog.hpp +++ b/map/bookmark_catalog.hpp @@ -22,6 +22,9 @@ public: size_t GetDownloadingCount() const { return m_downloadingIds.size(); } std::vector GetDownloadingNames() const; + std::string GetCatalogDownloadUrl(std::string const & serverId) const; + std::string GetCatalogFrontendUrl() const; + private: std::map m_downloadingIds; std::set m_downloadedIds; diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 8a1d7e18f2..ae906a3c8c 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -2078,6 +2078,16 @@ std::string BookmarkManager::GetCategoryCatalogDeeplink(kml::MarkGroupId categor return cat->GetCatalogDeeplink(); } +std::string BookmarkManager::GetCatalogDownloadUrl(std::string const & serverId) const +{ + return m_bookmarkCatalog.GetCatalogDownloadUrl(serverId); +} + +std::string BookmarkManager::GetCatalogFrontendUrl() const +{ + return m_bookmarkCatalog.GetCatalogFrontendUrl(); +} + void BookmarkManager::EnableTestMode(bool enable) { UserMarkIdStorage::Instance().EnableSaving(!enable); diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index f40585d31d..3abc1c0c67 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -287,6 +287,8 @@ public: std::vector GetDownloadingFromCatalogNames() const; bool IsCategoryFromCatalog(kml::MarkGroupId categoryId) const; std::string GetCategoryCatalogDeeplink(kml::MarkGroupId categoryId) const; + std::string GetCatalogDownloadUrl(std::string const & serverId) const; + std::string GetCatalogFrontendUrl() const; /// These functions are public for unit tests only. You shouldn't call them from client code. void EnableTestMode(bool enable);