forked from organicmaps/organicmaps
Renamed HLA to Local ads
This commit is contained in:
parent
454ba88167
commit
daaeb195f2
7 changed files with 42 additions and 43 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<dp::OGLContextFactory> 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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<uint8_t> 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<std::mutex> lock(m_mutex);
|
||||
|
@ -80,7 +80,7 @@ void HLAManager::Teardown()
|
|||
m_thread.join();
|
||||
}
|
||||
|
||||
void HLAManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine)
|
||||
void LocalAdsManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine)
|
||||
{
|
||||
m_drapeEngine = engine;
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ void HLAManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> 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<std::mutex> 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<Request> & campaignMwms)
|
||||
bool LocalAdsManager::WaitForRequest(std::vector<Request> & campaignMwms)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
|
@ -228,14 +228,14 @@ bool HLAManager::WaitForRequest(std::vector<Request> & campaignMwms)
|
|||
return true;
|
||||
}
|
||||
|
||||
void HLAManager::OnDownloadCountry(std::string const & countryName)
|
||||
void LocalAdsManager::OnDownloadCountry(std::string const & countryName)
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<std::mutex> 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<uint8_t> HLAManager::DownloadCampaign(MwmSet::MwmId const & mwmId) const
|
||||
std::vector<uint8_t> LocalAdsManager::DownloadCampaign(MwmSet::MwmId const & mwmId) const
|
||||
{
|
||||
platform::HttpClient request(MakeRemoteURL(mwmId));
|
||||
if (!request.RunHttpRequest() || request.ErrorCode() != 200)
|
||||
|
@ -260,7 +260,7 @@ std::vector<uint8_t> HLAManager::DownloadCampaign(MwmSet::MwmId const & mwmId) c
|
|||
return std::vector<uint8_t>(response.cbegin(), response.cend());
|
||||
}
|
||||
|
||||
df::CustomSymbols HLAManager::DeserializeCampaign(std::vector<uint8_t> && rawData,
|
||||
df::CustomSymbols LocalAdsManager::DeserializeCampaign(std::vector<uint8_t> && rawData,
|
||||
std::chrono::steady_clock::time_point timestamp)
|
||||
{
|
||||
df::CustomSymbols symbols;
|
||||
|
@ -276,7 +276,7 @@ df::CustomSymbols HLAManager::DeserializeCampaign(std::vector<uint8_t> && 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);
|
|
@ -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<std::vector<MwmSet::MwmId>(m2::RectD const &)>;
|
||||
using GetMwmIdByName = function<MwmSet::MwmId(std::string const &)>;
|
||||
|
||||
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<df::DrapeEngine> engine);
|
|
@ -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 \
|
||||
|
|
Loading…
Add table
Reference in a new issue