From dbe193dff09b7f5a27bf0439335297e2284ed69c Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 17 Jan 2019 13:48:56 +0300 Subject: [PATCH] [BM] Added web editor link --- .../maps/bookmarks/data/BookmarkManager.cpp | 9 +++++++++ .../maps/bookmarks/data/BookmarkManager.java | 9 +++++++++ map/bookmark_catalog.cpp | 20 +++++++++++++++---- map/bookmark_catalog.hpp | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index 0bdaa3b302..6c589a6746 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -858,6 +858,15 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogDownload return ToJavaString(env, bm.GetCatalog().GetDownloadUrl(ToNativeString(env, serverId))); } +JNIEXPORT jstring JNICALL +Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetWebEditorUrl( + JNIEnv * env, jobject, jstring serverId) +{ + auto & bm = frm()->GetBookmarkManager(); + return ToJavaString(env, bm.GetCatalog().GetWebEditorUrl(ToNativeString(env, serverId), + languages::GetCurrentNorm())); +} + JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeGetCatalogFrontendUrl( JNIEnv * env, jobject) diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 3e888aefea..e7cfb6bd8b 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -619,6 +619,12 @@ public enum BookmarkManager return nativeGetCatalogDownloadUrl(serverId); } + @NonNull + public String getWebEditorUrl(@NonNull String serverId) + { + return nativeGetWebEditorUrl(serverId); + } + @NonNull public String getCatalogFrontendUrl() { @@ -765,6 +771,9 @@ public enum BookmarkManager @NonNull private static native String nativeGetCatalogDownloadUrl(@NonNull String serverId); + @NonNull + private static native String nativeGetWebEditorUrl(@NonNull String serverId); + @NonNull private static native String nativeGetCatalogFrontendUrl(); diff --git a/map/bookmark_catalog.cpp b/map/bookmark_catalog.cpp index 0a9a793769..47ee2625a2 100644 --- a/map/bookmark_catalog.cpp +++ b/map/bookmark_catalog.cpp @@ -63,6 +63,13 @@ std::string BuildUploadUrl() return kCatalogFrontendServer + "storage/upload"; } +std::string BuildWebEditorUrl(std::string const & serverId, std::string const & language) +{ + if (kCatalogDownloadServer.empty()) + return {}; + return kCatalogDownloadServer + "webeditor/" + language + "/edit/" + serverId; +} + struct SubtagData { std::string m_name; @@ -268,6 +275,12 @@ std::string BookmarkCatalog::GetDownloadUrl(std::string const & serverId) const return BuildCatalogDownloadUrl(serverId); } +std::string BookmarkCatalog::GetWebEditorUrl(std::string const & serverId, + std::string const & language) const +{ + return BuildWebEditorUrl(serverId, language); +} + std::string BookmarkCatalog::GetFrontendUrl() const { return kCatalogFrontendServer + languages::GetCurrentNorm() + "/v2/mobilefront/"; @@ -428,13 +441,12 @@ void BookmarkCatalog::Upload(UploadData uploadData, std::string const & accessTo return; } - if (fileData->m_categoryData.m_accessRules == kml::AccessRules::Public && - uploadData.m_accessRules != kml::AccessRules::Public) + if (!fileData->m_categoryData.m_authorId.empty() && + fileData->m_categoryData.m_authorId != uploadData.m_userId) { if (uploadErrorCallback) { - uploadErrorCallback(UploadResult::AccessError, "Could not upload public bookmarks with " + - DebugPrint(uploadData.m_accessRules) + " access."); + uploadErrorCallback(UploadResult::AccessError, "Could not upload not own bookmarks."); } return; } diff --git a/map/bookmark_catalog.hpp b/map/bookmark_catalog.hpp index 1101ce1a64..ed699cbc49 100644 --- a/map/bookmark_catalog.hpp +++ b/map/bookmark_catalog.hpp @@ -78,6 +78,7 @@ public: std::vector GetDownloadingNames() const; std::string GetDownloadUrl(std::string const & serverId) const; + std::string GetWebEditorUrl(std::string const & serverId, std::string const & language) const; std::string GetFrontendUrl() const; void RequestTagGroups(std::string const & language, TagGroupsCallback && callback) const;