[core]Added new methods to advertise guides for already downloaded countries.

And save data about advertised guides.
This commit is contained in:
Kirill Zhdanovich 2013-08-26 14:20:44 +03:00 committed by Alex Zolotarev
parent 2aaca40f28
commit 0f431fa040
4 changed files with 29 additions and 0 deletions

View file

@ -1728,3 +1728,16 @@ bool Framework::GetGuideInfo(storage::TIndex const & index, guides::GuideInfo &
storage::TStatus t = GetCountryStatus(index);
return (t == storage::EOnDisk && GetGuidesManager().GetGuideInfo(guideId, info));
}
void Framework::GetGuidesInfosWithDownloadedMaps(vector <guides::GuideInfo> & guides)
{
vector <string> maps;
GetLocalMaps(maps);
for (size_t i = 0; i < maps.size(); ++i)
{
guides::GuideInfo tmp;
my::GetNameWithoutExt(maps[i]);
if (GetGuidesManager().GetGuideInfo(maps[i], tmp))
guides.push_back(tmp);
}
}

View file

@ -483,6 +483,7 @@ public:
public:
guides::GuidesManager & GetGuidesManager();
bool GetGuideInfo(storage::TIndex const & index, guides::GuideInfo & info);
void GetGuidesInfosWithDownloadedMaps(vector <guides::GuideInfo> & guides);
//@}
};

View file

@ -17,6 +17,7 @@
#define GUIDE_UPDATE_TIME_KEY "guideUpdateTime"
#define GUIDE_ADVERTISE_KEY "GuideAdvertised: "
#define GUIDE_UPDATE_PERIOD 60 * 60 * 24
using namespace guides;
@ -121,6 +122,18 @@ bool GuidesManager::ValidateAndParseGuidesData(string const & jsonData)
}
}
bool GuidesManager::WasAdvertised(string const & countryId)
{
bool flag = false;
Settings::Get(GUIDE_ADVERTISE_KEY + countryId, flag);
return flag;
}
void GuidesManager::SetWasAdvertised(string const & countryId)
{
Settings::Set(GUIDE_ADVERTISE_KEY + countryId, true);
}
void GuidesManager::SaveToFile() const
{
string const path = GetPlatform().WritableDir() + GetDataFileName();

View file

@ -40,6 +40,8 @@ public:
void SaveToFile() const;
bool GetGuideInfo(string const & countryId, GuideInfo & appInfo) const;
bool ValidateAndParseGuidesData(string const & jsonData);
bool WasAdvertised(string const & countryId);
void SetWasAdvertised(string const & countryId);
private:
void OnFinish(downloader::HttpRequest & request);