mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[core] Treat custom map download URL as CDN base, not meta server
- Update `MapFilesDownloader::LoadMetaConfig()` to skip the metaserver when a custom base URL is set and build MetaConfig with that URL as the only server. - Keep the existing metaserver-based behavior when no custom base URL is set. Signed-off-by: NoelClick <dev@noel.click>
This commit is contained in:
@@ -1508,8 +1508,8 @@ JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeGet3dMode(JNIEnv
|
|||||||
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetCustomMapDownloadUrl(JNIEnv * env, jclass,
|
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetCustomMapDownloadUrl(JNIEnv * env, jclass,
|
||||||
jstring url)
|
jstring url)
|
||||||
{
|
{
|
||||||
std::string const nativeUrl = jni::ToNativeString(env, url);
|
std::string nativeUrl = jni::ToNativeString(env, url);
|
||||||
GetPlatform().SetCustomMetaServerUrl(nativeUrl);
|
GetPlatform().SetCustomMapServerUrl(nativeUrl);
|
||||||
|
|
||||||
if (g_framework)
|
if (g_framework)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -155,16 +155,19 @@ std::string Platform::ReadPathForFile(std::string const & file, std::string sear
|
|||||||
"\nr: ", m_resourcesDir, "\ns: ", m_settingsDir));
|
"\nr: ", m_resourcesDir, "\ns: ", m_settingsDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::SetCustomMetaServerUrl(std::string const & url)
|
void Platform::SetCustomMapServerUrl(std::string & url)
|
||||||
{
|
{
|
||||||
g_customMetaServerUrl = url;
|
strings::Trim(url);
|
||||||
|
m_customMapServerUrl = std::move(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const & Platform::CustomMapServerUrl() const
|
||||||
|
{
|
||||||
|
return m_customMapServerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Platform::MetaServerUrl() const
|
std::string Platform::MetaServerUrl() const
|
||||||
{
|
{
|
||||||
if (!g_customMetaServerUrl.empty())
|
|
||||||
return g_customMetaServerUrl;
|
|
||||||
|
|
||||||
return METASERVER_URL;
|
return METASERVER_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,8 +268,9 @@ public:
|
|||||||
/// @return integer version in yyMMdd format.
|
/// @return integer version in yyMMdd format.
|
||||||
int32_t IntVersion() const;
|
int32_t IntVersion() const;
|
||||||
|
|
||||||
/// Set custom meta server url to allow user-defined download servers
|
/// Set custom map server url to allow user-defined download servers
|
||||||
void SetCustomMetaServerUrl(std::string const & url);
|
void SetCustomMapServerUrl(std::string & url);
|
||||||
|
std::string const & CustomMapServerUrl() const;
|
||||||
|
|
||||||
/// @return url for clients to download maps
|
/// @return url for clients to download maps
|
||||||
std::string MetaServerUrl() const;
|
std::string MetaServerUrl() const;
|
||||||
@@ -342,6 +343,8 @@ private:
|
|||||||
void ShutdownThreads();
|
void ShutdownThreads();
|
||||||
|
|
||||||
void GetSystemFontNames(FilesList & res) const;
|
void GetSystemFontNames(FilesList & res) const;
|
||||||
|
|
||||||
|
std::string m_customMapServerUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string DebugPrint(Platform::EError err);
|
std::string DebugPrint(Platform::EError err);
|
||||||
|
|||||||
@@ -156,6 +156,26 @@ std::string GetAcceptLanguage()
|
|||||||
MetaConfig MapFilesDownloader::LoadMetaConfig()
|
MetaConfig MapFilesDownloader::LoadMetaConfig()
|
||||||
{
|
{
|
||||||
Platform & pl = GetPlatform();
|
Platform & pl = GetPlatform();
|
||||||
|
std::optional<MetaConfig> metaConfig;
|
||||||
|
|
||||||
|
std::string const customServer = pl.CustomMapServerUrl();
|
||||||
|
|
||||||
|
if (!customServer.empty())
|
||||||
|
{
|
||||||
|
LOG(LINFO, ("Using custom map server URL:", customServer));
|
||||||
|
|
||||||
|
// Reuse default meta settings (timeouts, other endpoints) and override servers
|
||||||
|
metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
|
||||||
|
CHECK(metaConfig, ());
|
||||||
|
|
||||||
|
metaConfig->m_serversList.clear();
|
||||||
|
metaConfig->m_serversList.push_back(customServer);
|
||||||
|
|
||||||
|
LOG(LINFO, ("Got servers list (custom server):", metaConfig->m_serversList));
|
||||||
|
CHECK(!metaConfig->m_serversList.empty(), ());
|
||||||
|
return *metaConfig;
|
||||||
|
}
|
||||||
|
|
||||||
std::string const metaServerUrl = pl.MetaServerUrl();
|
std::string const metaServerUrl = pl.MetaServerUrl();
|
||||||
std::string httpResult;
|
std::string httpResult;
|
||||||
|
|
||||||
@@ -170,7 +190,7 @@ MetaConfig MapFilesDownloader::LoadMetaConfig()
|
|||||||
request.RunHttpRequest(httpResult);
|
request.RunHttpRequest(httpResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<MetaConfig> metaConfig = downloader::ParseMetaConfig(httpResult);
|
metaConfig = downloader::ParseMetaConfig(httpResult);
|
||||||
if (!metaConfig)
|
if (!metaConfig)
|
||||||
{
|
{
|
||||||
metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
|
metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
|
||||||
|
|||||||
Reference in New Issue
Block a user