From 7a5a22c8e6b5cb687011d4302b17a9cfc13db0ca Mon Sep 17 00:00:00 2001 From: Bignaux Ronan Date: Mon, 29 Oct 2018 23:36:03 +0100 Subject: fix:cmake:fix sdl include directory (#707) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7fd1bcd8..93ed3eb76 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,7 +406,7 @@ else() endif(FREETYPE_FOUND) if(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND) - include_directories( ${SDL_INCLUDE_DIRS} ${SDL_IMAGE_INCLUDE_DIRS}) + include_directories( ${SDL_INCLUDE_DIR} ${SDL_IMAGE_INCLUDE_DIRS}) set(SDL_IMAGE 1) if(SDLTTF_FOUND) set(SDL_TTF 1) -- cgit v1.2.1 From df9ec3f5e8703c8894887da3447c3ccbb490c91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20H=C3=B6hn?= Date: Mon, 29 Oct 2018 23:37:21 +0100 Subject: fix: working sailfish build on circleci using machine executor (#709) * fix: working sailfish build on circleci using machine executor * remove travis integration as no longer needed for sailfish build --- .circleci/config.yml | 18 ++++++++++++++++++ .travis.yml | 23 ----------------------- 2 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index eecf98b57..82f300dff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,6 +49,21 @@ jobs: command: bash scripts/update_doxygen.sh - store_artifacts: path: /root/project/doc + build_sailfish: + machine: true + steps: + - run: + name: install docker + command: circleci-install docker + - run: + name: make build dir and clone git repository + command: mkdir ../rpmbuild && git clone https://github.com/navit-gps/navit . + - run: + name: run build + command: ls -lah ../rpmbuild && docker run -e VERSION_ID=2.2.1.18 -v `pwd`/../rpmbuild:/home/nemo/rpmbuild:rw -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh + - store_artifacts: + name: Store rpm + path: ../rpmbuild/RPMS/ build_android_arm: working_directory: ~/code docker: @@ -257,6 +272,9 @@ workflows: - build_android_arm: requires: - sanity_check + - build_sailfish: + requires: + - sanity_check - build_win32: requires: - sanity_check diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09919cf68..000000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -sudo: required - -language: c - -services: - - docker - -before_install: -- mkdir ../rpmbuild -- docker pull hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 -- docker run -e VERSION_ID=2.2.1.18 -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh - -before_deploy: - - provider: pages - - skip-cleanup: true - - github-token: $GITHUB_TOKEN - - keep-history: true - - local-history: `pwd`/../rpmbuild/RPMS/armv7hl/ - - local-history: `pwd`/../rpmbuild/RPMS/i586/ -before_script: skip -script: skip -after_success: skip -after_script: skip -- cgit v1.2.1 From b0773218ab67e00e1aa7303829f342dce87c46c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20H=C3=B6hn?= Date: Mon, 12 Nov 2018 22:47:21 +0100 Subject: build:fix:replaced custom git clone command by standard checkout command (#713) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ändrad: .circleci/config.yml --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 82f300dff..8ea848c02 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,12 +52,13 @@ jobs: build_sailfish: machine: true steps: + - checkout - run: name: install docker command: circleci-install docker - run: - name: make build dir and clone git repository - command: mkdir ../rpmbuild && git clone https://github.com/navit-gps/navit . + name: make build dir + command: mkdir ../rpmbuild - run: name: run build command: ls -lah ../rpmbuild && docker run -e VERSION_ID=2.2.1.18 -v `pwd`/../rpmbuild:/home/nemo/rpmbuild:rw -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh -- cgit v1.2.1 From e70a28963ff9754d3257361fad93aebf59edee08 Mon Sep 17 00:00:00 2001 From: lains Date: Sun, 18 Nov 2018 22:59:14 +0100 Subject: Refactoring:Xmlconfig:Moving layout definition in their own .xml file (makes main navit.xml file lighter) (#559) Layouts contain quite heavy xml code, and there are many layouts available for navit. They are all inserted inside the main navit.xml, which makes it hard to edit because of its size, even if changes or customizations by users are very rarely on the layout code. I have thus moved the layout code away from navit.xml, each layout having its own xml definition file, called navit_layout_*.xml These files are inserted inside the main navit.xml file by using the already existing xi:include mechanism, this also allow for backwards compatibility (old monolithic navit.xml files are still valid and can be used). The other advantage for this is that f the user wants to have his/her own customized navit.xml, he/she can still include the shipped layout files, making their xml lighter. This also allow to enable/disable specific layouts easily by including or not each layout file. It is also easier to perform side-by-side comparison between two layout files. --- .circleci/config.yml | 14 +- .travis.yml | 23 + contrib/sailfish/navit-sailfish.spec | 6 + navit/CMakeLists.txt | 86 +- navit/android/CMakeLists.txt | 55 +- navit/android/build.gradle | 3 +- .../android/src/org/navitproject/navit/Navit.java | 115 +- navit/attr_def.h | 2 +- navit/file.c | 16 +- navit/file.h | 4 +- navit/layout.c | 22 +- navit/main.c | 21 +- navit/main.h | 1 + navit/navit.c | 66 +- navit/navit.h | 3 + navit/navit_layout_bike_shipped.xml | 1052 +++ navit/navit_layout_car_android_shipped.xml | 1338 ++++ navit/navit_layout_car_dark_shipped.xml | 1725 +++++ navit/navit_layout_car_shipped.xml | 2015 ++++++ navit/navit_layout_car_simple_shipped.xml | 122 + navit/navit_layout_th_shipped.xml | 547 ++ navit/navit_shipped.xml | 6952 +------------------- navit/script/check_itemdef | 42 - navit/script/itemgra.pl | 92 +- navit/start_real.c | 3 +- navit/support/glib/gutils.c | 4 +- navit/xmlconfig.c | 50 +- navit/xslt/android.xslt | 4 +- scripts/build_wince.sh | 1 + 29 files changed, 7322 insertions(+), 7062 deletions(-) create mode 100644 .travis.yml create mode 100644 navit/navit_layout_bike_shipped.xml create mode 100644 navit/navit_layout_car_android_shipped.xml create mode 100644 navit/navit_layout_car_dark_shipped.xml create mode 100644 navit/navit_layout_car_shipped.xml create mode 100644 navit/navit_layout_car_simple_shipped.xml create mode 100644 navit/navit_layout_th_shipped.xml delete mode 100755 navit/script/check_itemdef diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ea848c02..b74c73ef2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,11 +78,11 @@ jobs: name: Id command: cat /etc/*release - run: - name: Install cmake gettext libsaxonb-java librsvg2-bin pkg-config + name: Install cmake gettext libsaxonb-java librsvg2-bin pkg-config libprotobuf-c-dev protobuf-c-compiler command: | sudo apt-get update sudo apt-get install -y cmake gettext libsaxonb-java librsvg2-bin pkg-config libprotobuf-c-dev protobuf-c-compiler - cmake ./ -Dsvg2png_scaling:STRING=-1,24,32,48,64,96,128 -Dsvg2png_scaling_nav:STRING=-1,24,32,48,64,96,128 -Dsvg2png_scaling_flag:STRING=-1,24,32,64,96 + cmake ./ -Dsvg2png_scaling:STRING=-1,24,32,48,64,96,128 -Dsvg2png_scaling_nav:STRING=-1,24,32,48,64,96,128 -Dsvg2png_scaling_flag:STRING=-1,24,32,64,96 -DUSE_PLUGINS=n -DBUILD_MAPTOOL=n -DXSL_PROCESSING=y -DXSLTS=android -DANDROID=y -DSAMPLE_MAP=n - run: name: Process icons command: | @@ -104,14 +104,10 @@ jobs: - run: name: Process xml's command: | + make navit_config_xml cd navit - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navitldpi.xml OSD_SIZE=1 ICON_SMALL=24 ICON_MEDIUM=32 ICON_BIG=48 - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navitmdpi.xml OSD_SIZE=1.33 ICON_SMALL=32 ICON_MEDIUM=48 ICON_BIG=64 - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navithdpi.xml OSD_SIZE=2 ICON_SMALL=48 ICON_MEDIUM=64 ICON_BIG=96 - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navitxhdpi.xml OSD_SIZE=2.67 ICON_SMALL=64 ICON_MEDIUM=96 ICON_BIG=128 - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navitxxhdpi.xml OSD_SIZE=4 ICON_SMALL=96 ICON_MEDIUM=128 ICON_BIG=192 - saxonb-xslt -s:navit_shipped.xml -xsl:xslt/android.xslt -o:navitxxxhdpi.xml OSD_SIZE=5.33 ICON_SMALL=128 ICON_MEDIUM=192 ICON_BIG=256 - mv *dpi.xml android/res/raw + mkdir -p ./android/assets + cp -R config ./android/assets/ cd ../ - run: name: Chmod permissions diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..09919cf68 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +sudo: required + +language: c + +services: + - docker + +before_install: +- mkdir ../rpmbuild +- docker pull hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 +- docker run -e VERSION_ID=2.2.1.18 -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh + +before_deploy: + - provider: pages + - skip-cleanup: true + - github-token: $GITHUB_TOKEN + - keep-history: true + - local-history: `pwd`/../rpmbuild/RPMS/armv7hl/ + - local-history: `pwd`/../rpmbuild/RPMS/i586/ +before_script: skip +script: skip +after_success: skip +after_script: skip diff --git a/contrib/sailfish/navit-sailfish.spec b/contrib/sailfish/navit-sailfish.spec index 11980a77c..4f14be872 100755 --- a/contrib/sailfish/navit-sailfish.spec +++ b/contrib/sailfish/navit-sailfish.spec @@ -114,6 +114,12 @@ fi %files %defattr(644, root, root, 755) %{_datadir}/harbour-navit/navit.xml +%{_datadir}/harbour-navit/navit_layout_bike.xml +%{_datadir}/harbour-navit/navit_layout_car.xml +%{_datadir}/harbour-navit/navit_layout_car_android.xml +%{_datadir}/harbour-navit/navit_layout_car_dark.xml +%{_datadir}/harbour-navit/navit_layout_car_simple.xml +%{_datadir}/harbour-navit/navit_layout_th.xml %{_datadir}/harbour-navit/icons/ %{_datadir}/harbour-navit/maps/osm_bbox_11.3,47.9,11.7,48.2.bin %{_datadir}/harbour-navit/espeak-data/ diff --git a/navit/CMakeLists.txt b/navit/CMakeLists.txt index f6dbe5bb8..ca19ce41d 100644 --- a/navit/CMakeLists.txt +++ b/navit/CMakeLists.txt @@ -124,21 +124,37 @@ add_custom_command( ) # additional parameter are passed to the stylesheet processor as parameter -macro(process_xslt SRC_XML DEST_XML) - set(XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml" "${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}" ) +macro(process_xslt SRC_DIR SRC_XML DEST_DIR DEST_XML) + set(TMPFOLDER "${DEST_DIR}/${DEST_XML}") + # Create a unique temporary name based on the PATH and filename of the target xml file + string(REPLACE "/" "_" TMPFOLDER ${TMPFOLDER}) + string(REPLACE ":" "_" TMPFOLDER ${TMPFOLDER}) + string(REPLACE "\\" "_" TMPFOLDER ${TMPFOLDER}) + # Create this unique temporary directory inside ${CMAKE_CURRENT_BINARY_DIR}. This is where we will store our intermediate xml file (called ${SRC_XML}.temp after each xslt pass + set(TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/${TMPFOLDER}") + set(XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory "${TMPDIR}") + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/${SRC_XML}" "${TMPDIR}/${SRC_XML}.temp") + # Also copy the dtd file in the same directory as the xml file (required by the xslt processor) + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/navit.dtd" "${TMPDIR}/" ) if(XSL_PROCESSING) if(NOT XSLTS STREQUAL "") string(REPLACE "," ";" XSLTS "${XSLTS}") foreach(tmp ${XSLTS}) + # We will run this loop below for each xslt file provided in the XSLTS variable set(XSLT_FILE "${PROJECT_SOURCE_DIR}/navit/xslt/${tmp}.xslt") list(APPEND XSLT_FILES "${XSLT_FILE}") list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E echo Applying ${tmp}.xslt) - compose_xslt_transform_command(CMD "${XSLT_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}" "${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}.tmp" "${ARGN}") + compose_xslt_transform_command(CMD "${XSLT_FILE}" "${TMPDIR}/${SRC_XML}.temp" "${TMPDIR}/${SRC_XML}.output" "${ARGN}") list(APPEND XSLT_COMMANDS ${CMD}) - list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}.tmp" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}) + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename "${TMPDIR}/${SRC_XML}.output" "${TMPDIR}/${SRC_XML}.temp") endforeach() endif() endif(XSL_PROCESSING) + # Move the final resulting xml file to the target filename and directory (provided in arguments) + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR}) + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename "${TMPDIR}/${SRC_XML}.temp" "${DEST_DIR}/${DEST_XML}") + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E remove "${TMPDIR}/navit.dtd") + list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E remove_directory "${TMPDIR}") # Depend on all XSLT files, because the main XSLT file may pull in other files. # Ideally we'd parse the main XSLT file for includes, but that is tricky to do reliably. # Note that this list of files is only updated when (re)running CMake, so if files are @@ -146,26 +162,58 @@ macro(process_xslt SRC_XML DEST_XML) file(GLOB ALL_XSLT_FILES "${PROJECT_SOURCE_DIR}/navit/xslt/*.xslt") #message(FATAL_ERROR ${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML}) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML} + OUTPUT ${DEST_DIR}/${DEST_XML} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/navit/xslt/ - DEPENDS ${SRC_XML} "${CMAKE_CURRENT_BINARY_DIR}/navit.dtd" ${ALL_XSLT_FILES} + DEPENDS "${SRC_DIR}/${SRC_XML}" "${CMAKE_CURRENT_BINARY_DIR}/navit.dtd" ${ALL_XSLT_FILES} ${XSLT_COMMANDS} ) endmacro() +# Give instructions on how to build all navit_*.xml navit_layout_*.xml files, obtained applying relevant xslt tranformation on the source navit_shipped_*.xml files +# The following XMLCFG_ALL_FILE_PREFIXES variable below lists all xml config files, semicolon is the delimiter +# For example, it contains layout_navit_car, that will then be used to guess the source filename navit_layout_car_shipped.xml, installed as navit_layout_car.xml (or on android DPI-related files like navit_layout_car_xxxhdpi.xml) +set(XMLCFG_ALL_FILE_PREFIXES "navit;navit_layout_car;navit_layout_car_dark;navit_layout_car_android;navit_layout_car_simple;navit_layout_bike;navit_layout_th") if(ANDROID) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navitxxxhdpi.xml OSD_SIZE=5.33 ICON_SMALL=128 ICON_MEDIUM=192 ICON_BIG=256) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navitxxhdpi.xml OSD_SIZE=4 ICON_SMALL=96 ICON_MEDIUM=128 ICON_BIG=192) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navitxhdpi.xml OSD_SIZE=2.67 ICON_SMALL=64 ICON_MEDIUM=96 ICON_BIG=128) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navithdpi.xml OSD_SIZE=2 ICON_SMALL=48 ICON_MEDIUM=64 ICON_BIG=96) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navitmdpi.xml OSD_SIZE=1.33 ICON_SMALL=32 ICON_MEDIUM=48 ICON_BIG=64) - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navitldpi.xml OSD_SIZE=1 ICON_SMALL=24 ICON_MEDIUM=32 ICON_BIG=48) - add_custom_target( navit_config_xml ALL DEPENDS navitxxxhdpi.xml navitxxhdpi.xml navitxhdpi.xml navithdpi.xml navitmdpi.xml navitldpi.xml) + # On android, additional xlst transformations are applied to scale the OSD, icons etc... and the size is selected depending on the definition of the screen of the device (xxxhdpi, xxhdpi, ... ldpi) + # Files for all screen definitions are shipped inside the android package (suffixed with _xxxhdpi, _xxhdpi etc.), and it is only at runtime that the correct navit_*.xml (corresponding to the current device's resolution) is selected + set(XSLT_XXXHDPI_ARGS OSD_SIZE=5.33 ICON_SMALL=128 ICON_MEDIUM=192 ICON_BIG=256) + set(XSLT_XXHDPI_ARGS OSD_SIZE=4 ICON_SMALL=96 ICON_MEDIUM=128 ICON_BIG=192) + set(XSLT_XHDPI_ARGS OSD_SIZE=2.67 ICON_SMALL=64 ICON_MEDIUM=96 ICON_BIG=128) + set(XSLT_HDPI_ARGS OSD_SIZE=2 ICON_SMALL=48 ICON_MEDIUM=64 ICON_BIG=96) + set(XSLT_MDPI_ARGS OSD_SIZE=1.33 ICON_SMALL=32 ICON_MEDIUM=48 ICON_BIG=64) + set(XSLT_LDPI_ARGS OSD_SIZE=1 ICON_SMALL=24 ICON_MEDIUM=32 ICON_BIG=48) + + set(XMLCFG_OUTPUT_LIST "") # Used to build the list of generated *xml filenames (only file basename, directory part excluded) + foreach(XMLCFG_FILE_PREFIX ${XMLCFG_ALL_FILE_PREFIXES}) + set(XMLCFG_FILE_SHIPPED ${XMLCFG_FILE_PREFIX}_shipped.xml) + set(XMLCFG_DIR_OUTPUT_XXXHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xxxhdpi) + set(XMLCFG_DIR_OUTPUT_XXHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xxhdpi) + set(XMLCFG_DIR_OUTPUT_XHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xhdpi) + set(XMLCFG_DIR_OUTPUT_HDPI ${CMAKE_CURRENT_BINARY_DIR}/config/hdpi) + set(XMLCFG_DIR_OUTPUT_MDPI ${CMAKE_CURRENT_BINARY_DIR}/config/mdpi) + set(XMLCFG_DIR_OUTPUT_LDPI ${CMAKE_CURRENT_BINARY_DIR}/config/ldpi) + set(XMLCFG_FILE_OUTPUT ${XMLCFG_FILE_PREFIX}.xml) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XXXHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XXXHDPI_ARGS}) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XXHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XXHDPI_ARGS}) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XHDPI_ARGS}) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_HDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_HDPI_ARGS}) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_MDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_MDPI_ARGS}) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_LDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_LDPI_ARGS}) + set(XMLCFG_OUTPUT_LIST ${XMLCFG_OUTPUT_LIST} ${XMLCFG_DIR_OUTPUT_XXXHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_XXHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_XHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_HDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_MDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_LDPI}/${XMLCFG_FILE_PREFIX}.xml) + endforeach() + add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST}) else() - process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml navit.xml "") - add_custom_target( navit_config_xml_resource DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.xml COMMAND mkdir -p resources/share/navit COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/navit.xml resources/share/navit) + set(XMLCFG_OUTPUT_LIST "") # Used to build the list of generated *xml filenames (only file basename, directory part excluded) + set(XMLCFG_INSTALLED_PATH_LIST "") # A list of full path to installed xml files + foreach(XMLCFG_FILE_PREFIX ${XMLCFG_ALL_FILE_PREFIXES}) + set(XMLCFG_FILE_SHIPPED ${XMLCFG_FILE_PREFIX}_shipped.xml) + process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${CMAKE_CURRENT_BINARY_DIR}/ ${XMLCFG_FILE_PREFIX}.xml "") + set(XMLCFG_OUTPUT_LIST ${XMLCFG_OUTPUT_LIST} ${XMLCFG_FILE_PREFIX}.xml) + set(XMLCFG_INSTALLED_PATH_LIST ${XMLCFG_INSTALLED_PATH_LIST} ${CMAKE_CURRENT_BINARY_DIR}/${XMLCFG_FILE_PREFIX}.xml) + endforeach() + add_custom_target( navit_config_xml_resource DEPENDS ${XMLCFG_INSTALLED_PATH_LIST} COMMAND mkdir -p resources/share/navit COMMAND cp ${XMLCFG_INSTALLED_PATH_LIST} resources/share/navit) add_custom_target( locale_resource DEPENDS locales COMMAND mkdir -p resources/share COMMAND cp -a ${CMAKE_CURRENT_BINARY_DIR}/../locale resources/share/locale) - add_custom_target( navit_config_xml ALL DEPENDS navit.xml) + add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST}) endif() ADD_DEPENDENCIES(${NAVIT_LIBNAME} git_version) @@ -189,6 +237,12 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/navit.xml DESTINATION ${SHARE_DIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +foreach(XMLCFG_INSTALLED_PATH ${XMLCFG_INSTALLED_PATH_LIST}) + install(FILES ${XMLCFG_INSTALLED_PATH} + DESTINATION ${SHARE_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +endforeach() + get_directory_property(INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES) WRITE_FILE("cmake_plugin_settings.txt" "set(APPLE ${APPLE} CACHE BOOL init)\n" diff --git a/navit/android/CMakeLists.txt b/navit/android/CMakeLists.txt index f78532297..91a4b29e7 100644 --- a/navit/android/CMakeLists.txt +++ b/navit/android/CMakeLists.txt @@ -48,26 +48,53 @@ if (ANDROID AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja) add_custom_target( android_resources DEPENDS build.xml ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} ${LANG_RESOURCES} COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/res/raw/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/ldpi + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/mdpi + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/hdpi + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xhdpi + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxhdpi + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxxhdpi COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH} COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/navit/libnavit.so ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}/ COMMAND ${CMAKE_COMMAND} - -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/navit*.xml" - -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw - -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/ldpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/ldpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake COMMAND ${CMAKE_COMMAND} - -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/icons/*.png" - -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/drawable-nodpi - -D LOWER=1 - -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/mdpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/mdpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake COMMAND ${CMAKE_COMMAND} - -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/*/*/.libs/lib[b-z]*.so" - -D DST=${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH} - -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/hdpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/hdpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake COMMAND ${CMAKE_COMMAND} - -D GLOB_EXP="${PROJECT_BINARY_DIR}/po/*.mo" - -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw - -D LOWER=1 - -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xhdpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xhdpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + COMMAND ${CMAKE_COMMAND} + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xxhdpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxhdpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + COMMAND ${CMAKE_COMMAND} + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xxxhdpi/*.xml" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxxhdpi + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + COMMAND ${CMAKE_COMMAND} + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/icons/*.png" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/drawable-nodpi + -D LOWER=1 + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + COMMAND ${CMAKE_COMMAND} + -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/*/*/.libs/lib[b-z]*.so" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH} + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake + COMMAND ${CMAKE_COMMAND} + -D GLOB_EXP="${PROJECT_BINARY_DIR}/po/*.mo" + -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw + -D LOWER=1 + -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake ) add_dependencies (android_resources images locales ${NAVIT_LIBNAME}) diff --git a/navit/android/build.gradle b/navit/android/build.gradle index e2e42bc80..1385336bf 100644 --- a/navit/android/build.gradle +++ b/navit/android/build.gradle @@ -17,7 +17,7 @@ android { } externalNativeBuild { cmake { - arguments '-DUSE_PLUGINS=n', '-DBUILD_MAPTOOL=n', '-DXSL_PROCESSING=n', '-DSAMPLE_MAP=n' + arguments '-DUSE_PLUGINS=n', '-DBUILD_MAPTOOL=n', '-DXSL_PROCESSING=y', '-DXSLTS=android', '-DANDROID=y', '-DSAMPLE_MAP=n' } } } @@ -38,6 +38,7 @@ android { resources.srcDirs = ["src"] renderscript.srcDirs = ["src"] res.srcDirs = ["res"] + assets.srcDirs = ["assets"] } } externalNativeBuild { diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java index feb472764..e6a477a37 100644 --- a/navit/android/src/org/navitproject/navit/Navit.java +++ b/navit/android/src/org/navitproject/navit/Navit.java @@ -33,6 +33,7 @@ import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Point; @@ -162,32 +163,35 @@ public class Navit extends Activity { } } - /* Translates a string from its id + /** + * Translates a string from its id * in R.strings * * @param Rid resource identifier - * @retrun translated string + * @return translated string */ String getTstring(int Rid) { return getLocalizedString(getString(Rid)); } - private boolean extractRes(String resname, String result) { - boolean needs_update = false; - Log.e(TAG, "Res Name " + resname + ", result " + result); - int id = NavitResources.getIdentifier(resname, "raw", NAVIT_PACKAGE_NAME); - Log.e(TAG, "Res ID " + id); - if (id == 0) { - return false; - } + /** + * Check if a specific file needs to be extracted from the apk archive + * This is based on whether the file already exist, and if so, whether it is older than the archive or not + * + * @param filename The full path to the file + * @return true if file does not exist, but it can be created at the specified location, we will also return + * true if the file exist but the apk archive is more recent (probably package was upgraded) + */ + private boolean resourceFileNeedsUpdate(String filename) { + File resultfile = new File(filename); - File resultfile = new File(result); if (!resultfile.exists()) { - needs_update = true; File path = resultfile.getParentFile(); if (!path.exists() && !resultfile.getParentFile().mkdirs()) { + Log.e(TAG, "Could not create directory path for " + filename); return false; } + return true; } else { PackageManager pm = getPackageManager(); ApplicationInfo appInfo; @@ -200,16 +204,33 @@ public class Navit extends Activity { e.printStackTrace(); } if (apkUpdateTime > resultfile.lastModified()) { - needs_update = true; + return true; } } + return false; + } - if (needs_update) { - Log.e(TAG, "Extracting resource"); + /** + * Extract a ressource from the apk archive (res/raw) and save it to a local file + * + * @param result The full path to the local file + * @param resname The name of the ressource file in the archive + * @return true if the local file is extracted in @p result + */ + private boolean extractRes(String resname, String result) { + Log.d(TAG, "Res Name " + resname + ", result " + result); + int id = NavitResources.getIdentifier(resname, "raw", NAVIT_PACKAGE_NAME); + Log.d(TAG, "Res ID " + id); + if (id == 0) { + return false; + } + + if (resourceFileNeedsUpdate(result)) { + Log.d(TAG, "Extracting resource"); try { InputStream resourcestream = NavitResources.openRawResource(id); - FileOutputStream resultfilestream = new FileOutputStream(resultfile); + FileOutputStream resultfilestream = new FileOutputStream(new File(result)); byte[] buf = new byte[1024]; int i; while ((i = resourcestream.read(buf)) != -1) { @@ -224,6 +245,44 @@ public class Navit extends Activity { return true; } + /** + * Extract an asset from the apk archive (assets) and save it to a local file + * + * @param output The full path to the output local file + * @param assetFileName The full path of the asset file within the archive + * @return true if the local file is extracted in @p output + */ + private boolean extractAsset(String assetFileName, String output) { + AssetManager assetMgr = NavitResources.getAssets(); + InputStream assetstream; + Log.d(TAG, "Asset Name " + assetFileName + ", output " + output); + try { + assetstream = assetMgr.open(assetFileName); + } catch (IOException e) { + Log.e(TAG, "Failed opening asset '" + assetFileName + "'"); + return false; + } + + if (resourceFileNeedsUpdate(output)) { + Log.d(TAG, "Extracting asset '" + assetFileName + "'"); + + try { + FileOutputStream outputFilestream = new FileOutputStream(new File(output)); + byte[] buf = new byte[1024]; + int i = 0; + while ((i = assetstream.read(buf)) != -1) { + outputFilestream.write(buf, 0, i); + } + outputFilestream.close(); + } catch (Exception e) { + Log.e(TAG, "Exception " + e.getMessage()); + return false; + } + } + + return true; + } + private void showInfos() { SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE); boolean firstStart = settings.getBoolean("firstStart", true); @@ -386,13 +445,23 @@ public class Navit extends Activity { } else if (densityDpi < 640) { my_display_density = "xxxhdpi"; } else { - Log.e(TAG, "found device of very high density (" + densityDpi + ")"); - Log.e(TAG, "using xxxhdpi values"); + Log.w(TAG, "found device of very high density (" + densityDpi + ")"); + Log.w(TAG, "using xxxhdpi values"); my_display_density = "xxxhdpi"; } + Log.i(TAG, "Device density detected: " + my_display_density); - if (!extractRes("navit" + my_display_density, NAVIT_DATA_DIR + "/share/navit.xml")) { - Log.e(TAG, "Failed to extract navit.xml for " + my_display_density); + try { + AssetManager assetMgr = NavitResources.getAssets(); + String[] children = assetMgr.list("config/" + my_display_density); + for (String child : children) { + Log.d(TAG, "Processing config file '" + child + "' from assets"); + if (!extractAsset("config/" + my_display_density + "/" + child, NAVIT_DATA_DIR + "/share/" + child)) { + Log.e(TAG, "Failed to extract asset config/" + my_display_density + "/" + child); + } + } + } catch (IOException e) { + Log.e(TAG, "Failed to access assets using AssetManager"); } Log.d(TAG, "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK)); @@ -669,7 +738,7 @@ public class Navit extends Activity { /** - * @brief Shows the Options menu. + * Shows the Options menu. * * Calling this method has the same effect as pressing the hardware Menu button, where present, or touching * the overflow button in the Action bar. @@ -680,7 +749,7 @@ public class Navit extends Activity { /** - * @brief Shows the native keyboard or other input method. + * Shows the native keyboard or other input method. */ public int showNativeKeyboard() { /* @@ -721,7 +790,7 @@ public class Navit extends Activity { /** - * @brief Hides the native keyboard or other input method. + * Hides the native keyboard or other input method. */ public void hideNativeKeyboard() { mgr.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); diff --git a/navit/attr_def.h b/navit/attr_def.h index 0dffc93e5..2b51f11eb 100644 --- a/navit/attr_def.h +++ b/navit/attr_def.h @@ -344,7 +344,7 @@ ATTR(daylayout) ATTR(nightlayout) ATTR(xml_text) ATTR(layout_name) -ATTR_UNUSED +ATTR(default_layout) ATTR_UNUSED ATTR(status_text) ATTR(log_gpx_desc) diff --git a/navit/file.c b/navit/file.c index 0ef39bddd..4d7f226f8 100644 --- a/navit/file.c +++ b/navit/file.c @@ -231,7 +231,13 @@ file_create_url(char *url) { #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -int file_is_dir(char *name) { +/** + * @brief Check if a given path corresponds to a directory + * + * @param name The path to the filesystem element + * @return !=0 (true) if @p name is a directory + */ +int file_is_dir(const char *name) { struct stat buf; if (! stat(name, &buf)) { return S_ISDIR(buf.st_mode); @@ -240,7 +246,13 @@ int file_is_dir(char *name) { } -int file_is_reg(char *name) { +/** + * @brief Check if a given path corresponds to a regular file + * + * @param name The path to the filesystem element + * @return !=0 (true) if @p name is a regular file + */ +int file_is_reg(const char *name) { struct stat buf; if (! stat(name, &buf)) { return S_ISREG(buf.st_mode); diff --git a/navit/file.h b/navit/file.h index e44ca96ad..8105302ba 100644 --- a/navit/file.h +++ b/navit/file.h @@ -65,7 +65,8 @@ struct attr; int file_request(struct file *f, struct attr **options); char *file_http_header(struct file *f, char *header); struct file *file_create(char *name, struct attr **options); -int file_is_dir(char *name); +int file_is_dir(const char *name); +int file_is_reg(const char *name); long long file_size(struct file *file); int file_mkdir(char *name, int pflag); int file_mmap(struct file *file); @@ -95,7 +96,6 @@ int file_version(struct file *file, int byname); void *file_get_os_handle(struct file *file); int file_set_cache_size(int cache_size); void file_init(void); -int file_is_reg(char *name); void file_data_remove(struct file *file, unsigned char *data); /* end of prototypes */ diff --git a/navit/layout.c b/navit/layout.c index 25f60bc4b..f2f3d1a75 100644 --- a/navit/layout.c +++ b/navit/layout.c @@ -25,15 +25,31 @@ #include "layout.h" #include "coord.h" #include "debug.h" +#include "navit.h" - -struct layout * layout_new(struct attr *parent, struct attr **attrs) { +/** + * @brief Create a new layout object and attach it to a navit parent + * + * @param parent The parent for this layout (a navit attr) + * @param attrs An array of attributes that for this layout + * @return The newly created layout object + */ +struct layout * +layout_new(struct attr *parent, struct attr **attrs) { struct layout *l; + struct navit *navit; struct color def_color = {COLOR_BACKGROUND_}; struct attr *name_attr,*color_attr,*order_delta_attr,*font_attr,*day_attr,*night_attr,*active_attr; if (! (name_attr=attr_search(attrs, NULL, attr_name))) return NULL; + navit = parent->u.navit; + if (navit_get_layout_by_name(navit, name_attr->u.str)) { + dbg(lvl_warning, "Another layout with name '%s' has already been parsed. Discarding subsequent duplicate.", + name_attr->u.str); + return NULL; + } + l = g_new0(struct layout, 1); l->func=&layout_func; navit_object_ref((struct navit_object *)l); @@ -55,7 +71,7 @@ struct layout * layout_new(struct attr *parent, struct attr **attrs) { l->order_delta=order_delta_attr->u.num; if ((active_attr=attr_search(attrs, NULL, attr_active))) l->active = active_attr->u.num; - l->navit=parent->u.navit; + l->navit=navit; return l; } diff --git a/navit/main.c b/navit/main.c index 75a3a5f93..986947f0d 100644 --- a/navit/main.c +++ b/navit/main.c @@ -73,10 +73,19 @@ void setenv(char *var, char *val, int overwrite) { #endif /* - * environment_vars[][0:name,1-3:mode] - * ':' replaced with NAVIT_PREFIX - * '::' replaced with NAVIT_PREFIX and LIBDIR - * '~' replaced with HOME + * @def environment_vars + * + * @brief Environment variables automatically added (and expanded) by navit at startup + * + * A NUL-terminated string array + * environment_vars[0] is the name of the variable + * environment_vars[1] is the value used when running from source dir + * environment_vars[2] is the value used on Linux + * environment_vars[3] is the value used on Windows (see main_init()) + * environment_vars[4] is the value used on Android + * ':' is replaced with NAVIT_PREFIX + * '::' is replaced with NAVIT_PREFIX and LIBDIR + * '~' is replaced with HOME */ static char *environment_vars[][5]= { {"NAVIT_LIBDIR", ":", ":/"LIB_DIR, ":\\lib", ":/lib"}, @@ -319,6 +328,10 @@ static void win_set_nls(void) { } #endif +void main_update_default_layout(struct navit *navit) { + navit_update_current_layout(navit, NULL); +} + void main_init(const char *program) { char *s; #ifdef _UNICODE /* currently for wince */ diff --git a/navit/main.h b/navit/main.h index 47f275c09..910d56200 100644 --- a/navit/main.h +++ b/navit/main.h @@ -35,6 +35,7 @@ void main_add_navit(struct navit *nav); void main_remove_navit(struct navit *nav); int main_add_attr(struct attr *attr); int main_remove_attr(struct attr *attr); +void main_update_default_layout(struct navit *navit); void main_init(const char *program); void main_init_nls(void); int main(int argc, char **argv); diff --git a/navit/navit.c b/navit/navit.c index 84af773e2..90935786d 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -115,7 +115,8 @@ struct navit { GList *mapsets; GList *layouts; struct gui *gui; - struct layout *layout_current; + char *default_layout_name; /*!< The default layout indicated by the config file (if any) */ + struct layout *layout_current; /*!< The current layout theme used to display the map */ struct graphics *gra; struct action *action; struct transformation *trans, *trans_cursor; @@ -1343,6 +1344,7 @@ navit_new(struct attr *parent, struct attr **attrs) { this_->tracking_flag=1; this_->recentdest_count=10; this_->osd_configuration=-1; + this_->default_layout_name=NULL; this_->center_timeout = 10; this_->use_mousewheel = 1; @@ -2406,11 +2408,19 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) { attr_updated=(this_->vehicle->follow_curr != attr->u.num); this_->vehicle->follow_curr = attr->u.num; break; + case attr_default_layout: + if(!attr->u.str) + return 0; + if(this_->default_layout_name) /* There is already a default layout, ignore this new value */ + g_free(this_->default_layout_name); /* Drop the previous layout name, use the this one instead */ + this_->default_layout_name=g_strdup(attr->u.str); + attr_updated=1; + break; case attr_layout: if(!attr->u.layout) return 0; if(this_->layout_current!=attr->u.layout) { - this_->layout_current=attr->u.layout; + navit_update_current_layout(this_, attr->u.layout); graphics_font_destroy_all(this_->gra); navit_set_cursors(this_); if (this_->ready == 3) @@ -2789,6 +2799,58 @@ int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, return ret; } +/** + * @brief Select the default layout by name + * + * @param this_ The navit instance + * @param name The new default layout's name + * + * @return The first layout match (if any), or NULL if there was no match + */ +struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_name) { + struct attr_iter *iter; + struct attr layout_attr; + struct layout *result = NULL; + + if (!layout_name) + return NULL; + iter=navit_attr_iter_new(); + while (navit_get_attr(this_, attr_layout, &layout_attr, iter)) { + if (strcmp(layout_attr.u.layout->name, layout_name) == 0) { + result = layout_attr.u.layout; + } + } + navit_attr_iter_destroy(iter); + return result; +} + +/** + * @brief Set the current layout + * + * @param this_ The navit instance + * @param layout The layout to set as default (if NULL, we will set the current layout according to the default name stored in this_->default_layout_name + * + * @note If argument @p layout is NULL and the default layout name in the config file does not exist or has not been provided in the config file, the default layout is unchanged + */ +void navit_update_current_layout(struct navit *this_, struct layout *layout) { + struct layout *default_layout = NULL; + + if (layout) { + this_->layout_current=layout; + } else { + if (this_->default_layout_name) { /* If a default layout name was provided */ + default_layout=navit_get_layout_by_name(this_, this_->default_layout_name); + if (default_layout) { + dbg(lvl_debug, "Found the config-specified default layout '%s'", this_->default_layout_name); + this_->layout_current=default_layout; + return; + } else { + dbg(lvl_warning, "No definition exists in config for specified default layout '%s'", this_->default_layout_name); + } + } + } +} + static int navit_add_log(struct navit *this_, struct log *log) { struct attr type_attr; if (!log_get_attr(log, attr_type, &type_attr, NULL)) diff --git a/navit/navit.h b/navit/navit.h index 898ff6cff..7125c1878 100644 --- a/navit/navit.h +++ b/navit/navit.h @@ -39,6 +39,7 @@ struct coord_rect; struct displaylist; struct graphics; struct gui; +struct layout; struct mapset; struct message; struct navigation; @@ -103,6 +104,8 @@ void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orienta void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout); int navit_set_attr(struct navit *this_, struct attr *attr); int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); +struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_name); +void navit_update_current_layout(struct navit *this_, struct layout *layout); int navit_add_attr(struct navit *this_, struct attr *attr); int navit_remove_attr(struct navit *this_, struct attr *attr); struct attr_iter *navit_attr_iter_new(void); diff --git a/navit/navit_layout_bike_shipped.xml b/navit/navit_layout_bike_shipped.xml new file mode 100644 index 000000000..dd5a9943a --- /dev/null +++ b/navit/navit_layout_bike_shipped.xml @@ -0,0 +1,1052 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_car_android_shipped.xml b/navit/navit_layout_car_android_shipped.xml new file mode 100644 index 000000000..046d52d37 --- /dev/null +++ b/navit/navit_layout_car_android_shipped.xml @@ -0,0 +1,1338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_car_dark_shipped.xml b/navit/navit_layout_car_dark_shipped.xml new file mode 100644 index 000000000..b24978a57 --- /dev/null +++ b/navit/navit_layout_car_dark_shipped.xml @@ -0,0 +1,1725 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_car_shipped.xml b/navit/navit_layout_car_shipped.xml new file mode 100644 index 000000000..e772ab9f4 --- /dev/null +++ b/navit/navit_layout_car_shipped.xml @@ -0,0 +1,2015 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_car_simple_shipped.xml b/navit/navit_layout_car_simple_shipped.xml new file mode 100644 index 000000000..4029833f5 --- /dev/null +++ b/navit/navit_layout_car_simple_shipped.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_layout_th_shipped.xml b/navit/navit_layout_th_shipped.xml new file mode 100644 index 000000000..aebc79d6e --- /dev/null +++ b/navit/navit_layout_th_shipped.xml @@ -0,0 +1,547 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml index ae2eedd37..9e87d2fba 100644 --- a/navit/navit_shipped.xml +++ b/navit/navit_shipped.xml @@ -27,27 +27,32 @@ - - - + + + - + If you don't like the internal gui, set enabled=yes for the following tag and enabled=no for the gui internal tag + --> - - - + + + Main menu @@ -359,7 +364,7 @@ Waypoint - + @@ -374,9 +379,11 @@ Waypoint - + + --> @@ -420,6896 +427,15 @@ Waypoint - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/navit/script/check_itemdef b/navit/script/check_itemdef deleted file mode 100755 index 61ea1cb29..000000000 --- a/navit/script/check_itemdef +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/sh -function check_item_def -{ - grep -q "[(,]$1)" ../item_def.h || echo "$1 missing" -} - -function check_item_xml -{ - grep -q "^$1\$" check.$$ || echo "$1 will not be rendered" -} - - -awk '/check.$$ -echo item_def.h -grep "^ITEM" ../item_def.h | sed -e "s/ITEM(\(.*\))/\1/" -e "s/ITEM2([^,]*,\(.*\))/\1/" | -while read -r x -do - check_item_xml "$x" -done - -rm -f check.$$ -echo maptool.c -egrep '^ "[nw] +[^ ]+ +[^ ]+' ../maptool.c | sed "s/.* //" | sort -u | -while read -r x -do - check_item_def "${x%%\\n\"}" -done - -echo "navit.xml" -grep '/dev/null to get only the result without parsing information messages my $layout; my $type,$types; +my $garmintypes; my $order,$orders,@orders; my @layouts; -open(IN,"../navit.xml"); -while () { - if (/{$type}->{$layout}->{$order}=1; +my $input_stream; +my @input_stream_stack; +my $current_filename = "../navit_shipped.xml"; +if (!open($input_stream,$current_filename)) { + print(STDERR "Failed to open \"" . $current_filename . "\"\n"); + exit(1); +} +while(defined($input_stream)) { + #printf("%d input streams in file recursion stack. Current input stream is " . $input_stream . "\n", $#input_stream_stack+1); + while (<$input_stream>) { + #print($_); + if (/{$type}->{$layout}->{$order}=1; + } } } } + close($input_stream); + $input_stream = pop(@input_stream_stack); + #print("Popped input stream " . $input_stream . "\n"); } -close(IN); +print(STDERR "Finished parsing navit XML config\n"); +print(STDERR "Parsing item_def.h\n"); open(IN,"../item_def.h"); while () { if (/^ITEM2\([^,]*,(.*)\)/) { @@ -32,13 +76,26 @@ while () { } } close(IN); +print(STDERR "Parsing ../map/garmin/garmintypes.txt\n"); +open(IN,"../map/garmin/garmintypes.txt"); +while () { + if (/^[0-9][^=]*=\s*([^,]*),.*$/) { + $type=$1; + print("Garmintype: " . $type . "\n"); + $garmintypes->{$type}->{"none"}=1; + } +} +close(IN); + +print(STDERR "Outputting results\n"); my $typefmt="%-30s"; my $layoutfmt="%10s"; printf($typefmt,""); foreach $layout (@layouts) { printf($layoutfmt,$layout); } -printf("\n"); +print("\n"); +# Check which map items defined in ../item_def.h are actually handled by each layout foreach $type (sort keys %$result) { $marker=""; if (!$result->{$type}->{"none"}) { @@ -55,3 +112,10 @@ foreach $type (sort keys %$result) { } printf("\n"); } + +print("Analysis on ../map/garmin/garmintypes.txt:\n"); +foreach $type (sort keys %$garmintypes) { + if (!$result->{$type}->{"none"}) { + print($type . " exists in garmintypes.txt and missing in itemdef.h\n"); + } +} \ No newline at end of file diff --git a/navit/start_real.c b/navit/start_real.c index c3f8b5622..b7a0db48c 100644 --- a/navit/start_real.c +++ b/navit/start_real.c @@ -191,7 +191,7 @@ int main_real(int argc, char * const* argv) { li = g_list_next(li); } - dbg(lvl_debug,"Loading %s",config_file); + dbg(lvl_debug,"Loading config from '%s'",config_file); if (!config_load(config_file, &error)) { dbg(lvl_error, _("Error parsing config file '%s': %s"), config_file, error ? error->message : ""); } else { @@ -209,6 +209,7 @@ int main_real(int argc, char * const* argv) { dbg(lvl_error, "%s", _("Internal initialization failed, exiting. Check previous error messages.")); exit(5); } + main_update_default_layout(navit.u.navit); conf.type=attr_config; conf.u.config=config; if (startup_file) { diff --git a/navit/support/glib/gutils.c b/navit/support/glib/gutils.c index 6d3fda447..9a9477f19 100644 --- a/navit/support/glib/gutils.c +++ b/navit/support/glib/gutils.c @@ -756,7 +756,6 @@ g_path_get_basename (const gchar *file_name) return retval; } -#if NOT_NEEDED_FOR_NAVIT /** * g_path_is_absolute: * @file_name: a file name. @@ -785,6 +784,7 @@ g_path_is_absolute (const gchar *file_name) return FALSE; } +#if NOT_NEEDED_FOR_NAVIT /** * g_path_skip_root: * @file_name: a file name. @@ -851,6 +851,7 @@ g_path_skip_root (const gchar *file_name) return NULL; } +#endif /** * g_path_get_dirname: @@ -952,6 +953,7 @@ g_path_get_dirname (const gchar *file_name) return base; } +#if NOT_NEEDED_FOR_NAVIT /** * g_get_current_dir: * diff --git a/navit/xmlconfig.c b/navit/xmlconfig.c index 451a308e2..476997c2d 100644 --- a/navit/xmlconfig.c +++ b/navit/xmlconfig.c @@ -705,6 +705,15 @@ static void end_element (xml_context *context, static gboolean parse_file(struct xmldocument *document, xmlerror **error); +/** + * @brief Handle xi:include XML tags + * + * @param context The XML context in which we are parsing + * @param[in] attribute_names An array of strings containing all XML attributes of the xi:include tag + * @param[in] attribute_values An array of strings containing all XML values (one per entry in @p attribute_names) + * @param doc_old The current document being parsed (before moving to the one referenced in this xi:include + * @param[out] error A description of the error encountered if any + */ static void xinclude(xml_context *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error) { struct xmldocument doc_new; @@ -712,11 +721,15 @@ static void xinclude(xml_context *context, const gchar **attribute_names, const int i,count; const char *href=NULL; char **we_files; + char *included_filename=NULL; + char *doc_base=NULL; + char *tmp=NULL; if (doc_old->level >= 16) { g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include recursion too deep"); return; } + dbg(lvl_debug, "At level %d, processing xi:include in document href=\"%s\"", doc_old->level, doc_old->href); memset(&doc_new, 0, sizeof(doc_new)); i=0; while (attribute_names[i]) { @@ -746,8 +759,8 @@ static void xinclude(xml_context *context, const gchar **attribute_names, const } doc_new.level=doc_old->level+1; doc_new.user_data=doc_old->user_data; - if (! href) { - dbg(lvl_debug,"no href, using '%s'", doc_old->href); + if (!href) { + dbg(lvl_debug,"no href%s, using own ref '%s'", doc_new.xpointer?" (but xpointer provided)":"", doc_old->href); doc_new.href=doc_old->href; if (file_exists(doc_new.href)) { parse_file(&doc_new, error); @@ -757,23 +770,36 @@ static void xinclude(xml_context *context, const gchar **attribute_names, const } else { dbg(lvl_debug,"expanding '%s'", href); we=file_wordexp_new(href); - we_files=file_wordexp_get_array(we); + we_files=file_wordexp_get_array(we); /* Expand wildcards (if any) into a list of files */ count=file_wordexp_get_count(we); dbg(lvl_debug,"%d results", count); - if (file_exists(we_files[0])) { - for (i = 0 ; i < count ; i++) { - dbg(lvl_debug,"result[%d]='%s'", i, we_files[i]); - doc_new.href=we_files[i]; - parse_file(&doc_new, error); + for (i = 0 ; i < count ; i++) { + included_filename = g_strdup(we_files[i]); + if (*included_filename != '\0') { /* Non empty href */ + if (!g_path_is_absolute(included_filename)) { /* The filename's path is relative */ + doc_base = g_path_get_dirname(doc_old->href); /* Get our own absolute path */ + if (*doc_base && file_is_dir(doc_base)) { + tmp = included_filename; + included_filename = g_strconcat(doc_base, G_DIR_SEPARATOR_S, tmp, NULL); + g_free(tmp); /* Free initial included_filename buffer (saved in tmp) */ + } + g_free(doc_base); + dbg(lvl_debug,"converted relative filename='%s' to absolute filename='%s'", we_files[i], included_filename); + } + dbg(lvl_debug,"result[%d]='%s'", i, included_filename); + if (file_exists(included_filename)) { + doc_new.href=included_filename; + parse_file(&doc_new, error); /* Now run the parser on the included XML file */ + } else { + dbg(lvl_error,"Unable to include '%s'",included_filename); + } } - } else { - dbg(lvl_error,"Unable to include %s",we_files[0]); + g_free(included_filename); } file_wordexp_destroy(we); - } - } + static int strncmp_len(const char *s1, int s1len, const char *s2) { int ret; ret=strncmp(s1, s2, s1len); diff --git a/navit/xslt/android.xslt b/navit/xslt/android.xslt index 9ef181a88..412735273 100644 --- a/navit/xslt/android.xslt +++ b/navit/xslt/android.xslt @@ -68,7 +68,7 @@ - + @@ -110,7 +110,7 @@ - + diff --git a/scripts/build_wince.sh b/scripts/build_wince.sh index 7206979e7..20eb5036e 100644 --- a/scripts/build_wince.sh +++ b/scripts/build_wince.sh @@ -9,6 +9,7 @@ test -d output && rm -rf output mkdir output cp navit/navit.exe output/ cp navit/navit.xml output/ +cp navit/navit_layout*.xml output/ cp -r locale/ output/ cp -r navit/icons/ output/ cp -r ../navit/support/espeak/espeak-data/ output/ -- cgit v1.2.1