diff --git a/.gitignore b/.gitignore index bbd9c04cff..bc975bd19f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ data/*.mwm.osm2ft data/*.mwm.routing data/*.mwmmeta data/[!W]*.mwm -data/hla*.dat +data/local_ads*.dat # Compiled Python *.pyc diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index cd8d7d8509..198302b6f1 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -43,8 +43,8 @@ set( gps_track.hpp gps_tracker.cpp gps_tracker.hpp - hla_manager.cpp - hla_manager.hpp + local_ads_manager.cpp + local_ads_manager.hpp mwm_url.cpp mwm_url.hpp place_page_info.cpp diff --git a/map/framework.cpp b/map/framework.cpp index 49100905dd..ead18ca55f 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -276,9 +276,9 @@ TrafficManager & Framework::GetTrafficManager() return m_trafficManager; } -HLAManager & Framework::GetHLAManager() +LocalAdsManager & Framework::GetLocalAdsManager() { - return m_hlaManager; + return m_localAdsManager; } bool Framework::IsTrackingReporterEnabled() const @@ -314,7 +314,7 @@ void Framework::OnViewportChanged(ScreenBase const & screen) m_currentModelView = screen; m_trafficManager.UpdateViewport(m_currentModelView); - m_hlaManager.UpdateViewport(m_currentModelView); + m_localAdsManager.UpdateViewport(m_currentModelView); if (m_viewportChanged != nullptr) m_viewportChanged(screen); @@ -399,7 +399,7 @@ Framework::Framework() , m_trafficManager(bind(&Framework::GetMwmsByRect, this, _1), kMaxTrafficCacheSizeBytes, // Note. |m_routingSession| should be declared before |m_trafficManager|. m_routingSession) - , m_hlaManager(bind(&Framework::GetMwmsByRect, this, _1), bind(&Framework::GetMwmIdByName, this, _1)) + , m_localAdsManager(bind(&Framework::GetMwmsByRect, this, _1), bind(&Framework::GetMwmIdByName, this, _1)) , m_displacementModeManager([this](bool show) { int const mode = show ? dp::displacement::kHotelMode : dp::displacement::kDefaultMode; CallDrapeFunction(bind(&df::DrapeEngine::SetDisplacementMode, _1, mode)); @@ -506,7 +506,7 @@ Framework::Framework() Framework::~Framework() { m_trafficManager.Teardown(); - m_hlaManager.Teardown(); + m_localAdsManager.Teardown(); DestroyDrapeEngine(); m_model.SetOnMapDeregisteredCallback(nullptr); } @@ -623,7 +623,7 @@ void Framework::OnCountryFileDownloaded(storage::TCountryId const & countryId, s rect = id.GetInfo()->m_limitRect; } m_trafficManager.Invalidate(); - m_hlaManager.OnDownloadCountry(countryId); + m_localAdsManager.OnDownloadCountry(countryId); InvalidateRect(rect); m_searchEngine->ClearCaches(); } @@ -648,7 +648,7 @@ bool Framework::OnCountryFileDelete(storage::TCountryId const & countryId, stora m_model.DeregisterMap(platform::CountryFile(countryId)); deferredDelete = true; m_trafficManager.OnMwmDelete(mwmId); - m_hlaManager.OnDeleteCountry(countryId); + m_localAdsManager.OnDeleteCountry(countryId); } InvalidateRect(rect); @@ -1795,7 +1795,7 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, m_drapeApi.SetEngine(make_ref(m_drapeEngine)); m_trafficManager.SetDrapeEngine(make_ref(m_drapeEngine)); - m_hlaManager.SetDrapeEngine(make_ref(m_drapeEngine)); + m_localAdsManager.SetDrapeEngine(make_ref(m_drapeEngine)); benchmark::RunGraphicsBenchmark(this); } @@ -1832,7 +1832,7 @@ void Framework::DestroyDrapeEngine() { m_drapeApi.SetEngine(nullptr); m_trafficManager.Teardown(); - m_hlaManager.Teardown(); + m_localAdsManager.Teardown(); GpsTracker::Instance().Disconnect(); m_drapeEngine.reset(); } diff --git a/map/framework.hpp b/map/framework.hpp index 8db53b50db..d0b2c6ec1f 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -6,7 +6,7 @@ #include "map/city_finder.hpp" #include "map/displacement_mode_manager.hpp" #include "map/feature_vec_model.hpp" -#include "map/hla_manager.hpp" +#include "map/local_ads_manager.hpp" #include "map/mwm_url.hpp" #include "map/place_page_info.hpp" #include "map/track.hpp" @@ -177,7 +177,7 @@ protected: TrafficManager m_trafficManager; - HLAManager m_hlaManager; + LocalAdsManager m_localAdsManager; /// This function will be called by m_storage when latest local files /// is downloaded. @@ -793,7 +793,7 @@ public: TrafficManager & GetTrafficManager(); - HLAManager & GetHLAManager(); + LocalAdsManager & GetLocalAdsManager(); bool LoadTrafficEnabled(); void SaveTrafficEnabled(bool trafficEnabled); diff --git a/map/hla_manager.cpp b/map/local_ads_manager.cpp similarity index 87% rename from map/hla_manager.cpp rename to map/local_ads_manager.cpp index bd97566e90..7c83983eb2 100644 --- a/map/hla_manager.cpp +++ b/map/local_ads_manager.cpp @@ -1,4 +1,4 @@ -#include "map/hla_manager.hpp" +#include "map/local_ads_manager.hpp" #include "drape_frontend/drape_engine.hpp" #include "drape_frontend/visual_params.hpp" @@ -13,8 +13,8 @@ namespace { -std::string const kCampaignFile = "hla_campaigns.dat"; -std::string const kExpirationFile = "hla_expiration.dat"; +std::string const kCampaignFile = "local_ads_campaigns.dat"; +std::string const kExpirationFile = "local_ads_expiration.dat"; auto constexpr kWWanUpdateTimeout = std::chrono::hours(12); std::vector SerializeTimestamp(std::chrono::steady_clock::time_point ts) @@ -48,17 +48,17 @@ std::string GetPath(std::string const & fileName) } } // namespace -HLAManager::HLAManager(GetMwmsByRectFn const & getMwmsByRectFn, +LocalAdsManager::LocalAdsManager(GetMwmsByRectFn const & getMwmsByRectFn, GetMwmIdByName const & getMwmIdByName) : m_getMwmsByRectFn(getMwmsByRectFn) , m_getMwmIdByNameFn(getMwmIdByName) - , m_thread(&HLAManager::ThreadRoutine, this) + , m_thread(&LocalAdsManager::ThreadRoutine, this) { CHECK(m_getMwmsByRectFn != nullptr, ()); CHECK(m_getMwmIdByNameFn != nullptr, ()); } -HLAManager::~HLAManager() +LocalAdsManager::~LocalAdsManager() { #ifdef DEBUG { @@ -68,7 +68,7 @@ HLAManager::~HLAManager() #endif } -void HLAManager::Teardown() +void LocalAdsManager::Teardown() { { std::lock_guard lock(m_mutex); @@ -80,7 +80,7 @@ void HLAManager::Teardown() m_thread.join(); } -void HLAManager::SetDrapeEngine(ref_ptr engine) +void LocalAdsManager::SetDrapeEngine(ref_ptr engine) { m_drapeEngine = engine; { @@ -90,7 +90,7 @@ void HLAManager::SetDrapeEngine(ref_ptr engine) } } -void HLAManager::UpdateViewport(ScreenBase const & screen) +void LocalAdsManager::UpdateViewport(ScreenBase const & screen) { auto connectionStatus = GetPlatform().ConnectionStatus(); if (connectionStatus == Platform::EConnectionType::CONNECTION_NONE || @@ -104,7 +104,7 @@ void HLAManager::UpdateViewport(ScreenBase const & screen) if (mwms.empty()) return; - // Request HLA campaigns. + // Request local ads campaigns. { std::lock_guard lock(m_mutex); @@ -147,7 +147,7 @@ void HLAManager::UpdateViewport(ScreenBase const & screen) } } -void HLAManager::ThreadRoutine() +void LocalAdsManager::ThreadRoutine() { std::string const campaignFile = GetPath(kCampaignFile); std::string const expirationFile = GetPath(kExpirationFile); @@ -213,7 +213,7 @@ void HLAManager::ThreadRoutine() } } -bool HLAManager::WaitForRequest(std::vector & campaignMwms) +bool LocalAdsManager::WaitForRequest(std::vector & campaignMwms) { std::unique_lock lock(m_mutex); @@ -228,14 +228,14 @@ bool HLAManager::WaitForRequest(std::vector & campaignMwms) return true; } -void HLAManager::OnDownloadCountry(std::string const & countryName) +void LocalAdsManager::OnDownloadCountry(std::string const & countryName) { std::lock_guard lock(m_mutex); m_campaigns.erase(countryName); m_expiration.erase(countryName); } -void HLAManager::OnDeleteCountry(std::string const & countryName) +void LocalAdsManager::OnDeleteCountry(std::string const & countryName) { std::lock_guard lock(m_mutex); m_campaigns.erase(countryName); @@ -244,14 +244,14 @@ void HLAManager::OnDeleteCountry(std::string const & countryName) m_condition.notify_one(); } -string HLAManager::MakeRemoteURL(MwmSet::MwmId const &mwmId) const +string LocalAdsManager::MakeRemoteURL(MwmSet::MwmId const &mwmId) const { // TODO: build correct URL after server completion. return "http://172.27.15.68/campaigns.data"; } -std::vector HLAManager::DownloadCampaign(MwmSet::MwmId const & mwmId) const +std::vector LocalAdsManager::DownloadCampaign(MwmSet::MwmId const & mwmId) const { platform::HttpClient request(MakeRemoteURL(mwmId)); if (!request.RunHttpRequest() || request.ErrorCode() != 200) @@ -260,7 +260,7 @@ std::vector HLAManager::DownloadCampaign(MwmSet::MwmId const & mwmId) c return std::vector(response.cbegin(), response.cend()); } -df::CustomSymbols HLAManager::DeserializeCampaign(std::vector && rawData, +df::CustomSymbols LocalAdsManager::DeserializeCampaign(std::vector && rawData, std::chrono::steady_clock::time_point timestamp) { df::CustomSymbols symbols; @@ -276,7 +276,7 @@ df::CustomSymbols HLAManager::DeserializeCampaign(std::vector && rawDat return symbols; } -void HLAManager::ReadExpirationFile(std::string const & expirationFile) +void LocalAdsManager::ReadExpirationFile(std::string const & expirationFile) { if (!GetPlatform().IsFileExistsByFullPath(expirationFile)) { @@ -299,7 +299,7 @@ void HLAManager::ReadExpirationFile(std::string const & expirationFile) } } -void HLAManager::ReadCampaignFile(std::string const & campaignFile) +void LocalAdsManager::ReadCampaignFile(std::string const & campaignFile) { if (!GetPlatform().IsFileExistsByFullPath(campaignFile)) { @@ -332,7 +332,7 @@ void HLAManager::ReadCampaignFile(std::string const & campaignFile) } } -void HLAManager::SendSymbolsToRendering(df::CustomSymbols && symbols) +void LocalAdsManager::SendSymbolsToRendering(df::CustomSymbols && symbols) { if (m_drapeEngine == nullptr) { @@ -343,7 +343,7 @@ void HLAManager::SendSymbolsToRendering(df::CustomSymbols && symbols) m_drapeEngine->AddCustomSymbols(std::move(symbols)); } -void HLAManager::DeleteSymbolsFromRendering(MwmSet::MwmId const & mwmId) +void LocalAdsManager::DeleteSymbolsFromRendering(MwmSet::MwmId const & mwmId) { if (m_drapeEngine != nullptr) m_drapeEngine->RemoveCustomSymbols(mwmId); diff --git a/map/hla_manager.hpp b/map/local_ads_manager.hpp similarity index 90% rename from map/hla_manager.hpp rename to map/local_ads_manager.hpp index fd4acd006b..72b64d3115 100644 --- a/map/hla_manager.hpp +++ b/map/local_ads_manager.hpp @@ -23,16 +23,15 @@ namespace df class DrapeEngine; } // namespace df -// Hyper Local Ads (HLA) manager. -class HLAManager final +class LocalAdsManager final { public: using GetMwmsByRectFn = function(m2::RectD const &)>; using GetMwmIdByName = function; - HLAManager(GetMwmsByRectFn const & getMwmsByRectFn, GetMwmIdByName const & getMwmIdByName); - HLAManager(HLAManager && /* hlaManager */) = default; - ~HLAManager(); + LocalAdsManager(GetMwmsByRectFn const & getMwmsByRectFn, GetMwmIdByName const & getMwmIdByName); + LocalAdsManager(LocalAdsManager && /* localAdsManager */) = default; + ~LocalAdsManager(); void Teardown(); void SetDrapeEngine(ref_ptr engine); diff --git a/map/map.pro b/map/map.pro index d77cf3f23f..6cf25d1408 100644 --- a/map/map.pro +++ b/map/map.pro @@ -27,7 +27,7 @@ HEADERS += \ gps_track_filter.hpp \ gps_track_storage.hpp \ gps_tracker.hpp \ - hla_manager.hpp \ + local_ads_manager.hpp \ mwm_url.hpp \ place_page_info.hpp \ reachable_by_taxi_checker.hpp \ @@ -54,7 +54,7 @@ SOURCES += \ gps_track_filter.cpp \ gps_track_storage.cpp \ gps_tracker.cpp \ - hla_manager.cpp \ + local_ads_manager.cpp \ mwm_url.cpp \ place_page_info.cpp \ reachable_by_taxi_checker.cpp \