diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 40fc99e7ab..b4b0f4e425 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -60,7 +60,7 @@ LOCAL_SRC_FILES := \ nv_time/nv_time.cpp LOCAL_LDLIBS := -llog -lGLESv2 \ - -lmap -lgui -lversion -lsearch -lstorage -lindexer -lgraphics -lplatform -lanim \ + -lmap -lgui -lsearch -lstorage -lindexer -lgraphics -lplatform -lanim \ -lgeometry -lcoding -lbase -lexpat -lfreetype -lfribidi -lzlib -lbzip2 \ -ljansson -ltomcrypt -lprotobuf ./obj/local/$(TARGET_ARCH_ABI)/libgnustl_static.a diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 8c2e39f46a..fba492c7f3 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -472,11 +472,6 @@ namespace android m_work.RemoveLocalMaps(); } - void Framework::AddMap(string const & fileName) - { - m_work.AddMap(fileName); - } - void Framework::GetMapsWithoutSearch(vector & out) const { ASSERT ( out.empty(), () ); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index f17eae8d66..2050c3d38d 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -116,7 +116,6 @@ namespace android void AddLocalMaps(); void RemoveLocalMaps(); - void AddMap(string const & fileName); void GetMapsWithoutSearch(vector & out) const; diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index d6fe84e11f..c089185f25 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -11,11 +11,10 @@ #include "../indexer/feature_impl.hpp" #include "../indexer/geometry_serialization.hpp" #include "../indexer/scales.hpp" +#include "../indexer/mwm_version.hpp" #include "../geometry/polygon.hpp" -#include "../version/ver_serialization.hpp" - #include "../coding/internal/file_data.hpp" #include "../coding/file_container.hpp" diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index d7e08fb670..52d0230c15 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -29,10 +29,7 @@ #include "../../std/iomanip.hpp" #include "../../std/numeric.hpp" -#include "../../version/version.hpp" - -DEFINE_bool(version, false, "Display version"); DEFINE_bool(generate_update, false, "If specified, update.maps file will be generated from cells in the data path"); @@ -94,12 +91,6 @@ int main(int argc, char ** argv) string const path = FLAGS_data_path.empty() ? pl.WritableDir() : AddSlashIfNeeded(FLAGS_data_path); - if (FLAGS_version) - { - cout << "Tool version: " << VERSION_STRING << endl; - cout << "Built on: " << VERSION_DATE_STRING << endl; - } - #ifndef OMIM_PRODUCTION // Make a classificator if (FLAGS_generate_classif) diff --git a/generator/generator_tool/generator_tool.pro b/generator/generator_tool/generator_tool.pro index a4924a1a1c..6728ef024a 100644 --- a/generator/generator_tool/generator_tool.pro +++ b/generator/generator_tool/generator_tool.pro @@ -2,7 +2,7 @@ ROOT_DIR = ../.. DEPENDENCIES = generator storage indexer platform geometry coding base gflags expat sgitess \ - jansson version protobuf tomcrypt + jansson protobuf tomcrypt include($$ROOT_DIR/common.pri) diff --git a/indexer/data_factory.cpp b/indexer/data_factory.cpp index 398926bd3c..34011ad3ea 100644 --- a/indexer/data_factory.cpp +++ b/indexer/data_factory.cpp @@ -3,6 +3,7 @@ #include "data_factory.hpp" #include "interval_index.hpp" #include "old/interval_index_101.hpp" +#include "mwm_version.hpp" #include "../defines.hpp" @@ -10,17 +11,22 @@ #include "../coding/file_container.hpp" -void LoadMapHeader(FilesContainerR const & cont, feature::DataHeader & header) -{ - ModelReaderPtr r = cont.GetReader(HEADER_FILE_TAG); +typedef feature::DataHeader FHeaderT; - if (cont.IsReaderExist(VERSION_FILE_TAG)) - header.Load(r); +void LoadMapHeader(FilesContainerR const & cont, FHeaderT & header) +{ + ModelReaderPtr headerReader = cont.GetReader(HEADER_FILE_TAG); + + if (!cont.IsReaderExist(VERSION_FILE_TAG)) + header.LoadVer1(headerReader); else - header.LoadVer1(r); + { + ModelReaderPtr verReader = cont.GetReader(VERSION_FILE_TAG); + header.Load(headerReader, static_cast(ver::ReadVersion(verReader))); + } } -void LoadMapHeader(ModelReaderPtr const & reader, feature::DataHeader & header) +void LoadMapHeader(ModelReaderPtr const & reader, FHeaderT & header) { LoadMapHeader(FilesContainerR(reader), header); } @@ -32,18 +38,16 @@ void IndexFactory::Load(FilesContainerR const & cont) IntervalIndexIFace * IndexFactory::CreateIndex(ModelReaderPtr reader) { - using namespace feature; - IntervalIndexIFace * p; switch (m_header.GetVersion()) { - case DataHeader::v1: + case FHeaderT::v1: p = new old_101::IntervalIndex(reader); break; default: - p = new IntervalIndex(reader);; + p = new IntervalIndex(reader); break; } diff --git a/indexer/data_header.cpp b/indexer/data_header.cpp index fadef04e4e..be6c79961c 100644 --- a/indexer/data_header.cpp +++ b/indexer/data_header.cpp @@ -93,7 +93,7 @@ namespace feature WriteVarInt(w, static_cast(m_type)); } - void DataHeader::Load(ModelReaderPtr const & r) + void DataHeader::Load(ModelReaderPtr const & r, Version ver /*= unknownVersion*/) { ReaderSource src(r); m_codingParams.Load(src); @@ -106,7 +106,7 @@ namespace feature m_type = static_cast(ReadVarInt(src)); - m_ver = v2; + m_ver = ver; } void DataHeader::LoadVer1(ModelReaderPtr const & r) diff --git a/indexer/data_header.hpp b/indexer/data_header.hpp index 470e6483d5..88a80d555e 100644 --- a/indexer/data_header.hpp +++ b/indexer/data_header.hpp @@ -59,21 +59,24 @@ namespace feature pair GetScaleRange() const; + enum Version + { + unknownVersion = -1, + v1 = 0, // April 2011 + v2, // November 2011 (store type index, instead of raw type in mwm) + v3, // March 2013 (store type index, instead of raw type in search data) + lastVersion = v3 + }; + inline Version GetVersion() const { return m_ver; } + /// @name Serialization //@{ void Save(FileWriter & w) const; - void Load(ModelReaderPtr const & r); + void Load(ModelReaderPtr const & r, Version ver = unknownVersion); void LoadVer1(ModelReaderPtr const & r); //@} - enum Version { - v1, // April 2011 - v2, // November 2011 - latestVersion = v2 - }; - inline Version GetVersion() const { return m_ver; } - enum MapType { world, worldcoasts, diff --git a/indexer/indexer.pro b/indexer/indexer.pro index aa2357c3bc..81f19e71c1 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -42,6 +42,7 @@ SOURCES += \ search_string_utils.cpp \ string_file.cpp \ feature_algo.cpp \ + mwm_version.cpp \ HEADERS += \ feature.hpp \ @@ -89,6 +90,7 @@ HEADERS += \ drules_struct.pb.h \ string_file.hpp \ feature_algo.hpp \ + mwm_version.hpp \ OTHER_FILES += drules_struct.proto diff --git a/indexer/mwm_version.cpp b/indexer/mwm_version.cpp new file mode 100644 index 0000000000..acfcec028e --- /dev/null +++ b/indexer/mwm_version.cpp @@ -0,0 +1,43 @@ +#include "mwm_version.hpp" +#include "data_header.hpp" + +#include "../coding/varint.hpp" +#include "../coding/writer.hpp" +#include "../coding/reader.hpp" + +#include "../base/timer.hpp" + + +namespace ver { + +typedef feature::DataHeader FHeaderT; + +char MWM_PROLOG[] = "MWM"; + +void WriteVersion(Writer & w) +{ + w.Write(MWM_PROLOG, ARRAY_SIZE(MWM_PROLOG)); + + // write inner data version + WriteVarUint(w, static_cast(FHeaderT::lastVersion)); + + // static is used for equal time stamp for all "mwm" files in one generation process + static uint32_t generatorStartTime = my::TodayAsYYMMDD(); + WriteVarUint(w, generatorStartTime); +} + +uint32_t ReadVersion(ModelReaderPtr const & r) +{ + ReaderSource src(r); + + size_t const prologSize = ARRAY_SIZE(MWM_PROLOG); + char prolog[prologSize]; + src.Read(prolog, prologSize); + + if (strcmp(prolog, MWM_PROLOG) != 0) + return FHeaderT::v2; + + return ReadVarUint(src); +} + +} diff --git a/indexer/mwm_version.hpp b/indexer/mwm_version.hpp new file mode 100644 index 0000000000..9785bd3a45 --- /dev/null +++ b/indexer/mwm_version.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "../std/stdint.hpp" + + +class ModelReaderPtr; +class Writer; + +namespace ver +{ + class VersionData + { + uint32_t m_mwmVer; + uint32_t m_timeStamp; + }; + + void WriteVersion(Writer & w); + uint32_t ReadVersion(ModelReaderPtr const & r); +} diff --git a/map/benchmark_engine.cpp b/map/benchmark_engine.cpp index 55afff7cb9..64c51477d5 100644 --- a/map/benchmark_engine.cpp +++ b/map/benchmark_engine.cpp @@ -5,11 +5,10 @@ #include "../platform/platform.hpp" #include "../coding/file_container.hpp" +#include "../coding/reader_streambuf.hpp" #include "../std/fstream.hpp" -#include "../version/version.hpp" - template class DoGetBenchmarks { @@ -76,50 +75,47 @@ public: template void ForEachBenchmarkRecord(ToDo & toDo) { - Platform & pl = GetPlatform(); - - string buffer; try { string configPath; - Settings::Get("BenchmarkConfig", configPath); - ReaderPtr(pl.GetReader(configPath)).ReadAsString(buffer); + if (!Settings::Get("BenchmarkConfig", configPath)) + return; + + ReaderStreamBuf buffer(GetPlatform().GetReader(configPath)); + istream stream(&buffer); + + string line; + while (stream.good()) + { + getline(stream, line); + + vector parts; + strings::SimpleTokenizer it(line, " \t"); + while (it) + { + parts.push_back(*it); + ++it; + } + + if (!parts.empty()) + toDo(parts); + } } catch (RootException const & e) { LOG(LERROR, ("Error reading benchmarks: ", e.what())); - return; - } - - istringstream stream(buffer); - - string line; - while (stream.good()) - { - getline(stream, line); - - vector parts; - strings::SimpleTokenizer it(line, " "); - while (it) - { - parts.push_back(*it); - ++it; - } - - if (!parts.empty()) - toDo(parts); } } struct MapsCollector { vector m_maps; + void operator() (vector const & v) { - if (!v[0].empty()) - if (v[0][0] == '#') - return; - m_maps.push_back(v[0]); + ASSERT(!v[0].empty(), ()); + if (v[0][0] != '#') + m_maps.push_back(v[0]); } }; @@ -130,6 +126,7 @@ void BenchmarkEngine::PrepareMaps() m_framework->GetLocalMaps(files); for_each(files.begin(), files.end(), bind(&Framework::RemoveMap, m_framework, _1)); + // add only maps needed for benchmarks MapsCollector collector; ForEachBenchmarkRecord(collector); @@ -180,7 +177,6 @@ void BenchmarkEngine::SaveBenchmarkResults() for (size_t i = 0; i < m_benchmarkResults.size(); ++i) { fout << GetPlatform().DeviceName() << " " - << VERSION_STRING << " " << m_startTime << " " << m_benchmarkResults[i].m_name << " " << m_benchmarkResults[i].m_rect.minX() << " " diff --git a/omim.pro b/omim.pro index abee2ec558..87d85e8ab0 100644 --- a/omim.pro +++ b/omim.pro @@ -11,7 +11,6 @@ SUBDIRS = 3party \ base base/base_tests \ coding coding/coding_tests \ geometry \ - version \ indexer \ platform \ geometry/geometry_tests \ @@ -35,7 +34,6 @@ SUBDIRS = 3party \ base \ coding \ geometry \ - version \ platform \ anim \ indexer \ diff --git a/omim_light.pro b/omim_light.pro index c00cda39bb..a7a60838f2 100644 --- a/omim_light.pro +++ b/omim_light.pro @@ -15,7 +15,6 @@ SUBDIRS = \ platform \ search search/search_tests \ geometry/geometry_tests \ - version \ platform/platform_tests \ yg \ storage storage/storage_tests \ diff --git a/qt/about.cpp b/qt/about.cpp index f04ca97975..738940b3c1 100644 --- a/qt/about.cpp +++ b/qt/about.cpp @@ -1,7 +1,5 @@ #include "about.hpp" -#include "../version/version.hpp" - #include "../platform/platform.hpp" #include @@ -12,6 +10,7 @@ #include #include + AboutDialog::AboutDialog(QWidget * parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) { @@ -22,12 +21,7 @@ AboutDialog::AboutDialog(QWidget * parent) QLabel * labelIcon = new QLabel(); labelIcon->setPixmap(icon.pixmap(128)); - QString const versionString = tr("

%1 %2

" - "
" - "Built on %3" - ).arg(QString("MapsWithMe"), QLatin1String(VERSION_STRING), - QLatin1String(VERSION_DATE_STRING)); - QLabel * labelVersion = new QLabel(versionString); + QLabel * labelVersion = new QLabel(QString::fromAscii("TODO: Insert version to bundle.")); QHBoxLayout * hBox = new QHBoxLayout(); hBox->addWidget(labelIcon); @@ -39,8 +33,10 @@ AboutDialog::AboutDialog(QWidget * parent) ReaderPtr reader = GetPlatform().GetReader("about.html"); reader.ReadAsString(aboutText); } - catch (...) - {} + catch (RootException const & ex) + { + LOG(LWARNING, ("About text error: ", ex.Msg())); + } if (!aboutText.empty()) { diff --git a/qt/main.cpp b/qt/main.cpp index d498210c14..d31e1c36dc 100644 --- a/qt/main.cpp +++ b/qt/main.cpp @@ -10,8 +10,6 @@ #include "../coding/file_reader.hpp" -#include "../version/version.hpp" - #include "../std/cstdio.hpp" #include @@ -19,7 +17,6 @@ //#include -#define SETTING_EULA_ACCEPTED "EulaAccepted" namespace { @@ -63,9 +60,6 @@ int main(int argc, char * argv[]) InitializeFinalize mainGuard; UNUSED_VALUE(mainGuard); - LOG_SHORT(LINFO, ("Started MapsWithMe version", VERSION_STRING)); - LOG_SHORT(LINFO, ("Built on", VERSION_DATE_STRING)); - QApplication a(argc, argv); (void)GetPlatform(); @@ -86,8 +80,9 @@ int main(int argc, char * argv[]) Settings::Set("Units", u); // display EULA if needed + char const * settingsEULA = "EulaAccepted"; bool eulaAccepted = false; - if (!Settings::Get(SETTING_EULA_ACCEPTED, eulaAccepted) || !eulaAccepted) + if (!Settings::Get(settingsEULA, eulaAccepted) || !eulaAccepted) { QStringList buttons; buttons << "Accept" << "Decline"; @@ -99,7 +94,7 @@ int main(int argc, char * argv[]) } qt::InfoDialog eulaDialog("MapsWithMe End User Licensing Agreement", buffer.c_str(), NULL, buttons); eulaAccepted = (eulaDialog.exec() == 1); - Settings::Set(SETTING_EULA_ACCEPTED, eulaAccepted); + Settings::Set(settingsEULA, eulaAccepted); } int returnCode = -1; diff --git a/qt/qt.pro b/qt/qt.pro index a8879c79e9..2e493932c8 100644 --- a/qt/qt.pro +++ b/qt/qt.pro @@ -1,7 +1,7 @@ # Main application in qt. ROOT_DIR = .. DEPENDENCIES = map gui search storage indexer graphics platform anim geometry coding base \ - bzip2 freetype expat fribidi tomcrypt jansson version protobuf zlib + bzip2 freetype expat fribidi tomcrypt jansson protobuf zlib include($$ROOT_DIR/common.pri) diff --git a/version/empty_stub.cpp b/version/empty_stub.cpp deleted file mode 100644 index 9c100003dd..0000000000 --- a/version/empty_stub.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "version.hpp" diff --git a/version/ver_serialization.hpp b/version/ver_serialization.hpp deleted file mode 100644 index 060163c873..0000000000 --- a/version/ver_serialization.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "version.hpp" - -#include "../coding/write_to_sink.hpp" - -#include "../base/timer.hpp" - - -namespace ver -{ - template void WriteVersion(TSink & sink) - { - // static is used for equal time stamp for all "mwm" files in one generation process - static uint32_t generatorStartTime = my::TodayAsYYMMDD(); - - WriteToSink(sink, static_cast(Version::BUILD)); - WriteToSink(sink, static_cast(Version::GIT_HASH)); - - // actual date of data generation - WriteToSink(sink, generatorStartTime); - } -} diff --git a/version/version.pro b/version/version.pro deleted file mode 100644 index 74b0b5be94..0000000000 --- a/version/version.pro +++ /dev/null @@ -1,38 +0,0 @@ -# Used to generate project version header - -TARGET = version -TEMPLATE = lib -CONFIG += staticlib - -ROOT_DIR = .. - -include($$ROOT_DIR/common.pri) - -# Generate version header -VERSION_HEADER = ../../omim/version/version.hpp - -versiontarget.target = $$VERSION_HEADER -win32 { - versiontarget.commands = bash.exe $${IN_PWD}/../tools/unix/generate_version.sh $${IN_PWD}/.. $$VERSION_MAJOR $$VERSION_MINOR $$VERSION_HEADER -} -!win32 { - versiontarget.commands = $${IN_PWD}/../tools/unix/generate_version.sh $${IN_PWD}/.. $$VERSION_MAJOR $$VERSION_MINOR $$VERSION_HEADER -} -versiontarget.depends = FORCE - -PRE_TARGETDEPS += $$VERSION_HEADER -# regenerate version only in release and production builds -CONFIG(production) { - QMAKE_EXTRA_TARGETS += versiontarget -} -# also regenerate if file doesn't exist -!exists( $$VERSION_HEADER ) { - QMAKE_EXTRA_TARGETS += versiontarget -} - -HEADERS += \ - version.hpp \ - ver_serialization.hpp \ - -SOURCES += \ - empty_stub.cpp \