mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[core] Allow overriding map metaserver URL and reset downloader cache
- Add custom meta server API. - Implement override. - Add reset hook and implement reset. - Expose reset from Storage. - Let JNI set URL and reset cache. Signed-off-by: NoelClick <dev@noel.click>
This commit is contained in:
@@ -1505,6 +1505,22 @@ JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeGet3dMode(JNIEnv
|
|||||||
env->SetBooleanField(result, buildingsField, buildings);
|
env->SetBooleanField(result, buildingsField, buildings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetCustomMapDownloadUrl(JNIEnv * env, jclass,
|
||||||
|
jstring url)
|
||||||
|
{
|
||||||
|
std::string const nativeUrl = jni::ToNativeString(env, url);
|
||||||
|
GetPlatform().SetCustomMetaServerUrl(nativeUrl);
|
||||||
|
|
||||||
|
if (g_framework)
|
||||||
|
{
|
||||||
|
frm()->GetStorage().ResetMapDownloadMetaConfig();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(LINFO, ("nativeSetCustomMapDownloadUrl: framework not created yet, skipping ResetMapDownloadMetaConfig"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetAutoZoomEnabled(JNIEnv * env, jclass,
|
JNIEXPORT void JNICALL Java_app_organicmaps_sdk_Framework_nativeSetAutoZoomEnabled(JNIEnv * env, jclass,
|
||||||
jboolean enabled)
|
jboolean enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ bool GetFileTypeChecked(std::string const & path, Platform::EFileType & type)
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::string g_customMetaServerUrl;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
Platform::EError Platform::ErrnoToError()
|
Platform::EError Platform::ErrnoToError()
|
||||||
{
|
{
|
||||||
@@ -150,8 +155,16 @@ 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)
|
||||||
|
{
|
||||||
|
g_customMetaServerUrl = url;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Platform::MetaServerUrl() const
|
std::string Platform::MetaServerUrl() const
|
||||||
{
|
{
|
||||||
|
if (!g_customMetaServerUrl.empty())
|
||||||
|
return g_customMetaServerUrl;
|
||||||
|
|
||||||
return METASERVER_URL;
|
return METASERVER_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +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
|
||||||
|
void SetCustomMetaServerUrl(std::string const & url);
|
||||||
|
|
||||||
/// @return url for clients to download maps
|
/// @return url for clients to download maps
|
||||||
std::string MetaServerUrl() const;
|
std::string MetaServerUrl() const;
|
||||||
|
|
||||||
|
|||||||
@@ -190,4 +190,10 @@ void MapFilesDownloader::GetMetaConfig(MetaConfigCallback const & callback)
|
|||||||
callback(LoadMetaConfig());
|
callback(LoadMetaConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapFilesDownloader::ResetMetaConfig()
|
||||||
|
{
|
||||||
|
m_serversList.clear();
|
||||||
|
m_isMetaConfigRequested = false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace storage
|
} // namespace storage
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ public:
|
|||||||
void SetDownloadingPolicy(DownloadingPolicy * policy);
|
void SetDownloadingPolicy(DownloadingPolicy * policy);
|
||||||
void SetDataVersion(int64_t version) { m_dataVersion = version; }
|
void SetDataVersion(int64_t version) { m_dataVersion = version; }
|
||||||
|
|
||||||
|
/// Reset after changes, e.g. map download URL.
|
||||||
|
void ResetMetaConfig();
|
||||||
|
|
||||||
/// @name Legacy functions for Android resources downloading routine (initial World download).
|
/// @name Legacy functions for Android resources downloading routine (initial World download).
|
||||||
/// @{
|
/// @{
|
||||||
void EnsureMetaConfigReady(std::function<void()> && callback);
|
void EnsureMetaConfigReady(std::function<void()> && callback);
|
||||||
|
|||||||
@@ -585,6 +585,12 @@ public:
|
|||||||
|
|
||||||
void RestoreDownloadQueue();
|
void RestoreDownloadQueue();
|
||||||
|
|
||||||
|
void ResetMapDownloadMetaConfig()
|
||||||
|
{
|
||||||
|
if (m_downloader)
|
||||||
|
m_downloader->ResetMetaConfig();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnFinishDownloading();
|
void OnFinishDownloading();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user